azure_mgmt_policy 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2015-10-01-preview/generated/azure_mgmt_policy.rb +34 -0
  3. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_assignment.rb +94 -0
  4. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +94 -0
  5. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_definition.rb +98 -0
  6. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +94 -0
  7. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/models/policy_type.rb +17 -0
  8. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/module_definition.rb +9 -0
  9. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/policy_assignments.rb +1318 -0
  10. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/policy_client.rb +133 -0
  11. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/policy_definitions.rb +492 -0
  12. data/lib/2015-10-01-preview/generated/azure_mgmt_policy/version.rb +8 -0
  13. data/lib/2016-04-01/generated/azure_mgmt_policy.rb +34 -0
  14. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_assignment.rb +94 -0
  15. data/lib/{generated → 2016-04-01/generated}/azure_mgmt_policy/models/policy_assignment_list_result.rb +1 -1
  16. data/lib/2016-04-01/generated/azure_mgmt_policy/models/policy_definition.rb +98 -0
  17. data/lib/{generated → 2016-04-01/generated}/azure_mgmt_policy/models/policy_definition_list_result.rb +1 -1
  18. data/lib/{generated → 2016-04-01/generated}/azure_mgmt_policy/models/policy_type.rb +1 -1
  19. data/lib/2016-04-01/generated/azure_mgmt_policy/module_definition.rb +9 -0
  20. data/lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb +1318 -0
  21. data/lib/{generated → 2016-04-01/generated}/azure_mgmt_policy/policy_client.rb +7 -7
  22. data/lib/2016-04-01/generated/azure_mgmt_policy/policy_definitions.rb +492 -0
  23. data/lib/{generated → 2016-04-01/generated}/azure_mgmt_policy/version.rb +2 -2
  24. data/lib/2016-12-01/generated/azure_mgmt_policy.rb +35 -0
  25. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_assignment.rb +116 -0
  26. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +94 -0
  27. data/lib/{generated → 2016-12-01/generated}/azure_mgmt_policy/models/policy_definition.rb +1 -1
  28. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_definition_list_result.rb +94 -0
  29. data/lib/{generated → 2016-12-01/generated}/azure_mgmt_policy/models/policy_mode.rb +1 -1
  30. data/lib/2016-12-01/generated/azure_mgmt_policy/models/policy_type.rb +17 -0
  31. data/lib/2016-12-01/generated/azure_mgmt_policy/module_definition.rb +9 -0
  32. data/lib/2016-12-01/generated/azure_mgmt_policy/policy_assignments.rb +1318 -0
  33. data/lib/2016-12-01/generated/azure_mgmt_policy/policy_client.rb +133 -0
  34. data/lib/{generated → 2016-12-01/generated}/azure_mgmt_policy/policy_definitions.rb +34 -34
  35. data/lib/{generated/azure_mgmt_policy/module_definition.rb → 2016-12-01/generated/azure_mgmt_policy/version.rb} +3 -3
  36. data/lib/2017-06-01-preview/generated/azure_mgmt_policy.rb +37 -0
  37. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/models/error_response.rb +1 -1
  38. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/models/policy_assignment.rb +1 -1
  39. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_assignment_list_result.rb +94 -0
  40. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/models/policy_definition_reference.rb +1 -1
  41. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/models/policy_set_definition.rb +1 -1
  42. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/models/policy_set_definition_list_result.rb +1 -1
  43. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/models/policy_sku.rb +1 -1
  44. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/models/policy_type.rb +17 -0
  45. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/module_definition.rb +9 -0
  46. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/policy_assignments.rb +33 -33
  47. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/policy_client.rb +133 -0
  48. data/lib/{generated → 2017-06-01-preview/generated}/azure_mgmt_policy/policy_set_definitions.rb +36 -36
  49. data/lib/2017-06-01-preview/generated/azure_mgmt_policy/version.rb +8 -0
  50. data/lib/azure_mgmt_policy.rb +6 -1
  51. data/lib/module_definition.rb +7 -0
  52. data/lib/profiles/common/configurable.rb +73 -0
  53. data/lib/profiles/common/default.rb +68 -0
  54. data/lib/profiles/latest/modules/policy_profile_module.rb +95 -0
  55. data/lib/profiles/latest/policy_latest_profile_client.rb +33 -0
  56. data/lib/profiles/latest/policy_module_definition.rb +9 -0
  57. data/lib/profiles/v2017_03_09/modules/policy_profile_module.rb +64 -0
  58. data/lib/profiles/v2017_03_09/policy_module_definition.rb +9 -0
  59. data/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb +33 -0
  60. data/lib/version.rb +7 -0
  61. metadata +60 -20
  62. data/lib/generated/azure_mgmt_policy.rb +0 -41
