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