azure_mgmt_graph 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -13
  2. data/azure_mgmt_graph.gemspec +4 -5
  3. data/lib/azure_mgmt_graph.rb +3 -54
  4. data/lib/generated/azure_mgmt_graph.rb +58 -0
  5. data/lib/{azure_mgmt_graph/application_operations.rb → generated/azure_mgmt_graph/applications.rb} +37 -33
  6. data/lib/{azure_mgmt_graph → generated/azure_mgmt_graph}/graph_rbac_management_client.rb +18 -18
  7. data/lib/{azure_mgmt_graph/group_operations.rb → generated/azure_mgmt_graph/groups.rb} +214 -62
  8. data/lib/generated/azure_mgmt_graph/models/aadobject.rb +142 -0
  9. data/lib/generated/azure_mgmt_graph/models/adgroup.rb +84 -0
  10. data/lib/generated/azure_mgmt_graph/models/application.rb +146 -0
  11. data/lib/generated/azure_mgmt_graph/models/application_create_parameters.rb +137 -0
  12. data/lib/generated/azure_mgmt_graph/models/application_list_result.rb +52 -0
  13. data/lib/generated/azure_mgmt_graph/models/application_update_parameters.rb +126 -0
  14. data/lib/generated/azure_mgmt_graph/models/check_group_membership_parameters.rb +55 -0
  15. data/lib/generated/azure_mgmt_graph/models/check_group_membership_result.rb +46 -0
  16. data/lib/generated/azure_mgmt_graph/models/get_objects_result.rb +93 -0
  17. data/lib/generated/azure_mgmt_graph/models/group_add_member_parameters.rb +48 -0
  18. data/lib/generated/azure_mgmt_graph/models/group_create_parameters.rb +82 -0
  19. data/lib/generated/azure_mgmt_graph/models/group_get_member_groups_parameters.rb +46 -0
  20. data/lib/generated/azure_mgmt_graph/models/group_get_member_groups_result.rb +51 -0
  21. data/lib/generated/azure_mgmt_graph/models/group_list_result.rb +93 -0
  22. data/lib/generated/azure_mgmt_graph/models/key_credential.rb +94 -0
  23. data/lib/generated/azure_mgmt_graph/models/password_credential.rb +74 -0
  24. data/lib/generated/azure_mgmt_graph/models/password_profile.rb +54 -0
  25. data/lib/generated/azure_mgmt_graph/models/service_principal.rb +91 -0
  26. data/lib/generated/azure_mgmt_graph/models/service_principal_create_parameters.rb +54 -0
  27. data/lib/generated/azure_mgmt_graph/models/service_principal_list_result.rb +94 -0
  28. data/lib/generated/azure_mgmt_graph/models/user.rb +104 -0
  29. data/lib/generated/azure_mgmt_graph/models/user_create_parameters.rb +100 -0
  30. data/lib/generated/azure_mgmt_graph/models/user_get_member_groups_parameters.rb +46 -0
  31. data/lib/generated/azure_mgmt_graph/models/user_get_member_groups_result.rb +51 -0
  32. data/lib/generated/azure_mgmt_graph/models/user_list_result.rb +93 -0
  33. data/lib/generated/azure_mgmt_graph/models/user_update_parameters.rb +76 -0
  34. data/lib/{azure_mgmt_graph → generated/azure_mgmt_graph}/module_definition.rb +0 -0
  35. data/lib/generated/azure_mgmt_graph/objects.rb +112 -0
  36. data/lib/{azure_mgmt_graph/service_principal_operations.rb → generated/azure_mgmt_graph/service_principals.rb} +50 -27
  37. data/lib/{azure_mgmt_graph/user_operations.rb → generated/azure_mgmt_graph/users.rb} +243 -115
  38. data/lib/{azure_mgmt_graph → generated/azure_mgmt_graph}/version.rb +1 -1
  39. metadata +56 -74
  40. data/lib/azure_mgmt_graph/models/aadobject.rb +0 -138
  41. data/lib/azure_mgmt_graph/models/adgroup.rb +0 -92
  42. data/lib/azure_mgmt_graph/models/application.rb +0 -122
  43. data/lib/azure_mgmt_graph/models/application_create_parameters.rb +0 -160
  44. data/lib/azure_mgmt_graph/models/application_filter.rb +0 -74
  45. data/lib/azure_mgmt_graph/models/application_list_result.rb +0 -76
  46. data/lib/azure_mgmt_graph/models/get_objects_parameters.rb +0 -77
  47. data/lib/azure_mgmt_graph/models/get_objects_result.rb +0 -85
  48. data/lib/azure_mgmt_graph/models/group_add_member_parameters.rb +0 -56
  49. data/lib/azure_mgmt_graph/models/group_create_parameters.rb +0 -86
  50. data/lib/azure_mgmt_graph/models/group_get_member_groups_parameters.rb +0 -58
  51. data/lib/azure_mgmt_graph/models/group_get_member_groups_result.rb +0 -56
  52. data/lib/azure_mgmt_graph/models/group_list_result.rb +0 -85
  53. data/lib/azure_mgmt_graph/models/key_credential.rb +0 -105
  54. data/lib/azure_mgmt_graph/models/password_credential.rb +0 -87
  55. data/lib/azure_mgmt_graph/models/service_principal.rb +0 -92
  56. data/lib/azure_mgmt_graph/models/service_principal_create_parameters.rb +0 -66
  57. data/lib/azure_mgmt_graph/models/service_principal_list_result.rb +0 -86
  58. data/lib/azure_mgmt_graph/models/user.rb +0 -101
  59. data/lib/azure_mgmt_graph/models/user_create_parameters.rb +0 -103
  60. data/lib/azure_mgmt_graph/models/user_create_parameters_password_profile.rb +0 -65
  61. data/lib/azure_mgmt_graph/models/user_get_member_groups_parameters.rb +0 -58
  62. data/lib/azure_mgmt_graph/models/user_get_member_groups_result.rb +0 -56
  63. data/lib/azure_mgmt_graph/models/user_list_result.rb +0 -85
  64. data/lib/azure_mgmt_graph/object_operations.rb +0 -302
