azure_mgmt_authorization 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2015-06-01/generated/azure_mgmt_authorization/authorization_management_client.rb +130 -0
  3. data/lib/2015-06-01/generated/azure_mgmt_authorization/classic_administrators.rb +228 -0
  4. data/lib/2015-06-01/generated/azure_mgmt_authorization/models/classic_administrator.rb +90 -0
  5. data/lib/2015-06-01/generated/azure_mgmt_authorization/models/classic_administrator_list_result.rb +98 -0
  6. data/lib/2015-06-01/generated/azure_mgmt_authorization/module_definition.rb +9 -0
  7. data/lib/2015-06-01/generated/azure_mgmt_authorization.rb +30 -0
  8. data/lib/2015-07-01/generated/azure_mgmt_authorization/authorization_management_client.rb +1 -1
  9. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/authorization_management_client.rb +130 -0
  10. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/models/role_assignment.rb +115 -0
  11. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/models/role_assignment_create_parameters.rb +71 -0
  12. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/models/role_assignment_filter.rb +57 -0
  13. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/models/role_assignment_list_result.rb +98 -0
  14. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/module_definition.rb +9 -0
  15. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization/role_assignments.rb +1493 -0
  16. data/lib/2017-10-01-preview/generated/azure_mgmt_authorization.rb +32 -0
  17. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/authorization_management_client.rb +143 -0
  18. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/permission.rb +111 -0
  19. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/permission_get_result.rb +98 -0
  20. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/provider_operation.rb +101 -0
  21. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/provider_operations_metadata.rb +119 -0
  22. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/provider_operations_metadata_list_result.rb +98 -0
  23. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/resource_type.rb +77 -0
  24. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment.rb +115 -0
  25. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment_create_parameters.rb +71 -0
  26. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment_filter.rb +57 -0
  27. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment_list_result.rb +98 -0
  28. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_definition.rb +143 -0
  29. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_definition_filter.rb +57 -0
  30. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/models/role_definition_list_result.rb +98 -0
  31. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/module_definition.rb +9 -0
  32. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/permissions.rb +452 -0
  33. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/provider_operations_metadata_operations.rb +316 -0
  34. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/role_assignments.rb +1493 -0
  35. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization/role_definitions.rb +622 -0
  36. data/lib/2018-01-01-preview/generated/azure_mgmt_authorization.rb +44 -0
  37. data/lib/azure_mgmt_authorization.rb +3 -0
  38. data/lib/profiles/latest/modules/authorization_profile_module.rb +63 -71
  39. data/lib/version.rb +1 -1
  40. metadata +36 -2
