azure_mgmt_policy 0.17.8 → 0.17.9

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