azure_mgmt_policy_insights 0.17.7 → 0.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +1 -1
  3. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +1 -1
  4. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +1 -1
  5. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_insights_client.rb +1 -1
  6. data/lib/2018-07-01-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results.rb +43 -0
  7. data/lib/2018-07-01-preview/generated/azure_mgmt_policy_insights/models/query_options.rb +11 -0
  8. data/lib/2018-07-01-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +1 -1
  9. data/lib/2018-07-01-preview/generated/azure_mgmt_policy_insights/policy_states.rb +998 -32
  10. data/lib/2019-07-01/generated/azure_mgmt_policy_insights.rb +39 -0
  11. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/error_definition.rb +115 -0
  12. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/error_response.rb +47 -0
  13. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/query_options.rb +54 -0
  14. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/remediation.rb +172 -0
  15. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/remediation_deployment.rb +124 -0
  16. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/remediation_deployment_summary.rb +75 -0
  17. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/remediation_deployments_list_result.rb +101 -0
  18. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/remediation_filters.rb +55 -0
  19. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/remediation_list_result.rb +100 -0
  20. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/resource_discovery_mode.rb +16 -0
  21. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/models/typed_error_info.rb +59 -0
  22. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/module_definition.rb +9 -0
  23. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/policy_insights_client.rb +131 -0
  24. data/lib/2019-07-01/generated/azure_mgmt_policy_insights/remediations.rb +3294 -0
  25. data/lib/2019-10-01/generated/azure_mgmt_policy_insights.rb +18 -13
  26. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/component_event_details.rb +132 -0
  27. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/component_state_details.rb +109 -0
  28. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/expression_evaluation_details.rb +12 -0
  29. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/policy_event.rb +416 -0
  30. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/policy_events_query_results.rb +125 -0
  31. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/policy_state.rb +21 -0
  32. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/policy_states_query_results.rb +43 -0
  33. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/models/query_options.rb +12 -1
  34. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/policy_events.rb +1961 -0
  35. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/policy_insights_client.rb +5 -1
  36. data/lib/2019-10-01/generated/azure_mgmt_policy_insights/policy_states.rb +998 -32
  37. data/lib/azure_mgmt_policy_insights.rb +4 -3
  38. data/lib/profiles/latest/modules/policyinsights_profile_module.rb +23 -11
  39. data/lib/version.rb +1 -1
  40. metadata +23 -3