@@ -5,14 +5,14 @@
5
5
 
6
6
  module Azure::ARM::Graph
7
7
  #
8
- # UserOperations
8
+ # The Graph RBAC Management Client
9
9
  #
10
- class UserOperations
10
+ class Users
11
11
  include Azure::ARM::Graph::Models
12
12
  include MsRestAzure
13
13
 
14
14
  #
15
- # Creates and initializes a new instance of the UserOperations class.
15
+ # Creates and initializes a new instance of the Users class.
16
16
  # @param client service class for accessing basic functionality.
17
17
  #
18
18
  def initialize(client)
@@ -23,64 +23,75 @@ module Azure::ARM::Graph
23
23
  attr_reader :client
24
24
 
25
25
  #
26
- # Delete a user. Reference:
27
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
26
+ # Create a new user. Reference:
27
+ # https://msdn.microsoft.com/library/azure/ad/graph/api/users-operations#CreateUser
28
28
  #
29
- # @param user [String] user object id or user principal name
29
+ # @param parameters [UserCreateParameters] Parameters to create a user.
30
30
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
31
  # will be added to the HTTP request.
32
32
  #
33
+ # @return [User] operation results.
33
34
  #
34
- def delete(user, custom_headers = nil)
35
- response = delete_async(user, custom_headers).value!
36
- nil
35
+ def create(parameters, custom_headers = nil)
36
+ response = create_async(parameters, custom_headers).value!
37
+ response.body unless response.nil?
37
38
  end
38
39
 
39
40
  #
40
- # Delete a user. Reference:
41
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
41
+ # Create a new user. Reference:
42
+ # https://msdn.microsoft.com/library/azure/ad/graph/api/users-operations#CreateUser
42
43
  #
43
- # @param user [String] user object id or user principal name
44
+ # @param parameters [UserCreateParameters] Parameters to create a user.
44
45
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
45
46
  # will be added to the HTTP request.
46
47
  #
47
48
  # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
48
49
  #
49
- def delete_with_http_info(user, custom_headers = nil)
50
- delete_async(user, custom_headers).value!
50
+ def create_with_http_info(parameters, custom_headers = nil)
51
+ create_async(parameters, custom_headers).value!
51
52
  end