@@ -0,0 +1,1493 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Authorization::Mgmt::V2017_10_01_preview
7
+ #
8
+ # Role based access control provides you a way to apply granular level policy
9
+ # administration down to individual resources or resource groups. These
10
+ # operations enable you to manage role definitions and role assignments. A
11
+ # role definition describes the set of actions that can be performed on
12
+ # resources. A role assignment grants access to Azure Active Directory users.
13
+ #
14
+ class RoleAssignments
15
+ include MsRestAzure
16
+
17
+ #
18
+ # Creates and initializes a new instance of the RoleAssignments class.
19
+ # @param client service class for accessing basic functionality.
20
+ #
21
+ def initialize(client)
22
+ @client = client
23
+ end
24
+
25
+ # @return [AuthorizationManagementClient] reference to the AuthorizationManagementClient
26
+ attr_reader :client
27
+
28
+ #
29
+ # Gets role assignments for a resource.
30
+ #
31
+ # @param resource_group_name [String] The name of the resource group.
32
+ # @param resource_provider_namespace [String] The namespace of the resource
33
+ # provider.
34
+ # @param parent_resource_path [String] The parent resource identity.
35
+ # @param resource_type [String] The resource type of the resource.
36
+ # @param resource_name [String] The name of the resource to get role
37
+ # assignments for.
38
+ # @param filter [String] The filter to apply on the operation. Use
39
+ # $filter=atScope() to return all role assignments at or above the scope. Use
40
+ # $filter=principalId eq {id} to return all role assignments at, above or below
41
+ # the scope for the specified principal.
42
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
43
+ # will be added to the HTTP request.
44
+ #
45
+ # @return [Array<RoleAssignment>] operation results.
46
+ #
47
+ def list_for_resource(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
48
+ first_page = list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers)
49
+ first_page.get_all_items
50
+ end
51
+
52
+ #
53
+ # Gets role assignments for a resource.
54
+ #
55
+ # @param resource_group_name [String] The name of the resource group.
56
+ # @param resource_provider_namespace [String] The namespace of the resource
57
+ # provider.
58
+ # @param parent_resource_path [String] The parent resource identity.
59
+ # @param resource_type [String] The resource type of the resource.
60
+ # @param resource_name [String] The name of the resource to get role
61
+ # assignments for.
62
+ # @param filter [String] The filter to apply on the operation. Use
63
+ # $filter=atScope() to return all role assignments at or above the scope. Use
64
+ # $filter=principalId eq {id} to return all role assignments at, above or below
65
+ # the scope for the specified principal.
66
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
67
+ # will be added to the HTTP request.
68
+ #
69
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
70
+ #
71
+ def list_for_resource_with_http_info(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
72
+ list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers).value!
73
+ end
74
+
75
+ #
76
+ # Gets role assignments for a resource.
77
+ #
78
+ # @param resource_group_name [String] The name of the resource group.
79
+ # @param resource_provider_namespace [String] The namespace of the resource
80
+ # provider.
81
+ # @param parent_resource_path [String] The parent resource identity.
82
+ # @param resource_type [String] The resource type of the resource.
83
+ # @param resource_name [String] The name of the resource to get role
84
+ # assignments for.
85
+ # @param filter [String] The filter to apply on the operation. Use
86
+ # $filter=atScope() to return all role assignments at or above the scope. Use
87
+ # $filter=principalId eq {id} to return all role assignments at, above or below
88
+ # the scope for the specified principal.
89
+ # @param [Hash{String => String}] A hash of custom headers that will be added
90
+ # to the HTTP request.
91
+ #
92
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
93
+ #
94
+ def list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
95
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
96
+ fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
97
+ fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
98
+ fail ArgumentError, 'resource_type is nil' if resource_type.nil?
99
+ fail ArgumentError, 'resource_name is nil' if resource_name.nil?
100
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
101
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
102
+
103
+
104
+ request_headers = {}
105
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
106
+
107
+ # Set Headers
108
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
109
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
110
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'
111
+
112
+ request_url = @base_url || @client.base_url
113
+
114
+ options = {
115
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
116
+ path_params: {'resourceGroupName' => resource_group_name,'resourceProviderNamespace' => resource_provider_namespace,'resourceName' => resource_name,'subscriptionId' => @client.subscription_id},
117
+ skip_encoding_path_params: {'parentResourcePath' => parent_resource_path,'resourceType' => resource_type},
118
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
119
+ headers: request_headers.merge(custom_headers || {}),
120
+ base_url: request_url
121
+ }
122
+ promise = @client.make_request_async(:get, path_template, options)
123
+
124
+ promise = promise.then do |result|
125
+ http_response = result.response
126
+ status_code = http_response.status
127
+ response_content = http_response.body
128
+ unless status_code == 200
129
+ error_model = JSON.load(response_content)
130
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
131
+ end
132
+
133
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
134
+ # Deserialize Response
135
+ if status_code == 200
136
+ begin
137
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
138
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
139
+ result.body = @client.deserialize(result_mapper, parsed_response)
140
+ rescue Exception => e
141
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
142
+ end
143
+ end
144
+
145
+ result
146
+ end
147
+
148
+ promise.execute
149
+ end
150
+
151
+ #
152
+ # Gets role assignments for a resource group.
153
+ #
154
+ # @param resource_group_name [String] The name of the resource group.
155
+ # @param filter [String] The filter to apply on the operation. Use
156
+ # $filter=atScope() to return all role assignments at or above the scope. Use
157
+ # $filter=principalId eq {id} to return all role assignments at, above or below
158
+ # the scope for the specified principal.
159
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
160
+ # will be added to the HTTP request.
161
+ #
162
+ # @return [Array<RoleAssignment>] operation results.
163
+ #
164
+ def list_for_resource_group(resource_group_name, filter:nil, custom_headers:nil)
165
+ first_page = list_for_resource_group_as_lazy(resource_group_name, filter:filter, custom_headers:custom_headers)
166
+ first_page.get_all_items
167
+ end
168
+
169
+ #
170
+ # Gets role assignments for a resource group.
171
+ #
172
+ # @param resource_group_name [String] The name of the resource group.
173
+ # @param filter [String] The filter to apply on the operation. Use
174
+ # $filter=atScope() to return all role assignments at or above the scope. Use
175
+ # $filter=principalId eq {id} to return all role assignments at, above or below
176
+ # the scope for the specified principal.
177
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
178
+ # will be added to the HTTP request.
179
+ #
180
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
181
+ #
182
+ def list_for_resource_group_with_http_info(resource_group_name, filter:nil, custom_headers:nil)
183
+ list_for_resource_group_async(resource_group_name, filter:filter, custom_headers:custom_headers).value!
184
+ end
185
+
186
+ #
187
+ # Gets role assignments for a resource group.
188
+ #
189
+ # @param resource_group_name [String] The name of the resource group.
190
+ # @param filter [String] The filter to apply on the operation. Use
191
+ # $filter=atScope() to return all role assignments at or above the scope. Use
192
+ # $filter=principalId eq {id} to return all role assignments at, above or below
193
+ # the scope for the specified principal.
194
+ # @param [Hash{String => String}] A hash of custom headers that will be added
195
+ # to the HTTP request.
196
+ #
197
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
198
+ #
199
+ def list_for_resource_group_async(resource_group_name, filter:nil, custom_headers:nil)
200
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
201
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
202
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
203
+
204
+
205
+ request_headers = {}
206
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
207
+
208
+ # Set Headers
209
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
210
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
211
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'
212
+
213
+ request_url = @base_url || @client.base_url
214
+
215
+ options = {
216
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
217
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
218
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
219
+ headers: request_headers.merge(custom_headers || {}),
220
+ base_url: request_url
221
+ }
222
+ promise = @client.make_request_async(:get, path_template, options)
223
+
224
+ promise = promise.then do |result|
225
+ http_response = result.response
226
+ status_code = http_response.status
227
+ response_content = http_response.body
228
+ unless status_code == 200
229
+ error_model = JSON.load(response_content)
230
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
231
+ end
232
+
233
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
234
+ # Deserialize Response
235
+ if status_code == 200
236
+ begin
237
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
238
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
239
+ result.body = @client.deserialize(result_mapper, parsed_response)
240
+ rescue Exception => e
241
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
242
+ end
243
+ end
244
+
245
+ result
246
+ end
247
+
248
+ promise.execute
249
+ end
250
+
251
+ #
252
+ # Deletes a role assignment.
253
+ #
254
+ # @param scope [String] The scope of the role assignment to delete.
255
+ # @param role_assignment_name [String] The name of the role assignment to
256
+ # delete.
257
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
258
+ # will be added to the HTTP request.
259
+ #
260
+ # @return [RoleAssignment] operation results.
261
+ #
262
+ def delete(scope, role_assignment_name, custom_headers:nil)
263
+ response = delete_async(scope, role_assignment_name, custom_headers:custom_headers).value!
264
+ response.body unless response.nil?
265
+ end
266
+
267
+ #
268
+ # Deletes a role assignment.
269
+ #
270
+ # @param scope [String] The scope of the role assignment to delete.
271
+ # @param role_assignment_name [String] The name of the role assignment to
272
+ # delete.
273
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
274
+ # will be added to the HTTP request.
275
+ #
276
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
277
+ #
278
+ def delete_with_http_info(scope, role_assignment_name, custom_headers:nil)
279
+ delete_async(scope, role_assignment_name, custom_headers:custom_headers).value!
280
+ end
281
+
282
+ #
283
+ # Deletes a role assignment.
284
+ #
285
+ # @param scope [String] The scope of the role assignment to delete.
286
+ # @param role_assignment_name [String] The name of the role assignment to
287
+ # delete.
288
+ # @param [Hash{String => String}] A hash of custom headers that will be added
289
+ # to the HTTP request.
290
+ #
291
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
292
+ #
293
+ def delete_async(scope, role_assignment_name, custom_headers:nil)
294
+ fail ArgumentError, 'scope is nil' if scope.nil?
295
+ fail ArgumentError, 'role_assignment_name is nil' if role_assignment_name.nil?
296
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
297
+
298
+
299
+ request_headers = {}
300
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
301
+
302
+ # Set Headers
303
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
304
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
305
+ path_template = '{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'
306
+
307
+ request_url = @base_url || @client.base_url
308
+
309
+ options = {
310
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
311
+ path_params: {'roleAssignmentName' => role_assignment_name},
312
+ skip_encoding_path_params: {'scope' => scope},
313
+ query_params: {'api-version' => @client.api_version},
314
+ headers: request_headers.merge(custom_headers || {}),
315
+ base_url: request_url
316
+ }
317
+ promise = @client.make_request_async(:delete, path_template, options)
318
+
319
+ promise = promise.then do |result|
320
+ http_response = result.response
321
+ status_code = http_response.status
322
+ response_content = http_response.body
323
+ unless status_code == 200
324
+ error_model = JSON.load(response_content)
325
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
326
+ end
327
+
328
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
329
+ # Deserialize Response
330
+ if status_code == 200
331
+ begin
332
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
333
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignment.mapper()
334
+ result.body = @client.deserialize(result_mapper, parsed_response)
335
+ rescue Exception => e
336
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
337
+ end
338
+ end
339
+
340
+ result
341
+ end
342
+
343
+ promise.execute
344
+ end
345
+
346
+ #
347
+ # Creates a role assignment.
348
+ #
349
+ # @param scope [String] The scope of the role assignment to create. The scope
350
+ # can be any REST resource instance. For example, use
351
+ # '/subscriptions/{subscription-id}/' for a subscription,
352
+ # '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a
353
+ # resource group, and
354
+ # '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}'
355
+ # for a resource.
356
+ # @param role_assignment_name [String] The name of the role assignment to
357
+ # create. It can be any valid GUID.
358
+ # @param parameters [RoleAssignmentCreateParameters] Parameters for the role
359
+ # assignment.
360
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
361
+ # will be added to the HTTP request.
362
+ #
363
+ # @return [RoleAssignment] operation results.
364
+ #
365
+ def create(scope, role_assignment_name, parameters, custom_headers:nil)
366
+ response = create_async(scope, role_assignment_name, parameters, custom_headers:custom_headers).value!
367
+ response.body unless response.nil?
368
+ end
369
+
370
+ #
371
+ # Creates a role assignment.
372
+ #
373
+ # @param scope [String] The scope of the role assignment to create. The scope
374
+ # can be any REST resource instance. For example, use
375
+ # '/subscriptions/{subscription-id}/' for a subscription,
376
+ # '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a
377
+ # resource group, and
378
+ # '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}'
379
+ # for a resource.
380
+ # @param role_assignment_name [String] The name of the role assignment to
381
+ # create. It can be any valid GUID.
382
+ # @param parameters [RoleAssignmentCreateParameters] Parameters for the role
383
+ # assignment.
384
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
385
+ # will be added to the HTTP request.
386
+ #
387
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
388
+ #
389
+ def create_with_http_info(scope, role_assignment_name, parameters, custom_headers:nil)
390
+ create_async(scope, role_assignment_name, parameters, custom_headers:custom_headers).value!
391
+ end
392
+
393
+ #
394
+ # Creates a role assignment.
395
+ #
396
+ # @param scope [String] The scope of the role assignment to create. The scope
397
+ # can be any REST resource instance. For example, use
398
+ # '/subscriptions/{subscription-id}/' for a subscription,
399
+ # '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a
400
+ # resource group, and
401
+ # '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}'
402
+ # for a resource.
403
+ # @param role_assignment_name [String] The name of the role assignment to
404
+ # create. It can be any valid GUID.
405
+ # @param parameters [RoleAssignmentCreateParameters] Parameters for the role
406
+ # assignment.
407
+ # @param [Hash{String => String}] A hash of custom headers that will be added
408
+ # to the HTTP request.
409
+ #
410
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
411
+ #
412
+ def create_async(scope, role_assignment_name, parameters, custom_headers:nil)
413
+ fail ArgumentError, 'scope is nil' if scope.nil?
414
+ fail ArgumentError, 'role_assignment_name is nil' if role_assignment_name.nil?
415
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
416
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
417
+
418
+
419
+ request_headers = {}
420
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
421
+
422
+ # Set Headers
423
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
424
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
425
+
426
+ # Serialize Request
427
+ request_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentCreateParameters.mapper()
428
+ request_content = @client.serialize(request_mapper, parameters)
429
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
430
+
431
+ path_template = '{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'
432
+
433
+ request_url = @base_url || @client.base_url
434
+
435
+ options = {
436
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
437
+ path_params: {'roleAssignmentName' => role_assignment_name},
438
+ skip_encoding_path_params: {'scope' => scope},
439
+ query_params: {'api-version' => @client.api_version},
440
+ body: request_content,
441
+ headers: request_headers.merge(custom_headers || {}),
442
+ base_url: request_url
443
+ }
444
+ promise = @client.make_request_async(:put, path_template, options)
445
+
446
+ promise = promise.then do |result|
447
+ http_response = result.response
448
+ status_code = http_response.status
449
+ response_content = http_response.body
450
+ unless status_code == 201
451
+ error_model = JSON.load(response_content)
452
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
453
+ end
454
+
455
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
456
+ # Deserialize Response
457
+ if status_code == 201
458
+ begin
459
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
460
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignment.mapper()
461
+ result.body = @client.deserialize(result_mapper, parsed_response)
462
+ rescue Exception => e
463
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
464
+ end
465
+ end
466
+
467
+ result
468
+ end
469
+
470
+ promise.execute
471
+ end
472
+
473
+ #
474
+ # Get the specified role assignment.
475
+ #
476
+ # @param scope [String] The scope of the role assignment.
477
+ # @param role_assignment_name [String] The name of the role assignment to get.
478
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
479
+ # will be added to the HTTP request.
480
+ #
481
+ # @return [RoleAssignment] operation results.
482
+ #
483
+ def get(scope, role_assignment_name, custom_headers:nil)
484
+ response = get_async(scope, role_assignment_name, custom_headers:custom_headers).value!
485
+ response.body unless response.nil?
486
+ end
487
+
488
+ #
489
+ # Get the specified role assignment.
490
+ #
491
+ # @param scope [String] The scope of the role assignment.
492
+ # @param role_assignment_name [String] The name of the role assignment to get.
493
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
494
+ # will be added to the HTTP request.
495
+ #
496
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
497
+ #
498
+ def get_with_http_info(scope, role_assignment_name, custom_headers:nil)
499
+ get_async(scope, role_assignment_name, custom_headers:custom_headers).value!
500
+ end
501
+
502
+ #
503
+ # Get the specified role assignment.
504
+ #
505
+ # @param scope [String] The scope of the role assignment.
506
+ # @param role_assignment_name [String] The name of the role assignment to get.
507
+ # @param [Hash{String => String}] A hash of custom headers that will be added
508
+ # to the HTTP request.
509
+ #
510
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
511
+ #
512
+ def get_async(scope, role_assignment_name, custom_headers:nil)
513
+ fail ArgumentError, 'scope is nil' if scope.nil?
514
+ fail ArgumentError, 'role_assignment_name is nil' if role_assignment_name.nil?
515
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
516
+
517
+
518
+ request_headers = {}
519
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
520
+
521
+ # Set Headers
522
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
523
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
524
+ path_template = '{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'
525
+
526
+ request_url = @base_url || @client.base_url
527
+
528
+ options = {
529
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
530
+ path_params: {'roleAssignmentName' => role_assignment_name},
531
+ skip_encoding_path_params: {'scope' => scope},
532
+ query_params: {'api-version' => @client.api_version},
533
+ headers: request_headers.merge(custom_headers || {}),
534
+ base_url: request_url
535
+ }
536
+ promise = @client.make_request_async(:get, path_template, options)
537
+
538
+ promise = promise.then do |result|
539
+ http_response = result.response
540
+ status_code = http_response.status
541
+ response_content = http_response.body
542
+ unless status_code == 200
543
+ error_model = JSON.load(response_content)
544
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
545
+ end
546
+
547
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
548
+ # Deserialize Response
549
+ if status_code == 200
550
+ begin
551
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
552
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignment.mapper()
553
+ result.body = @client.deserialize(result_mapper, parsed_response)
554
+ rescue Exception => e
555
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
556
+ end
557
+ end
558
+
559
+ result
560
+ end
561
+
562
+ promise.execute
563
+ end
564
+
565
+ #
566
+ # Deletes a role assignment.
567
+ #
568
+ # @param role_assignment_id [String] The ID of the role assignment to delete.
569
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
570
+ # will be added to the HTTP request.
571
+ #
572
+ # @return [RoleAssignment] operation results.
573
+ #
574
+ def delete_by_id(role_assignment_id, custom_headers:nil)
575
+ response = delete_by_id_async(role_assignment_id, custom_headers:custom_headers).value!
576
+ response.body unless response.nil?
577
+ end
578
+
579
+ #
580
+ # Deletes a role assignment.
581
+ #
582
+ # @param role_assignment_id [String] The ID of the role assignment to delete.
583
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
584
+ # will be added to the HTTP request.
585
+ #
586
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
587
+ #
588
+ def delete_by_id_with_http_info(role_assignment_id, custom_headers:nil)
589
+ delete_by_id_async(role_assignment_id, custom_headers:custom_headers).value!
590
+ end
591
+
592
+ #
593
+ # Deletes a role assignment.
594
+ #
595
+ # @param role_assignment_id [String] The ID of the role assignment to delete.
596
+ # @param [Hash{String => String}] A hash of custom headers that will be added
597
+ # to the HTTP request.
598
+ #
599
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
600
+ #
601
+ def delete_by_id_async(role_assignment_id, custom_headers:nil)
602
+ fail ArgumentError, 'role_assignment_id is nil' if role_assignment_id.nil?
603
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
604
+
605
+
606
+ request_headers = {}
607
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
608
+
609
+ # Set Headers
610
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
611
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
612
+ path_template = '{roleAssignmentId}'
613
+
614
+ request_url = @base_url || @client.base_url
615
+
616
+ options = {
617
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
618
+ skip_encoding_path_params: {'roleAssignmentId' => role_assignment_id},
619
+ query_params: {'api-version' => @client.api_version},
620
+ headers: request_headers.merge(custom_headers || {}),
621
+ base_url: request_url
622
+ }
623
+ promise = @client.make_request_async(:delete, path_template, options)
624
+
625
+ promise = promise.then do |result|
626
+ http_response = result.response
627
+ status_code = http_response.status
628
+ response_content = http_response.body
629
+ unless status_code == 200
630
+ error_model = JSON.load(response_content)
631
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
632
+ end
633
+
634
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
635
+ # Deserialize Response
636
+ if status_code == 200
637
+ begin
638
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
639
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignment.mapper()
640
+ result.body = @client.deserialize(result_mapper, parsed_response)
641
+ rescue Exception => e
642
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
643
+ end
644
+ end
645
+
646
+ result
647
+ end
648
+
649
+ promise.execute
650
+ end
651
+
652
+ #
653
+ # Creates a role assignment by ID.
654
+ #
655
+ # @param role_assignment_id [String] The ID of the role assignment to create.
656
+ # @param parameters [RoleAssignmentCreateParameters] Parameters for the role
657
+ # assignment.
658
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
659
+ # will be added to the HTTP request.
660
+ #
661
+ # @return [RoleAssignment] operation results.
662
+ #
663
+ def create_by_id(role_assignment_id, parameters, custom_headers:nil)
664
+ response = create_by_id_async(role_assignment_id, parameters, custom_headers:custom_headers).value!
665
+ response.body unless response.nil?
666
+ end
667
+
668
+ #
669
+ # Creates a role assignment by ID.
670
+ #
671
+ # @param role_assignment_id [String] The ID of the role assignment to create.
672
+ # @param parameters [RoleAssignmentCreateParameters] Parameters for the role
673
+ # assignment.
674
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
675
+ # will be added to the HTTP request.
676
+ #
677
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
678
+ #
679
+ def create_by_id_with_http_info(role_assignment_id, parameters, custom_headers:nil)
680
+ create_by_id_async(role_assignment_id, parameters, custom_headers:custom_headers).value!
681
+ end
682
+
683
+ #
684
+ # Creates a role assignment by ID.
685
+ #
686
+ # @param role_assignment_id [String] The ID of the role assignment to create.
687
+ # @param parameters [RoleAssignmentCreateParameters] Parameters for the role
688
+ # assignment.
689
+ # @param [Hash{String => String}] A hash of custom headers that will be added
690
+ # to the HTTP request.
691
+ #
692
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
693
+ #
694
+ def create_by_id_async(role_assignment_id, parameters, custom_headers:nil)
695
+ fail ArgumentError, 'role_assignment_id is nil' if role_assignment_id.nil?
696
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
697
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
698
+
699
+
700
+ request_headers = {}
701
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
702
+
703
+ # Set Headers
704
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
705
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
706
+
707
+ # Serialize Request
708
+ request_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentCreateParameters.mapper()
709
+ request_content = @client.serialize(request_mapper, parameters)
710
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
711
+
712
+ path_template = '{roleAssignmentId}'
713
+
714
+ request_url = @base_url || @client.base_url
715
+
716
+ options = {
717
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
718
+ skip_encoding_path_params: {'roleAssignmentId' => role_assignment_id},
719
+ query_params: {'api-version' => @client.api_version},
720
+ body: request_content,
721
+ headers: request_headers.merge(custom_headers || {}),
722
+ base_url: request_url
723
+ }
724
+ promise = @client.make_request_async(:put, path_template, options)
725
+
726
+ promise = promise.then do |result|
727
+ http_response = result.response
728
+ status_code = http_response.status
729
+ response_content = http_response.body
730
+ unless status_code == 201
731
+ error_model = JSON.load(response_content)
732
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
733
+ end
734
+
735
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
736
+ # Deserialize Response
737
+ if status_code == 201
738
+ begin
739
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
740
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignment.mapper()
741
+ result.body = @client.deserialize(result_mapper, parsed_response)
742
+ rescue Exception => e
743
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
744
+ end
745
+ end
746
+
747
+ result
748
+ end
749
+
750
+ promise.execute
751
+ end
752
+
753
+ #
754
+ # Gets a role assignment by ID.
755
+ #
756
+ # @param role_assignment_id [String] The ID of the role assignment to get.
757
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
758
+ # will be added to the HTTP request.
759
+ #
760
+ # @return [RoleAssignment] operation results.
761
+ #
762
+ def get_by_id(role_assignment_id, custom_headers:nil)
763
+ response = get_by_id_async(role_assignment_id, custom_headers:custom_headers).value!
764
+ response.body unless response.nil?
765
+ end
766
+
767
+ #
768
+ # Gets a role assignment by ID.
769
+ #
770
+ # @param role_assignment_id [String] The ID of the role assignment to get.
771
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
772
+ # will be added to the HTTP request.
773
+ #
774
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
775
+ #
776
+ def get_by_id_with_http_info(role_assignment_id, custom_headers:nil)
777
+ get_by_id_async(role_assignment_id, custom_headers:custom_headers).value!
778
+ end
779
+
780
+ #
781
+ # Gets a role assignment by ID.
782
+ #
783
+ # @param role_assignment_id [String] The ID of the role assignment to get.
784
+ # @param [Hash{String => String}] A hash of custom headers that will be added
785
+ # to the HTTP request.
786
+ #
787
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
788
+ #
789
+ def get_by_id_async(role_assignment_id, custom_headers:nil)
790
+ fail ArgumentError, 'role_assignment_id is nil' if role_assignment_id.nil?
791
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
792
+
793
+
794
+ request_headers = {}
795
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
796
+
797
+ # Set Headers
798
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
799
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
800
+ path_template = '{roleAssignmentId}'
801
+
802
+ request_url = @base_url || @client.base_url
803
+
804
+ options = {
805
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
806
+ skip_encoding_path_params: {'roleAssignmentId' => role_assignment_id},
807
+ query_params: {'api-version' => @client.api_version},
808
+ headers: request_headers.merge(custom_headers || {}),
809
+ base_url: request_url
810
+ }
811
+ promise = @client.make_request_async(:get, path_template, options)
812
+
813
+ promise = promise.then do |result|
814
+ http_response = result.response
815
+ status_code = http_response.status
816
+ response_content = http_response.body
817
+ unless status_code == 200
818
+ error_model = JSON.load(response_content)
819
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
820
+ end
821
+
822
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
823
+ # Deserialize Response
824
+ if status_code == 200
825
+ begin
826
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
827
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignment.mapper()
828
+ result.body = @client.deserialize(result_mapper, parsed_response)
829
+ rescue Exception => e
830
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
831
+ end
832
+ end
833
+
834
+ result
835
+ end
836
+
837
+ promise.execute
838
+ end
839
+
840
+ #
841
+ # Gets all role assignments for the subscription.
842
+ #
843
+ # @param filter [String] The filter to apply on the operation. Use
844
+ # $filter=atScope() to return all role assignments at or above the scope. Use
845
+ # $filter=principalId eq {id} to return all role assignments at, above or below
846
+ # the scope for the specified principal.
847
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
848
+ # will be added to the HTTP request.
849
+ #
850
+ # @return [Array<RoleAssignment>] operation results.
851
+ #
852
+ def list(filter:nil, custom_headers:nil)
853
+ first_page = list_as_lazy(filter:filter, custom_headers:custom_headers)
854
+ first_page.get_all_items
855
+ end
856
+
857
+ #
858
+ # Gets all role assignments for the subscription.
859
+ #
860
+ # @param filter [String] The filter to apply on the operation. Use
861
+ # $filter=atScope() to return all role assignments at or above the scope. Use
862
+ # $filter=principalId eq {id} to return all role assignments at, above or below
863
+ # the scope for the specified principal.
864
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
865
+ # will be added to the HTTP request.
866
+ #
867
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
868
+ #
869
+ def list_with_http_info(filter:nil, custom_headers:nil)
870
+ list_async(filter:filter, custom_headers:custom_headers).value!
871
+ end
872
+
873
+ #
874
+ # Gets all role assignments for the subscription.
875
+ #
876
+ # @param filter [String] The filter to apply on the operation. Use
877
+ # $filter=atScope() to return all role assignments at or above the scope. Use
878
+ # $filter=principalId eq {id} to return all role assignments at, above or below
879
+ # the scope for the specified principal.
880
+ # @param [Hash{String => String}] A hash of custom headers that will be added
881
+ # to the HTTP request.
882
+ #
883
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
884
+ #
885
+ def list_async(filter:nil, custom_headers:nil)
886
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
887
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
888
+
889
+
890
+ request_headers = {}
891
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
892
+
893
+ # Set Headers
894
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
895
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
896
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'
897
+
898
+ request_url = @base_url || @client.base_url
899
+
900
+ options = {
901
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
902
+ path_params: {'subscriptionId' => @client.subscription_id},
903
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
904
+ headers: request_headers.merge(custom_headers || {}),
905
+ base_url: request_url
906
+ }
907
+ promise = @client.make_request_async(:get, path_template, options)
908
+
909
+ promise = promise.then do |result|
910
+ http_response = result.response
911
+ status_code = http_response.status
912
+ response_content = http_response.body
913
+ unless status_code == 200
914
+ error_model = JSON.load(response_content)
915
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
916
+ end
917
+
918
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
919
+ # Deserialize Response
920
+ if status_code == 200
921
+ begin
922
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
923
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
924
+ result.body = @client.deserialize(result_mapper, parsed_response)
925
+ rescue Exception => e
926
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
927
+ end
928
+ end
929
+
930
+ result
931
+ end
932
+
933
+ promise.execute
934
+ end
935
+
936
+ #
937
+ # Gets role assignments for a scope.
938
+ #
939
+ # @param scope [String] The scope of the role assignments.
940
+ # @param filter [String] The filter to apply on the operation. Use
941
+ # $filter=atScope() to return all role assignments at or above the scope. Use
942
+ # $filter=principalId eq {id} to return all role assignments at, above or below
943
+ # the scope for the specified principal.
944
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
945
+ # will be added to the HTTP request.
946
+ #
947
+ # @return [Array<RoleAssignment>] operation results.
948
+ #
949
+ def list_for_scope(scope, filter:nil, custom_headers:nil)
950
+ first_page = list_for_scope_as_lazy(scope, filter:filter, custom_headers:custom_headers)
951
+ first_page.get_all_items
952
+ end
953
+
954
+ #
955
+ # Gets role assignments for a scope.
956
+ #
957
+ # @param scope [String] The scope of the role assignments.
958
+ # @param filter [String] The filter to apply on the operation. Use
959
+ # $filter=atScope() to return all role assignments at or above the scope. Use
960
+ # $filter=principalId eq {id} to return all role assignments at, above or below
961
+ # the scope for the specified principal.
962
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
963
+ # will be added to the HTTP request.
964
+ #
965
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
966
+ #
967
+ def list_for_scope_with_http_info(scope, filter:nil, custom_headers:nil)
968
+ list_for_scope_async(scope, filter:filter, custom_headers:custom_headers).value!
969
+ end
970
+
971
+ #
972
+ # Gets role assignments for a scope.
973
+ #
974
+ # @param scope [String] The scope of the role assignments.
975
+ # @param filter [String] The filter to apply on the operation. Use
976
+ # $filter=atScope() to return all role assignments at or above the scope. Use
977
+ # $filter=principalId eq {id} to return all role assignments at, above or below
978
+ # the scope for the specified principal.
979
+ # @param [Hash{String => String}] A hash of custom headers that will be added
980
+ # to the HTTP request.
981
+ #
982
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
983
+ #
984
+ def list_for_scope_async(scope, filter:nil, custom_headers:nil)
985
+ fail ArgumentError, 'scope is nil' if scope.nil?
986
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
987
+
988
+
989
+ request_headers = {}
990
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
991
+
992
+ # Set Headers
993
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
994
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
995
+ path_template = '{scope}/providers/Microsoft.Authorization/roleAssignments'
996
+
997
+ request_url = @base_url || @client.base_url
998
+
999
+ options = {
1000
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1001
+ skip_encoding_path_params: {'scope' => scope},
1002
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
1003
+ headers: request_headers.merge(custom_headers || {}),
1004
+ base_url: request_url
1005
+ }
1006
+ promise = @client.make_request_async(:get, path_template, options)
1007
+
1008
+ promise = promise.then do |result|
1009
+ http_response = result.response
1010
+ status_code = http_response.status
1011
+ response_content = http_response.body
1012
+ unless status_code == 200
1013
+ error_model = JSON.load(response_content)
1014
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1015
+ end
1016
+
1017
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1018
+ # Deserialize Response
1019
+ if status_code == 200
1020
+ begin
1021
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1022
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
1023
+ result.body = @client.deserialize(result_mapper, parsed_response)
1024
+ rescue Exception => e
1025
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1026
+ end
1027
+ end
1028
+
1029
+ result
1030
+ end
1031
+
1032
+ promise.execute
1033
+ end
1034
+
1035
+ #
1036
+ # Gets role assignments for a resource.
1037
+ #
1038
+ # @param next_page_link [String] The NextLink from the previous successful call
1039
+ # to List operation.
1040
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1041
+ # will be added to the HTTP request.
1042
+ #
1043
+ # @return [RoleAssignmentListResult] operation results.
1044
+ #
1045
+ def list_for_resource_next(next_page_link, custom_headers:nil)
1046
+ response = list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
1047
+ response.body unless response.nil?
1048
+ end
1049
+
1050
+ #
1051
+ # Gets role assignments for a resource.
1052
+ #
1053
+ # @param next_page_link [String] The NextLink from the previous successful call
1054
+ # to List operation.
1055
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1056
+ # will be added to the HTTP request.
1057
+ #
1058
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1059
+ #
1060
+ def list_for_resource_next_with_http_info(next_page_link, custom_headers:nil)
1061
+ list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
1062
+ end
1063
+
1064
+ #
1065
+ # Gets role assignments for a resource.
1066
+ #
1067
+ # @param next_page_link [String] The NextLink from the previous successful call
1068
+ # to List operation.
1069
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1070
+ # to the HTTP request.
1071
+ #
1072
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1073
+ #
1074
+ def list_for_resource_next_async(next_page_link, custom_headers:nil)
1075
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1076
+
1077
+
1078
+ request_headers = {}
1079
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1080
+
1081
+ # Set Headers
1082
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1083
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1084
+ path_template = '{nextLink}'
1085
+
1086
+ request_url = @base_url || @client.base_url
1087
+
1088
+ options = {
1089
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1090
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1091
+ headers: request_headers.merge(custom_headers || {}),
1092
+ base_url: request_url
1093
+ }
1094
+ promise = @client.make_request_async(:get, path_template, options)
1095
+
1096
+ promise = promise.then do |result|
1097
+ http_response = result.response
1098
+ status_code = http_response.status
1099
+ response_content = http_response.body
1100
+ unless status_code == 200
1101
+ error_model = JSON.load(response_content)
1102
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1103
+ end
1104
+
1105
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1106
+ # Deserialize Response
1107
+ if status_code == 200
1108
+ begin
1109
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1110
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
1111
+ result.body = @client.deserialize(result_mapper, parsed_response)
1112
+ rescue Exception => e
1113
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1114
+ end
1115
+ end
1116
+
1117
+ result
1118
+ end
1119
+
1120
+ promise.execute
1121
+ end
1122
+
1123
+ #
1124
+ # Gets role assignments for a resource group.
1125
+ #
1126
+ # @param next_page_link [String] The NextLink from the previous successful call
1127
+ # to List operation.
1128
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1129
+ # will be added to the HTTP request.
1130
+ #
1131
+ # @return [RoleAssignmentListResult] operation results.
1132
+ #
1133
+ def list_for_resource_group_next(next_page_link, custom_headers:nil)
1134
+ response = list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
1135
+ response.body unless response.nil?
1136
+ end
1137
+
1138
+ #
1139
+ # Gets role assignments for a resource group.
1140
+ #
1141
+ # @param next_page_link [String] The NextLink from the previous successful call
1142
+ # to List operation.
1143
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1144
+ # will be added to the HTTP request.
1145
+ #
1146
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1147
+ #
1148
+ def list_for_resource_group_next_with_http_info(next_page_link, custom_headers:nil)
1149
+ list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
1150
+ end
1151
+
1152
+ #
1153
+ # Gets role assignments for a resource group.
1154
+ #
1155
+ # @param next_page_link [String] The NextLink from the previous successful call
1156
+ # to List operation.
1157
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1158
+ # to the HTTP request.
1159
+ #
1160
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1161
+ #
1162
+ def list_for_resource_group_next_async(next_page_link, custom_headers:nil)
1163
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1164
+
1165
+
1166
+ request_headers = {}
1167
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1168
+
1169
+ # Set Headers
1170
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1171
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1172
+ path_template = '{nextLink}'
1173
+
1174
+ request_url = @base_url || @client.base_url
1175
+
1176
+ options = {
1177
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1178
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1179
+ headers: request_headers.merge(custom_headers || {}),
1180
+ base_url: request_url
1181
+ }
1182
+ promise = @client.make_request_async(:get, path_template, options)
1183
+
1184
+ promise = promise.then do |result|
1185
+ http_response = result.response
1186
+ status_code = http_response.status
1187
+ response_content = http_response.body
1188
+ unless status_code == 200
1189
+ error_model = JSON.load(response_content)
1190
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1191
+ end
1192
+
1193
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1194
+ # Deserialize Response
1195
+ if status_code == 200
1196
+ begin
1197
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1198
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
1199
+ result.body = @client.deserialize(result_mapper, parsed_response)
1200
+ rescue Exception => e
1201
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1202
+ end
1203
+ end
1204
+
1205
+ result
1206
+ end
1207
+
1208
+ promise.execute
1209
+ end
1210
+
1211
+ #
1212
+ # Gets all role assignments for the subscription.
1213
+ #
1214
+ # @param next_page_link [String] The NextLink from the previous successful call
1215
+ # to List operation.
1216
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1217
+ # will be added to the HTTP request.
1218
+ #
1219
+ # @return [RoleAssignmentListResult] operation results.
1220
+ #
1221
+ def list_next(next_page_link, custom_headers:nil)
1222
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
1223
+ response.body unless response.nil?
1224
+ end
1225
+
1226
+ #
1227
+ # Gets all role assignments for the subscription.
1228
+ #
1229
+ # @param next_page_link [String] The NextLink from the previous successful call
1230
+ # to List operation.
1231
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1232
+ # will be added to the HTTP request.
1233
+ #
1234
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1235
+ #
1236
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
1237
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
1238
+ end
1239
+
1240
+ #
1241
+ # Gets all role assignments for the subscription.
1242
+ #
1243
+ # @param next_page_link [String] The NextLink from the previous successful call
1244
+ # to List operation.
1245
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1246
+ # to the HTTP request.
1247
+ #
1248
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1249
+ #
1250
+ def list_next_async(next_page_link, custom_headers:nil)
1251
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1252
+
1253
+
1254
+ request_headers = {}
1255
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1256
+
1257
+ # Set Headers
1258
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1259
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1260
+ path_template = '{nextLink}'
1261
+
1262
+ request_url = @base_url || @client.base_url
1263
+
1264
+ options = {
1265
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1266
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1267
+ headers: request_headers.merge(custom_headers || {}),
1268
+ base_url: request_url
1269
+ }
1270
+ promise = @client.make_request_async(:get, path_template, options)
1271
+
1272
+ promise = promise.then do |result|
1273
+ http_response = result.response
1274
+ status_code = http_response.status
1275
+ response_content = http_response.body
1276
+ unless status_code == 200
1277
+ error_model = JSON.load(response_content)
1278
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1279
+ end
1280
+
1281
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1282
+ # Deserialize Response
1283
+ if status_code == 200
1284
+ begin
1285
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1286
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
1287
+ result.body = @client.deserialize(result_mapper, parsed_response)
1288
+ rescue Exception => e
1289
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1290
+ end
1291
+ end
1292
+
1293
+ result
1294
+ end
1295
+
1296
+ promise.execute
1297
+ end
1298
+
1299
+ #
1300
+ # Gets role assignments for a scope.
1301
+ #
1302
+ # @param next_page_link [String] The NextLink from the previous successful call
1303
+ # to List operation.
1304
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1305
+ # will be added to the HTTP request.
1306
+ #
1307
+ # @return [RoleAssignmentListResult] operation results.
1308
+ #
1309
+ def list_for_scope_next(next_page_link, custom_headers:nil)
1310
+ response = list_for_scope_next_async(next_page_link, custom_headers:custom_headers).value!
1311
+ response.body unless response.nil?
1312
+ end
1313
+
1314
+ #
1315
+ # Gets role assignments for a scope.
1316
+ #
1317
+ # @param next_page_link [String] The NextLink from the previous successful call
1318
+ # to List operation.
1319
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1320
+ # will be added to the HTTP request.
1321
+ #
1322
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1323
+ #
1324
+ def list_for_scope_next_with_http_info(next_page_link, custom_headers:nil)
1325
+ list_for_scope_next_async(next_page_link, custom_headers:custom_headers).value!
1326
+ end
1327
+
1328
+ #
1329
+ # Gets role assignments for a scope.
1330
+ #
1331
+ # @param next_page_link [String] The NextLink from the previous successful call
1332
+ # to List operation.
1333
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1334
+ # to the HTTP request.
1335
+ #
1336
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1337
+ #
1338
+ def list_for_scope_next_async(next_page_link, custom_headers:nil)
1339
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1340
+
1341
+
1342
+ request_headers = {}
1343
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1344
+
1345
+ # Set Headers
1346
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1347
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1348
+ path_template = '{nextLink}'
1349
+
1350
+ request_url = @base_url || @client.base_url
1351
+
1352
+ options = {
1353
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1354
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1355
+ headers: request_headers.merge(custom_headers || {}),
1356
+ base_url: request_url
1357
+ }
1358
+ promise = @client.make_request_async(:get, path_template, options)
1359
+
1360
+ promise = promise.then do |result|
1361
+ http_response = result.response
1362
+ status_code = http_response.status
1363
+ response_content = http_response.body
1364
+ unless status_code == 200
1365
+ error_model = JSON.load(response_content)
1366
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
1367
+ end
1368
+
1369
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1370
+ # Deserialize Response
1371
+ if status_code == 200
1372
+ begin
1373
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1374
+ result_mapper = Azure::Authorization::Mgmt::V2017_10_01_preview::Models::RoleAssignmentListResult.mapper()
1375
+ result.body = @client.deserialize(result_mapper, parsed_response)
1376
+ rescue Exception => e
1377
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1378
+ end
1379
+ end
1380
+
1381
+ result
1382
+ end
1383
+
1384
+ promise.execute
1385
+ end
1386
+
1387
+ #
1388
+ # Gets role assignments for a resource.
1389
+ #
1390
+ # @param resource_group_name [String] The name of the resource group.
1391
+ # @param resource_provider_namespace [String] The namespace of the resource
1392
+ # provider.
1393
+ # @param parent_resource_path [String] The parent resource identity.
1394
+ # @param resource_type [String] The resource type of the resource.
1395
+ # @param resource_name [String] The name of the resource to get role
1396
+ # assignments for.
1397
+ # @param filter [String] The filter to apply on the operation. Use
1398
+ # $filter=atScope() to return all role assignments at or above the scope. Use
1399
+ # $filter=principalId eq {id} to return all role assignments at, above or below
1400
+ # the scope for the specified principal.
1401
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1402
+ # will be added to the HTTP request.
1403
+ #
1404
+ # @return [RoleAssignmentListResult] which provide lazy access to pages of the
1405
+ # response.
1406
+ #
1407
+ def list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
1408
+ response = list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers).value!
1409
+ unless response.nil?
1410
+ page = response.body
1411
+ page.next_method = Proc.new do |next_page_link|
1412
+ list_for_resource_next_async(next_page_link, custom_headers:custom_headers)
1413
+ end
1414
+ page
1415
+ end
1416
+ end
1417
+
1418
+ #
1419
+ # Gets role assignments for a resource group.
1420
+ #
1421
+ # @param resource_group_name [String] The name of the resource group.
1422
+ # @param filter [String] The filter to apply on the operation. Use
1423
+ # $filter=atScope() to return all role assignments at or above the scope. Use
1424
+ # $filter=principalId eq {id} to return all role assignments at, above or below
1425
+ # the scope for the specified principal.
1426
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1427
+ # will be added to the HTTP request.
1428
+ #
1429
+ # @return [RoleAssignmentListResult] which provide lazy access to pages of the
1430
+ # response.
1431
+ #
1432
+ def list_for_resource_group_as_lazy(resource_group_name, filter:nil, custom_headers:nil)
1433
+ response = list_for_resource_group_async(resource_group_name, filter:filter, custom_headers:custom_headers).value!
1434
+ unless response.nil?
1435
+ page = response.body
1436
+ page.next_method = Proc.new do |next_page_link|
1437
+ list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers)
1438
+ end
1439
+ page
1440
+ end
1441
+ end
1442
+
1443
+ #
1444
+ # Gets all role assignments for the subscription.
1445
+ #
1446
+ # @param filter [String] The filter to apply on the operation. Use
1447
+ # $filter=atScope() to return all role assignments at or above the scope. Use
1448
+ # $filter=principalId eq {id} to return all role assignments at, above or below
1449
+ # the scope for the specified principal.
1450
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1451
+ # will be added to the HTTP request.
1452
+ #
1453
+ # @return [RoleAssignmentListResult] which provide lazy access to pages of the
1454
+ # response.
1455
+ #
1456
+ def list_as_lazy(filter:nil, custom_headers:nil)
1457
+ response = list_async(filter:filter, custom_headers:custom_headers).value!
1458
+ unless response.nil?
1459
+ page = response.body
1460
+ page.next_method = Proc.new do |next_page_link|
1461
+ list_next_async(next_page_link, custom_headers:custom_headers)
1462
+ end
1463
+ page
1464
+ end
1465
+ end
1466
+
1467
+ #
1468
+ # Gets role assignments for a scope.
1469
+ #
1470
+ # @param scope [String] The scope of the role assignments.
1471
+ # @param filter [String] The filter to apply on the operation. Use
1472
+ # $filter=atScope() to return all role assignments at or above the scope. Use
1473
+ # $filter=principalId eq {id} to return all role assignments at, above or below
1474
+ # the scope for the specified principal.
1475
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1476
+ # will be added to the HTTP request.
1477
+ #
1478
+ # @return [RoleAssignmentListResult] which provide lazy access to pages of the
1479
+ # response.
1480
+ #
1481
+ def list_for_scope_as_lazy(scope, filter:nil, custom_headers:nil)
1482
+ response = list_for_scope_async(scope, filter:filter, custom_headers:custom_headers).value!
1483
+ unless response.nil?
1484
+ page = response.body
1485
+ page.next_method = Proc.new do |next_page_link|
1486
+ list_for_scope_next_async(next_page_link, custom_headers:custom_headers)
1487
+ end
1488
+ page
1489
+ end
1490
+ end
1491
+
1492
+ end
1493
+ end