azure_mgmt_policy 0.17.1 → 0.17.2

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