52
53
 
53
54
  #
54
- # Delete a user. Reference:
55
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
55
+ # Create a new user. Reference:
56
+ # https://msdn.microsoft.com/library/azure/ad/graph/api/users-operations#CreateUser
56
57
  #
57
- # @param user [String] user object id or user principal name
58
+ # @param parameters [UserCreateParameters] Parameters to create a user.
58
59
  # @param [Hash{String => String}] A hash of custom headers that will be added
59
60
  # to the HTTP request.
60
61
  #
61
62
  # @return [Concurrent::Promise] Promise object which holds the HTTP response.
62
63
  #
63
- def delete_async(user, custom_headers = nil)
64
- fail ArgumentError, 'user is nil' if user.nil?
64
+ def create_async(parameters, custom_headers = nil)
65
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
65
66
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
66
67
  fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
68
+
69
+
67
70
  request_headers = {}
68
71
 
69
72
  # Set Headers
70
73
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
71
74
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
72
- path_template = '/{tenantID}/users/{user}'
75
+
76
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
77
+
78
+ # Serialize Request
79
+ request_mapper = UserCreateParameters.mapper()
80
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
81
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
82
+
83
+ path_template = '/{tenantID}/users'
73
84
  options = {
74
85
  middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
75
86
  path_params: {'tenantID' => @client.tenant_id},
76
- skip_encoding_path_params: {'user' => user},
77
87
  query_params: {'api-version' => @client.api_version},
88
+ body: request_content,
78
89
  headers: request_headers.merge(custom_headers || {})
79
90
  }
80
91
 
81
92
  request_url = @base_url || @client.base_url
82
93
 
83
- request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
94
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
84
95
  promise = request.run_promise do |req|
85
96
  @client.credentials.sign_request(req) unless @client.credentials.nil?
86
97
  end
@@ -88,7 +99,7 @@ module Azure::ARM::Graph
88
99
  promise = promise.then do |http_response|
89
100
  status_code = http_response.status
90
101
  response_content = http_response.body
91
- unless status_code == 204
102
+ unless status_code == 201
92
103
  error_model = JSON.load(response_content)
93
104
  fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
94
105
  end
@@ -96,6 +107,16 @@ module Azure::ARM::Graph
96
107
  # Create Result
97
108
  result = MsRestAzure::AzureOperationResponse.new(request, http_response)
98
109
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
110
+ # Deserialize Response
111
+ if status_code == 201
112
+ begin
113
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
114
+ result_mapper = User.mapper()
115
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
116
+ rescue Exception => e
117
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
118
+ end
119
+ end
99
120
 
100
121
  result
101
122
  end
@@ -104,73 +125,86 @@ module Azure::ARM::Graph
104
125
  end
105
126
 
106
127
  #
107
- # Create a new user. Reference:
108
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
128
+ # Gets list of users for the current tenant. Reference
129
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUsers
109
130
  #
110
- # @param parameters [UserCreateParameters] Parameters to create a user.
131
+ # @param filter [String] The filter to apply on the operation.
111
132
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
112
133
  # will be added to the HTTP request.
113
134
  #
114
- # @return [User] operation results.
135
+ # @return [UserListResult] which provide lazy access to pages of the response.
115
136
  #
116
- def create(parameters, custom_headers = nil)
117
- response = create_async(parameters, custom_headers).value!
118
- response.body unless response.nil?
137
+ def list_as_lazy(filter = nil, custom_headers = nil)
138
+ response = list_async(filter, custom_headers).value!
139
+ unless response.nil?
140
+ page = response.body
141
+ page.next_method = Proc.new do |next_link|
142
+ list_next_async(next_link, custom_headers)
143
+ end
144
+ page
145
+ end
119
146
  end
120
147
 
121
148
  #
122
- # Create a new user. Reference:
123
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
149
+ # Gets list of users for the current tenant. Reference
150
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUsers
124
151
  #