@@ -3,7 +3,7 @@
3
3
  # Changes may cause incorrect behavior and will be lost if the code is
4
4
  # regenerated.
5
5
 
6
- module Azure::ARM::Policy
6
+ module Azure::Policy::Mgmt::V2016_04_01
7
7
  #
8
8
  # A service client - single point of access to the REST API.
9
9
  #
@@ -20,6 +20,9 @@ module Azure::ARM::Policy
20
20
  # @return [String] The ID of the target subscription.
21
21
  attr_accessor :subscription_id
22
22
 
23
+ # @return [String] The API version to use for the operation.
24
+ attr_reader :api_version
25
+
23
26
  # @return [String] Gets or sets the preferred language for the response.
24
27
  attr_accessor :accept_language
25
28
 
@@ -34,9 +37,6 @@ module Azure::ARM::Policy
34
37
  # @return [PolicyAssignments] policy_assignments
35
38
  attr_reader :policy_assignments
36
39
 
37
- # @return [PolicySetDefinitions] policy_set_definitions
38
- attr_reader :policy_set_definitions
39
-
40
40
  # @return [PolicyDefinitions] policy_definitions
41
41
  attr_reader :policy_definitions
42
42
 
@@ -54,8 +54,8 @@ module Azure::ARM::Policy
54
54
  @credentials = credentials
55
55
 
56
56
  @policy_assignments = PolicyAssignments.new(self)
57
- @policy_set_definitions = PolicySetDefinitions.new(self)
58
57
  @policy_definitions = PolicyDefinitions.new(self)
58
+ @api_version = '2016-04-01'
59
59
  @accept_language = 'en-US'
60
60
  @long_running_operation_retry_timeout = 30
61
61
  @generate_client_request_id = true
@@ -124,8 +124,8 @@ module Azure::ARM::Policy
124
124
  #
125
125
  def add_telemetry
126
126
  sdk_information = 'azure_mgmt_policy'
127
- if defined? Azure::ARM::Policy::VERSION
128
- sdk_information = "#{sdk_information}/#{Azure::ARM::Policy::VERSION}"
127
+ if defined? Azure::Policy::Mgmt::V2016_04_01::VERSION
128
+ sdk_information = "#{sdk_information}/#{Azure::Policy::Mgmt::V2016_04_01::VERSION}"
129
129
  end
130
130
  add_user_agent_information(sdk_information)
131
131
  end