@@ -0,0 +1,3294 @@
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::PolicyInsights::Mgmt::V2019_07_01
7
+ #
8
+ # Remediations
9
+ #
10
+ class Remediations
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Remediations class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [PolicyInsightsClient] reference to the PolicyInsightsClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Gets all deployments for a remediation at management group scope.
26
+ #
27
+ # @param management_group_id [String] Management group ID.
28
+ # @param remediation_name [String] The name of the remediation.
29
+ # @param query_options [QueryOptions] Additional parameters for the operation
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
32
+ #
33
+ # @return [Array<RemediationDeployment>] operation results.
34
+ #
35
+ def list_deployments_at_management_group(management_group_id, remediation_name, query_options:nil, custom_headers:nil)
36
+ first_page = list_deployments_at_management_group_as_lazy(management_group_id, remediation_name, query_options:query_options, custom_headers:custom_headers)
37
+ first_page.get_all_items
38
+ end
39
+
40
+ #
41
+ # Gets all deployments for a remediation at management group scope.
42
+ #
43
+ # @param management_group_id [String] Management group ID.
44
+ # @param remediation_name [String] The name of the remediation.
45
+ # @param query_options [QueryOptions] Additional parameters for the operation
46
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
47
+ # will be added to the HTTP request.
48
+ #
49
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
50
+ #
51
+ def list_deployments_at_management_group_with_http_info(management_group_id, remediation_name, query_options:nil, custom_headers:nil)
52
+ list_deployments_at_management_group_async(management_group_id, remediation_name, query_options:query_options, custom_headers:custom_headers).value!
53
+ end
54
+
55
+ #
56
+ # Gets all deployments for a remediation at management group scope.
57
+ #
58
+ # @param management_group_id [String] Management group ID.
59
+ # @param remediation_name [String] The name of the remediation.
60
+ # @param query_options [QueryOptions] Additional parameters for the operation
61
+ # @param [Hash{String => String}] A hash of custom headers that will be added
62
+ # to the HTTP request.
63
+ #
64
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
65
+ #
66
+ def list_deployments_at_management_group_async(management_group_id, remediation_name, query_options:nil, custom_headers:nil)
67
+ management_groups_namespace = 'Microsoft.Management'
68
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
69
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
70
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
71
+
72
+ top = nil
73
+ unless query_options.nil?
74
+ top = query_options.Top
75
+ end
76
+
77
+ request_headers = {}
78
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
79
+
80
+ # Set Headers
81
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
82
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
83
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments'
84
+
85
+ request_url = @base_url || @client.base_url
86
+
87
+ options = {
88
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
89
+ path_params: {'managementGroupsNamespace' => management_groups_namespace,'managementGroupId' => management_group_id,'remediationName' => remediation_name},
90
+ query_params: {'api-version' => @client.api_version,'$top' => top},
91
+ headers: request_headers.merge(custom_headers || {}),
92
+ base_url: request_url
93
+ }
94
+ promise = @client.make_request_async(:post, path_template, options)
95
+
96
+ promise = promise.then do |result|
97
+ http_response = result.response
98
+ status_code = http_response.status
99
+ response_content = http_response.body
100
+ unless status_code == 200
101
+ error_model = JSON.load(response_content)
102
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
103
+ end
104
+
105
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
106
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
107
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
108
+ # Deserialize Response
109
+ if status_code == 200
110
+ begin
111
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
112
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
113
+ result.body = @client.deserialize(result_mapper, parsed_response)
114
+ rescue Exception => e
115
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
116
+ end
117
+ end
118
+
119
+ result
120
+ end
121
+
122
+ promise.execute
123
+ end
124
+
125
+ #
126
+ # Cancels a remediation at management group scope.
127
+ #
128
+ # @param management_group_id [String] Management group ID.
129
+ # @param remediation_name [String] The name of the remediation.
130
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
131
+ # will be added to the HTTP request.
132
+ #
133
+ # @return [Remediation] operation results.
134
+ #
135
+ def cancel_at_management_group(management_group_id, remediation_name, custom_headers:nil)
136
+ response = cancel_at_management_group_async(management_group_id, remediation_name, custom_headers:custom_headers).value!
137
+ response.body unless response.nil?
138
+ end
139
+
140
+ #
141
+ # Cancels a remediation at management group scope.
142
+ #
143
+ # @param management_group_id [String] Management group ID.
144
+ # @param remediation_name [String] The name of the remediation.
145
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
146
+ # will be added to the HTTP request.
147
+ #
148
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
149
+ #
150
+ def cancel_at_management_group_with_http_info(management_group_id, remediation_name, custom_headers:nil)
151
+ cancel_at_management_group_async(management_group_id, remediation_name, custom_headers:custom_headers).value!
152
+ end
153
+
154
+ #
155
+ # Cancels a remediation at management group scope.
156
+ #
157
+ # @param management_group_id [String] Management group ID.
158
+ # @param remediation_name [String] The name of the remediation.
159
+ # @param [Hash{String => String}] A hash of custom headers that will be added
160
+ # to the HTTP request.
161
+ #
162
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
163
+ #
164
+ def cancel_at_management_group_async(management_group_id, remediation_name, custom_headers:nil)
165
+ management_groups_namespace = 'Microsoft.Management'
166
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
167
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
168
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
169
+
170
+
171
+ request_headers = {}
172
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
173
+
174
+ # Set Headers
175
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
176
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
177
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel'
178
+
179
+ request_url = @base_url || @client.base_url
180
+
181
+ options = {
182
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
183
+ path_params: {'managementGroupsNamespace' => management_groups_namespace,'managementGroupId' => management_group_id,'remediationName' => remediation_name},
184
+ query_params: {'api-version' => @client.api_version},
185
+ headers: request_headers.merge(custom_headers || {}),
186
+ base_url: request_url
187
+ }
188
+ promise = @client.make_request_async(:post, path_template, options)
189
+
190
+ promise = promise.then do |result|
191
+ http_response = result.response
192
+ status_code = http_response.status
193
+ response_content = http_response.body
194
+ unless status_code == 200
195
+ error_model = JSON.load(response_content)
196
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
197
+ end
198
+
199
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
200
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
201
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
202
+ # Deserialize Response
203
+ if status_code == 200
204
+ begin
205
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
206
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
207
+ result.body = @client.deserialize(result_mapper, parsed_response)
208
+ rescue Exception => e
209
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
210
+ end
211
+ end
212
+
213
+ result
214
+ end
215
+
216
+ promise.execute
217
+ end
218
+
219
+ #
220
+ # Gets all remediations for the management group.
221
+ #
222
+ # @param management_group_id [String] Management group ID.
223
+ # @param query_options [QueryOptions] Additional parameters for the operation
224
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
225
+ # will be added to the HTTP request.
226
+ #
227
+ # @return [Array<Remediation>] operation results.
228
+ #
229
+ def list_for_management_group(management_group_id, query_options:nil, custom_headers:nil)
230
+ first_page = list_for_management_group_as_lazy(management_group_id, query_options:query_options, custom_headers:custom_headers)
231
+ first_page.get_all_items
232
+ end
233
+
234
+ #
235
+ # Gets all remediations for the management group.
236
+ #
237
+ # @param management_group_id [String] Management group ID.
238
+ # @param query_options [QueryOptions] Additional parameters for the operation
239
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
240
+ # will be added to the HTTP request.
241
+ #
242
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
243
+ #
244
+ def list_for_management_group_with_http_info(management_group_id, query_options:nil, custom_headers:nil)
245
+ list_for_management_group_async(management_group_id, query_options:query_options, custom_headers:custom_headers).value!
246
+ end
247
+
248
+ #
249
+ # Gets all remediations for the management group.
250
+ #
251
+ # @param management_group_id [String] Management group ID.
252
+ # @param query_options [QueryOptions] Additional parameters for the operation
253
+ # @param [Hash{String => String}] A hash of custom headers that will be added
254
+ # to the HTTP request.
255
+ #
256
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
257
+ #
258
+ def list_for_management_group_async(management_group_id, query_options:nil, custom_headers:nil)
259
+ management_groups_namespace = 'Microsoft.Management'
260
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
261
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
262
+
263
+ top = nil
264
+ filter = nil
265
+ unless query_options.nil?
266
+ top = query_options.Top
267
+ end
268
+ unless query_options.nil?
269
+ filter = query_options.Filter
270
+ end
271
+
272
+ request_headers = {}
273
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
274
+
275
+ # Set Headers
276
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
277
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
278
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations'
279
+
280
+ request_url = @base_url || @client.base_url
281
+
282
+ options = {
283
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
284
+ path_params: {'managementGroupsNamespace' => management_groups_namespace,'managementGroupId' => management_group_id},
285
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$filter' => filter},
286
+ headers: request_headers.merge(custom_headers || {}),
287
+ base_url: request_url
288
+ }
289
+ promise = @client.make_request_async(:get, path_template, options)
290
+
291
+ promise = promise.then do |result|
292
+ http_response = result.response
293
+ status_code = http_response.status
294
+ response_content = http_response.body
295
+ unless status_code == 200
296
+ error_model = JSON.load(response_content)
297
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
298
+ end
299
+
300
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
301
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
302
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
303
+ # Deserialize Response
304
+ if status_code == 200
305
+ begin
306
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
307
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
308
+ result.body = @client.deserialize(result_mapper, parsed_response)
309
+ rescue Exception => e
310
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
311
+ end
312
+ end
313
+
314
+ result
315
+ end
316
+
317
+ promise.execute
318
+ end
319
+
320
+ #
321
+ # Creates or updates a remediation at management group scope.
322
+ #
323
+ # @param management_group_id [String] Management group ID.
324
+ # @param remediation_name [String] The name of the remediation.
325
+ # @param parameters [Remediation] The remediation parameters.
326
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
327
+ # will be added to the HTTP request.
328
+ #
329
+ # @return [Remediation] operation results.
330
+ #
331
+ def create_or_update_at_management_group(management_group_id, remediation_name, parameters, custom_headers:nil)
332
+ response = create_or_update_at_management_group_async(management_group_id, remediation_name, parameters, custom_headers:custom_headers).value!
333
+ response.body unless response.nil?
334
+ end
335
+
336
+ #
337
+ # Creates or updates a remediation at management group scope.
338
+ #
339
+ # @param management_group_id [String] Management group ID.
340
+ # @param remediation_name [String] The name of the remediation.
341
+ # @param parameters [Remediation] The remediation parameters.
342
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
343
+ # will be added to the HTTP request.
344
+ #
345
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
346
+ #
347
+ def create_or_update_at_management_group_with_http_info(management_group_id, remediation_name, parameters, custom_headers:nil)
348
+ create_or_update_at_management_group_async(management_group_id, remediation_name, parameters, custom_headers:custom_headers).value!
349
+ end
350
+
351
+ #
352
+ # Creates or updates a remediation at management group scope.
353
+ #
354
+ # @param management_group_id [String] Management group ID.
355
+ # @param remediation_name [String] The name of the remediation.
356
+ # @param parameters [Remediation] The remediation parameters.
357
+ # @param [Hash{String => String}] A hash of custom headers that will be added
358
+ # to the HTTP request.
359
+ #
360
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
361
+ #
362
+ def create_or_update_at_management_group_async(management_group_id, remediation_name, parameters, custom_headers:nil)
363
+ management_groups_namespace = 'Microsoft.Management'
364
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
365
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
366
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
367
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
368
+
369
+
370
+ request_headers = {}
371
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
372
+
373
+ # Set Headers
374
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
375
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
376
+
377
+ # Serialize Request
378
+ request_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
379
+ request_content = @client.serialize(request_mapper, parameters)
380
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
381
+
382
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
383
+
384
+ request_url = @base_url || @client.base_url
385
+
386
+ options = {
387
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
388
+ path_params: {'managementGroupsNamespace' => management_groups_namespace,'managementGroupId' => management_group_id,'remediationName' => remediation_name},
389
+ query_params: {'api-version' => @client.api_version},
390
+ body: request_content,
391
+ headers: request_headers.merge(custom_headers || {}),
392
+ base_url: request_url
393
+ }
394
+ promise = @client.make_request_async(:put, path_template, options)
395
+
396
+ promise = promise.then do |result|
397
+ http_response = result.response
398
+ status_code = http_response.status
399
+ response_content = http_response.body
400
+ unless status_code == 200 || status_code == 201
401
+ error_model = JSON.load(response_content)
402
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
403
+ end
404
+
405
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
406
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
407
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
408
+ # Deserialize Response
409
+ if status_code == 200
410
+ begin
411
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
412
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
413
+ result.body = @client.deserialize(result_mapper, parsed_response)
414
+ rescue Exception => e
415
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
416
+ end
417
+ end
418
+ # Deserialize Response
419
+ if status_code == 201
420
+ begin
421
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
422
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
423
+ result.body = @client.deserialize(result_mapper, parsed_response)
424
+ rescue Exception => e
425
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
426
+ end
427
+ end
428
+
429
+ result
430
+ end
431
+
432
+ promise.execute
433
+ end
434
+
435
+ #
436
+ # Gets an existing remediation at management group scope.
437
+ #
438
+ # @param management_group_id [String] Management group ID.
439
+ # @param remediation_name [String] The name of the remediation.
440
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
441
+ # will be added to the HTTP request.
442
+ #
443
+ # @return [Remediation] operation results.
444
+ #
445
+ def get_at_management_group(management_group_id, remediation_name, custom_headers:nil)
446
+ response = get_at_management_group_async(management_group_id, remediation_name, custom_headers:custom_headers).value!
447
+ response.body unless response.nil?
448
+ end
449
+
450
+ #
451
+ # Gets an existing remediation at management group scope.
452
+ #
453
+ # @param management_group_id [String] Management group ID.
454
+ # @param remediation_name [String] The name of the remediation.
455
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
456
+ # will be added to the HTTP request.
457
+ #
458
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
459
+ #
460
+ def get_at_management_group_with_http_info(management_group_id, remediation_name, custom_headers:nil)
461
+ get_at_management_group_async(management_group_id, remediation_name, custom_headers:custom_headers).value!
462
+ end
463
+
464
+ #
465
+ # Gets an existing remediation at management group scope.
466
+ #
467
+ # @param management_group_id [String] Management group ID.
468
+ # @param remediation_name [String] The name of the remediation.
469
+ # @param [Hash{String => String}] A hash of custom headers that will be added
470
+ # to the HTTP request.
471
+ #
472
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
473
+ #
474
+ def get_at_management_group_async(management_group_id, remediation_name, custom_headers:nil)
475
+ management_groups_namespace = 'Microsoft.Management'
476
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
477
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
478
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.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 = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
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: {'managementGroupsNamespace' => management_groups_namespace,'managementGroupId' => management_group_id,'remediationName' => remediation_name},
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
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
511
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
512
+ # Deserialize Response
513
+ if status_code == 200
514
+ begin
515
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
516
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
517
+ result.body = @client.deserialize(result_mapper, parsed_response)
518
+ rescue Exception => e
519
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
520
+ end
521
+ end
522
+
523
+ result
524
+ end
525
+
526
+ promise.execute
527
+ end
528
+
529
+ #
530
+ # Deletes an existing remediation at management group scope.
531
+ #
532
+ # @param management_group_id [String] Management group ID.
533
+ # @param remediation_name [String] The name of the remediation.
534
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
535
+ # will be added to the HTTP request.
536
+ #
537
+ # @return [Remediation] operation results.
538
+ #
539
+ def delete_at_management_group(management_group_id, remediation_name, custom_headers:nil)
540
+ response = delete_at_management_group_async(management_group_id, remediation_name, custom_headers:custom_headers).value!
541
+ response.body unless response.nil?
542
+ end
543
+
544
+ #
545
+ # Deletes an existing remediation at management group scope.
546
+ #
547
+ # @param management_group_id [String] Management group ID.
548
+ # @param remediation_name [String] The name of the remediation.
549
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
550
+ # will be added to the HTTP request.
551
+ #
552
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
553
+ #
554
+ def delete_at_management_group_with_http_info(management_group_id, remediation_name, custom_headers:nil)
555
+ delete_at_management_group_async(management_group_id, remediation_name, custom_headers:custom_headers).value!
556
+ end
557
+
558
+ #
559
+ # Deletes an existing remediation at management group scope.
560
+ #
561
+ # @param management_group_id [String] Management group ID.
562
+ # @param remediation_name [String] The name of the remediation.
563
+ # @param [Hash{String => String}] A hash of custom headers that will be added
564
+ # to the HTTP request.
565
+ #
566
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
567
+ #
568
+ def delete_at_management_group_async(management_group_id, remediation_name, custom_headers:nil)
569
+ management_groups_namespace = 'Microsoft.Management'
570
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
571
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
572
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
573
+
574
+
575
+ request_headers = {}
576
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
577
+
578
+ # Set Headers
579
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
580
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
581
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
582
+
583
+ request_url = @base_url || @client.base_url
584
+
585
+ options = {
586
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
587
+ path_params: {'managementGroupsNamespace' => management_groups_namespace,'managementGroupId' => management_group_id,'remediationName' => remediation_name},
588
+ query_params: {'api-version' => @client.api_version},
589
+ headers: request_headers.merge(custom_headers || {}),
590
+ base_url: request_url
591
+ }
592
+ promise = @client.make_request_async(:delete, path_template, options)
593
+
594
+ promise = promise.then do |result|
595
+ http_response = result.response
596
+ status_code = http_response.status
597
+ response_content = http_response.body
598
+ unless status_code == 200 || status_code == 204
599
+ error_model = JSON.load(response_content)
600
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
601
+ end
602
+
603
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
604
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
605
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
606
+ # Deserialize Response
607
+ if status_code == 200
608
+ begin
609
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
610
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
611
+ result.body = @client.deserialize(result_mapper, parsed_response)
612
+ rescue Exception => e
613
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
614
+ end
615
+ end
616
+
617
+ result
618
+ end
619
+
620
+ promise.execute
621
+ end
622
+
623
+ #
624
+ # Gets all deployments for a remediation at subscription scope.
625
+ #
626
+ # @param remediation_name [String] The name of the remediation.
627
+ # @param query_options [QueryOptions] Additional parameters for the operation
628
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
629
+ # will be added to the HTTP request.
630
+ #
631
+ # @return [Array<RemediationDeployment>] operation results.
632
+ #
633
+ def list_deployments_at_subscription(remediation_name, query_options:nil, custom_headers:nil)
634
+ first_page = list_deployments_at_subscription_as_lazy(remediation_name, query_options:query_options, custom_headers:custom_headers)
635
+ first_page.get_all_items
636
+ end
637
+
638
+ #
639
+ # Gets all deployments for a remediation at subscription scope.
640
+ #
641
+ # @param remediation_name [String] The name of the remediation.
642
+ # @param query_options [QueryOptions] Additional parameters for the operation
643
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
644
+ # will be added to the HTTP request.
645
+ #
646
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
647
+ #
648
+ def list_deployments_at_subscription_with_http_info(remediation_name, query_options:nil, custom_headers:nil)
649
+ list_deployments_at_subscription_async(remediation_name, query_options:query_options, custom_headers:custom_headers).value!
650
+ end
651
+
652
+ #
653
+ # Gets all deployments for a remediation at subscription scope.
654
+ #
655
+ # @param remediation_name [String] The name of the remediation.
656
+ # @param query_options [QueryOptions] Additional parameters for the operation
657
+ # @param [Hash{String => String}] A hash of custom headers that will be added
658
+ # to the HTTP request.
659
+ #
660
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
661
+ #
662
+ def list_deployments_at_subscription_async(remediation_name, query_options:nil, custom_headers:nil)
663
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
664
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
665
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
666
+
667
+ top = nil
668
+ unless query_options.nil?
669
+ top = query_options.Top
670
+ end
671
+
672
+ request_headers = {}
673
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
674
+
675
+ # Set Headers
676
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
677
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
678
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments'
679
+
680
+ request_url = @base_url || @client.base_url
681
+
682
+ options = {
683
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
684
+ path_params: {'subscriptionId' => @client.subscription_id,'remediationName' => remediation_name},
685
+ query_params: {'api-version' => @client.api_version,'$top' => top},
686
+ headers: request_headers.merge(custom_headers || {}),
687
+ base_url: request_url
688
+ }
689
+ promise = @client.make_request_async(:post, path_template, options)
690
+
691
+ promise = promise.then do |result|
692
+ http_response = result.response
693
+ status_code = http_response.status
694
+ response_content = http_response.body
695
+ unless status_code == 200
696
+ error_model = JSON.load(response_content)
697
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
698
+ end
699
+
700
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
701
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
702
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
703
+ # Deserialize Response
704
+ if status_code == 200
705
+ begin
706
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
707
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
708
+ result.body = @client.deserialize(result_mapper, parsed_response)
709
+ rescue Exception => e
710
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
711
+ end
712
+ end
713
+
714
+ result
715
+ end
716
+
717
+ promise.execute
718
+ end
719
+
720
+ #
721
+ # Cancels a remediation at subscription scope.
722
+ #
723
+ # @param remediation_name [String] The name of the remediation.
724
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
725
+ # will be added to the HTTP request.
726
+ #
727
+ # @return [Remediation] operation results.
728
+ #
729
+ def cancel_at_subscription(remediation_name, custom_headers:nil)
730
+ response = cancel_at_subscription_async(remediation_name, custom_headers:custom_headers).value!
731
+ response.body unless response.nil?
732
+ end
733
+
734
+ #
735
+ # Cancels a remediation at subscription scope.
736
+ #
737
+ # @param remediation_name [String] The name of the remediation.
738
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
739
+ # will be added to the HTTP request.
740
+ #
741
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
742
+ #
743
+ def cancel_at_subscription_with_http_info(remediation_name, custom_headers:nil)
744
+ cancel_at_subscription_async(remediation_name, custom_headers:custom_headers).value!
745
+ end
746
+
747
+ #
748
+ # Cancels a remediation at subscription scope.
749
+ #
750
+ # @param remediation_name [String] The name of the remediation.
751
+ # @param [Hash{String => String}] A hash of custom headers that will be added
752
+ # to the HTTP request.
753
+ #
754
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
755
+ #
756
+ def cancel_at_subscription_async(remediation_name, custom_headers:nil)
757
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
758
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
759
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
760
+
761
+
762
+ request_headers = {}
763
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
764
+
765
+ # Set Headers
766
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
767
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
768
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel'
769
+
770
+ request_url = @base_url || @client.base_url
771
+
772
+ options = {
773
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
774
+ path_params: {'subscriptionId' => @client.subscription_id,'remediationName' => remediation_name},
775
+ query_params: {'api-version' => @client.api_version},
776
+ headers: request_headers.merge(custom_headers || {}),
777
+ base_url: request_url
778
+ }
779
+ promise = @client.make_request_async(:post, path_template, options)
780
+
781
+ promise = promise.then do |result|
782
+ http_response = result.response
783
+ status_code = http_response.status
784
+ response_content = http_response.body
785
+ unless status_code == 200
786
+ error_model = JSON.load(response_content)
787
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
788
+ end
789
+
790
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
791
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
792
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
793
+ # Deserialize Response
794
+ if status_code == 200
795
+ begin
796
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
797
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
798
+ result.body = @client.deserialize(result_mapper, parsed_response)
799
+ rescue Exception => e
800
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
801
+ end
802
+ end
803
+
804
+ result
805
+ end
806
+
807
+ promise.execute
808
+ end
809
+
810
+ #
811
+ # Gets all remediations for the subscription.
812
+ #
813
+ # @param query_options [QueryOptions] Additional parameters for the operation
814
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
815
+ # will be added to the HTTP request.
816
+ #
817
+ # @return [Array<Remediation>] operation results.
818
+ #
819
+ def list_for_subscription(query_options:nil, custom_headers:nil)
820
+ first_page = list_for_subscription_as_lazy(query_options:query_options, custom_headers:custom_headers)
821
+ first_page.get_all_items
822
+ end
823
+
824
+ #
825
+ # Gets all remediations for the subscription.
826
+ #
827
+ # @param query_options [QueryOptions] Additional parameters for the operation
828
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
829
+ # will be added to the HTTP request.
830
+ #
831
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
832
+ #
833
+ def list_for_subscription_with_http_info(query_options:nil, custom_headers:nil)
834
+ list_for_subscription_async(query_options:query_options, custom_headers:custom_headers).value!
835
+ end
836
+
837
+ #
838
+ # Gets all remediations for the subscription.
839
+ #
840
+ # @param query_options [QueryOptions] Additional parameters for the operation
841
+ # @param [Hash{String => String}] A hash of custom headers that will be added
842
+ # to the HTTP request.
843
+ #
844
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
845
+ #
846
+ def list_for_subscription_async(query_options:nil, custom_headers:nil)
847
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
848
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
849
+
850
+ top = nil
851
+ filter = nil
852
+ unless query_options.nil?
853
+ top = query_options.Top
854
+ end
855
+ unless query_options.nil?
856
+ filter = query_options.Filter
857
+ end
858
+
859
+ request_headers = {}
860
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
861
+
862
+ # Set Headers
863
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
864
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
865
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations'
866
+
867
+ request_url = @base_url || @client.base_url
868
+
869
+ options = {
870
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
871
+ path_params: {'subscriptionId' => @client.subscription_id},
872
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$filter' => filter},
873
+ headers: request_headers.merge(custom_headers || {}),
874
+ base_url: request_url
875
+ }
876
+ promise = @client.make_request_async(:get, path_template, options)
877
+
878
+ promise = promise.then do |result|
879
+ http_response = result.response
880
+ status_code = http_response.status
881
+ response_content = http_response.body
882
+ unless status_code == 200
883
+ error_model = JSON.load(response_content)
884
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
885
+ end
886
+
887
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
888
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
889
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
890
+ # Deserialize Response
891
+ if status_code == 200
892
+ begin
893
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
894
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
895
+ result.body = @client.deserialize(result_mapper, parsed_response)
896
+ rescue Exception => e
897
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
898
+ end
899
+ end
900
+
901
+ result
902
+ end
903
+
904
+ promise.execute
905
+ end
906
+
907
+ #
908
+ # Creates or updates a remediation at subscription scope.
909
+ #
910
+ # @param remediation_name [String] The name of the remediation.
911
+ # @param parameters [Remediation] The remediation parameters.
912
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
913
+ # will be added to the HTTP request.
914
+ #
915
+ # @return [Remediation] operation results.
916
+ #
917
+ def create_or_update_at_subscription(remediation_name, parameters, custom_headers:nil)
918
+ response = create_or_update_at_subscription_async(remediation_name, parameters, custom_headers:custom_headers).value!
919
+ response.body unless response.nil?
920
+ end
921
+
922
+ #
923
+ # Creates or updates a remediation at subscription scope.
924
+ #
925
+ # @param remediation_name [String] The name of the remediation.
926
+ # @param parameters [Remediation] The remediation parameters.
927
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
928
+ # will be added to the HTTP request.
929
+ #
930
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
931
+ #
932
+ def create_or_update_at_subscription_with_http_info(remediation_name, parameters, custom_headers:nil)
933
+ create_or_update_at_subscription_async(remediation_name, parameters, custom_headers:custom_headers).value!
934
+ end
935
+
936
+ #
937
+ # Creates or updates a remediation at subscription scope.
938
+ #
939
+ # @param remediation_name [String] The name of the remediation.
940
+ # @param parameters [Remediation] The remediation parameters.
941
+ # @param [Hash{String => String}] A hash of custom headers that will be added
942
+ # to the HTTP request.
943
+ #
944
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
945
+ #
946
+ def create_or_update_at_subscription_async(remediation_name, parameters, custom_headers:nil)
947
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
948
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
949
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
950
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
951
+
952
+
953
+ request_headers = {}
954
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
955
+
956
+ # Set Headers
957
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
958
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
959
+
960
+ # Serialize Request
961
+ request_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
962
+ request_content = @client.serialize(request_mapper, parameters)
963
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
964
+
965
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
966
+
967
+ request_url = @base_url || @client.base_url
968
+
969
+ options = {
970
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
971
+ path_params: {'subscriptionId' => @client.subscription_id,'remediationName' => remediation_name},
972
+ query_params: {'api-version' => @client.api_version},
973
+ body: request_content,
974
+ headers: request_headers.merge(custom_headers || {}),
975
+ base_url: request_url
976
+ }
977
+ promise = @client.make_request_async(:put, path_template, options)
978
+
979
+ promise = promise.then do |result|
980
+ http_response = result.response
981
+ status_code = http_response.status
982
+ response_content = http_response.body
983
+ unless status_code == 200 || status_code == 201
984
+ error_model = JSON.load(response_content)
985
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
986
+ end
987
+
988
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
989
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
990
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
991
+ # Deserialize Response
992
+ if status_code == 200
993
+ begin
994
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
995
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
996
+ result.body = @client.deserialize(result_mapper, parsed_response)
997
+ rescue Exception => e
998
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
999
+ end
1000
+ end
1001
+ # Deserialize Response
1002
+ if status_code == 201
1003
+ begin
1004
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1005
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1006
+ result.body = @client.deserialize(result_mapper, parsed_response)
1007
+ rescue Exception => e
1008
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1009
+ end
1010
+ end
1011
+
1012
+ result
1013
+ end
1014
+
1015
+ promise.execute
1016
+ end
1017
+
1018
+ #
1019
+ # Gets an existing remediation at subscription scope.
1020
+ #
1021
+ # @param remediation_name [String] The name of the remediation.
1022
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1023
+ # will be added to the HTTP request.
1024
+ #
1025
+ # @return [Remediation] operation results.
1026
+ #
1027
+ def get_at_subscription(remediation_name, custom_headers:nil)
1028
+ response = get_at_subscription_async(remediation_name, custom_headers:custom_headers).value!
1029
+ response.body unless response.nil?
1030
+ end
1031
+
1032
+ #
1033
+ # Gets an existing remediation at subscription scope.
1034
+ #
1035
+ # @param remediation_name [String] The name of the remediation.
1036
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1037
+ # will be added to the HTTP request.
1038
+ #
1039
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1040
+ #
1041
+ def get_at_subscription_with_http_info(remediation_name, custom_headers:nil)
1042
+ get_at_subscription_async(remediation_name, custom_headers:custom_headers).value!
1043
+ end
1044
+
1045
+ #
1046
+ # Gets an existing remediation at subscription scope.
1047
+ #
1048
+ # @param remediation_name [String] The name of the remediation.
1049
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1050
+ # to the HTTP request.
1051
+ #
1052
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1053
+ #
1054
+ def get_at_subscription_async(remediation_name, custom_headers:nil)
1055
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1056
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1057
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1058
+
1059
+
1060
+ request_headers = {}
1061
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1062
+
1063
+ # Set Headers
1064
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1065
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1066
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
1067
+
1068
+ request_url = @base_url || @client.base_url
1069
+
1070
+ options = {
1071
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1072
+ path_params: {'subscriptionId' => @client.subscription_id,'remediationName' => remediation_name},
1073
+ query_params: {'api-version' => @client.api_version},
1074
+ headers: request_headers.merge(custom_headers || {}),
1075
+ base_url: request_url
1076
+ }
1077
+ promise = @client.make_request_async(:get, path_template, options)
1078
+
1079
+ promise = promise.then do |result|
1080
+ http_response = result.response
1081
+ status_code = http_response.status
1082
+ response_content = http_response.body
1083
+ unless status_code == 200
1084
+ error_model = JSON.load(response_content)
1085
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1086
+ end
1087
+
1088
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1089
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1090
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1091
+ # Deserialize Response
1092
+ if status_code == 200
1093
+ begin
1094
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1095
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1096
+ result.body = @client.deserialize(result_mapper, parsed_response)
1097
+ rescue Exception => e
1098
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1099
+ end
1100
+ end
1101
+
1102
+ result
1103
+ end
1104
+
1105
+ promise.execute
1106
+ end
1107
+
1108
+ #
1109
+ # Deletes an existing remediation at subscription scope.
1110
+ #
1111
+ # @param remediation_name [String] The name of the remediation.
1112
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1113
+ # will be added to the HTTP request.
1114
+ #
1115
+ # @return [Remediation] operation results.
1116
+ #
1117
+ def delete_at_subscription(remediation_name, custom_headers:nil)
1118
+ response = delete_at_subscription_async(remediation_name, custom_headers:custom_headers).value!
1119
+ response.body unless response.nil?
1120
+ end
1121
+
1122
+ #
1123
+ # Deletes an existing remediation at subscription scope.
1124
+ #
1125
+ # @param remediation_name [String] The name of the remediation.
1126
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1127
+ # will be added to the HTTP request.
1128
+ #
1129
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1130
+ #
1131
+ def delete_at_subscription_with_http_info(remediation_name, custom_headers:nil)
1132
+ delete_at_subscription_async(remediation_name, custom_headers:custom_headers).value!
1133
+ end
1134
+
1135
+ #
1136
+ # Deletes an existing remediation at subscription scope.
1137
+ #
1138
+ # @param remediation_name [String] The name of the remediation.
1139
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1140
+ # to the HTTP request.
1141
+ #
1142
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1143
+ #
1144
+ def delete_at_subscription_async(remediation_name, custom_headers:nil)
1145
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1146
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1147
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1148
+
1149
+
1150
+ request_headers = {}
1151
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1152
+
1153
+ # Set Headers
1154
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1155
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1156
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
1157
+
1158
+ request_url = @base_url || @client.base_url
1159
+
1160
+ options = {
1161
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1162
+ path_params: {'subscriptionId' => @client.subscription_id,'remediationName' => remediation_name},
1163
+ query_params: {'api-version' => @client.api_version},
1164
+ headers: request_headers.merge(custom_headers || {}),
1165
+ base_url: request_url
1166
+ }
1167
+ promise = @client.make_request_async(:delete, path_template, options)
1168
+
1169
+ promise = promise.then do |result|
1170
+ http_response = result.response
1171
+ status_code = http_response.status
1172
+ response_content = http_response.body
1173
+ unless status_code == 200 || status_code == 204
1174
+ error_model = JSON.load(response_content)
1175
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1176
+ end
1177
+
1178
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1179
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1180
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1181
+ # Deserialize Response
1182
+ if status_code == 200
1183
+ begin
1184
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1185
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1186
+ result.body = @client.deserialize(result_mapper, parsed_response)
1187
+ rescue Exception => e
1188
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1189
+ end
1190
+ end
1191
+
1192
+ result
1193
+ end
1194
+
1195
+ promise.execute
1196
+ end
1197
+
1198
+ #
1199
+ # Gets all deployments for a remediation at resource group scope.
1200
+ #
1201
+ # @param resource_group_name [String] Resource group name.
1202
+ # @param remediation_name [String] The name of the remediation.
1203
+ # @param query_options [QueryOptions] Additional parameters for the operation
1204
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1205
+ # will be added to the HTTP request.
1206
+ #
1207
+ # @return [Array<RemediationDeployment>] operation results.
1208
+ #
1209
+ def list_deployments_at_resource_group(resource_group_name, remediation_name, query_options:nil, custom_headers:nil)
1210
+ first_page = list_deployments_at_resource_group_as_lazy(resource_group_name, remediation_name, query_options:query_options, custom_headers:custom_headers)
1211
+ first_page.get_all_items
1212
+ end
1213
+
1214
+ #
1215
+ # Gets all deployments for a remediation at resource group scope.
1216
+ #
1217
+ # @param resource_group_name [String] Resource group name.
1218
+ # @param remediation_name [String] The name of the remediation.
1219
+ # @param query_options [QueryOptions] Additional parameters for the operation
1220
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1221
+ # will be added to the HTTP request.
1222
+ #
1223
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1224
+ #
1225
+ def list_deployments_at_resource_group_with_http_info(resource_group_name, remediation_name, query_options:nil, custom_headers:nil)
1226
+ list_deployments_at_resource_group_async(resource_group_name, remediation_name, query_options:query_options, custom_headers:custom_headers).value!
1227
+ end
1228
+
1229
+ #
1230
+ # Gets all deployments for a remediation at resource group scope.
1231
+ #
1232
+ # @param resource_group_name [String] Resource group name.
1233
+ # @param remediation_name [String] The name of the remediation.
1234
+ # @param query_options [QueryOptions] Additional parameters for the operation
1235
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1236
+ # to the HTTP request.
1237
+ #
1238
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1239
+ #
1240
+ def list_deployments_at_resource_group_async(resource_group_name, remediation_name, query_options:nil, custom_headers:nil)
1241
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1242
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1243
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1244
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1245
+
1246
+ top = nil
1247
+ unless query_options.nil?
1248
+ top = query_options.Top
1249
+ end
1250
+
1251
+ request_headers = {}
1252
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1253
+
1254
+ # Set Headers
1255
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1256
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1257
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments'
1258
+
1259
+ request_url = @base_url || @client.base_url
1260
+
1261
+ options = {
1262
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1263
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'remediationName' => remediation_name},
1264
+ query_params: {'api-version' => @client.api_version,'$top' => top},
1265
+ headers: request_headers.merge(custom_headers || {}),
1266
+ base_url: request_url
1267
+ }
1268
+ promise = @client.make_request_async(:post, path_template, options)
1269
+
1270
+ promise = promise.then do |result|
1271
+ http_response = result.response
1272
+ status_code = http_response.status
1273
+ response_content = http_response.body
1274
+ unless status_code == 200
1275
+ error_model = JSON.load(response_content)
1276
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1277
+ end
1278
+
1279
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1280
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1281
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1282
+ # Deserialize Response
1283
+ if status_code == 200
1284
+ begin
1285
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1286
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
1287
+ result.body = @client.deserialize(result_mapper, parsed_response)
1288
+ rescue Exception => e
1289
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1290
+ end
1291
+ end
1292
+
1293
+ result
1294
+ end
1295
+
1296
+ promise.execute
1297
+ end
1298
+
1299
+ #
1300
+ # Cancels a remediation at resource group scope.
1301
+ #
1302
+ # @param resource_group_name [String] Resource group name.
1303
+ # @param remediation_name [String] The name of the remediation.
1304
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1305
+ # will be added to the HTTP request.
1306
+ #
1307
+ # @return [Remediation] operation results.
1308
+ #
1309
+ def cancel_at_resource_group(resource_group_name, remediation_name, custom_headers:nil)
1310
+ response = cancel_at_resource_group_async(resource_group_name, remediation_name, custom_headers:custom_headers).value!
1311
+ response.body unless response.nil?
1312
+ end
1313
+
1314
+ #
1315
+ # Cancels a remediation at resource group scope.
1316
+ #
1317
+ # @param resource_group_name [String] Resource group name.
1318
+ # @param remediation_name [String] The name of the remediation.
1319
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1320
+ # will be added to the HTTP request.
1321
+ #
1322
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1323
+ #
1324
+ def cancel_at_resource_group_with_http_info(resource_group_name, remediation_name, custom_headers:nil)
1325
+ cancel_at_resource_group_async(resource_group_name, remediation_name, custom_headers:custom_headers).value!
1326
+ end
1327
+
1328
+ #
1329
+ # Cancels a remediation at resource group scope.
1330
+ #
1331
+ # @param resource_group_name [String] Resource group name.
1332
+ # @param remediation_name [String] The name of the remediation.
1333
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1334
+ # to the HTTP request.
1335
+ #
1336
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1337
+ #
1338
+ def cancel_at_resource_group_async(resource_group_name, remediation_name, custom_headers:nil)
1339
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1340
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1341
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1342
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1343
+
1344
+
1345
+ request_headers = {}
1346
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1347
+
1348
+ # Set Headers
1349
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1350
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1351
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel'
1352
+
1353
+ request_url = @base_url || @client.base_url
1354
+
1355
+ options = {
1356
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1357
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'remediationName' => remediation_name},
1358
+ query_params: {'api-version' => @client.api_version},
1359
+ headers: request_headers.merge(custom_headers || {}),
1360
+ base_url: request_url
1361
+ }
1362
+ promise = @client.make_request_async(:post, path_template, options)
1363
+
1364
+ promise = promise.then do |result|
1365
+ http_response = result.response
1366
+ status_code = http_response.status
1367
+ response_content = http_response.body
1368
+ unless status_code == 200
1369
+ error_model = JSON.load(response_content)
1370
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1371
+ end
1372
+
1373
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1374
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1375
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1376
+ # Deserialize Response
1377
+ if status_code == 200
1378
+ begin
1379
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1380
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1381
+ result.body = @client.deserialize(result_mapper, parsed_response)
1382
+ rescue Exception => e
1383
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1384
+ end
1385
+ end
1386
+
1387
+ result
1388
+ end
1389
+
1390
+ promise.execute
1391
+ end
1392
+
1393
+ #
1394
+ # Gets all remediations for the subscription.
1395
+ #
1396
+ # @param resource_group_name [String] Resource group name.
1397
+ # @param query_options [QueryOptions] Additional parameters for the operation
1398
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1399
+ # will be added to the HTTP request.
1400
+ #
1401
+ # @return [Array<Remediation>] operation results.
1402
+ #
1403
+ def list_for_resource_group(resource_group_name, query_options:nil, custom_headers:nil)
1404
+ first_page = list_for_resource_group_as_lazy(resource_group_name, query_options:query_options, custom_headers:custom_headers)
1405
+ first_page.get_all_items
1406
+ end
1407
+
1408
+ #
1409
+ # Gets all remediations for the subscription.
1410
+ #
1411
+ # @param resource_group_name [String] Resource group name.
1412
+ # @param query_options [QueryOptions] Additional parameters for the operation
1413
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1414
+ # will be added to the HTTP request.
1415
+ #
1416
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1417
+ #
1418
+ def list_for_resource_group_with_http_info(resource_group_name, query_options:nil, custom_headers:nil)
1419
+ list_for_resource_group_async(resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
1420
+ end
1421
+
1422
+ #
1423
+ # Gets all remediations for the subscription.
1424
+ #
1425
+ # @param resource_group_name [String] Resource group name.
1426
+ # @param query_options [QueryOptions] Additional parameters for the operation
1427
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1428
+ # to the HTTP request.
1429
+ #
1430
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1431
+ #
1432
+ def list_for_resource_group_async(resource_group_name, query_options:nil, custom_headers:nil)
1433
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1434
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1435
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1436
+
1437
+ top = nil
1438
+ filter = nil
1439
+ unless query_options.nil?
1440
+ top = query_options.Top
1441
+ end
1442
+ unless query_options.nil?
1443
+ filter = query_options.Filter
1444
+ end
1445
+
1446
+ request_headers = {}
1447
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1448
+
1449
+ # Set Headers
1450
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1451
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1452
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations'
1453
+
1454
+ request_url = @base_url || @client.base_url
1455
+
1456
+ options = {
1457
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1458
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name},
1459
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$filter' => filter},
1460
+ headers: request_headers.merge(custom_headers || {}),
1461
+ base_url: request_url
1462
+ }
1463
+ promise = @client.make_request_async(:get, path_template, options)
1464
+
1465
+ promise = promise.then do |result|
1466
+ http_response = result.response
1467
+ status_code = http_response.status
1468
+ response_content = http_response.body
1469
+ unless status_code == 200
1470
+ error_model = JSON.load(response_content)
1471
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1472
+ end
1473
+
1474
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1475
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1476
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1477
+ # Deserialize Response
1478
+ if status_code == 200
1479
+ begin
1480
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1481
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
1482
+ result.body = @client.deserialize(result_mapper, parsed_response)
1483
+ rescue Exception => e
1484
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1485
+ end
1486
+ end
1487
+
1488
+ result
1489
+ end
1490
+
1491
+ promise.execute
1492
+ end
1493
+
1494
+ #
1495
+ # Creates or updates a remediation at resource group scope.
1496
+ #
1497
+ # @param resource_group_name [String] Resource group name.
1498
+ # @param remediation_name [String] The name of the remediation.
1499
+ # @param parameters [Remediation] The remediation parameters.
1500
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1501
+ # will be added to the HTTP request.
1502
+ #
1503
+ # @return [Remediation] operation results.
1504
+ #
1505
+ def create_or_update_at_resource_group(resource_group_name, remediation_name, parameters, custom_headers:nil)
1506
+ response = create_or_update_at_resource_group_async(resource_group_name, remediation_name, parameters, custom_headers:custom_headers).value!
1507
+ response.body unless response.nil?
1508
+ end
1509
+
1510
+ #
1511
+ # Creates or updates a remediation at resource group scope.
1512
+ #
1513
+ # @param resource_group_name [String] Resource group name.
1514
+ # @param remediation_name [String] The name of the remediation.
1515
+ # @param parameters [Remediation] The remediation parameters.
1516
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1517
+ # will be added to the HTTP request.
1518
+ #
1519
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1520
+ #
1521
+ def create_or_update_at_resource_group_with_http_info(resource_group_name, remediation_name, parameters, custom_headers:nil)
1522
+ create_or_update_at_resource_group_async(resource_group_name, remediation_name, parameters, custom_headers:custom_headers).value!
1523
+ end
1524
+
1525
+ #
1526
+ # Creates or updates a remediation at resource group scope.
1527
+ #
1528
+ # @param resource_group_name [String] Resource group name.
1529
+ # @param remediation_name [String] The name of the remediation.
1530
+ # @param parameters [Remediation] The remediation parameters.
1531
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1532
+ # to the HTTP request.
1533
+ #
1534
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1535
+ #
1536
+ def create_or_update_at_resource_group_async(resource_group_name, remediation_name, parameters, custom_headers:nil)
1537
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1538
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1539
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1540
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1541
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
1542
+
1543
+
1544
+ request_headers = {}
1545
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1546
+
1547
+ # Set Headers
1548
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1549
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1550
+
1551
+ # Serialize Request
1552
+ request_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1553
+ request_content = @client.serialize(request_mapper, parameters)
1554
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
1555
+
1556
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
1557
+
1558
+ request_url = @base_url || @client.base_url
1559
+
1560
+ options = {
1561
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1562
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'remediationName' => remediation_name},
1563
+ query_params: {'api-version' => @client.api_version},
1564
+ body: request_content,
1565
+ headers: request_headers.merge(custom_headers || {}),
1566
+ base_url: request_url
1567
+ }
1568
+ promise = @client.make_request_async(:put, path_template, options)
1569
+
1570
+ promise = promise.then do |result|
1571
+ http_response = result.response
1572
+ status_code = http_response.status
1573
+ response_content = http_response.body
1574
+ unless status_code == 200 || status_code == 201
1575
+ error_model = JSON.load(response_content)
1576
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1577
+ end
1578
+
1579
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1580
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1581
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1582
+ # Deserialize Response
1583
+ if status_code == 200
1584
+ begin
1585
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1586
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1587
+ result.body = @client.deserialize(result_mapper, parsed_response)
1588
+ rescue Exception => e
1589
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1590
+ end
1591
+ end
1592
+ # Deserialize Response
1593
+ if status_code == 201
1594
+ begin
1595
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1596
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1597
+ result.body = @client.deserialize(result_mapper, parsed_response)
1598
+ rescue Exception => e
1599
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1600
+ end
1601
+ end
1602
+
1603
+ result
1604
+ end
1605
+
1606
+ promise.execute
1607
+ end
1608
+
1609
+ #
1610
+ # Gets an existing remediation at resource group scope.
1611
+ #
1612
+ # @param resource_group_name [String] Resource group name.
1613
+ # @param remediation_name [String] The name of the remediation.
1614
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1615
+ # will be added to the HTTP request.
1616
+ #
1617
+ # @return [Remediation] operation results.
1618
+ #
1619
+ def get_at_resource_group(resource_group_name, remediation_name, custom_headers:nil)
1620
+ response = get_at_resource_group_async(resource_group_name, remediation_name, custom_headers:custom_headers).value!
1621
+ response.body unless response.nil?
1622
+ end
1623
+
1624
+ #
1625
+ # Gets an existing remediation at resource group scope.
1626
+ #
1627
+ # @param resource_group_name [String] Resource group name.
1628
+ # @param remediation_name [String] The name of the remediation.
1629
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1630
+ # will be added to the HTTP request.
1631
+ #
1632
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1633
+ #
1634
+ def get_at_resource_group_with_http_info(resource_group_name, remediation_name, custom_headers:nil)
1635
+ get_at_resource_group_async(resource_group_name, remediation_name, custom_headers:custom_headers).value!
1636
+ end
1637
+
1638
+ #
1639
+ # Gets an existing remediation at resource group scope.
1640
+ #
1641
+ # @param resource_group_name [String] Resource group name.
1642
+ # @param remediation_name [String] The name of the remediation.
1643
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1644
+ # to the HTTP request.
1645
+ #
1646
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1647
+ #
1648
+ def get_at_resource_group_async(resource_group_name, remediation_name, custom_headers:nil)
1649
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1650
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1651
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1652
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1653
+
1654
+
1655
+ request_headers = {}
1656
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1657
+
1658
+ # Set Headers
1659
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1660
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1661
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
1662
+
1663
+ request_url = @base_url || @client.base_url
1664
+
1665
+ options = {
1666
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1667
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'remediationName' => remediation_name},
1668
+ query_params: {'api-version' => @client.api_version},
1669
+ headers: request_headers.merge(custom_headers || {}),
1670
+ base_url: request_url
1671
+ }
1672
+ promise = @client.make_request_async(:get, path_template, options)
1673
+
1674
+ promise = promise.then do |result|
1675
+ http_response = result.response
1676
+ status_code = http_response.status
1677
+ response_content = http_response.body
1678
+ unless status_code == 200
1679
+ error_model = JSON.load(response_content)
1680
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1681
+ end
1682
+
1683
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1684
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1685
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1686
+ # Deserialize Response
1687
+ if status_code == 200
1688
+ begin
1689
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1690
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1691
+ result.body = @client.deserialize(result_mapper, parsed_response)
1692
+ rescue Exception => e
1693
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1694
+ end
1695
+ end
1696
+
1697
+ result
1698
+ end
1699
+
1700
+ promise.execute
1701
+ end
1702
+
1703
+ #
1704
+ # Deletes an existing remediation at resource group scope.
1705
+ #
1706
+ # @param resource_group_name [String] Resource group name.
1707
+ # @param remediation_name [String] The name of the remediation.
1708
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1709
+ # will be added to the HTTP request.
1710
+ #
1711
+ # @return [Remediation] operation results.
1712
+ #
1713
+ def delete_at_resource_group(resource_group_name, remediation_name, custom_headers:nil)
1714
+ response = delete_at_resource_group_async(resource_group_name, remediation_name, custom_headers:custom_headers).value!
1715
+ response.body unless response.nil?
1716
+ end
1717
+
1718
+ #
1719
+ # Deletes an existing remediation at resource group scope.
1720
+ #
1721
+ # @param resource_group_name [String] Resource group name.
1722
+ # @param remediation_name [String] The name of the remediation.
1723
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1724
+ # will be added to the HTTP request.
1725
+ #
1726
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1727
+ #
1728
+ def delete_at_resource_group_with_http_info(resource_group_name, remediation_name, custom_headers:nil)
1729
+ delete_at_resource_group_async(resource_group_name, remediation_name, custom_headers:custom_headers).value!
1730
+ end
1731
+
1732
+ #
1733
+ # Deletes an existing remediation at resource group scope.
1734
+ #
1735
+ # @param resource_group_name [String] Resource group name.
1736
+ # @param remediation_name [String] The name of the remediation.
1737
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1738
+ # to the HTTP request.
1739
+ #
1740
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1741
+ #
1742
+ def delete_at_resource_group_async(resource_group_name, remediation_name, custom_headers:nil)
1743
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1744
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1745
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1746
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1747
+
1748
+
1749
+ request_headers = {}
1750
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1751
+
1752
+ # Set Headers
1753
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1754
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1755
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
1756
+
1757
+ request_url = @base_url || @client.base_url
1758
+
1759
+ options = {
1760
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1761
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'remediationName' => remediation_name},
1762
+ query_params: {'api-version' => @client.api_version},
1763
+ headers: request_headers.merge(custom_headers || {}),
1764
+ base_url: request_url
1765
+ }
1766
+ promise = @client.make_request_async(:delete, path_template, options)
1767
+
1768
+ promise = promise.then do |result|
1769
+ http_response = result.response
1770
+ status_code = http_response.status
1771
+ response_content = http_response.body
1772
+ unless status_code == 200 || status_code == 204
1773
+ error_model = JSON.load(response_content)
1774
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1775
+ end
1776
+
1777
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1778
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1779
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1780
+ # Deserialize Response
1781
+ if status_code == 200
1782
+ begin
1783
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1784
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1785
+ result.body = @client.deserialize(result_mapper, parsed_response)
1786
+ rescue Exception => e
1787
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1788
+ end
1789
+ end
1790
+
1791
+ result
1792
+ end
1793
+
1794
+ promise.execute
1795
+ end
1796
+
1797
+ #
1798
+ # Gets all deployments for a remediation at resource scope.
1799
+ #
1800
+ # @param resource_id [String] Resource ID.
1801
+ # @param remediation_name [String] The name of the remediation.
1802
+ # @param query_options [QueryOptions] Additional parameters for the operation
1803
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1804
+ # will be added to the HTTP request.
1805
+ #
1806
+ # @return [Array<RemediationDeployment>] operation results.
1807
+ #
1808
+ def list_deployments_at_resource(resource_id, remediation_name, query_options:nil, custom_headers:nil)
1809
+ first_page = list_deployments_at_resource_as_lazy(resource_id, remediation_name, query_options:query_options, custom_headers:custom_headers)
1810
+ first_page.get_all_items
1811
+ end
1812
+
1813
+ #
1814
+ # Gets all deployments for a remediation at resource scope.
1815
+ #
1816
+ # @param resource_id [String] Resource ID.
1817
+ # @param remediation_name [String] The name of the remediation.
1818
+ # @param query_options [QueryOptions] Additional parameters for the operation
1819
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1820
+ # will be added to the HTTP request.
1821
+ #
1822
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1823
+ #
1824
+ def list_deployments_at_resource_with_http_info(resource_id, remediation_name, query_options:nil, custom_headers:nil)
1825
+ list_deployments_at_resource_async(resource_id, remediation_name, query_options:query_options, custom_headers:custom_headers).value!
1826
+ end
1827
+
1828
+ #
1829
+ # Gets all deployments for a remediation at resource scope.
1830
+ #
1831
+ # @param resource_id [String] Resource ID.
1832
+ # @param remediation_name [String] The name of the remediation.
1833
+ # @param query_options [QueryOptions] Additional parameters for the operation
1834
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1835
+ # to the HTTP request.
1836
+ #
1837
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1838
+ #
1839
+ def list_deployments_at_resource_async(resource_id, remediation_name, query_options:nil, custom_headers:nil)
1840
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
1841
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1842
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1843
+
1844
+ top = nil
1845
+ unless query_options.nil?
1846
+ top = query_options.Top
1847
+ end
1848
+
1849
+ request_headers = {}
1850
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1851
+
1852
+ # Set Headers
1853
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1854
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1855
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments'
1856
+
1857
+ request_url = @base_url || @client.base_url
1858
+
1859
+ options = {
1860
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1861
+ path_params: {'remediationName' => remediation_name},
1862
+ skip_encoding_path_params: {'resourceId' => resource_id},
1863
+ query_params: {'api-version' => @client.api_version,'$top' => top},
1864
+ headers: request_headers.merge(custom_headers || {}),
1865
+ base_url: request_url
1866
+ }
1867
+ promise = @client.make_request_async(:post, path_template, options)
1868
+
1869
+ promise = promise.then do |result|
1870
+ http_response = result.response
1871
+ status_code = http_response.status
1872
+ response_content = http_response.body
1873
+ unless status_code == 200
1874
+ error_model = JSON.load(response_content)
1875
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1876
+ end
1877
+
1878
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1879
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1880
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1881
+ # Deserialize Response
1882
+ if status_code == 200
1883
+ begin
1884
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1885
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
1886
+ result.body = @client.deserialize(result_mapper, parsed_response)
1887
+ rescue Exception => e
1888
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1889
+ end
1890
+ end
1891
+
1892
+ result
1893
+ end
1894
+
1895
+ promise.execute
1896
+ end
1897
+
1898
+ #
1899
+ # Cancel a remediation at resource scope.
1900
+ #
1901
+ # @param resource_id [String] Resource ID.
1902
+ # @param remediation_name [String] The name of the remediation.
1903
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1904
+ # will be added to the HTTP request.
1905
+ #
1906
+ # @return [Remediation] operation results.
1907
+ #
1908
+ def cancel_at_resource(resource_id, remediation_name, custom_headers:nil)
1909
+ response = cancel_at_resource_async(resource_id, remediation_name, custom_headers:custom_headers).value!
1910
+ response.body unless response.nil?
1911
+ end
1912
+
1913
+ #
1914
+ # Cancel a remediation at resource scope.
1915
+ #
1916
+ # @param resource_id [String] Resource ID.
1917
+ # @param remediation_name [String] The name of the remediation.
1918
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1919
+ # will be added to the HTTP request.
1920
+ #
1921
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1922
+ #
1923
+ def cancel_at_resource_with_http_info(resource_id, remediation_name, custom_headers:nil)
1924
+ cancel_at_resource_async(resource_id, remediation_name, custom_headers:custom_headers).value!
1925
+ end
1926
+
1927
+ #
1928
+ # Cancel a remediation at resource scope.
1929
+ #
1930
+ # @param resource_id [String] Resource ID.
1931
+ # @param remediation_name [String] The name of the remediation.
1932
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1933
+ # to the HTTP request.
1934
+ #
1935
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1936
+ #
1937
+ def cancel_at_resource_async(resource_id, remediation_name, custom_headers:nil)
1938
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
1939
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
1940
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1941
+
1942
+
1943
+ request_headers = {}
1944
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1945
+
1946
+ # Set Headers
1947
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1948
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1949
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel'
1950
+
1951
+ request_url = @base_url || @client.base_url
1952
+
1953
+ options = {
1954
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1955
+ path_params: {'remediationName' => remediation_name},
1956
+ skip_encoding_path_params: {'resourceId' => resource_id},
1957
+ query_params: {'api-version' => @client.api_version},
1958
+ headers: request_headers.merge(custom_headers || {}),
1959
+ base_url: request_url
1960
+ }
1961
+ promise = @client.make_request_async(:post, path_template, options)
1962
+
1963
+ promise = promise.then do |result|
1964
+ http_response = result.response
1965
+ status_code = http_response.status
1966
+ response_content = http_response.body
1967
+ unless status_code == 200
1968
+ error_model = JSON.load(response_content)
1969
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1970
+ end
1971
+
1972
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1973
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1974
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1975
+ # Deserialize Response
1976
+ if status_code == 200
1977
+ begin
1978
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1979
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
1980
+ result.body = @client.deserialize(result_mapper, parsed_response)
1981
+ rescue Exception => e
1982
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1983
+ end
1984
+ end
1985
+
1986
+ result
1987
+ end
1988
+
1989
+ promise.execute
1990
+ end
1991
+
1992
+ #
1993
+ # Gets all remediations for a resource.
1994
+ #
1995
+ # @param resource_id [String] Resource ID.
1996
+ # @param query_options [QueryOptions] Additional parameters for the operation
1997
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1998
+ # will be added to the HTTP request.
1999
+ #
2000
+ # @return [Array<Remediation>] operation results.
2001
+ #
2002
+ def list_for_resource(resource_id, query_options:nil, custom_headers:nil)
2003
+ first_page = list_for_resource_as_lazy(resource_id, query_options:query_options, custom_headers:custom_headers)
2004
+ first_page.get_all_items
2005
+ end
2006
+
2007
+ #
2008
+ # Gets all remediations for a resource.
2009
+ #
2010
+ # @param resource_id [String] Resource ID.
2011
+ # @param query_options [QueryOptions] Additional parameters for the operation
2012
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2013
+ # will be added to the HTTP request.
2014
+ #
2015
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2016
+ #
2017
+ def list_for_resource_with_http_info(resource_id, query_options:nil, custom_headers:nil)
2018
+ list_for_resource_async(resource_id, query_options:query_options, custom_headers:custom_headers).value!
2019
+ end
2020
+
2021
+ #
2022
+ # Gets all remediations for a resource.
2023
+ #
2024
+ # @param resource_id [String] Resource ID.
2025
+ # @param query_options [QueryOptions] Additional parameters for the operation
2026
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2027
+ # to the HTTP request.
2028
+ #
2029
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2030
+ #
2031
+ def list_for_resource_async(resource_id, query_options:nil, custom_headers:nil)
2032
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
2033
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
2034
+
2035
+ top = nil
2036
+ filter = nil
2037
+ unless query_options.nil?
2038
+ top = query_options.Top
2039
+ end
2040
+ unless query_options.nil?
2041
+ filter = query_options.Filter
2042
+ end
2043
+
2044
+ request_headers = {}
2045
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2046
+
2047
+ # Set Headers
2048
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2049
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2050
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/remediations'
2051
+
2052
+ request_url = @base_url || @client.base_url
2053
+
2054
+ options = {
2055
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2056
+ skip_encoding_path_params: {'resourceId' => resource_id},
2057
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$filter' => filter},
2058
+ headers: request_headers.merge(custom_headers || {}),
2059
+ base_url: request_url
2060
+ }
2061
+ promise = @client.make_request_async(:get, path_template, options)
2062
+
2063
+ promise = promise.then do |result|
2064
+ http_response = result.response
2065
+ status_code = http_response.status
2066
+ response_content = http_response.body
2067
+ unless status_code == 200
2068
+ error_model = JSON.load(response_content)
2069
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2070
+ end
2071
+
2072
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2073
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2074
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2075
+ # Deserialize Response
2076
+ if status_code == 200
2077
+ begin
2078
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2079
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
2080
+ result.body = @client.deserialize(result_mapper, parsed_response)
2081
+ rescue Exception => e
2082
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2083
+ end
2084
+ end
2085
+
2086
+ result
2087
+ end
2088
+
2089
+ promise.execute
2090
+ end
2091
+
2092
+ #
2093
+ # Creates or updates a remediation at resource scope.
2094
+ #
2095
+ # @param resource_id [String] Resource ID.
2096
+ # @param remediation_name [String] The name of the remediation.
2097
+ # @param parameters [Remediation] The remediation parameters.
2098
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2099
+ # will be added to the HTTP request.
2100
+ #
2101
+ # @return [Remediation] operation results.
2102
+ #
2103
+ def create_or_update_at_resource(resource_id, remediation_name, parameters, custom_headers:nil)
2104
+ response = create_or_update_at_resource_async(resource_id, remediation_name, parameters, custom_headers:custom_headers).value!
2105
+ response.body unless response.nil?
2106
+ end
2107
+
2108
+ #
2109
+ # Creates or updates a remediation at resource scope.
2110
+ #
2111
+ # @param resource_id [String] Resource ID.
2112
+ # @param remediation_name [String] The name of the remediation.
2113
+ # @param parameters [Remediation] The remediation parameters.
2114
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2115
+ # will be added to the HTTP request.
2116
+ #
2117
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2118
+ #
2119
+ def create_or_update_at_resource_with_http_info(resource_id, remediation_name, parameters, custom_headers:nil)
2120
+ create_or_update_at_resource_async(resource_id, remediation_name, parameters, custom_headers:custom_headers).value!
2121
+ end
2122
+
2123
+ #
2124
+ # Creates or updates a remediation at resource scope.
2125
+ #
2126
+ # @param resource_id [String] Resource ID.
2127
+ # @param remediation_name [String] The name of the remediation.
2128
+ # @param parameters [Remediation] The remediation parameters.
2129
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2130
+ # to the HTTP request.
2131
+ #
2132
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2133
+ #
2134
+ def create_or_update_at_resource_async(resource_id, remediation_name, parameters, custom_headers:nil)
2135
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
2136
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
2137
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
2138
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
2139
+
2140
+
2141
+ request_headers = {}
2142
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2143
+
2144
+ # Set Headers
2145
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2146
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2147
+
2148
+ # Serialize Request
2149
+ request_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
2150
+ request_content = @client.serialize(request_mapper, parameters)
2151
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
2152
+
2153
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
2154
+
2155
+ request_url = @base_url || @client.base_url
2156
+
2157
+ options = {
2158
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2159
+ path_params: {'remediationName' => remediation_name},
2160
+ skip_encoding_path_params: {'resourceId' => resource_id},
2161
+ query_params: {'api-version' => @client.api_version},
2162
+ body: request_content,
2163
+ headers: request_headers.merge(custom_headers || {}),
2164
+ base_url: request_url
2165
+ }
2166
+ promise = @client.make_request_async(:put, path_template, options)
2167
+
2168
+ promise = promise.then do |result|
2169
+ http_response = result.response
2170
+ status_code = http_response.status
2171
+ response_content = http_response.body
2172
+ unless status_code == 200 || status_code == 201
2173
+ error_model = JSON.load(response_content)
2174
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2175
+ end
2176
+
2177
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2178
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2179
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2180
+ # Deserialize Response
2181
+ if status_code == 200
2182
+ begin
2183
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2184
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
2185
+ result.body = @client.deserialize(result_mapper, parsed_response)
2186
+ rescue Exception => e
2187
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2188
+ end
2189
+ end
2190
+ # Deserialize Response
2191
+ if status_code == 201
2192
+ begin
2193
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2194
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
2195
+ result.body = @client.deserialize(result_mapper, parsed_response)
2196
+ rescue Exception => e
2197
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2198
+ end
2199
+ end
2200
+
2201
+ result
2202
+ end
2203
+
2204
+ promise.execute
2205
+ end
2206
+
2207
+ #
2208
+ # Gets an existing remediation at resource scope.
2209
+ #
2210
+ # @param resource_id [String] Resource ID.
2211
+ # @param remediation_name [String] The name of the remediation.
2212
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2213
+ # will be added to the HTTP request.
2214
+ #
2215
+ # @return [Remediation] operation results.
2216
+ #
2217
+ def get_at_resource(resource_id, remediation_name, custom_headers:nil)
2218
+ response = get_at_resource_async(resource_id, remediation_name, custom_headers:custom_headers).value!
2219
+ response.body unless response.nil?
2220
+ end
2221
+
2222
+ #
2223
+ # Gets an existing remediation at resource scope.
2224
+ #
2225
+ # @param resource_id [String] Resource ID.
2226
+ # @param remediation_name [String] The name of the remediation.
2227
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2228
+ # will be added to the HTTP request.
2229
+ #
2230
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2231
+ #
2232
+ def get_at_resource_with_http_info(resource_id, remediation_name, custom_headers:nil)
2233
+ get_at_resource_async(resource_id, remediation_name, custom_headers:custom_headers).value!
2234
+ end
2235
+
2236
+ #
2237
+ # Gets an existing remediation at resource scope.
2238
+ #
2239
+ # @param resource_id [String] Resource ID.
2240
+ # @param remediation_name [String] The name of the remediation.
2241
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2242
+ # to the HTTP request.
2243
+ #
2244
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2245
+ #
2246
+ def get_at_resource_async(resource_id, remediation_name, custom_headers:nil)
2247
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
2248
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
2249
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
2250
+
2251
+
2252
+ request_headers = {}
2253
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2254
+
2255
+ # Set Headers
2256
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2257
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2258
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
2259
+
2260
+ request_url = @base_url || @client.base_url
2261
+
2262
+ options = {
2263
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2264
+ path_params: {'remediationName' => remediation_name},
2265
+ skip_encoding_path_params: {'resourceId' => resource_id},
2266
+ query_params: {'api-version' => @client.api_version},
2267
+ headers: request_headers.merge(custom_headers || {}),
2268
+ base_url: request_url
2269
+ }
2270
+ promise = @client.make_request_async(:get, path_template, options)
2271
+
2272
+ promise = promise.then do |result|
2273
+ http_response = result.response
2274
+ status_code = http_response.status
2275
+ response_content = http_response.body
2276
+ unless status_code == 200
2277
+ error_model = JSON.load(response_content)
2278
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2279
+ end
2280
+
2281
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2282
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2283
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2284
+ # Deserialize Response
2285
+ if status_code == 200
2286
+ begin
2287
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2288
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
2289
+ result.body = @client.deserialize(result_mapper, parsed_response)
2290
+ rescue Exception => e
2291
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2292
+ end
2293
+ end
2294
+
2295
+ result
2296
+ end
2297
+
2298
+ promise.execute
2299
+ end
2300
+
2301
+ #
2302
+ # Deletes an existing remediation at individual resource scope.
2303
+ #
2304
+ # @param resource_id [String] Resource ID.
2305
+ # @param remediation_name [String] The name of the remediation.
2306
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2307
+ # will be added to the HTTP request.
2308
+ #
2309
+ # @return [Remediation] operation results.
2310
+ #
2311
+ def delete_at_resource(resource_id, remediation_name, custom_headers:nil)
2312
+ response = delete_at_resource_async(resource_id, remediation_name, custom_headers:custom_headers).value!
2313
+ response.body unless response.nil?
2314
+ end
2315
+
2316
+ #
2317
+ # Deletes an existing remediation at individual resource scope.
2318
+ #
2319
+ # @param resource_id [String] Resource ID.
2320
+ # @param remediation_name [String] The name of the remediation.
2321
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2322
+ # will be added to the HTTP request.
2323
+ #
2324
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2325
+ #
2326
+ def delete_at_resource_with_http_info(resource_id, remediation_name, custom_headers:nil)
2327
+ delete_at_resource_async(resource_id, remediation_name, custom_headers:custom_headers).value!
2328
+ end
2329
+
2330
+ #
2331
+ # Deletes an existing remediation at individual resource scope.
2332
+ #
2333
+ # @param resource_id [String] Resource ID.
2334
+ # @param remediation_name [String] The name of the remediation.
2335
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2336
+ # to the HTTP request.
2337
+ #
2338
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2339
+ #
2340
+ def delete_at_resource_async(resource_id, remediation_name, custom_headers:nil)
2341
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
2342
+ fail ArgumentError, 'remediation_name is nil' if remediation_name.nil?
2343
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
2344
+
2345
+
2346
+ request_headers = {}
2347
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2348
+
2349
+ # Set Headers
2350
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2351
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2352
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}'
2353
+
2354
+ request_url = @base_url || @client.base_url
2355
+
2356
+ options = {
2357
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2358
+ path_params: {'remediationName' => remediation_name},
2359
+ skip_encoding_path_params: {'resourceId' => resource_id},
2360
+ query_params: {'api-version' => @client.api_version},
2361
+ headers: request_headers.merge(custom_headers || {}),
2362
+ base_url: request_url
2363
+ }
2364
+ promise = @client.make_request_async(:delete, path_template, options)
2365
+
2366
+ promise = promise.then do |result|
2367
+ http_response = result.response
2368
+ status_code = http_response.status
2369
+ response_content = http_response.body
2370
+ unless status_code == 200 || status_code == 204
2371
+ error_model = JSON.load(response_content)
2372
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2373
+ end
2374
+
2375
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2376
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2377
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2378
+ # Deserialize Response
2379
+ if status_code == 200
2380
+ begin
2381
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2382
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::Remediation.mapper()
2383
+ result.body = @client.deserialize(result_mapper, parsed_response)
2384
+ rescue Exception => e
2385
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2386
+ end
2387
+ end
2388
+
2389
+ result
2390
+ end
2391
+
2392
+ promise.execute
2393
+ end
2394
+
2395
+ #
2396
+ # Gets all deployments for a remediation at management group scope.
2397
+ #
2398
+ # @param next_page_link [String] The NextLink from the previous successful call
2399
+ # to List operation.
2400
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2401
+ # will be added to the HTTP request.
2402
+ #
2403
+ # @return [RemediationDeploymentsListResult] operation results.
2404
+ #
2405
+ def list_deployments_at_management_group_next(next_page_link, custom_headers:nil)
2406
+ response = list_deployments_at_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
2407
+ response.body unless response.nil?
2408
+ end
2409
+
2410
+ #
2411
+ # Gets all deployments for a remediation at management group scope.
2412
+ #
2413
+ # @param next_page_link [String] The NextLink from the previous successful call
2414
+ # to List operation.
2415
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2416
+ # will be added to the HTTP request.
2417
+ #
2418
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2419
+ #
2420
+ def list_deployments_at_management_group_next_with_http_info(next_page_link, custom_headers:nil)
2421
+ list_deployments_at_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
2422
+ end
2423
+
2424
+ #
2425
+ # Gets all deployments for a remediation at management group scope.
2426
+ #
2427
+ # @param next_page_link [String] The NextLink from the previous successful call
2428
+ # to List operation.
2429
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2430
+ # to the HTTP request.
2431
+ #
2432
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2433
+ #
2434
+ def list_deployments_at_management_group_next_async(next_page_link, custom_headers:nil)
2435
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2436
+
2437
+
2438
+ request_headers = {}
2439
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2440
+
2441
+ # Set Headers
2442
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2443
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2444
+ path_template = '{nextLink}'
2445
+
2446
+ request_url = @base_url || @client.base_url
2447
+
2448
+ options = {
2449
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2450
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2451
+ headers: request_headers.merge(custom_headers || {}),
2452
+ base_url: request_url
2453
+ }
2454
+ promise = @client.make_request_async(:post, path_template, options)
2455
+
2456
+ promise = promise.then do |result|
2457
+ http_response = result.response
2458
+ status_code = http_response.status
2459
+ response_content = http_response.body
2460
+ unless status_code == 200
2461
+ error_model = JSON.load(response_content)
2462
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2463
+ end
2464
+
2465
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2466
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2467
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2468
+ # Deserialize Response
2469
+ if status_code == 200
2470
+ begin
2471
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2472
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
2473
+ result.body = @client.deserialize(result_mapper, parsed_response)
2474
+ rescue Exception => e
2475
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2476
+ end
2477
+ end
2478
+
2479
+ result
2480
+ end
2481
+
2482
+ promise.execute
2483
+ end
2484
+
2485
+ #
2486
+ # Gets all remediations for the management group.
2487
+ #
2488
+ # @param next_page_link [String] The NextLink from the previous successful call
2489
+ # to List operation.
2490
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2491
+ # will be added to the HTTP request.
2492
+ #
2493
+ # @return [RemediationListResult] operation results.
2494
+ #
2495
+ def list_for_management_group_next(next_page_link, custom_headers:nil)
2496
+ response = list_for_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
2497
+ response.body unless response.nil?
2498
+ end
2499
+
2500
+ #
2501
+ # Gets all remediations for the management group.
2502
+ #
2503
+ # @param next_page_link [String] The NextLink from the previous successful call
2504
+ # to List operation.
2505
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2506
+ # will be added to the HTTP request.
2507
+ #
2508
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2509
+ #
2510
+ def list_for_management_group_next_with_http_info(next_page_link, custom_headers:nil)
2511
+ list_for_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
2512
+ end
2513
+
2514
+ #
2515
+ # Gets all remediations for the management group.
2516
+ #
2517
+ # @param next_page_link [String] The NextLink from the previous successful call
2518
+ # to List operation.
2519
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2520
+ # to the HTTP request.
2521
+ #
2522
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2523
+ #
2524
+ def list_for_management_group_next_async(next_page_link, custom_headers:nil)
2525
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2526
+
2527
+
2528
+ request_headers = {}
2529
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2530
+
2531
+ # Set Headers
2532
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2533
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2534
+ path_template = '{nextLink}'
2535
+
2536
+ request_url = @base_url || @client.base_url
2537
+
2538
+ options = {
2539
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2540
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2541
+ headers: request_headers.merge(custom_headers || {}),
2542
+ base_url: request_url
2543
+ }
2544
+ promise = @client.make_request_async(:get, path_template, options)
2545
+
2546
+ promise = promise.then do |result|
2547
+ http_response = result.response
2548
+ status_code = http_response.status
2549
+ response_content = http_response.body
2550
+ unless status_code == 200
2551
+ error_model = JSON.load(response_content)
2552
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2553
+ end
2554
+
2555
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2556
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2557
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2558
+ # Deserialize Response
2559
+ if status_code == 200
2560
+ begin
2561
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2562
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
2563
+ result.body = @client.deserialize(result_mapper, parsed_response)
2564
+ rescue Exception => e
2565
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2566
+ end
2567
+ end
2568
+
2569
+ result
2570
+ end
2571
+
2572
+ promise.execute
2573
+ end
2574
+
2575
+ #
2576
+ # Gets all deployments for a remediation at subscription scope.
2577
+ #
2578
+ # @param next_page_link [String] The NextLink from the previous successful call
2579
+ # to List operation.
2580
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2581
+ # will be added to the HTTP request.
2582
+ #
2583
+ # @return [RemediationDeploymentsListResult] operation results.
2584
+ #
2585
+ def list_deployments_at_subscription_next(next_page_link, custom_headers:nil)
2586
+ response = list_deployments_at_subscription_next_async(next_page_link, custom_headers:custom_headers).value!
2587
+ response.body unless response.nil?
2588
+ end
2589
+
2590
+ #
2591
+ # Gets all deployments for a remediation at subscription scope.
2592
+ #
2593
+ # @param next_page_link [String] The NextLink from the previous successful call
2594
+ # to List operation.
2595
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2596
+ # will be added to the HTTP request.
2597
+ #
2598
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2599
+ #
2600
+ def list_deployments_at_subscription_next_with_http_info(next_page_link, custom_headers:nil)
2601
+ list_deployments_at_subscription_next_async(next_page_link, custom_headers:custom_headers).value!
2602
+ end
2603
+
2604
+ #
2605
+ # Gets all deployments for a remediation at subscription scope.
2606
+ #
2607
+ # @param next_page_link [String] The NextLink from the previous successful call
2608
+ # to List operation.
2609
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2610
+ # to the HTTP request.
2611
+ #
2612
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2613
+ #
2614
+ def list_deployments_at_subscription_next_async(next_page_link, custom_headers:nil)
2615
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2616
+
2617
+
2618
+ request_headers = {}
2619
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2620
+
2621
+ # Set Headers
2622
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2623
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2624
+ path_template = '{nextLink}'
2625
+
2626
+ request_url = @base_url || @client.base_url
2627
+
2628
+ options = {
2629
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2630
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2631
+ headers: request_headers.merge(custom_headers || {}),
2632
+ base_url: request_url
2633
+ }
2634
+ promise = @client.make_request_async(:post, path_template, options)
2635
+
2636
+ promise = promise.then do |result|
2637
+ http_response = result.response
2638
+ status_code = http_response.status
2639
+ response_content = http_response.body
2640
+ unless status_code == 200
2641
+ error_model = JSON.load(response_content)
2642
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2643
+ end
2644
+
2645
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2646
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2647
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2648
+ # Deserialize Response
2649
+ if status_code == 200
2650
+ begin
2651
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2652
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
2653
+ result.body = @client.deserialize(result_mapper, parsed_response)
2654
+ rescue Exception => e
2655
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2656
+ end
2657
+ end
2658
+
2659
+ result
2660
+ end
2661
+
2662
+ promise.execute
2663
+ end
2664
+
2665
+ #
2666
+ # Gets all remediations for the subscription.
2667
+ #
2668
+ # @param next_page_link [String] The NextLink from the previous successful call
2669
+ # to List operation.
2670
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2671
+ # will be added to the HTTP request.
2672
+ #
2673
+ # @return [RemediationListResult] operation results.
2674
+ #
2675
+ def list_for_subscription_next(next_page_link, custom_headers:nil)
2676
+ response = list_for_subscription_next_async(next_page_link, custom_headers:custom_headers).value!
2677
+ response.body unless response.nil?
2678
+ end
2679
+
2680
+ #
2681
+ # Gets all remediations for the subscription.
2682
+ #
2683
+ # @param next_page_link [String] The NextLink from the previous successful call
2684
+ # to List operation.
2685
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2686
+ # will be added to the HTTP request.
2687
+ #
2688
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2689
+ #
2690
+ def list_for_subscription_next_with_http_info(next_page_link, custom_headers:nil)
2691
+ list_for_subscription_next_async(next_page_link, custom_headers:custom_headers).value!
2692
+ end
2693
+
2694
+ #
2695
+ # Gets all remediations for the subscription.
2696
+ #
2697
+ # @param next_page_link [String] The NextLink from the previous successful call
2698
+ # to List operation.
2699
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2700
+ # to the HTTP request.
2701
+ #
2702
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2703
+ #
2704
+ def list_for_subscription_next_async(next_page_link, custom_headers:nil)
2705
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2706
+
2707
+
2708
+ request_headers = {}
2709
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2710
+
2711
+ # Set Headers
2712
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2713
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2714
+ path_template = '{nextLink}'
2715
+
2716
+ request_url = @base_url || @client.base_url
2717
+
2718
+ options = {
2719
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2720
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2721
+ headers: request_headers.merge(custom_headers || {}),
2722
+ base_url: request_url
2723
+ }
2724
+ promise = @client.make_request_async(:get, path_template, options)
2725
+
2726
+ promise = promise.then do |result|
2727
+ http_response = result.response
2728
+ status_code = http_response.status
2729
+ response_content = http_response.body
2730
+ unless status_code == 200
2731
+ error_model = JSON.load(response_content)
2732
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2733
+ end
2734
+
2735
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2736
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2737
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2738
+ # Deserialize Response
2739
+ if status_code == 200
2740
+ begin
2741
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2742
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
2743
+ result.body = @client.deserialize(result_mapper, parsed_response)
2744
+ rescue Exception => e
2745
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2746
+ end
2747
+ end
2748
+
2749
+ result
2750
+ end
2751
+
2752
+ promise.execute
2753
+ end
2754
+
2755
+ #
2756
+ # Gets all deployments for a remediation at resource group scope.
2757
+ #
2758
+ # @param next_page_link [String] The NextLink from the previous successful call
2759
+ # to List operation.
2760
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2761
+ # will be added to the HTTP request.
2762
+ #
2763
+ # @return [RemediationDeploymentsListResult] operation results.
2764
+ #
2765
+ def list_deployments_at_resource_group_next(next_page_link, custom_headers:nil)
2766
+ response = list_deployments_at_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
2767
+ response.body unless response.nil?
2768
+ end
2769
+
2770
+ #
2771
+ # Gets all deployments for a remediation at resource group scope.
2772
+ #
2773
+ # @param next_page_link [String] The NextLink from the previous successful call
2774
+ # to List operation.
2775
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2776
+ # will be added to the HTTP request.
2777
+ #
2778
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2779
+ #
2780
+ def list_deployments_at_resource_group_next_with_http_info(next_page_link, custom_headers:nil)
2781
+ list_deployments_at_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
2782
+ end
2783
+
2784
+ #
2785
+ # Gets all deployments for a remediation at resource group scope.
2786
+ #
2787
+ # @param next_page_link [String] The NextLink from the previous successful call
2788
+ # to List operation.
2789
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2790
+ # to the HTTP request.
2791
+ #
2792
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2793
+ #
2794
+ def list_deployments_at_resource_group_next_async(next_page_link, custom_headers:nil)
2795
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2796
+
2797
+
2798
+ request_headers = {}
2799
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2800
+
2801
+ # Set Headers
2802
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2803
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2804
+ path_template = '{nextLink}'
2805
+
2806
+ request_url = @base_url || @client.base_url
2807
+
2808
+ options = {
2809
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2810
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2811
+ headers: request_headers.merge(custom_headers || {}),
2812
+ base_url: request_url
2813
+ }
2814
+ promise = @client.make_request_async(:post, path_template, options)
2815
+
2816
+ promise = promise.then do |result|
2817
+ http_response = result.response
2818
+ status_code = http_response.status
2819
+ response_content = http_response.body
2820
+ unless status_code == 200
2821
+ error_model = JSON.load(response_content)
2822
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2823
+ end
2824
+
2825
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2826
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2827
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2828
+ # Deserialize Response
2829
+ if status_code == 200
2830
+ begin
2831
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2832
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
2833
+ result.body = @client.deserialize(result_mapper, parsed_response)
2834
+ rescue Exception => e
2835
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2836
+ end
2837
+ end
2838
+
2839
+ result
2840
+ end
2841
+
2842
+ promise.execute
2843
+ end
2844
+
2845
+ #
2846
+ # Gets all remediations for the subscription.
2847
+ #
2848
+ # @param next_page_link [String] The NextLink from the previous successful call
2849
+ # to List operation.
2850
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2851
+ # will be added to the HTTP request.
2852
+ #
2853
+ # @return [RemediationListResult] operation results.
2854
+ #
2855
+ def list_for_resource_group_next(next_page_link, custom_headers:nil)
2856
+ response = list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
2857
+ response.body unless response.nil?
2858
+ end
2859
+
2860
+ #
2861
+ # Gets all remediations for the subscription.
2862
+ #
2863
+ # @param next_page_link [String] The NextLink from the previous successful call
2864
+ # to List operation.
2865
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2866
+ # will be added to the HTTP request.
2867
+ #
2868
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2869
+ #
2870
+ def list_for_resource_group_next_with_http_info(next_page_link, custom_headers:nil)
2871
+ list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
2872
+ end
2873
+
2874
+ #
2875
+ # Gets all remediations for the subscription.
2876
+ #
2877
+ # @param next_page_link [String] The NextLink from the previous successful call
2878
+ # to List operation.
2879
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2880
+ # to the HTTP request.
2881
+ #
2882
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2883
+ #
2884
+ def list_for_resource_group_next_async(next_page_link, custom_headers:nil)
2885
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2886
+
2887
+
2888
+ request_headers = {}
2889
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2890
+
2891
+ # Set Headers
2892
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2893
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2894
+ path_template = '{nextLink}'
2895
+
2896
+ request_url = @base_url || @client.base_url
2897
+
2898
+ options = {
2899
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2900
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2901
+ headers: request_headers.merge(custom_headers || {}),
2902
+ base_url: request_url
2903
+ }
2904
+ promise = @client.make_request_async(:get, path_template, options)
2905
+
2906
+ promise = promise.then do |result|
2907
+ http_response = result.response
2908
+ status_code = http_response.status
2909
+ response_content = http_response.body
2910
+ unless status_code == 200
2911
+ error_model = JSON.load(response_content)
2912
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2913
+ end
2914
+
2915
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2916
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
2917
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
2918
+ # Deserialize Response
2919
+ if status_code == 200
2920
+ begin
2921
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2922
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
2923
+ result.body = @client.deserialize(result_mapper, parsed_response)
2924
+ rescue Exception => e
2925
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2926
+ end
2927
+ end
2928
+
2929
+ result
2930
+ end
2931
+
2932
+ promise.execute
2933
+ end
2934
+
2935
+ #
2936
+ # Gets all deployments for a remediation at resource scope.
2937
+ #
2938
+ # @param next_page_link [String] The NextLink from the previous successful call
2939
+ # to List operation.
2940
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2941
+ # will be added to the HTTP request.
2942
+ #
2943
+ # @return [RemediationDeploymentsListResult] operation results.
2944
+ #
2945
+ def list_deployments_at_resource_next(next_page_link, custom_headers:nil)
2946
+ response = list_deployments_at_resource_next_async(next_page_link, custom_headers:custom_headers).value!
2947
+ response.body unless response.nil?
2948
+ end
2949
+
2950
+ #
2951
+ # Gets all deployments for a remediation at resource scope.
2952
+ #
2953
+ # @param next_page_link [String] The NextLink from the previous successful call
2954
+ # to List operation.
2955
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2956
+ # will be added to the HTTP request.
2957
+ #
2958
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2959
+ #
2960
+ def list_deployments_at_resource_next_with_http_info(next_page_link, custom_headers:nil)
2961
+ list_deployments_at_resource_next_async(next_page_link, custom_headers:custom_headers).value!
2962
+ end
2963
+
2964
+ #
2965
+ # Gets all deployments for a remediation at resource scope.
2966
+ #
2967
+ # @param next_page_link [String] The NextLink from the previous successful call
2968
+ # to List operation.
2969
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2970
+ # to the HTTP request.
2971
+ #
2972
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2973
+ #
2974
+ def list_deployments_at_resource_next_async(next_page_link, custom_headers:nil)
2975
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
2976
+
2977
+
2978
+ request_headers = {}
2979
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2980
+
2981
+ # Set Headers
2982
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2983
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2984
+ path_template = '{nextLink}'
2985
+
2986
+ request_url = @base_url || @client.base_url
2987
+
2988
+ options = {
2989
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2990
+ skip_encoding_path_params: {'nextLink' => next_page_link},
2991
+ headers: request_headers.merge(custom_headers || {}),
2992
+ base_url: request_url
2993
+ }
2994
+ promise = @client.make_request_async(:post, path_template, options)
2995
+
2996
+ promise = promise.then do |result|
2997
+ http_response = result.response
2998
+ status_code = http_response.status
2999
+ response_content = http_response.body
3000
+ unless status_code == 200
3001
+ error_model = JSON.load(response_content)
3002
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
3003
+ end
3004
+
3005
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
3006
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
3007
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
3008
+ # Deserialize Response
3009
+ if status_code == 200
3010
+ begin
3011
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
3012
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationDeploymentsListResult.mapper()
3013
+ result.body = @client.deserialize(result_mapper, parsed_response)
3014
+ rescue Exception => e
3015
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
3016
+ end
3017
+ end
3018
+
3019
+ result
3020
+ end
3021
+
3022
+ promise.execute
3023
+ end
3024
+
3025
+ #
3026
+ # Gets all remediations for a resource.
3027
+ #
3028
+ # @param next_page_link [String] The NextLink from the previous successful call
3029
+ # to List operation.
3030
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3031
+ # will be added to the HTTP request.
3032
+ #
3033
+ # @return [RemediationListResult] operation results.
3034
+ #
3035
+ def list_for_resource_next(next_page_link, custom_headers:nil)
3036
+ response = list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
3037
+ response.body unless response.nil?
3038
+ end
3039
+
3040
+ #
3041
+ # Gets all remediations for a resource.
3042
+ #
3043
+ # @param next_page_link [String] The NextLink from the previous successful call
3044
+ # to List operation.
3045
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3046
+ # will be added to the HTTP request.
3047
+ #
3048
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
3049
+ #
3050
+ def list_for_resource_next_with_http_info(next_page_link, custom_headers:nil)
3051
+ list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
3052
+ end
3053
+
3054
+ #
3055
+ # Gets all remediations for a resource.
3056
+ #
3057
+ # @param next_page_link [String] The NextLink from the previous successful call
3058
+ # to List operation.
3059
+ # @param [Hash{String => String}] A hash of custom headers that will be added
3060
+ # to the HTTP request.
3061
+ #
3062
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
3063
+ #
3064
+ def list_for_resource_next_async(next_page_link, custom_headers:nil)
3065
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
3066
+
3067
+
3068
+ request_headers = {}
3069
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
3070
+
3071
+ # Set Headers
3072
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
3073
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
3074
+ path_template = '{nextLink}'
3075
+
3076
+ request_url = @base_url || @client.base_url
3077
+
3078
+ options = {
3079
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
3080
+ skip_encoding_path_params: {'nextLink' => next_page_link},
3081
+ headers: request_headers.merge(custom_headers || {}),
3082
+ base_url: request_url
3083
+ }
3084
+ promise = @client.make_request_async(:get, path_template, options)
3085
+
3086
+ promise = promise.then do |result|
3087
+ http_response = result.response
3088
+ status_code = http_response.status
3089
+ response_content = http_response.body
3090
+ unless status_code == 200
3091
+ error_model = JSON.load(response_content)
3092
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
3093
+ end
3094
+
3095
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
3096
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
3097
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
3098
+ # Deserialize Response
3099
+ if status_code == 200
3100
+ begin
3101
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
3102
+ result_mapper = Azure::PolicyInsights::Mgmt::V2019_07_01::Models::RemediationListResult.mapper()
3103
+ result.body = @client.deserialize(result_mapper, parsed_response)
3104
+ rescue Exception => e
3105
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
3106
+ end
3107
+ end
3108
+
3109
+ result
3110
+ end
3111
+
3112
+ promise.execute
3113
+ end
3114
+
3115
+ #
3116
+ # Gets all deployments for a remediation at management group scope.
3117
+ #
3118
+ # @param management_group_id [String] Management group ID.
3119
+ # @param remediation_name [String] The name of the remediation.
3120
+ # @param query_options [QueryOptions] Additional parameters for the operation
3121
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3122
+ # will be added to the HTTP request.
3123
+ #
3124
+ # @return [RemediationDeploymentsListResult] which provide lazy access to pages
3125
+ # of the response.
3126
+ #
3127
+ def list_deployments_at_management_group_as_lazy(management_group_id, remediation_name, query_options:nil, custom_headers:nil)
3128
+ response = list_deployments_at_management_group_async(management_group_id, remediation_name, query_options:query_options, custom_headers:custom_headers).value!
3129
+ unless response.nil?
3130
+ page = response.body
3131
+ page.next_method = Proc.new do |next_page_link|
3132
+ list_deployments_at_management_group_next_async(next_page_link, custom_headers:custom_headers)
3133
+ end
3134
+ page
3135
+ end
3136
+ end
3137
+
3138
+ #
3139
+ # Gets all remediations for the management group.
3140
+ #
3141
+ # @param management_group_id [String] Management group ID.
3142
+ # @param query_options [QueryOptions] Additional parameters for the operation
3143
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3144
+ # will be added to the HTTP request.
3145
+ #
3146
+ # @return [RemediationListResult] which provide lazy access to pages of the
3147
+ # response.
3148
+ #
3149
+ def list_for_management_group_as_lazy(management_group_id, query_options:nil, custom_headers:nil)
3150
+ response = list_for_management_group_async(management_group_id, query_options:query_options, custom_headers:custom_headers).value!
3151
+ unless response.nil?
3152
+ page = response.body
3153
+ page.next_method = Proc.new do |next_page_link|
3154
+ list_for_management_group_next_async(next_page_link, custom_headers:custom_headers)
3155
+ end
3156
+ page
3157
+ end
3158
+ end
3159
+
3160
+ #
3161
+ # Gets all deployments for a remediation at subscription scope.
3162
+ #
3163
+ # @param remediation_name [String] The name of the remediation.
3164
+ # @param query_options [QueryOptions] Additional parameters for the operation
3165
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3166
+ # will be added to the HTTP request.
3167
+ #
3168
+ # @return [RemediationDeploymentsListResult] which provide lazy access to pages
3169
+ # of the response.
3170
+ #
3171
+ def list_deployments_at_subscription_as_lazy(remediation_name, query_options:nil, custom_headers:nil)
3172
+ response = list_deployments_at_subscription_async(remediation_name, query_options:query_options, custom_headers:custom_headers).value!
3173
+ unless response.nil?
3174
+ page = response.body
3175
+ page.next_method = Proc.new do |next_page_link|
3176
+ list_deployments_at_subscription_next_async(next_page_link, custom_headers:custom_headers)
3177
+ end
3178
+ page
3179
+ end
3180
+ end
3181
+
3182
+ #
3183
+ # Gets all remediations for the subscription.
3184
+ #
3185
+ # @param query_options [QueryOptions] Additional parameters for the operation
3186
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3187
+ # will be added to the HTTP request.
3188
+ #
3189
+ # @return [RemediationListResult] which provide lazy access to pages of the
3190
+ # response.
3191
+ #
3192
+ def list_for_subscription_as_lazy(query_options:nil, custom_headers:nil)
3193
+ response = list_for_subscription_async(query_options:query_options, custom_headers:custom_headers).value!
3194
+ unless response.nil?
3195
+ page = response.body
3196
+ page.next_method = Proc.new do |next_page_link|
3197
+ list_for_subscription_next_async(next_page_link, custom_headers:custom_headers)
3198
+ end
3199
+ page
3200
+ end
3201
+ end
3202
+
3203
+ #
3204
+ # Gets all deployments for a remediation at resource group scope.
3205
+ #
3206
+ # @param resource_group_name [String] Resource group name.
3207
+ # @param remediation_name [String] The name of the remediation.
3208
+ # @param query_options [QueryOptions] Additional parameters for the operation
3209
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3210
+ # will be added to the HTTP request.
3211
+ #
3212
+ # @return [RemediationDeploymentsListResult] which provide lazy access to pages
3213
+ # of the response.
3214
+ #
3215
+ def list_deployments_at_resource_group_as_lazy(resource_group_name, remediation_name, query_options:nil, custom_headers:nil)
3216
+ response = list_deployments_at_resource_group_async(resource_group_name, remediation_name, query_options:query_options, custom_headers:custom_headers).value!
3217
+ unless response.nil?
3218
+ page = response.body
3219
+ page.next_method = Proc.new do |next_page_link|
3220
+ list_deployments_at_resource_group_next_async(next_page_link, custom_headers:custom_headers)
3221
+ end
3222
+ page
3223
+ end
3224
+ end
3225
+
3226
+ #
3227
+ # Gets all remediations for the subscription.
3228
+ #
3229
+ # @param resource_group_name [String] Resource group name.
3230
+ # @param query_options [QueryOptions] Additional parameters for the operation
3231
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3232
+ # will be added to the HTTP request.
3233
+ #
3234
+ # @return [RemediationListResult] which provide lazy access to pages of the
3235
+ # response.
3236
+ #
3237
+ def list_for_resource_group_as_lazy(resource_group_name, query_options:nil, custom_headers:nil)
3238
+ response = list_for_resource_group_async(resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
3239
+ unless response.nil?
3240
+ page = response.body
3241
+ page.next_method = Proc.new do |next_page_link|
3242
+ list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers)
3243
+ end
3244
+ page
3245
+ end
3246
+ end
3247
+
3248
+ #
3249
+ # Gets all deployments for a remediation at resource scope.
3250
+ #
3251
+ # @param resource_id [String] Resource ID.
3252
+ # @param remediation_name [String] The name of the remediation.
3253
+ # @param query_options [QueryOptions] Additional parameters for the operation
3254
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3255
+ # will be added to the HTTP request.
3256
+ #
3257
+ # @return [RemediationDeploymentsListResult] which provide lazy access to pages
3258
+ # of the response.
3259
+ #
3260
+ def list_deployments_at_resource_as_lazy(resource_id, remediation_name, query_options:nil, custom_headers:nil)
3261
+ response = list_deployments_at_resource_async(resource_id, remediation_name, query_options:query_options, custom_headers:custom_headers).value!
3262
+ unless response.nil?
3263
+ page = response.body
3264
+ page.next_method = Proc.new do |next_page_link|
3265
+ list_deployments_at_resource_next_async(next_page_link, custom_headers:custom_headers)
3266
+ end
3267
+ page
3268
+ end
3269
+ end
3270
+
3271
+ #
3272
+ # Gets all remediations for a resource.
3273
+ #
3274
+ # @param resource_id [String] Resource ID.
3275
+ # @param query_options [QueryOptions] Additional parameters for the operation
3276
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
3277
+ # will be added to the HTTP request.
3278
+ #
3279
+ # @return [RemediationListResult] which provide lazy access to pages of the
3280
+ # response.
3281
+ #
3282
+ def list_for_resource_as_lazy(resource_id, query_options:nil, custom_headers:nil)
3283
+ response = list_for_resource_async(resource_id, query_options:query_options, custom_headers:custom_headers).value!
3284
+ unless response.nil?
3285
+ page = response.body
3286
+ page.next_method = Proc.new do |next_page_link|
3287
+ list_for_resource_next_async(next_page_link, custom_headers:custom_headers)
3288
+ end
3289
+ page
3290
+ end
3291
+ end
3292
+
3293
+ end
3294
+ end