125
- # @param parameters [UserCreateParameters] Parameters to create a user.
152
+ # @param filter [String] The filter to apply on the operation.
153
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
154
+ # will be added to the HTTP request.
155
+ #
156
+ # @return [UserListResult] operation results.
157
+ #
158
+ def list(filter = nil, custom_headers = nil)
159
+ first_page = list_as_lazy(filter, custom_headers)
160
+ first_page.get_all_items
161
+ end
162
+
163
+ #
164
+ # Gets list of users for the current tenant. Reference
165
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUsers
166
+ #
167
+ # @param filter [String] The filter to apply on the operation.
126
168
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
127
169
  # will be added to the HTTP request.
128
170
  #
129
171
  # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
130
172
  #
131
- def create_with_http_info(parameters, custom_headers = nil)
132
- create_async(parameters, custom_headers).value!
173
+ def list_with_http_info(filter = nil, custom_headers = nil)
174
+ list_async(filter, custom_headers).value!
133
175
  end
134
176
 
135
177
  #
136
- # Create a new user. Reference:
137
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
178
+ # Gets list of users for the current tenant. Reference
179
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUsers
138
180
  #
139
- # @param parameters [UserCreateParameters] Parameters to create a user.
181
+ # @param filter [String] The filter to apply on the operation.
140
182
  # @param [Hash{String => String}] A hash of custom headers that will be added
141
183
  # to the HTTP request.
142
184
  #
143
185
  # @return [Concurrent::Promise] Promise object which holds the HTTP response.
144
186
  #
145
- def create_async(parameters, custom_headers = nil)
146
- fail ArgumentError, 'parameters is nil' if parameters.nil?
147
- parameters.validate unless parameters.nil?
187
+ def list_async(filter = nil, custom_headers = nil)
148
188
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
149
189
  fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
190
+
191
+
150
192
  request_headers = {}
151
193
 
152
194
  # Set Headers
153
195
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
154
196
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
155
-
156
- # Serialize Request
157
- request_headers['Content-Type'] = 'application/json; charset=utf-8'
158
- unless parameters.nil?
159
- parameters = UserCreateParameters.serialize_object(parameters)
160
- end
161
- request_content = parameters != nil ? JSON.generate(parameters, quirks_mode: true) : nil
162
197
  path_template = '/{tenantID}/users'
163
198
  options = {
164
199
  middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
165
200
  path_params: {'tenantID' => @client.tenant_id},
166
- query_params: {'api-version' => @client.api_version},
167
- body: request_content,
201
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
168
202
  headers: request_headers.merge(custom_headers || {})
169
203
  }
170
204
 
171
205
  request_url = @base_url || @client.base_url
172
206
 
173
- request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
207
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
174
208
  promise = request.run_promise do |req|
175
209
  @client.credentials.sign_request(req) unless @client.credentials.nil?
176
210
  end
@@ -178,7 +212,7 @@ module Azure::ARM::Graph
178
212
  promise = promise.then do |http_response|
179
213
  status_code = http_response.status
180
214
  response_content = http_response.body
181
- unless status_code == 201
215
+ unless status_code == 200
182
216
  error_model = JSON.load(response_content)
183
217
  fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
184
218
  end
@@ -187,13 +221,11 @@ module Azure::ARM::Graph
187
221
  result = MsRestAzure::AzureOperationResponse.new(request, http_response)
188
222
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
189
223
  # Deserialize Response
190
- if status_code == 201
224
+ if status_code == 200
191
225
  begin
192
226
  parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
193
- unless parsed_response.nil?
194
- parsed_response = User.deserialize_object(parsed_response)
195
- end
196
- result.body = parsed_response
227
+ result_mapper = UserListResult.mapper()
228
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
197
229
  rescue Exception => e
198
230
  fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
199
231
  end
@@ -206,54 +238,64 @@ module Azure::ARM::Graph
206
238
  end
207
239
 
208
240
  #
209
- # Gets list of users for the current tenant.
241
+ # Gets user information from the directory. Reference:
242
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetAUser
210
243
  #
211
- # @param filter [String] The filter to apply on the operation.
244
+ # @param upn_or_object_id [String] User object Id or user principal name to
245
+ # get user information.
212
246
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
213
247
  # will be added to the HTTP request.
214
248
  #
215
- # @return [UserListResult] operation results.
249
+ # @return [User] operation results.
216
250
  #