@@ -0,0 +1,492 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Policy::Mgmt::V2016_04_01
7
+ #
8
+ # To manage and control access to your resources, you can define customized
9
+ # policies and assign them at a scope.
10
+ #
11
+ class PolicyDefinitions
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the PolicyDefinitions class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return [PolicyClient] reference to the PolicyClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Creates or updates a policy definition.
27
+ #
28
+ # @param policy_definition_name [String] The name of the policy definition to
29
+ # create.
30
+ # @param parameters [PolicyDefinition] The policy definition properties.
31
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
32
+ # will be added to the HTTP request.
33
+ #
34
+ # @return [PolicyDefinition] operation results.
35
+ #
36
+ def create_or_update(policy_definition_name, parameters, custom_headers = nil)
37
+ response = create_or_update_async(policy_definition_name, parameters, custom_headers).value!
38
+ response.body unless response.nil?
39
+ end
40
+
41
+ #
42
+ # Creates or updates a policy definition.
43
+ #
44
+ # @param policy_definition_name [String] The name of the policy definition to
45
+ # create.
46
+ # @param parameters [PolicyDefinition] The policy definition properties.
47
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
48
+ # will be added to the HTTP request.
49
+ #
50
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
51
+ #
52
+ def create_or_update_with_http_info(policy_definition_name, parameters, custom_headers = nil)
53
+ create_or_update_async(policy_definition_name, parameters, custom_headers).value!
54
+ end
55
+
56
+ #
57
+ # Creates or updates a policy definition.
58
+ #
59
+ # @param policy_definition_name [String] The name of the policy definition to
60
+ # create.
61
+ # @param parameters [PolicyDefinition] The policy definition properties.
62
+ # @param [Hash{String => String}] A hash of custom headers that will be added
63
+ # to the HTTP request.
64
+ #
65
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
66
+ #
67
+ def create_or_update_async(policy_definition_name, parameters, custom_headers = nil)
68
+ fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
69
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
70
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
71
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
72
+
73
+
74
+ request_headers = {}
75
+
76
+ # Set Headers
77
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
78
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
79
+
80
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
81
+
82
+ # Serialize Request
83
+ request_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyDefinition.mapper()
84
+ request_content = @client.serialize(request_mapper, parameters)
85
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
86
+
87
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'
88
+
89
+ request_url = @base_url || @client.base_url
90
+
91
+ options = {
92
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
93
+ path_params: {'policyDefinitionName' => policy_definition_name,'subscriptionId' => @client.subscription_id},
94
+ query_params: {'api-version' => @client.api_version},
95
+ body: request_content,
96
+ headers: request_headers.merge(custom_headers || {}),
97
+ base_url: request_url
98
+ }
99
+ promise = @client.make_request_async(:put, path_template, options)
100
+
101
+ promise = promise.then do |result|
102
+ http_response = result.response
103
+ status_code = http_response.status
104
+ response_content = http_response.body
105
+ unless status_code == 201
106
+ error_model = JSON.load(response_content)
107
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
108
+ end
109
+
110
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
111
+ # Deserialize Response
112
+ if status_code == 201
113
+ begin
114
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
115
+ result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyDefinition.mapper()
116
+ result.body = @client.deserialize(result_mapper, parsed_response)
117
+ rescue Exception => e
118
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
119
+ end
120
+ end
121
+
122
+ result
123
+ end
124
+
125
+ promise.execute
126
+ end
127
+
128
+ #
129
+ # Deletes a policy definition.
130
+ #
131
+ # @param policy_definition_name [String] The name of the policy definition to
132
+ # delete.
133
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
134
+ # will be added to the HTTP request.
135
+ #
136
+ #
137
+ def delete(policy_definition_name, custom_headers = nil)
138
+ response = delete_async(policy_definition_name, custom_headers).value!
139
+ nil
140
+ end
141
+
142
+ #
143
+ # Deletes a policy definition.
144
+ #
145
+ # @param policy_definition_name [String] The name of the policy definition to
146
+ # delete.
147
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
148
+ # will be added to the HTTP request.
149
+ #
150
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
151
+ #
152
+ def delete_with_http_info(policy_definition_name, custom_headers = nil)
153
+ delete_async(policy_definition_name, custom_headers).value!
154
+ end
155
+
156
+ #
157
+ # Deletes a policy definition.
158
+ #
159
+ # @param policy_definition_name [String] The name of the policy definition to
160
+ # delete.
161
+ # @param [Hash{String => String}] A hash of custom headers that will be added
162
+ # to the HTTP request.
163
+ #
164
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
165
+ #
166
+ def delete_async(policy_definition_name, custom_headers = nil)
167
+ fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
168
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
169
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
170
+
171
+
172
+ request_headers = {}
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 = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'
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: {'policyDefinitionName' => policy_definition_name,'subscriptionId' => @client.subscription_id},
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(:delete, 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 == 204 || status_code == 200
195
+ error_model = JSON.load(response_content)
196
+ fail MsRestAzure::AzureOperationError.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
+
201
+ result
202
+ end
203
+
204
+ promise.execute
205
+ end
206
+
207
+ #
208
+ # Gets the policy definition.
209
+ #
210
+ # @param policy_definition_name [String] The name of the policy definition to
211
+ # get.
212
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
213
+ # will be added to the HTTP request.
214
+ #
215
+ # @return [PolicyDefinition] operation results.
216
+ #
217
+ def get(policy_definition_name, custom_headers = nil)
218
+ response = get_async(policy_definition_name, custom_headers).value!
219
+ response.body unless response.nil?
220
+ end
221
+
222
+ #
223
+ # Gets the policy definition.
224
+ #
225
+ # @param policy_definition_name [String] The name of the policy definition to
226
+ # get.
227
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
228
+ # will be added to the HTTP request.
229
+ #
230
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
231
+ #
232
+ def get_with_http_info(policy_definition_name, custom_headers = nil)
233
+ get_async(policy_definition_name, custom_headers).value!
234
+ end
235
+
236
+ #
237
+ # Gets the policy definition.
238
+ #
239
+ # @param policy_definition_name [String] The name of the policy definition to
240
+ # get.
241
+ # @param [Hash{String => String}] A hash of custom headers that will be added
242
+ # to the HTTP request.
243
+ #
244
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
245
+ #
246
+ def get_async(policy_definition_name, custom_headers = nil)
247
+ fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
248
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
249
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
250
+
251
+
252
+ request_headers = {}
253
+
254
+ # Set Headers
255
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
256
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
257
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'
258
+
259
+ request_url = @base_url || @client.base_url
260
+
261
+ options = {
262
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
263
+ path_params: {'policyDefinitionName' => policy_definition_name,'subscriptionId' => @client.subscription_id},
264
+ query_params: {'api-version' => @client.api_version},
265
+ headers: request_headers.merge(custom_headers || {}),
266
+ base_url: request_url
267
+ }
268
+ promise = @client.make_request_async(:get, path_template, options)
269
+
270
+ promise = promise.then do |result|
271
+ http_response = result.response
272
+ status_code = http_response.status
273
+ response_content = http_response.body
274
+ unless status_code == 200
275
+ error_model = JSON.load(response_content)
276
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
277
+ end
278
+
279
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
280
+ # Deserialize Response
281
+ if status_code == 200
282
+ begin
283
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
284
+ result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyDefinition.mapper()
285
+ result.body = @client.deserialize(result_mapper, parsed_response)
286
+ rescue Exception => e
287
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
288
+ end
289
+ end
290
+
291
+ result
292
+ end
293
+
294
+ promise.execute
295
+ end
296
+
297
+ #
298
+ # Gets all the policy definitions for a subscription.
299
+ #
300
+ # @param filter [String] The filter to apply on the operation.
301
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
302
+ # will be added to the HTTP request.
303
+ #
304
+ # @return [Array<PolicyDefinition>] operation results.
305
+ #
306
+ def list(filter = nil, custom_headers = nil)
307
+ first_page = list_as_lazy(filter, custom_headers)
308
+ first_page.get_all_items
309
+ end
310
+
311
+ #
312
+ # Gets all the policy definitions for a subscription.
313
+ #
314
+ # @param filter [String] The filter to apply on the operation.
315
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
316
+ # will be added to the HTTP request.
317
+ #
318
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
319
+ #
320
+ def list_with_http_info(filter = nil, custom_headers = nil)
321
+ list_async(filter, custom_headers).value!
322
+ end
323
+
324
+ #
325
+ # Gets all the policy definitions for a subscription.
326
+ #
327
+ # @param filter [String] The filter to apply on the operation.
328
+ # @param [Hash{String => String}] A hash of custom headers that will be added
329
+ # to the HTTP request.
330
+ #
331
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
332
+ #
333
+ def list_async(filter = nil, custom_headers = nil)
334
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
335
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
336
+
337
+
338
+ request_headers = {}
339
+
340
+ # Set Headers
341
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
342
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
343
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'
344
+
345
+ request_url = @base_url || @client.base_url
346
+
347
+ options = {
348
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
349
+ path_params: {'subscriptionId' => @client.subscription_id},
350
+ query_params: {'$filter' => filter,'api-version' => @client.api_version},
351
+ headers: request_headers.merge(custom_headers || {}),
352
+ base_url: request_url
353
+ }
354
+ promise = @client.make_request_async(:get, path_template, options)
355
+
356
+ promise = promise.then do |result|
357
+ http_response = result.response
358
+ status_code = http_response.status
359
+ response_content = http_response.body
360
+ unless status_code == 200
361
+ error_model = JSON.load(response_content)
362
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
363
+ end
364
+
365
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
366
+ # Deserialize Response
367
+ if status_code == 200
368
+ begin
369
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
370
+ result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyDefinitionListResult.mapper()
371
+ result.body = @client.deserialize(result_mapper, parsed_response)
372
+ rescue Exception => e
373
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
374
+ end
375
+ end
376
+
377
+ result
378
+ end
379
+
380
+ promise.execute
381
+ end
382
+
383
+ #
384
+ # Gets all the policy definitions for a subscription.
385
+ #
386
+ # @param next_page_link [String] The NextLink from the previous successful call
387
+ # to List operation.
388
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
389
+ # will be added to the HTTP request.
390
+ #
391
+ # @return [PolicyDefinitionListResult] operation results.
392
+ #
393
+ def list_next(next_page_link, custom_headers = nil)
394
+ response = list_next_async(next_page_link, custom_headers).value!
395
+ response.body unless response.nil?
396
+ end
397
+
398
+ #
399
+ # Gets all the policy definitions for a subscription.
400
+ #
401
+ # @param next_page_link [String] The NextLink from the previous successful call
402
+ # to List operation.
403
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
404
+ # will be added to the HTTP request.
405
+ #
406
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
407
+ #
408
+ def list_next_with_http_info(next_page_link, custom_headers = nil)
409
+ list_next_async(next_page_link, custom_headers).value!
410
+ end
411
+
412
+ #
413
+ # Gets all the policy definitions for a subscription.
414
+ #
415
+ # @param next_page_link [String] The NextLink from the previous successful call
416
+ # to List operation.
417
+ # @param [Hash{String => String}] A hash of custom headers that will be added
418
+ # to the HTTP request.
419
+ #
420
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
421
+ #
422
+ def list_next_async(next_page_link, custom_headers = nil)
423
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
424
+
425
+
426
+ request_headers = {}
427
+
428
+ # Set Headers
429
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
430
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
431
+ path_template = '{nextLink}'
432
+
433
+ request_url = @base_url || @client.base_url
434
+
435
+ options = {
436
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
437
+ skip_encoding_path_params: {'nextLink' => next_page_link},
438
+ headers: request_headers.merge(custom_headers || {}),
439
+ base_url: request_url
440
+ }
441
+ promise = @client.make_request_async(:get, path_template, options)
442
+
443
+ promise = promise.then do |result|
444
+ http_response = result.response
445
+ status_code = http_response.status
446
+ response_content = http_response.body
447
+ unless status_code == 200
448
+ error_model = JSON.load(response_content)
449
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
450
+ end
451
+
452
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
453
+ # Deserialize Response
454
+ if status_code == 200
455
+ begin
456
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
457
+ result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyDefinitionListResult.mapper()
458
+ result.body = @client.deserialize(result_mapper, parsed_response)
459
+ rescue Exception => e
460
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
461
+ end
462
+ end
463
+
464
+ result
465
+ end
466
+
467
+ promise.execute
468
+ end
469
+
470
+ #
471
+ # Gets all the policy definitions for a subscription.
472
+ #
473
+ # @param filter [String] The filter to apply on the operation.
474
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
475
+ # will be added to the HTTP request.
476
+ #
477
+ # @return [PolicyDefinitionListResult] which provide lazy access to pages of
478
+ # the response.
479
+ #
480
+ def list_as_lazy(filter = nil, custom_headers = nil)
481
+ response = list_async(filter, custom_headers).value!
482
+ unless response.nil?
483
+ page = response.body
484
+ page.next_method = Proc.new do |next_page_link|
485
+ list_next_async(next_page_link, custom_headers)
486
+ end
487
+ page
488
+ end
489
+ end
490
+
491
+ end
492
+ end