azure_mgmt_policy 0.14.0 → 0.15.0

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