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,622 @@
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::V2018_01_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 RoleDefinitions
15
+ include MsRestAzure
16
+
17
+ #
18
+ # Creates and initializes a new instance of the RoleDefinitions 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
+ # Deletes a role definition.
30
+ #
31
+ # @param scope [String] The scope of the role definition.
32
+ # @param role_definition_id [String] The ID of the role definition to delete.
33
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
34
+ # will be added to the HTTP request.
35
+ #
36
+ # @return [RoleDefinition] operation results.
37
+ #
38
+ def delete(scope, role_definition_id, custom_headers:nil)
39
+ response = delete_async(scope, role_definition_id, custom_headers:custom_headers).value!
40
+ response.body unless response.nil?
41
+ end
42
+
43
+ #
44
+ # Deletes a role definition.
45
+ #
46
+ # @param scope [String] The scope of the role definition.
47
+ # @param role_definition_id [String] The ID of the role definition to delete.
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
52
+ #
53
+ def delete_with_http_info(scope, role_definition_id, custom_headers:nil)
54
+ delete_async(scope, role_definition_id, custom_headers:custom_headers).value!
55
+ end
56
+
57
+ #
58
+ # Deletes a role definition.
59
+ #
60
+ # @param scope [String] The scope of the role definition.
61
+ # @param role_definition_id [String] The ID of the role definition to delete.
62
+ # @param [Hash{String => String}] A hash of custom headers that will be added
63
+ # to the HTTP request.
64
+ #
65
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
66
+ #
67
+ def delete_async(scope, role_definition_id, custom_headers:nil)
68
+ fail ArgumentError, 'scope is nil' if scope.nil?
69
+ fail ArgumentError, 'role_definition_id is nil' if role_definition_id.nil?
70
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
71
+
72
+
73
+ request_headers = {}
74
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
75
+
76
+ # Set Headers
77
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
78
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
79
+ path_template = '{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'
80
+
81
+ request_url = @base_url || @client.base_url
82
+
83
+ options = {
84
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
85
+ path_params: {'roleDefinitionId' => role_definition_id},
86
+ skip_encoding_path_params: {'scope' => scope},
87
+ query_params: {'api-version' => @client.api_version},
88
+ headers: request_headers.merge(custom_headers || {}),
89
+ base_url: request_url
90
+ }
91
+ promise = @client.make_request_async(:delete, path_template, options)
92
+
93
+ promise = promise.then do |result|
94
+ http_response = result.response
95
+ status_code = http_response.status
96
+ response_content = http_response.body
97
+ unless status_code == 200
98
+ error_model = JSON.load(response_content)
99
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
100
+ end
101
+
102
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
103
+ # Deserialize Response
104
+ if status_code == 200
105
+ begin
106
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
107
+ result_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinition.mapper()
108
+ result.body = @client.deserialize(result_mapper, parsed_response)
109
+ rescue Exception => e
110
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
111
+ end
112
+ end
113
+
114
+ result
115
+ end
116
+
117
+ promise.execute
118
+ end
119
+
120
+ #
121
+ # Get role definition by name (GUID).
122
+ #
123
+ # @param scope [String] The scope of the role definition.
124
+ # @param role_definition_id [String] The ID of the role definition.
125
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
126
+ # will be added to the HTTP request.
127
+ #
128
+ # @return [RoleDefinition] operation results.
129
+ #
130
+ def get(scope, role_definition_id, custom_headers:nil)
131
+ response = get_async(scope, role_definition_id, custom_headers:custom_headers).value!
132
+ response.body unless response.nil?
133
+ end
134
+
135
+ #
136
+ # Get role definition by name (GUID).
137
+ #
138
+ # @param scope [String] The scope of the role definition.
139
+ # @param role_definition_id [String] The ID of the role definition.
140
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
141
+ # will be added to the HTTP request.
142
+ #
143
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
144
+ #
145
+ def get_with_http_info(scope, role_definition_id, custom_headers:nil)
146
+ get_async(scope, role_definition_id, custom_headers:custom_headers).value!
147
+ end
148
+
149
+ #
150
+ # Get role definition by name (GUID).
151
+ #
152
+ # @param scope [String] The scope of the role definition.
153
+ # @param role_definition_id [String] The ID of the role definition.
154
+ # @param [Hash{String => String}] A hash of custom headers that will be added
155
+ # to the HTTP request.
156
+ #
157
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
158
+ #
159
+ def get_async(scope, role_definition_id, custom_headers:nil)
160
+ fail ArgumentError, 'scope is nil' if scope.nil?
161
+ fail ArgumentError, 'role_definition_id is nil' if role_definition_id.nil?
162
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
163
+
164
+
165
+ request_headers = {}
166
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
167
+
168
+ # Set Headers
169
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
170
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
171
+ path_template = '{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'
172
+
173
+ request_url = @base_url || @client.base_url
174
+
175
+ options = {
176
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
177
+ path_params: {'roleDefinitionId' => role_definition_id},
178
+ skip_encoding_path_params: {'scope' => scope},
179
+ query_params: {'api-version' => @client.api_version},
180
+ headers: request_headers.merge(custom_headers || {}),
181
+ base_url: request_url
182
+ }
183
+ promise = @client.make_request_async(:get, path_template, options)
184
+
185
+ promise = promise.then do |result|
186
+ http_response = result.response
187
+ status_code = http_response.status
188
+ response_content = http_response.body
189
+ unless status_code == 200
190
+ error_model = JSON.load(response_content)
191
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
192
+ end
193
+
194
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
195
+ # Deserialize Response
196
+ if status_code == 200
197
+ begin
198
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
199
+ result_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinition.mapper()
200
+ result.body = @client.deserialize(result_mapper, parsed_response)
201
+ rescue Exception => e
202
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
203
+ end
204
+ end
205
+
206
+ result
207
+ end
208
+
209
+ promise.execute
210
+ end
211
+
212
+ #
213
+ # Creates or updates a role definition.
214
+ #
215
+ # @param scope [String] The scope of the role definition.
216
+ # @param role_definition_id [String] The ID of the role definition.
217
+ # @param role_definition [RoleDefinition] The values for the role definition.
218
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
219
+ # will be added to the HTTP request.
220
+ #
221
+ # @return [RoleDefinition] operation results.
222
+ #
223
+ def create_or_update(scope, role_definition_id, role_definition, custom_headers:nil)
224
+ response = create_or_update_async(scope, role_definition_id, role_definition, custom_headers:custom_headers).value!
225
+ response.body unless response.nil?
226
+ end
227
+
228
+ #
229
+ # Creates or updates a role definition.
230
+ #
231
+ # @param scope [String] The scope of the role definition.
232
+ # @param role_definition_id [String] The ID of the role definition.
233
+ # @param role_definition [RoleDefinition] The values for the role definition.
234
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
235
+ # will be added to the HTTP request.
236
+ #
237
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
238
+ #
239
+ def create_or_update_with_http_info(scope, role_definition_id, role_definition, custom_headers:nil)
240
+ create_or_update_async(scope, role_definition_id, role_definition, custom_headers:custom_headers).value!
241
+ end
242
+
243
+ #
244
+ # Creates or updates a role definition.
245
+ #
246
+ # @param scope [String] The scope of the role definition.
247
+ # @param role_definition_id [String] The ID of the role definition.
248
+ # @param role_definition [RoleDefinition] The values for the role definition.
249
+ # @param [Hash{String => String}] A hash of custom headers that will be added
250
+ # to the HTTP request.
251
+ #
252
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
253
+ #
254
+ def create_or_update_async(scope, role_definition_id, role_definition, custom_headers:nil)
255
+ fail ArgumentError, 'scope is nil' if scope.nil?
256
+ fail ArgumentError, 'role_definition_id is nil' if role_definition_id.nil?
257
+ fail ArgumentError, 'role_definition is nil' if role_definition.nil?
258
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
259
+
260
+
261
+ request_headers = {}
262
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
263
+
264
+ # Set Headers
265
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
266
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
267
+
268
+ # Serialize Request
269
+ request_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinition.mapper()
270
+ request_content = @client.serialize(request_mapper, role_definition)
271
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
272
+
273
+ path_template = '{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'
274
+
275
+ request_url = @base_url || @client.base_url
276
+
277
+ options = {
278
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
279
+ path_params: {'roleDefinitionId' => role_definition_id},
280
+ skip_encoding_path_params: {'scope' => scope},
281
+ query_params: {'api-version' => @client.api_version},
282
+ body: request_content,
283
+ headers: request_headers.merge(custom_headers || {}),
284
+ base_url: request_url
285
+ }
286
+ promise = @client.make_request_async(:put, path_template, options)
287
+
288
+ promise = promise.then do |result|
289
+ http_response = result.response
290
+ status_code = http_response.status
291
+ response_content = http_response.body
292
+ unless status_code == 201
293
+ error_model = JSON.load(response_content)
294
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
295
+ end
296
+
297
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
298
+ # Deserialize Response
299
+ if status_code == 201
300
+ begin
301
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
302
+ result_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinition.mapper()
303
+ result.body = @client.deserialize(result_mapper, parsed_response)
304
+ rescue Exception => e
305
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
306
+ end
307
+ end
308
+
309
+ result
310
+ end
311
+
312
+ promise.execute
313
+ end
314
+
315
+ #
316
+ # Get all role definitions that are applicable at scope and above.
317
+ #
318
+ # @param scope [String] The scope of the role definition.
319
+ # @param filter [String] The filter to apply on the operation. Use
320
+ # atScopeAndBelow filter to search below the given scope as well.
321
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
322
+ # will be added to the HTTP request.
323
+ #
324
+ # @return [Array<RoleDefinition>] operation results.
325
+ #
326
+ def list(scope, filter:nil, custom_headers:nil)
327
+ first_page = list_as_lazy(scope, filter:filter, custom_headers:custom_headers)
328
+ first_page.get_all_items
329
+ end
330
+
331
+ #
332
+ # Get all role definitions that are applicable at scope and above.
333
+ #
334
+ # @param scope [String] The scope of the role definition.
335
+ # @param filter [String] The filter to apply on the operation. Use
336
+ # atScopeAndBelow filter to search below the given scope as well.
337
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
338
+ # will be added to the HTTP request.
339
+ #
340
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
341
+ #
342
+ def list_with_http_info(scope, filter:nil, custom_headers:nil)
343
+ list_async(scope, filter:filter, custom_headers:custom_headers).value!
344
+ end
345
+
346
+ #
347
+ # Get all role definitions that are applicable at scope and above.
348
+ #
349
+ # @param scope [String] The scope of the role definition.
350
+ # @param filter [String] The filter to apply on the operation. Use
351
+ # atScopeAndBelow filter to search below the given scope as well.
352
+ # @param [Hash{String => String}] A hash of custom headers that will be added
353
+ # to the HTTP request.
354
+ #
355
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
356
+ #
357
+ def list_async(scope, filter:nil, custom_headers:nil)
358
+ fail ArgumentError, 'scope is nil' if scope.nil?
359
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
360
+
361
+
362
+ request_headers = {}
363
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
364
+
365
+ # Set Headers
366
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
367
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
368
+ path_template = '{scope}/providers/Microsoft.Authorization/roleDefinitions'
369
+
370
+ request_url = @base_url || @client.base_url
371
+
372
+ options = {
373
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
374
+ skip_encoding_path_params: {'scope' => scope},
375
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
376
+ headers: request_headers.merge(custom_headers || {}),
377
+ base_url: request_url
378
+ }
379
+ promise = @client.make_request_async(:get, path_template, options)
380
+
381
+ promise = promise.then do |result|
382
+ http_response = result.response
383
+ status_code = http_response.status
384
+ response_content = http_response.body
385
+ unless status_code == 200
386
+ error_model = JSON.load(response_content)
387
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
388
+ end
389
+
390
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
391
+ # Deserialize Response
392
+ if status_code == 200
393
+ begin
394
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
395
+ result_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinitionListResult.mapper()
396
+ result.body = @client.deserialize(result_mapper, parsed_response)
397
+ rescue Exception => e
398
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
399
+ end
400
+ end
401
+
402
+ result
403
+ end
404
+
405
+ promise.execute
406
+ end
407
+
408
+ #
409
+ # Gets a role definition by ID.
410
+ #
411
+ # @param role_id [String] The fully qualified role definition ID. Use the
412
+ # format,
413
+ # /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}
414
+ # for subscription level role definitions, or
415
+ # /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for
416
+ # tenant level role definitions.
417
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
418
+ # will be added to the HTTP request.
419
+ #
420
+ # @return [RoleDefinition] operation results.
421
+ #
422
+ def get_by_id(role_id, custom_headers:nil)
423
+ response = get_by_id_async(role_id, custom_headers:custom_headers).value!
424
+ response.body unless response.nil?
425
+ end
426
+
427
+ #
428
+ # Gets a role definition by ID.
429
+ #
430
+ # @param role_id [String] The fully qualified role definition ID. Use the
431
+ # format,
432
+ # /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}
433
+ # for subscription level role definitions, or
434
+ # /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for
435
+ # tenant level role definitions.
436
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
437
+ # will be added to the HTTP request.
438
+ #
439
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
440
+ #
441
+ def get_by_id_with_http_info(role_id, custom_headers:nil)
442
+ get_by_id_async(role_id, custom_headers:custom_headers).value!
443
+ end
444
+
445
+ #
446
+ # Gets a role definition by ID.
447
+ #
448
+ # @param role_id [String] The fully qualified role definition ID. Use the
449
+ # format,
450
+ # /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}
451
+ # for subscription level role definitions, or
452
+ # /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for
453
+ # tenant level role definitions.
454
+ # @param [Hash{String => String}] A hash of custom headers that will be added
455
+ # to the HTTP request.
456
+ #
457
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
458
+ #
459
+ def get_by_id_async(role_id, custom_headers:nil)
460
+ fail ArgumentError, 'role_id is nil' if role_id.nil?
461
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
462
+
463
+
464
+ request_headers = {}
465
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
466
+
467
+ # Set Headers
468
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
469
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
470
+ path_template = '{roleId}'
471
+
472
+ request_url = @base_url || @client.base_url
473
+
474
+ options = {
475
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
476
+ skip_encoding_path_params: {'roleId' => role_id},
477
+ query_params: {'api-version' => @client.api_version},
478
+ headers: request_headers.merge(custom_headers || {}),
479
+ base_url: request_url
480
+ }
481
+ promise = @client.make_request_async(:get, path_template, options)
482
+
483
+ promise = promise.then do |result|
484
+ http_response = result.response
485
+ status_code = http_response.status
486
+ response_content = http_response.body
487
+ unless status_code == 200
488
+ error_model = JSON.load(response_content)
489
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
490
+ end
491
+
492
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
493
+ # Deserialize Response
494
+ if status_code == 200
495
+ begin
496
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
497
+ result_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinition.mapper()
498
+ result.body = @client.deserialize(result_mapper, parsed_response)
499
+ rescue Exception => e
500
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
501
+ end
502
+ end
503
+
504
+ result
505
+ end
506
+
507
+ promise.execute
508
+ end
509
+
510
+ #
511
+ # Get all role definitions that are applicable at scope and above.
512
+ #
513
+ # @param next_page_link [String] The NextLink from the previous successful call
514
+ # to List operation.
515
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
516
+ # will be added to the HTTP request.
517
+ #
518
+ # @return [RoleDefinitionListResult] operation results.
519
+ #
520
+ def list_next(next_page_link, custom_headers:nil)
521
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
522
+ response.body unless response.nil?
523
+ end
524
+
525
+ #
526
+ # Get all role definitions that are applicable at scope and above.
527
+ #
528
+ # @param next_page_link [String] The NextLink from the previous successful call
529
+ # to List operation.
530
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
531
+ # will be added to the HTTP request.
532
+ #
533
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
534
+ #
535
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
536
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
537
+ end
538
+
539
+ #
540
+ # Get all role definitions that are applicable at scope and above.
541
+ #
542
+ # @param next_page_link [String] The NextLink from the previous successful call
543
+ # to List operation.
544
+ # @param [Hash{String => String}] A hash of custom headers that will be added
545
+ # to the HTTP request.
546
+ #
547
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
548
+ #
549
+ def list_next_async(next_page_link, custom_headers:nil)
550
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
551
+
552
+
553
+ request_headers = {}
554
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
555
+
556
+ # Set Headers
557
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
558
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
559
+ path_template = '{nextLink}'
560
+
561
+ request_url = @base_url || @client.base_url
562
+
563
+ options = {
564
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
565
+ skip_encoding_path_params: {'nextLink' => next_page_link},
566
+ headers: request_headers.merge(custom_headers || {}),
567
+ base_url: request_url
568
+ }
569
+ promise = @client.make_request_async(:get, path_template, options)
570
+
571
+ promise = promise.then do |result|
572
+ http_response = result.response
573
+ status_code = http_response.status
574
+ response_content = http_response.body
575
+ unless status_code == 200
576
+ error_model = JSON.load(response_content)
577
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
578
+ end
579
+
580
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
581
+ # Deserialize Response
582
+ if status_code == 200
583
+ begin
584
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
585
+ result_mapper = Azure::Authorization::Mgmt::V2018_01_01_preview::Models::RoleDefinitionListResult.mapper()
586
+ result.body = @client.deserialize(result_mapper, parsed_response)
587
+ rescue Exception => e
588
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
589
+ end
590
+ end
591
+
592
+ result
593
+ end
594
+
595
+ promise.execute
596
+ end
597
+
598
+ #
599
+ # Get all role definitions that are applicable at scope and above.
600
+ #
601
+ # @param scope [String] The scope of the role definition.
602
+ # @param filter [String] The filter to apply on the operation. Use
603
+ # atScopeAndBelow filter to search below the given scope as well.
604
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
605
+ # will be added to the HTTP request.
606
+ #
607
+ # @return [RoleDefinitionListResult] which provide lazy access to pages of the
608
+ # response.
609
+ #
610
+ def list_as_lazy(scope, filter:nil, custom_headers:nil)
611
+ response = list_async(scope, filter:filter, custom_headers:custom_headers).value!
612
+ unless response.nil?
613
+ page = response.body
614
+ page.next_method = Proc.new do |next_page_link|
615
+ list_next_async(next_page_link, custom_headers:custom_headers)
616
+ end
617
+ page
618
+ end
619
+ end
620
+
621
+ end
622
+ end
@@ -0,0 +1,44 @@
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
+ require 'uri'
7
+ require 'cgi'
8
+ require 'date'
9
+ require 'json'
10
+ require 'base64'
11
+ require 'erb'
12
+ require 'securerandom'
13
+ require 'time'
14
+ require 'timeliness'
15
+ require 'faraday'
16
+ require 'faraday-cookie_jar'
17
+ require 'concurrent'
18
+ require 'ms_rest'
19
+ require '2018-01-01-preview/generated/azure_mgmt_authorization/module_definition'
20
+ require 'ms_rest_azure'
21
+
22
+ module Azure::Authorization::Mgmt::V2018_01_01_preview
23
+ autoload :ProviderOperationsMetadataOperations, '2018-01-01-preview/generated/azure_mgmt_authorization/provider_operations_metadata_operations.rb'
24
+ autoload :Permissions, '2018-01-01-preview/generated/azure_mgmt_authorization/permissions.rb'
25
+ autoload :RoleAssignments, '2018-01-01-preview/generated/azure_mgmt_authorization/role_assignments.rb'
26
+ autoload :RoleDefinitions, '2018-01-01-preview/generated/azure_mgmt_authorization/role_definitions.rb'
27
+ autoload :AuthorizationManagementClient, '2018-01-01-preview/generated/azure_mgmt_authorization/authorization_management_client.rb'
28
+
29
+ module Models
30
+ autoload :RoleDefinitionFilter, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_definition_filter.rb'
31
+ autoload :RoleDefinition, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_definition.rb'
32
+ autoload :ResourceType, '2018-01-01-preview/generated/azure_mgmt_authorization/models/resource_type.rb'
33
+ autoload :RoleDefinitionListResult, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_definition_list_result.rb'
34
+ autoload :ProviderOperationsMetadataListResult, '2018-01-01-preview/generated/azure_mgmt_authorization/models/provider_operations_metadata_list_result.rb'
35
+ autoload :RoleAssignmentFilter, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment_filter.rb'
36
+ autoload :PermissionGetResult, '2018-01-01-preview/generated/azure_mgmt_authorization/models/permission_get_result.rb'
37
+ autoload :RoleAssignment, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment.rb'
38
+ autoload :ProviderOperationsMetadata, '2018-01-01-preview/generated/azure_mgmt_authorization/models/provider_operations_metadata.rb'
39
+ autoload :RoleAssignmentListResult, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment_list_result.rb'
40
+ autoload :ProviderOperation, '2018-01-01-preview/generated/azure_mgmt_authorization/models/provider_operation.rb'
41
+ autoload :RoleAssignmentCreateParameters, '2018-01-01-preview/generated/azure_mgmt_authorization/models/role_assignment_create_parameters.rb'
42
+ autoload :Permission, '2018-01-01-preview/generated/azure_mgmt_authorization/models/permission.rb'
43
+ end
44
+ end
@@ -2,5 +2,8 @@
2
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  # Licensed under the MIT License. See License.txt in the project root for license information.
4
4
 
5
+ require '2015-06-01/generated/azure_mgmt_authorization'
5
6
  require '2015-07-01/generated/azure_mgmt_authorization'
7
+ require '2017-10-01-preview/generated/azure_mgmt_authorization'
8
+ require '2018-01-01-preview/generated/azure_mgmt_authorization'
6
9
  require 'profiles/latest/authorization_latest_profile_client'