azure_mgmt_policy 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,7 @@ module Azure::ARM::Policy
84
84
  request_content = @client.serialize(request_mapper, parameters)
85
85
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
86
86
 
87
- path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policysetdefinitions/{policySetDefinitionName}'
87
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
88
88
 
89
89
  request_url = @base_url || @client.base_url
90
90
 
@@ -184,7 +184,7 @@ module Azure::ARM::Policy
184
184
  # Set Headers
185
185
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
186
186
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
187
- path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policysetdefinitions/{policySetDefinitionName}'
187
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
188
188
 
189
189
  request_url = @base_url || @client.base_url
190
190
 
@@ -264,7 +264,7 @@ module Azure::ARM::Policy
264
264
  # Set Headers
265
265
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
266
266
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
267
- path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policysetdefinitions/{policySetDefinitionName}'
267
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
268
268
 
269
269
  request_url = @base_url || @client.base_url
270
270
 
@@ -281,7 +281,551 @@ module Azure::ARM::Policy
281
281
  http_response = result.response
282
282
  status_code = http_response.status
283
283
  response_content = http_response.body
284
- unless status_code == 200 || status_code == 404
284
+ unless status_code == 200
285
+ error_model = JSON.load(response_content)
286
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
287
+ end
288
+
289
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
290
+ # Deserialize Response
291
+ if status_code == 200
292
+ begin
293
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
294
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinition.mapper()
295
+ result.body = @client.deserialize(result_mapper, parsed_response)
296
+ rescue Exception => e
297
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
298
+ end
299
+ end
300
+
301
+ result
302
+ end
303
+
304
+ promise.execute
305
+ end
306
+
307
+ #
308
+ # Gets the built in policy set definition.
309
+ #
310
+ # @param policy_set_definition_name [String] The name of the policy set
311
+ # definition to get.
312
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
313
+ # will be added to the HTTP request.
314
+ #
315
+ # @return [PolicySetDefinition] operation results.
316
+ #
317
+ def get_built_in(policy_set_definition_name, custom_headers = nil)
318
+ response = get_built_in_async(policy_set_definition_name, custom_headers).value!
319
+ response.body unless response.nil?
320
+ end
321
+
322
+ #
323
+ # Gets the built in policy set definition.
324
+ #
325
+ # @param policy_set_definition_name [String] The name of the policy set
326
+ # definition to get.
327
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
328
+ # will be added to the HTTP request.
329
+ #
330
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
331
+ #
332
+ def get_built_in_with_http_info(policy_set_definition_name, custom_headers = nil)
333
+ get_built_in_async(policy_set_definition_name, custom_headers).value!
334
+ end
335
+
336
+ #
337
+ # Gets the built in policy set definition.
338
+ #
339
+ # @param policy_set_definition_name [String] The name of the policy set
340
+ # definition to get.
341
+ # @param [Hash{String => String}] A hash of custom headers that will be added
342
+ # to the HTTP request.
343
+ #
344
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
345
+ #
346
+ def get_built_in_async(policy_set_definition_name, custom_headers = nil)
347
+ fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_name.nil?
348
+ api_version = '2017-06-01-preview'
349
+
350
+
351
+ request_headers = {}
352
+
353
+ # Set Headers
354
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
355
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
356
+ path_template = 'providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
357
+
358
+ request_url = @base_url || @client.base_url
359
+
360
+ options = {
361
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
362
+ path_params: {'policySetDefinitionName' => policy_set_definition_name},
363
+ query_params: {'api-version' => api_version},
364
+ headers: request_headers.merge(custom_headers || {}),
365
+ base_url: request_url
366
+ }
367
+ promise = @client.make_request_async(:get, path_template, options)
368
+
369
+ promise = promise.then do |result|
370
+ http_response = result.response
371
+ status_code = http_response.status
372
+ response_content = http_response.body
373
+ unless status_code == 200
374
+ error_model = JSON.load(response_content)
375
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
376
+ end
377
+
378
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
379
+ # Deserialize Response
380
+ if status_code == 200
381
+ begin
382
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
383
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinition.mapper()
384
+ result.body = @client.deserialize(result_mapper, parsed_response)
385
+ rescue Exception => e
386
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
387
+ end
388
+ end
389
+
390
+ result
391
+ end
392
+
393
+ promise.execute
394
+ end
395
+
396
+ #
397
+ # Gets all the policy set definitions for a subscription.
398
+ #
399
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
400
+ # will be added to the HTTP request.
401
+ #
402
+ # @return [Array<PolicySetDefinition>] operation results.
403
+ #
404
+ def list(custom_headers = nil)
405
+ first_page = list_as_lazy(custom_headers)
406
+ first_page.get_all_items
407
+ end
408
+
409
+ #
410
+ # Gets all the policy set definitions for a subscription.
411
+ #
412
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
413
+ # will be added to the HTTP request.
414
+ #
415
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
416
+ #
417
+ def list_with_http_info(custom_headers = nil)
418
+ list_async(custom_headers).value!
419
+ end
420
+
421
+ #
422
+ # Gets all the policy set definitions for a subscription.
423
+ #
424
+ # @param [Hash{String => String}] A hash of custom headers that will be added
425
+ # to the HTTP request.
426
+ #
427
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
428
+ #
429
+ def list_async(custom_headers = nil)
430
+ api_version = '2017-06-01-preview'
431
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
432
+
433
+
434
+ request_headers = {}
435
+
436
+ # Set Headers
437
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
438
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
439
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'
440
+
441
+ request_url = @base_url || @client.base_url
442
+
443
+ options = {
444
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
445
+ path_params: {'subscriptionId' => @client.subscription_id},
446
+ query_params: {'api-version' => api_version},
447
+ headers: request_headers.merge(custom_headers || {}),
448
+ base_url: request_url
449
+ }
450
+ promise = @client.make_request_async(:get, path_template, options)
451
+
452
+ promise = promise.then do |result|
453
+ http_response = result.response
454
+ status_code = http_response.status
455
+ response_content = http_response.body
456
+ unless status_code == 200
457
+ error_model = JSON.load(response_content)
458
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
459
+ end
460
+
461
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
462
+ # Deserialize Response
463
+ if status_code == 200
464
+ begin
465
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
466
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinitionListResult.mapper()
467
+ result.body = @client.deserialize(result_mapper, parsed_response)
468
+ rescue Exception => e
469
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
470
+ end
471
+ end
472
+
473
+ result
474
+ end
475
+
476
+ promise.execute
477
+ end
478
+
479
+ #
480
+ # Gets all the built in policy set definitions.
481
+ #
482
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
483
+ # will be added to the HTTP request.
484
+ #
485
+ # @return [Array<PolicySetDefinition>] operation results.
486
+ #
487
+ def list_built_in(custom_headers = nil)
488
+ first_page = list_built_in_as_lazy(custom_headers)
489
+ first_page.get_all_items
490
+ end
491
+
492
+ #
493
+ # Gets all the built in policy set definitions.
494
+ #
495
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
496
+ # will be added to the HTTP request.
497
+ #
498
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
499
+ #
500
+ def list_built_in_with_http_info(custom_headers = nil)
501
+ list_built_in_async(custom_headers).value!
502
+ end
503
+
504
+ #
505
+ # Gets all the built in policy set definitions.
506
+ #
507
+ # @param [Hash{String => String}] A hash of custom headers that will be added
508
+ # to the HTTP request.
509
+ #
510
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
511
+ #
512
+ def list_built_in_async(custom_headers = nil)
513
+ api_version = '2017-06-01-preview'
514
+
515
+
516
+ request_headers = {}
517
+
518
+ # Set Headers
519
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
520
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
521
+ path_template = 'providers/Microsoft.Authorization/policySetDefinitions'
522
+
523
+ request_url = @base_url || @client.base_url
524
+
525
+ options = {
526
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
527
+ query_params: {'api-version' => api_version},
528
+ headers: request_headers.merge(custom_headers || {}),
529
+ base_url: request_url
530
+ }
531
+ promise = @client.make_request_async(:get, path_template, options)
532
+
533
+ promise = promise.then do |result|
534
+ http_response = result.response
535
+ status_code = http_response.status
536
+ response_content = http_response.body
537
+ unless status_code == 200
538
+ error_model = JSON.load(response_content)
539
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
540
+ end
541
+
542
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
543
+ # Deserialize Response
544
+ if status_code == 200
545
+ begin
546
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
547
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinitionListResult.mapper()
548
+ result.body = @client.deserialize(result_mapper, parsed_response)
549
+ rescue Exception => e
550
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
551
+ end
552
+ end
553
+
554
+ result
555
+ end
556
+
557
+ promise.execute
558
+ end
559
+
560
+ #
561
+ # Creates or updates a policy set definition at management group level.
562
+ #
563
+ # @param policy_set_definition_name [String] The name of the policy set
564
+ # definition to create.
565
+ # @param parameters [PolicySetDefinition] The policy set definition properties.
566
+ # @param management_group_id [String] The ID of the management group.
567
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
568
+ # will be added to the HTTP request.
569
+ #
570
+ # @return [PolicySetDefinition] operation results.
571
+ #
572
+ def create_or_update_at_management_group(policy_set_definition_name, parameters, management_group_id, custom_headers = nil)
573
+ response = create_or_update_at_management_group_async(policy_set_definition_name, parameters, management_group_id, custom_headers).value!
574
+ response.body unless response.nil?
575
+ end
576
+
577
+ #
578
+ # Creates or updates a policy set definition at management group level.
579
+ #
580
+ # @param policy_set_definition_name [String] The name of the policy set
581
+ # definition to create.
582
+ # @param parameters [PolicySetDefinition] The policy set definition properties.
583
+ # @param management_group_id [String] The ID of the management group.
584
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
585
+ # will be added to the HTTP request.
586
+ #
587
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
588
+ #
589
+ def create_or_update_at_management_group_with_http_info(policy_set_definition_name, parameters, management_group_id, custom_headers = nil)
590
+ create_or_update_at_management_group_async(policy_set_definition_name, parameters, management_group_id, custom_headers).value!
591
+ end
592
+
593
+ #
594
+ # Creates or updates a policy set definition at management group level.
595
+ #
596
+ # @param policy_set_definition_name [String] The name of the policy set
597
+ # definition to create.
598
+ # @param parameters [PolicySetDefinition] The policy set definition properties.
599
+ # @param management_group_id [String] The ID of the management group.
600
+ # @param [Hash{String => String}] A hash of custom headers that will be added
601
+ # to the HTTP request.
602
+ #
603
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
604
+ #
605
+ def create_or_update_at_management_group_async(policy_set_definition_name, parameters, management_group_id, custom_headers = nil)
606
+ fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_name.nil?
607
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
608
+ api_version = '2017-06-01-preview'
609
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
610
+
611
+
612
+ request_headers = {}
613
+
614
+ # Set Headers
615
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
616
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
617
+
618
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
619
+
620
+ # Serialize Request
621
+ request_mapper = Azure::ARM::Policy::Models::PolicySetDefinition.mapper()
622
+ request_content = @client.serialize(request_mapper, parameters)
623
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
624
+
625
+ path_template = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
626
+
627
+ request_url = @base_url || @client.base_url
628
+
629
+ options = {
630
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
631
+ path_params: {'policySetDefinitionName' => policy_set_definition_name,'managementGroupId' => management_group_id},
632
+ query_params: {'api-version' => api_version},
633
+ body: request_content,
634
+ headers: request_headers.merge(custom_headers || {}),
635
+ base_url: request_url
636
+ }
637
+ promise = @client.make_request_async(:put, path_template, options)
638
+
639
+ promise = promise.then do |result|
640
+ http_response = result.response
641
+ status_code = http_response.status
642
+ response_content = http_response.body
643
+ unless status_code == 201 || status_code == 200
644
+ error_model = JSON.load(response_content)
645
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
646
+ end
647
+
648
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
649
+ # Deserialize Response
650
+ if status_code == 201
651
+ begin
652
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
653
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinition.mapper()
654
+ result.body = @client.deserialize(result_mapper, parsed_response)
655
+ rescue Exception => e
656
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
657
+ end
658
+ end
659
+ # Deserialize Response
660
+ if status_code == 200
661
+ begin
662
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
663
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinition.mapper()
664
+ result.body = @client.deserialize(result_mapper, parsed_response)
665
+ rescue Exception => e
666
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
667
+ end
668
+ end
669
+
670
+ result
671
+ end
672
+
673
+ promise.execute
674
+ end
675
+
676
+ #
677
+ # Deletes a policy set definition at management group level.
678
+ #
679
+ # @param policy_set_definition_name [String] The name of the policy set
680
+ # definition to delete.
681
+ # @param management_group_id [String] The ID of the management group.
682
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
683
+ # will be added to the HTTP request.
684
+ #
685
+ #
686
+ def delete_at_management_group(policy_set_definition_name, management_group_id, custom_headers = nil)
687
+ response = delete_at_management_group_async(policy_set_definition_name, management_group_id, custom_headers).value!
688
+ nil
689
+ end
690
+
691
+ #
692
+ # Deletes a policy set definition at management group level.
693
+ #
694
+ # @param policy_set_definition_name [String] The name of the policy set
695
+ # definition to delete.
696
+ # @param management_group_id [String] The ID of the management group.
697
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
698
+ # will be added to the HTTP request.
699
+ #
700
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
701
+ #
702
+ def delete_at_management_group_with_http_info(policy_set_definition_name, management_group_id, custom_headers = nil)
703
+ delete_at_management_group_async(policy_set_definition_name, management_group_id, custom_headers).value!
704
+ end
705
+
706
+ #
707
+ # Deletes a policy set definition at management group level.
708
+ #
709
+ # @param policy_set_definition_name [String] The name of the policy set
710
+ # definition to delete.
711
+ # @param management_group_id [String] The ID of the management group.
712
+ # @param [Hash{String => String}] A hash of custom headers that will be added
713
+ # to the HTTP request.
714
+ #
715
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
716
+ #
717
+ def delete_at_management_group_async(policy_set_definition_name, management_group_id, custom_headers = nil)
718
+ fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_name.nil?
719
+ api_version = '2017-06-01-preview'
720
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
721
+
722
+
723
+ request_headers = {}
724
+
725
+ # Set Headers
726
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
727
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
728
+ path_template = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
729
+
730
+ request_url = @base_url || @client.base_url
731
+
732
+ options = {
733
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
734
+ path_params: {'policySetDefinitionName' => policy_set_definition_name,'managementGroupId' => management_group_id},
735
+ query_params: {'api-version' => api_version},
736
+ headers: request_headers.merge(custom_headers || {}),
737
+ base_url: request_url
738
+ }
739
+ promise = @client.make_request_async(:delete, path_template, options)
740
+
741
+ promise = promise.then do |result|
742
+ http_response = result.response
743
+ status_code = http_response.status
744
+ response_content = http_response.body
745
+ unless status_code == 204 || status_code == 200
746
+ error_model = JSON.load(response_content)
747
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
748
+ end
749
+
750
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
751
+
752
+ result
753
+ end
754
+
755
+ promise.execute
756
+ end
757
+
758
+ #
759
+ # Gets the policy set definition at management group level.
760
+ #
761
+ # @param policy_set_definition_name [String] The name of the policy set
762
+ # definition to get.
763
+ # @param management_group_id [String] The ID of the management group.
764
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
765
+ # will be added to the HTTP request.
766
+ #
767
+ # @return [PolicySetDefinition] operation results.
768
+ #
769
+ def get_at_management_group(policy_set_definition_name, management_group_id, custom_headers = nil)
770
+ response = get_at_management_group_async(policy_set_definition_name, management_group_id, custom_headers).value!
771
+ response.body unless response.nil?
772
+ end
773
+
774
+ #
775
+ # Gets the policy set definition at management group level.
776
+ #
777
+ # @param policy_set_definition_name [String] The name of the policy set
778
+ # definition to get.
779
+ # @param management_group_id [String] The ID of the management group.
780
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
781
+ # will be added to the HTTP request.
782
+ #
783
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
784
+ #
785
+ def get_at_management_group_with_http_info(policy_set_definition_name, management_group_id, custom_headers = nil)
786
+ get_at_management_group_async(policy_set_definition_name, management_group_id, custom_headers).value!
787
+ end
788
+
789
+ #
790
+ # Gets the policy set definition at management group level.
791
+ #
792
+ # @param policy_set_definition_name [String] The name of the policy set
793
+ # definition to get.
794
+ # @param management_group_id [String] The ID of the management group.
795
+ # @param [Hash{String => String}] A hash of custom headers that will be added
796
+ # to the HTTP request.
797
+ #
798
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
799
+ #
800
+ def get_at_management_group_async(policy_set_definition_name, management_group_id, custom_headers = nil)
801
+ fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_name.nil?
802
+ api_version = '2017-06-01-preview'
803
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
804
+
805
+
806
+ request_headers = {}
807
+
808
+ # Set Headers
809
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
810
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
811
+ path_template = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'
812
+
813
+ request_url = @base_url || @client.base_url
814
+
815
+ options = {
816
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
817
+ path_params: {'policySetDefinitionName' => policy_set_definition_name,'managementGroupId' => management_group_id},
818
+ query_params: {'api-version' => api_version},
819
+ headers: request_headers.merge(custom_headers || {}),
820
+ base_url: request_url
821
+ }
822
+ promise = @client.make_request_async(:get, path_template, options)
823
+
824
+ promise = promise.then do |result|
825
+ http_response = result.response
826
+ status_code = http_response.status
827
+ response_content = http_response.body
828
+ unless status_code == 200
285
829
  error_model = JSON.load(response_content)
