azure_mgmt_policy 0.4.0

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