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