286
830
  fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
287
831
  end
@@ -305,41 +849,44 @@ module Azure::ARM::Policy
305
849
  end
306
850
 
307
851
  #
308
- # Gets all the policy set definitions for a subscription.
852
+ # Gets all the policy set definitions for a subscription at management group.
309
853
  #
854
+ # @param management_group_id [String] The ID of the management group.
310
855
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
311
856
  # will be added to the HTTP request.
312
857
  #
313
858
  # @return [Array<PolicySetDefinition>] operation results.
314
859
  #
315
- def list(custom_headers = nil)
316
- first_page = list_as_lazy(custom_headers)
860
+ def list_by_management_group(management_group_id, custom_headers = nil)
861
+ first_page = list_by_management_group_as_lazy(management_group_id, custom_headers)
317
862
  first_page.get_all_items
318
863
  end
319
864
 
320
865
  #
321
- # Gets all the policy set definitions for a subscription.
866
+ # Gets all the policy set definitions for a subscription at management group.
322
867
  #
868
+ # @param management_group_id [String] The ID of the management group.
323
869
  # @param custom_headers [Hash{String => String}] A hash of custom headers that
324
870
  # will be added to the HTTP request.
325
871
  #
326
872
  # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
327
873
  #
328
- def list_with_http_info(custom_headers = nil)
329
- list_async(custom_headers).value!
874
+ def list_by_management_group_with_http_info(management_group_id, custom_headers = nil)
875
+ list_by_management_group_async(management_group_id, custom_headers).value!
330
876
  end