217
- def list(filter = nil, custom_headers = nil)
218
- response = list_async(filter, custom_headers).value!
251
+ def get(upn_or_object_id, custom_headers = nil)
252
+ response = get_async(upn_or_object_id, custom_headers).value!
219
253
  response.body unless response.nil?
220
254
  end
221
255
 
222
256
  #
223
- # Gets list of users for the current tenant.
257
+ # Gets user information from the directory. Reference:
258
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetAUser
224
259
  #
225
- # @param filter [String] The filter to apply on the operation.
260
+ # @param upn_or_object_id [String] User object Id or user principal name to
261
+ # get user information.
226
262
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
227
263
  # will be added to the HTTP request.
228
264
  #
229
265
  # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
230
266
  #
231
- def list_with_http_info(filter = nil, custom_headers = nil)
232
- list_async(filter, custom_headers).value!
267
+ def get_with_http_info(upn_or_object_id, custom_headers = nil)
268
+ get_async(upn_or_object_id, custom_headers).value!
233
269
  end
234
270
 
235
271
  #
236
- # Gets list of users for the current tenant.
272
+ # Gets user information from the directory. Reference:
273
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetAUser
237
274
  #
238
- # @param filter [String] The filter to apply on the operation.
275
+ # @param upn_or_object_id [String] User object Id or user principal name to
276
+ # get user information.
239
277
  # @param [Hash{String => String}] A hash of custom headers that will be added
240
278
  # to the HTTP request.
241
279
  #
242
280
  # @return [Concurrent::Promise] Promise object which holds the HTTP response.
243
281
  #
244
- def list_async(filter = nil, custom_headers = nil)
282
+ def get_async(upn_or_object_id, custom_headers = nil)
283
+ fail ArgumentError, 'upn_or_object_id is nil' if upn_or_object_id.nil?
245
284
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
246
285
  fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
286
+
287
+
247
288
  request_headers = {}
248
289
 
249
290
  # Set Headers
250
291
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
251
292
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
252
- path_template = '/{tenantID}/users'
293
+ path_template = '/{tenantID}/users/{upnOrObjectId}'
253
294
  options = {
254
295
  middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
255
296
  path_params: {'tenantID' => @client.tenant_id},
256
- query_params: {'$filter' => filter,'api-version' => @client.api_version},
297
+ skip_encoding_path_params: {'upnOrObjectId' => upn_or_object_id},
298
+ query_params: {'api-version' => @client.api_version},
257
299
  headers: request_headers.merge(custom_headers || {})
258
300
  }
259
301
 
@@ -279,10 +321,8 @@ module Azure::ARM::Graph
279
321
  if status_code == 200
280
322
  begin
281
323
  parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
282
- unless parsed_response.nil?
283
- parsed_response = UserListResult.deserialize_object(parsed_response)
284
- end
285
- result.body = parsed_response
324
+ result_mapper = User.mapper()
325
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
286
326
  rescue Exception => e
287
327
  fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
288
328
  end
@@ -295,68 +335,85 @@ module Azure::ARM::Graph
295
335
  end
296
336
 
297
337
  #
298
- # Gets user information from the directory. Reference:
299
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
338
+ # Updates an exisitng user. Reference:
339
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#UpdateUser
300
340
  #
301
341
  # @param upn_or_object_id [String] User object Id or user principal name to
302
342
  # get user information.
343
+ # @param parameters [UserUpdateParameters] Parameters to update an exisitng
344
+ # user.
303
345
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
304
346
  # will be added to the HTTP request.
305
347
  #
306
- # @return [User] operation results.
307
348
  #
308
- def get(upn_or_object_id, custom_headers = nil)
309
- response = get_async(upn_or_object_id, custom_headers).value!
310
- response.body unless response.nil?
349
+ def update(upn_or_object_id, parameters, custom_headers = nil)
350
+ response = update_async(upn_or_object_id, parameters, custom_headers).value!
351
+ nil
311
352
  end
312
353
 
313
354
  #
314
- # Gets user information from the directory. Reference:
315
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
355
+ # Updates an exisitng user. Reference:
356
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#UpdateUser
316
357
  #
317
358
  # @param upn_or_object_id [String] User object Id or user principal name to
