azure_mgmt_policy 0.17.6 → 0.17.7

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