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