azure_mgmt_policy 0.17.4 → 0.17.9

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