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