331
877
 
332
878
  #
333
- # Gets all the policy set definitions for a subscription.
879
+ # Gets all the policy set definitions for a subscription at management group.
334
880
  #
881
+ # @param management_group_id [String] The ID of the management group.
335
882
  # @param [Hash{String => String}] A hash of custom headers that will be added
336
883
  # to the HTTP request.
337
884
  #
338
885
  # @return [Concurrent::Promise] Promise object which holds the HTTP response.
339
886
  #
340
- def list_async(custom_headers = nil)
887
+ def list_by_management_group_async(management_group_id, custom_headers = nil)
341
888
  api_version = '2017-06-01-preview'
342
- fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
889
+ fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
343
890
 
344
891
 
345
892
  request_headers = {}
@@ -347,13 +894,13 @@ module Azure::ARM::Policy
347
894
  # Set Headers
348
895
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
349
896
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
350
- path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policysetdefinitions'
897
+ path_template = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'
351
898
 
352
899
  request_url = @base_url || @client.base_url
353
900
 
354
901
  options = {
355
902
  middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
356
- path_params: {'subscriptionId' => @client.subscription_id},
903
+ path_params: {'managementGroupId' => management_group_id},
357
904
  query_params: {'api-version' => api_version},
358
905
  headers: request_headers.merge(custom_headers || {}),
359
906
  base_url: request_url
@@ -474,6 +1021,180 @@ module Azure::ARM::Policy
474
1021
  promise.execute
475
1022
  end
476
1023
 
1024
+ #
1025
+ # Gets all the built in policy set definitions.
1026
+ #
1027
+ # @param next_page_link [String] The NextLink from the previous successful call
1028
+ # to List operation.
1029
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1030
+ # will be added to the HTTP request.
1031
+ #
1032
+ # @return [PolicySetDefinitionListResult] operation results.
1033
+ #
1034
+ def list_built_in_next(next_page_link, custom_headers = nil)
1035
+ response = list_built_in_next_async(next_page_link, custom_headers).value!
1036
+ response.body unless response.nil?
1037
+ end
1038
+
1039
+ #
1040
+ # Gets all the built in policy set definitions.
1041
+ #
1042
+ # @param next_page_link [String] The NextLink from the previous successful call
1043
+ # to List operation.
1044
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1045
+ # will be added to the HTTP request.
1046
+ #
1047
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1048
+ #
1049
+ def list_built_in_next_with_http_info(next_page_link, custom_headers = nil)
1050
+ list_built_in_next_async(next_page_link, custom_headers).value!
1051
+ end
1052
+
1053
+ #
1054
+ # Gets all the built in policy set definitions.
1055
+ #
1056
+ # @param next_page_link [String] The NextLink from the previous successful call
1057
+ # to List operation.
1058
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1059
+ # to the HTTP request.
1060
+ #
1061
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1062
+ #
1063
+ def list_built_in_next_async(next_page_link, custom_headers = nil)
1064
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1065
+
1066
+
1067
+ request_headers = {}
1068
+
1069
+ # Set Headers
1070
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1071
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1072
+ path_template = '{nextLink}'
1073
+
1074
+ request_url = @base_url || @client.base_url
1075
+
1076
+ options = {
1077
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1078
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1079
+ headers: request_headers.merge(custom_headers || {}),
1080
+ base_url: request_url
1081
+ }
1082
+ promise = @client.make_request_async(:get, path_template, options)
1083
+
1084
+ promise = promise.then do |result|
1085
+ http_response = result.response
1086
+ status_code = http_response.status
1087
+ response_content = http_response.body
1088
+ unless status_code == 200
1089
+ error_model = JSON.load(response_content)
1090
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1091
+ end
1092
+
1093
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1094
+ # Deserialize Response
1095
+ if status_code == 200
1096
+ begin
1097
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1098
+ result_mapper = Azure::ARM::Policy::Models::PolicySetDefinitionListResult.mapper()
1099
+ result.body = @client.deserialize(result_mapper, parsed_response)
1100
+ rescue Exception => e
1101
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1102
+ end
1103
+ end
1104
+
1105
+ result
1106
+ end
1107
+
1108
+ promise.execute
1109
+ end
1110
+
1111
+ #
1112
+ # Gets all the policy set definitions for a subscription at management group.
1113
+ #
1114
+ # @param next_page_link [String] The NextLink from the previous successful call
1115
+ # to List operation.
1116
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1117
+ # will be added to the HTTP request.
1118
+ #
1119
+ # @return [PolicySetDefinitionListResult] operation results.
1120
+ #
1121
+ def list_by_management_group_next(next_page_link, custom_headers = nil)
1122
+ response = list_by_management_group_next_async(next_page_link, custom_headers).value!
1123
+ response.body unless response.nil?
1124
+ end
1125
+
1126
+ #
1127
+ # Gets all the policy set definitions for a subscription at management group.
1128
+ #
1129
+ # @param next_page_link [String] The NextLink from the previous successful call
1130
+ # to List operation.
1131
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1132
+ # will be added to the HTTP request.
1133
+ #
1134
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1135
+ #
1136
+ def list_by_management_group_next_with_http_info(next_page_link, custom_headers = nil)
1137
+ list_by_management_group_next_async(next_page_link, custom_headers).value!
1138
+ end
1139
+
1140
+ #
1141
+ # Gets all the policy set definitions for a subscription at management group.
1142
+ #
1143
+ # @param next_page_link [String] The NextLink from the previous successful call
1144
+ # to List operation.
1145
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1146
+ # to the HTTP request.
1147
+ #
1148
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1149
+ #
1150
+ def list_by_management_group_next_async(next_page_link, custom_headers = nil)
1151
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1152
+
1153
+
1154
+ request_headers = {}
1155
+
1156
+ # Set Headers
1157
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1158
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1159
+ path_template = '{nextLink}'
1160
+
1161
+ request_url = @base_url || @client.base_url
1162
+
1163
+ options = {
1164
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1165
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1166
+ headers: request_headers.merge(custom_headers || {}),
1167
+ base_url: request_url
1168
+ }
1169
+ promise = @client.make_request_async(:get, path_template, options)
1170
+
1171
+ promise = promise.then do |result|
1172
+ http_response = result.response
1173
+ status_code = http_response.status
1174
+ response_content = http_response.body
1175
+ unless status_code == 200
1176
+ error_model = JSON.load(response_content)
1177
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1178
+ end
1179
+
1180
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-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::ARM::Policy::Models::PolicySetDefinitionListResult.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
+
477
1198
  #
478
1199
  # Gets all the policy set definitions for a subscription.
479
1200
  #
@@ -494,5 +1215,46 @@ module Azure::ARM::Policy
494
1215
  end
495
1216
  end
496
1217
 
1218
+ #
1219
+ # Gets all the built in policy set definitions.
1220
+ #
1221
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1222
+ # will be added to the HTTP request.
1223
+ #
1224
+ # @return [PolicySetDefinitionListResult] which provide lazy access to pages of
1225
+ # the response.
1226
+ #
1227
+ def list_built_in_as_lazy(custom_headers = nil)
1228
+ response = list_built_in_async(custom_headers).value!
1229
+ unless response.nil?
1230
+ page = response.body
1231
+ page.next_method = Proc.new do |next_page_link|
1232
+ list_built_in_next_async(next_page_link, custom_headers)
1233
+ end
1234
+ page
1235
+ end
1236
+ end
1237
+
1238
+ #
1239
+ # Gets all the policy set definitions for a subscription at management group.
1240
+ #
1241
+ # @param management_group_id [String] The ID of the management group.
1242
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1243
+ # will be added to the HTTP request.
1244
+ #
1245
+ # @return [PolicySetDefinitionListResult] which provide lazy access to pages of
1246
+ # the response.
1247
+ #
1248
+ def list_by_management_group_as_lazy(management_group_id, custom_headers = nil)
1249
+ response = list_by_management_group_async(management_group_id, custom_headers).value!
1250
+ unless response.nil?
1251
+ page = response.body
1252
+ page.next_method = Proc.new do |next_page_link|
1253
+ list_by_management_group_next_async(next_page_link, custom_headers)
1254
+ end
1255
+ page
1256
+ end
1257
+ end
1258
+
497
1259
  end
498
1260
  end