318
359
  # get user information.
360
+ # @param parameters [UserUpdateParameters] Parameters to update an exisitng
361
+ # user.
319
362
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
320
363
  # will be added to the HTTP request.
321
364
  #
322
365
  # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
323
366
  #
324
- def get_with_http_info(upn_or_object_id, custom_headers = nil)
325
- get_async(upn_or_object_id, custom_headers).value!
367
+ def update_with_http_info(upn_or_object_id, parameters, custom_headers = nil)
368
+ update_async(upn_or_object_id, parameters, custom_headers).value!
326
369
  end
327
370
 
328
371
  #
329
- # Gets user information from the directory. Reference:
330
- # http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx
372
+ # Updates an exisitng user. Reference:
373
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#UpdateUser
331
374
  #
332
375
  # @param upn_or_object_id [String] User object Id or user principal name to
333
376
  # get user information.
377
+ # @param parameters [UserUpdateParameters] Parameters to update an exisitng
378
+ # user.
334
379
  # @param [Hash{String => String}] A hash of custom headers that will be added
335
380
  # to the HTTP request.
336
381
  #
337
382
  # @return [Concurrent::Promise] Promise object which holds the HTTP response.
338
383
  #
339
- def get_async(upn_or_object_id, custom_headers = nil)
384
+ def update_async(upn_or_object_id, parameters, custom_headers = nil)
340
385
  fail ArgumentError, 'upn_or_object_id is nil' if upn_or_object_id.nil?
386
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
341
387
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
342
388
  fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
389
+
390
+
343
391
  request_headers = {}
344
392
 
345
393
  # Set Headers
346
394
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
347
395
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
396
+
397
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
398
+
399
+ # Serialize Request
400
+ request_mapper = UserUpdateParameters.mapper()
401
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
402
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
403
+
348
404
  path_template = '/{tenantID}/users/{upnOrObjectId}'
349
405
  options = {
350
406
  middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
351
407
  path_params: {'tenantID' => @client.tenant_id},
352
408
  skip_encoding_path_params: {'upnOrObjectId' => upn_or_object_id},
353
409
  query_params: {'api-version' => @client.api_version},
410
+ body: request_content,
354
411
  headers: request_headers.merge(custom_headers || {})
355
412
  }
356
413
 
357
414
  request_url = @base_url || @client.base_url
358
415
 
359
- request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
416
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :patch, options)
360
417
  promise = request.run_promise do |req|
361
418
  @client.credentials.sign_request(req) unless @client.credentials.nil?
362
419
  end
@@ -364,7 +421,7 @@ module Azure::ARM::Graph
364
421
  promise = promise.then do |http_response|
365
422
  status_code = http_response.status
366
423
  response_content = http_response.body
367
- unless status_code == 200
424
+ unless status_code == 204
368
425
  error_model = JSON.load(response_content)
369
426
  fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
370
427
  end
@@ -372,19 +429,90 @@ module Azure::ARM::Graph
372
429
  # Create Result
373
430
  result = MsRestAzure::AzureOperationResponse.new(request, http_response)
374
431
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
375
- # Deserialize Response
376
- if status_code == 200
377
- begin
378
- parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
379
- unless parsed_response.nil?
380
- parsed_response = User.deserialize_object(parsed_response)
381
- end
382
- result.body = parsed_response
383
- rescue Exception => e
384
- fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
385
- end
432
+
433
+ result
434
+ end
435
+
436
+ promise.execute
437
+ end
438
+
439
+ #
440
+ # Delete a user. Reference:
441
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#DeleteUser
442
+ #
443
+ # @param upn_or_object_id [String] user object id or user principal name (upn)
444
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
445
+ # will be added to the HTTP request.
446
+ #
447
+ #
448
+ def delete(upn_or_object_id, custom_headers = nil)
449
+ response = delete_async(upn_or_object_id, custom_headers).value!
450
+ nil
451
+ end
452
+
453
+ #
454
+ # Delete a user. Reference:
455
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#DeleteUser
456
+ #
457
+ # @param upn_or_object_id [String] user object id or user principal name (upn)
458
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
459
+ # will be added to the HTTP request.
460
+ #
461
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
462
+ #
463
+ def delete_with_http_info(upn_or_object_id, custom_headers = nil)
464
+ delete_async(upn_or_object_id, custom_headers).value!
465
+ end
466
+
467
+ #
468
+ # Delete a user. Reference:
469
+ # https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#DeleteUser
470
+ #
471
+ # @param upn_or_object_id [String] user object id or user principal name (upn)
472
+ # @param [Hash{String => String}] A hash of custom headers that will be added
473
+ # to the HTTP request.
474
+ #
475
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
476
+ #
477
+ def delete_async(upn_or_object_id, custom_headers = nil)
478
+ fail ArgumentError, 'upn_or_object_id is nil' if upn_or_object_id.nil?
479
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
480
+ fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
481
+
482
+
483
+ request_headers = {}
484
+
485
+ # Set Headers
486
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
487
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
488
+ path_template = '/{tenantID}/users/{upnOrObjectId}'
489
+ options = {
490
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
491
+ path_params: {'tenantID' => @client.tenant_id},
492
+ skip_encoding_path_params: {'upnOrObjectId' => upn_or_object_id},
493
+ query_params: {'api-version' => @client.api_version},
494
+ headers: request_headers.merge(custom_headers || {})
495
+ }
496
+
497
+ request_url = @base_url || @client.base_url
498
+
499
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
500
+ promise = request.run_promise do |req|
501
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
502
+ end
503
+
504
+ promise = promise.then do |http_response|
505
+ status_code = http_response.status
506
+ response_content = http_response.body
507
+ unless status_code == 204
508
+ error_model = JSON.load(response_content)
509
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
386
510
  end
387
511
 
512
+ # Create Result
513
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
514
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
515
+
388
516
  result
389
517
  end
390
518
 
@@ -436,21 +564,23 @@ module Azure::ARM::Graph
436
564
  def get_member_groups_async(object_id, parameters, custom_headers = nil)
437
565
  fail ArgumentError, 'object_id is nil' if object_id.nil?
438
566
  fail ArgumentError, 'parameters is nil' if parameters.nil?
439
- parameters.validate unless parameters.nil?
440
567
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
441
568
  fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
569
+
570
+
442
571
  request_headers = {}
443
572
 
444
573
  # Set Headers
445
574
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
446
575
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
447
576
 
448
- # Serialize Request
449
577
  request_headers['Content-Type'] = 'application/json; charset=utf-8'
450
- unless parameters.nil?
451
- parameters = UserGetMemberGroupsParameters.serialize_object(parameters)
452
- end
453
- request_content = parameters != nil ? JSON.generate(parameters, quirks_mode: true) : nil
578
+
579
+ # Serialize Request
580
+ request_mapper = UserGetMemberGroupsParameters.mapper()
581
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
582
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
583
+
454
584
  path_template = '/{tenantID}/users/{objectId}/getMemberGroups'
455
585
  options = {
456
586
  middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
@@ -483,10 +613,8 @@ module Azure::ARM::Graph
483
613
  if status_code == 200
484
614
  begin
485
615
  parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
486
- unless parsed_response.nil?
487
- parsed_response = UserGetMemberGroupsResult.deserialize_object(parsed_response)
488
- end
489
- result.body = parsed_response
616
+ result_mapper = UserGetMemberGroupsResult.mapper()
617
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
490
618
  rescue Exception => e
491
619
  fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
492
620
  end
@@ -538,6 +666,8 @@ module Azure::ARM::Graph
538
666
  fail ArgumentError, 'next_link is nil' if next_link.nil?
539
667
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
540
668
  fail ArgumentError, '@client.tenant_id is nil' if @client.tenant_id.nil?
669
+
670
+
541
671
  request_headers = {}
542
672
 
543
673
  # Set Headers
@@ -574,10 +704,8 @@ module Azure::ARM::Graph
574
704
  if status_code == 200
575
705
  begin
576
706
  parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
577
- unless parsed_response.nil?
578
- parsed_response = UserListResult.deserialize_object(parsed_response)
579
- end
580
- result.body = parsed_response
707
+ result_mapper = UserListResult.mapper()
708
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
581
709
  rescue Exception => e
582
710
  fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
583
711
  end