azure_mgmt_devtestlabs 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/LICENSE.txt +21 -0
  4. data/Rakefile +5 -0
  5. data/azure_mgmt_devtestlabs.gemspec +34 -0
  6. data/lib/azure_mgmt_devtestlabs.rb +5 -0
  7. data/lib/generated/azure_mgmt_devtestlabs.rb +103 -0
  8. data/lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb +477 -0
  9. data/lib/generated/azure_mgmt_devtestlabs/artifact_source_operations.rb +669 -0
  10. data/lib/generated/azure_mgmt_devtestlabs/cost_operations.rb +124 -0
  11. data/lib/generated/azure_mgmt_devtestlabs/custom_image_operations.rb +648 -0
  12. data/lib/generated/azure_mgmt_devtestlabs/dev_test_labs_client.rb +110 -0
  13. data/lib/generated/azure_mgmt_devtestlabs/formula_operations.rb +608 -0
  14. data/lib/generated/azure_mgmt_devtestlabs/gallery_image_operations.rb +252 -0
  15. data/lib/generated/azure_mgmt_devtestlabs/lab_operations.rb +1403 -0
  16. data/lib/generated/azure_mgmt_devtestlabs/models/apply_artifacts_request.rb +53 -0
  17. data/lib/generated/azure_mgmt_devtestlabs/models/arm_template_info.rb +54 -0
  18. data/lib/generated/azure_mgmt_devtestlabs/models/artifact.rb +151 -0
  19. data/lib/generated/azure_mgmt_devtestlabs/models/artifact_deployment_status_properties.rb +66 -0
  20. data/lib/generated/azure_mgmt_devtestlabs/models/artifact_install_properties.rb +63 -0
  21. data/lib/generated/azure_mgmt_devtestlabs/models/artifact_parameter_properties.rb +54 -0
  22. data/lib/generated/azure_mgmt_devtestlabs/models/artifact_source.rb +183 -0
  23. data/lib/generated/azure_mgmt_devtestlabs/models/cost.rb +139 -0
  24. data/lib/generated/azure_mgmt_devtestlabs/models/cost_per_day_properties.rb +65 -0
  25. data/lib/generated/azure_mgmt_devtestlabs/models/custom_image.rb +164 -0
  26. data/lib/generated/azure_mgmt_devtestlabs/models/custom_image_os_type.rb +17 -0
  27. data/lib/generated/azure_mgmt_devtestlabs/models/custom_image_properties_custom.rb +65 -0
  28. data/lib/generated/azure_mgmt_devtestlabs/models/custom_image_properties_from_vm.rb +66 -0
  29. data/lib/generated/azure_mgmt_devtestlabs/models/day_details.rb +44 -0
  30. data/lib/generated/azure_mgmt_devtestlabs/models/enable_status.rb +16 -0
  31. data/lib/generated/azure_mgmt_devtestlabs/models/evaluate_policies_properties.rb +64 -0
  32. data/lib/generated/azure_mgmt_devtestlabs/models/evaluate_policies_request.rb +52 -0
  33. data/lib/generated/azure_mgmt_devtestlabs/models/evaluate_policies_response.rb +52 -0
  34. data/lib/generated/azure_mgmt_devtestlabs/models/formula.rb +174 -0
  35. data/lib/generated/azure_mgmt_devtestlabs/models/formula_properties_from_vm.rb +45 -0
  36. data/lib/generated/azure_mgmt_devtestlabs/models/gallery_image.rb +153 -0
  37. data/lib/generated/azure_mgmt_devtestlabs/models/gallery_image_reference.rb +84 -0
  38. data/lib/generated/azure_mgmt_devtestlabs/models/generate_arm_template_request.rb +72 -0
  39. data/lib/generated/azure_mgmt_devtestlabs/models/generate_upload_uri_parameter.rb +44 -0
  40. data/lib/generated/azure_mgmt_devtestlabs/models/generate_upload_uri_response.rb +44 -0
  41. data/lib/generated/azure_mgmt_devtestlabs/models/hour_details.rb +44 -0
  42. data/lib/generated/azure_mgmt_devtestlabs/models/lab.rb +162 -0
  43. data/lib/generated/azure_mgmt_devtestlabs/models/lab_cost_type.rb +17 -0
  44. data/lib/generated/azure_mgmt_devtestlabs/models/lab_storage_type.rb +16 -0
  45. data/lib/generated/azure_mgmt_devtestlabs/models/lab_vhd.rb +44 -0
  46. data/lib/generated/azure_mgmt_devtestlabs/models/lab_virtual_machine.rb +321 -0
  47. data/lib/generated/azure_mgmt_devtestlabs/models/linux_os_info.rb +46 -0
  48. data/lib/generated/azure_mgmt_devtestlabs/models/linux_os_state.rb +17 -0
  49. data/lib/generated/azure_mgmt_devtestlabs/models/parameter_info.rb +54 -0
  50. data/lib/generated/azure_mgmt_devtestlabs/models/policy.rb +175 -0
  51. data/lib/generated/azure_mgmt_devtestlabs/models/policy_evaluator_type.rb +16 -0
  52. data/lib/generated/azure_mgmt_devtestlabs/models/policy_fact_name.rb +19 -0
  53. data/lib/generated/azure_mgmt_devtestlabs/models/policy_set_result.rb +63 -0
  54. data/lib/generated/azure_mgmt_devtestlabs/models/policy_status.rb +16 -0
  55. data/lib/generated/azure_mgmt_devtestlabs/models/policy_violation.rb +54 -0
  56. data/lib/generated/azure_mgmt_devtestlabs/models/resource_cost_properties.rb +106 -0
  57. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_artifact.rb +93 -0
  58. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_artifact_source.rb +94 -0
  59. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_custom_image.rb +93 -0
  60. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_formula.rb +93 -0
  61. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_gallery_image.rb +93 -0
  62. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_lab.rb +93 -0
  63. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_lab_vhd.rb +93 -0
  64. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_lab_virtual_machine.rb +95 -0
  65. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_policy.rb +93 -0
  66. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_schedule.rb +93 -0
  67. data/lib/generated/azure_mgmt_devtestlabs/models/response_with_continuation_virtual_network.rb +94 -0
  68. data/lib/generated/azure_mgmt_devtestlabs/models/schedule.rb +175 -0
  69. data/lib/generated/azure_mgmt_devtestlabs/models/source_control_type.rb +16 -0
  70. data/lib/generated/azure_mgmt_devtestlabs/models/subnet.rb +65 -0
  71. data/lib/generated/azure_mgmt_devtestlabs/models/subnet_override.rb +78 -0
  72. data/lib/generated/azure_mgmt_devtestlabs/models/subscription_notification.rb +67 -0
  73. data/lib/generated/azure_mgmt_devtestlabs/models/subscription_notification_properties.rb +44 -0
  74. data/lib/generated/azure_mgmt_devtestlabs/models/subscription_notification_state.rb +20 -0
  75. data/lib/generated/azure_mgmt_devtestlabs/models/usage_permission_type.rb +17 -0
  76. data/lib/generated/azure_mgmt_devtestlabs/models/virtual_network.rb +169 -0
  77. data/lib/generated/azure_mgmt_devtestlabs/models/week_details.rb +61 -0
  78. data/lib/generated/azure_mgmt_devtestlabs/models/windows_os_info.rb +45 -0
  79. data/lib/generated/azure_mgmt_devtestlabs/models/windows_os_state.rb +17 -0
  80. data/lib/generated/azure_mgmt_devtestlabs/module_definition.rb +8 -0
  81. data/lib/generated/azure_mgmt_devtestlabs/policy_operations.rb +690 -0
  82. data/lib/generated/azure_mgmt_devtestlabs/policy_set.rb +137 -0
  83. data/lib/generated/azure_mgmt_devtestlabs/schedule_operations.rb +796 -0
  84. data/lib/generated/azure_mgmt_devtestlabs/version.rb +8 -0
  85. data/lib/generated/azure_mgmt_devtestlabs/virtual_machine.rb +1155 -0
  86. data/lib/generated/azure_mgmt_devtestlabs/virtual_network_operations.rb +759 -0
  87. metadata +199 -0
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure end
7
+ module Azure::ARM end
8
+ module Azure::ARM::DevTestLabs end
@@ -0,0 +1,690 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::DevTestLabs
7
+ #
8
+ # The DevTest Labs Client.
9
+ #
10
+ class PolicyOperations
11
+ include Azure::ARM::DevTestLabs::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the PolicyOperations class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return reference to the DevTestLabsClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # List policies in a given policy set.
27
+ #
28
+ # @param resource_group_name [String] The name of the resource group.
29
+ # @param lab_name [String] The name of the lab.
30
+ # @param policy_set_name [String] The name of the policy set.
31
+ # @param filter [String] The filter to apply on the operation.
32
+ # @param top [Integer] The maximum number of resources to return from the
33
+ # operation.
34
+ # @param order_by [String] The ordering expression for the results, using
35
+ # OData notation.
36
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
37
+ # will be added to the HTTP request.
38
+ #
39
+ # @return [ResponseWithContinuationPolicy] which provide lazy access to pages
40
+ # of the response.
41
+ #
42
+ def list_as_lazy(resource_group_name, lab_name, policy_set_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
43
+ response = list_async(resource_group_name, lab_name, policy_set_name, filter, top, order_by, custom_headers).value!
44
+ unless response.nil?
45
+ page = response.body
46
+ page.next_method = Proc.new do |next_link|
47
+ list_next_async(next_link, custom_headers)
48
+ end
49
+ page
50
+ end
51
+ end
52
+
53
+ #
54
+ # List policies in a given policy set.
55
+ #
56
+ # @param resource_group_name [String] The name of the resource group.
57
+ # @param lab_name [String] The name of the lab.
58
+ # @param policy_set_name [String] The name of the policy set.
59
+ # @param filter [String] The filter to apply on the operation.
60
+ # @param top [Integer] The maximum number of resources to return from the
61
+ # operation.
62
+ # @param order_by [String] The ordering expression for the results, using
63
+ # OData notation.
64
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
65
+ # will be added to the HTTP request.
66
+ #
67
+ # @return [Array<Policy>] operation results.
68
+ #
69
+ def list(resource_group_name, lab_name, policy_set_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
70
+ first_page = list_as_lazy(resource_group_name, lab_name, policy_set_name, filter, top, order_by, custom_headers)
71
+ first_page.get_all_items
72
+ end
73
+
74
+ #
75
+ # List policies in a given policy set.
76
+ #
77
+ # @param resource_group_name [String] The name of the resource group.
78
+ # @param lab_name [String] The name of the lab.
79
+ # @param policy_set_name [String] The name of the policy set.
80
+ # @param filter [String] The filter to apply on the operation.
81
+ # @param top [Integer] The maximum number of resources to return from the
82
+ # operation.
83
+ # @param order_by [String] The ordering expression for the results, using
84
+ # OData notation.
85
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
86
+ # will be added to the HTTP request.
87
+ #
88
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
89
+ #
90
+ def list_with_http_info(resource_group_name, lab_name, policy_set_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
91
+ list_async(resource_group_name, lab_name, policy_set_name, filter, top, order_by, custom_headers).value!
92
+ end
93
+
94
+ #
95
+ # List policies in a given policy set.
96
+ #
97
+ # @param resource_group_name [String] The name of the resource group.
98
+ # @param lab_name [String] The name of the lab.
99
+ # @param policy_set_name [String] The name of the policy set.
100
+ # @param filter [String] The filter to apply on the operation.
101
+ # @param top [Integer] The maximum number of resources to return from the
102
+ # operation.
103
+ # @param order_by [String] The ordering expression for the results, using
104
+ # OData notation.
105
+ # @param [Hash{String => String}] A hash of custom headers that will be added
106
+ # to the HTTP request.
107
+ #
108
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
109
+ #
110
+ def list_async(resource_group_name, lab_name, policy_set_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
111
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
112
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
113
+ fail ArgumentError, 'lab_name is nil' if lab_name.nil?
114
+ fail ArgumentError, 'policy_set_name is nil' if policy_set_name.nil?
115
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
116
+
117
+
118
+ request_headers = {}
119
+
120
+ # Set Headers
121
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
122
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
123
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies'
124
+ options = {
125
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
126
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'policySetName' => policy_set_name},
127
+ query_params: {'$filter' => filter,'$top' => top,'$orderBy' => order_by,'api-version' => @client.api_version},
128
+ headers: request_headers.merge(custom_headers || {})
129
+ }
130
+
131
+ request_url = @base_url || @client.base_url
132
+
133
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
134
+ promise = request.run_promise do |req|
135
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
136
+ end
137
+
138
+ promise = promise.then do |http_response|
139
+ status_code = http_response.status
140
+ response_content = http_response.body
141
+ unless status_code == 200
142
+ error_model = JSON.load(response_content)
143
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
144
+ end
145
+
146
+ # Create Result
147
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
148
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
149
+ # Deserialize Response
150
+ if status_code == 200
151
+ begin
152
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
153
+ result_mapper = ResponseWithContinuationPolicy.mapper()
154
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
155
+ rescue Exception => e
156
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
157
+ end
158
+ end
159
+
160
+ result
161
+ end
162
+
163
+ promise.execute
164
+ end
165
+
166
+ #
167
+ # Get policy.
168
+ #
169
+ # @param resource_group_name [String] The name of the resource group.
170
+ # @param lab_name [String] The name of the lab.
171
+ # @param policy_set_name [String] The name of the policy set.
172
+ # @param name [String] The name of the policy.
173
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
174
+ # will be added to the HTTP request.
175
+ #
176
+ # @return [Policy] operation results.
177
+ #
178
+ def get_resource(resource_group_name, lab_name, policy_set_name, name, custom_headers = nil)
179
+ response = get_resource_async(resource_group_name, lab_name, policy_set_name, name, custom_headers).value!
180
+ response.body unless response.nil?
181
+ end
182
+
183
+ #
184
+ # Get policy.
185
+ #
186
+ # @param resource_group_name [String] The name of the resource group.
187
+ # @param lab_name [String] The name of the lab.
188
+ # @param policy_set_name [String] The name of the policy set.
189
+ # @param name [String] The name of the policy.
190
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
191
+ # will be added to the HTTP request.
192
+ #
193
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
194
+ #
195
+ def get_resource_with_http_info(resource_group_name, lab_name, policy_set_name, name, custom_headers = nil)
196
+ get_resource_async(resource_group_name, lab_name, policy_set_name, name, custom_headers).value!
197
+ end
198
+
199
+ #
200
+ # Get policy.
201
+ #
202
+ # @param resource_group_name [String] The name of the resource group.
203
+ # @param lab_name [String] The name of the lab.
204
+ # @param policy_set_name [String] The name of the policy set.
205
+ # @param name [String] The name of the policy.
206
+ # @param [Hash{String => String}] A hash of custom headers that will be added
207
+ # to the HTTP request.
208
+ #
209
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
210
+ #
211
+ def get_resource_async(resource_group_name, lab_name, policy_set_name, name, custom_headers = nil)
212
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
213
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
214
+ fail ArgumentError, 'lab_name is nil' if lab_name.nil?
215
+ fail ArgumentError, 'policy_set_name is nil' if policy_set_name.nil?
216
+ fail ArgumentError, 'name is nil' if name.nil?
217
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
218
+
219
+
220
+ request_headers = {}
221
+
222
+ # Set Headers
223
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
224
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
225
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'
226
+ options = {
227
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
228
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'policySetName' => policy_set_name,'name' => name},
229
+ query_params: {'api-version' => @client.api_version},
230
+ headers: request_headers.merge(custom_headers || {})
231
+ }
232
+
233
+ request_url = @base_url || @client.base_url
234
+
235
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
236
+ promise = request.run_promise do |req|
237
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
238
+ end
239
+
240
+ promise = promise.then do |http_response|
241
+ status_code = http_response.status
242
+ response_content = http_response.body
243
+ unless status_code == 200
244
+ error_model = JSON.load(response_content)
245
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
246
+ end
247
+
248
+ # Create Result
249
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
250
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
251
+ # Deserialize Response
252
+ if status_code == 200
253
+ begin
254
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
255
+ result_mapper = Policy.mapper()
256
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
257
+ rescue Exception => e
258
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
259
+ end
260
+ end
261
+
262
+ result
263
+ end
264
+
265
+ promise.execute
266
+ end
267
+
268
+ #
269
+ # Create or replace an existing policy.
270
+ #
271
+ # @param resource_group_name [String] The name of the resource group.
272
+ # @param lab_name [String] The name of the lab.
273
+ # @param policy_set_name [String] The name of the policy set.
274
+ # @param name [String] The name of the policy.
275
+ # @param policy [Policy]
276
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
277
+ # will be added to the HTTP request.
278
+ #
279
+ # @return [Policy] operation results.
280
+ #
281
+ def create_or_update_resource(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers = nil)
282
+ response = create_or_update_resource_async(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers).value!
283
+ response.body unless response.nil?
284
+ end
285
+
286
+ #
287
+ # Create or replace an existing policy.
288
+ #
289
+ # @param resource_group_name [String] The name of the resource group.
290
+ # @param lab_name [String] The name of the lab.
291
+ # @param policy_set_name [String] The name of the policy set.
292
+ # @param name [String] The name of the policy.
293
+ # @param policy [Policy]
294
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
295
+ # will be added to the HTTP request.
296
+ #
297
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
298
+ #
299
+ def create_or_update_resource_with_http_info(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers = nil)
300
+ create_or_update_resource_async(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers).value!
301
+ end
302
+
303
+ #
304
+ # Create or replace an existing policy.
305
+ #
306
+ # @param resource_group_name [String] The name of the resource group.
307
+ # @param lab_name [String] The name of the lab.
308
+ # @param policy_set_name [String] The name of the policy set.
309
+ # @param name [String] The name of the policy.
310
+ # @param policy [Policy]
311
+ # @param [Hash{String => String}] A hash of custom headers that will be added
312
+ # to the HTTP request.
313
+ #
314
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
315
+ #
316
+ def create_or_update_resource_async(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers = nil)
317
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
318
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
319
+ fail ArgumentError, 'lab_name is nil' if lab_name.nil?
320
+ fail ArgumentError, 'policy_set_name is nil' if policy_set_name.nil?
321
+ fail ArgumentError, 'name is nil' if name.nil?
322
+ fail ArgumentError, 'policy is nil' if policy.nil?
323
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
324
+
325
+
326
+ request_headers = {}
327
+
328
+ # Set Headers
329
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
330
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
331
+
332
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
333
+
334
+ # Serialize Request
335
+ request_mapper = Policy.mapper()
336
+ request_content = @client.serialize(request_mapper, policy, 'policy')
337
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
338
+
339
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'
340
+ options = {
341
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
342
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'policySetName' => policy_set_name,'name' => name},
343
+ query_params: {'api-version' => @client.api_version},
344
+ body: request_content,
345
+ headers: request_headers.merge(custom_headers || {})
346
+ }
347
+
348
+ request_url = @base_url || @client.base_url
349
+
350
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :put, options)
351
+ promise = request.run_promise do |req|
352
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
353
+ end
354
+
355
+ promise = promise.then do |http_response|
356
+ status_code = http_response.status
357
+ response_content = http_response.body
358
+ unless status_code == 200 || status_code == 201
359
+ error_model = JSON.load(response_content)
360
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
361
+ end
362
+
363
+ # Create Result
364
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
365
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
366
+ # Deserialize Response
367
+ if status_code == 200
368
+ begin
369
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
370
+ result_mapper = Policy.mapper()
371
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
372
+ rescue Exception => e
373
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
374
+ end
375
+ end
376
+ # Deserialize Response
377
+ if status_code == 201
378
+ begin
379
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
380
+ result_mapper = Policy.mapper()
381
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
382
+ rescue Exception => e
383
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
384
+ end
385
+ end
386
+
387
+ result
388
+ end
389
+
390
+ promise.execute
391
+ end
392
+
393
+ #
394
+ # Delete policy.
395
+ #
396
+ # @param resource_group_name [String] The name of the resource group.
397
+ # @param lab_name [String] The name of the lab.
398
+ # @param policy_set_name [String] The name of the policy set.
399
+ # @param name [String] The name of the policy.
400
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
401
+ # will be added to the HTTP request.
402
+ #
403
+ #
404
+ def delete_resource(resource_group_name, lab_name, policy_set_name, name, custom_headers = nil)
405
+ response = delete_resource_async(resource_group_name, lab_name, policy_set_name, name, custom_headers).value!
406
+ nil
407
+ end
408
+
409
+ #
410
+ # Delete policy.
411
+ #
412
+ # @param resource_group_name [String] The name of the resource group.
413
+ # @param lab_name [String] The name of the lab.
414
+ # @param policy_set_name [String] The name of the policy set.
415
+ # @param name [String] The name of the policy.
416
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
417
+ # will be added to the HTTP request.
418
+ #
419
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
420
+ #
421
+ def delete_resource_with_http_info(resource_group_name, lab_name, policy_set_name, name, custom_headers = nil)
422
+ delete_resource_async(resource_group_name, lab_name, policy_set_name, name, custom_headers).value!
423
+ end
424
+
425
+ #
426
+ # Delete policy.
427
+ #
428
+ # @param resource_group_name [String] The name of the resource group.
429
+ # @param lab_name [String] The name of the lab.
430
+ # @param policy_set_name [String] The name of the policy set.
431
+ # @param name [String] The name of the policy.
432
+ # @param [Hash{String => String}] A hash of custom headers that will be added
433
+ # to the HTTP request.
434
+ #
435
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
436
+ #
437
+ def delete_resource_async(resource_group_name, lab_name, policy_set_name, name, custom_headers = nil)
438
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
439
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
440
+ fail ArgumentError, 'lab_name is nil' if lab_name.nil?
441
+ fail ArgumentError, 'policy_set_name is nil' if policy_set_name.nil?
442
+ fail ArgumentError, 'name is nil' if name.nil?
443
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
444
+
445
+
446
+ request_headers = {}
447
+
448
+ # Set Headers
449
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
450
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
451
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'
452
+ options = {
453
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
454
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'policySetName' => policy_set_name,'name' => name},
455
+ query_params: {'api-version' => @client.api_version},
456
+ headers: request_headers.merge(custom_headers || {})
457
+ }
458
+
459
+ request_url = @base_url || @client.base_url
460
+
461
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
462
+ promise = request.run_promise do |req|
463
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
464
+ end
465
+
466
+ promise = promise.then do |http_response|
467
+ status_code = http_response.status
468
+ response_content = http_response.body
469
+ unless status_code == 200 || status_code == 204
470
+ error_model = JSON.load(response_content)
471
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
472
+ end
473
+
474
+ # Create Result
475
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
476
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
477
+
478
+ result
479
+ end
480
+
481
+ promise.execute
482
+ end
483
+
484
+ #
485
+ # Modify properties of policies.
486
+ #
487
+ # @param resource_group_name [String] The name of the resource group.
488
+ # @param lab_name [String] The name of the lab.
489
+ # @param policy_set_name [String] The name of the policy set.
490
+ # @param name [String] The name of the policy.
491
+ # @param policy [Policy]
492
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
493
+ # will be added to the HTTP request.
494
+ #
495
+ # @return [Policy] operation results.
496
+ #
497
+ def patch_resource(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers = nil)
498
+ response = patch_resource_async(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers).value!
499
+ response.body unless response.nil?
500
+ end
501
+
502
+ #
503
+ # Modify properties of policies.
504
+ #
505
+ # @param resource_group_name [String] The name of the resource group.
506
+ # @param lab_name [String] The name of the lab.
507
+ # @param policy_set_name [String] The name of the policy set.
508
+ # @param name [String] The name of the policy.
509
+ # @param policy [Policy]
510
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
511
+ # will be added to the HTTP request.
512
+ #
513
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
514
+ #
515
+ def patch_resource_with_http_info(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers = nil)
516
+ patch_resource_async(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers).value!
517
+ end
518
+
519
+ #
520
+ # Modify properties of policies.
521
+ #
522
+ # @param resource_group_name [String] The name of the resource group.
523
+ # @param lab_name [String] The name of the lab.
524
+ # @param policy_set_name [String] The name of the policy set.
525
+ # @param name [String] The name of the policy.
526
+ # @param policy [Policy]
527
+ # @param [Hash{String => String}] A hash of custom headers that will be added
528
+ # to the HTTP request.
529
+ #
530
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
531
+ #
532
+ def patch_resource_async(resource_group_name, lab_name, policy_set_name, name, policy, custom_headers = nil)
533
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
534
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
535
+ fail ArgumentError, 'lab_name is nil' if lab_name.nil?
536
+ fail ArgumentError, 'policy_set_name is nil' if policy_set_name.nil?
537
+ fail ArgumentError, 'name is nil' if name.nil?
538
+ fail ArgumentError, 'policy is nil' if policy.nil?
539
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
540
+
541
+
542
+ request_headers = {}
543
+
544
+ # Set Headers
545
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
546
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
547
+
548
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
549
+
550
+ # Serialize Request
551
+ request_mapper = Policy.mapper()
552
+ request_content = @client.serialize(request_mapper, policy, 'policy')
553
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
554
+
555
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}'
556
+ options = {
557
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
558
+ path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'policySetName' => policy_set_name,'name' => name},
559
+ query_params: {'api-version' => @client.api_version},
560
+ body: request_content,
561
+ headers: request_headers.merge(custom_headers || {})
562
+ }
563
+
564
+ request_url = @base_url || @client.base_url
565
+
566
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :patch, options)
567
+ promise = request.run_promise do |req|
568
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
569
+ end
570
+
571
+ promise = promise.then do |http_response|
572
+ status_code = http_response.status
573
+ response_content = http_response.body
574
+ unless status_code == 200
575
+ error_model = JSON.load(response_content)
576
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
577
+ end
578
+
579
+ # Create Result
580
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
581
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
582
+ # Deserialize Response
583
+ if status_code == 200
584
+ begin
585
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
586
+ result_mapper = Policy.mapper()
587
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
588
+ rescue Exception => e
589
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
590
+ end
591
+ end
592
+
593
+ result
594
+ end
595
+
596
+ promise.execute
597
+ end
598
+
599
+ #
600
+ # List policies in a given policy set.
601
+ #
602
+ # @param next_page_link [String] The NextLink from the previous successful
603
+ # call to List operation.
604
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
605
+ # will be added to the HTTP request.
606
+ #
607
+ # @return [ResponseWithContinuationPolicy] operation results.
608
+ #
609
+ def list_next(next_page_link, custom_headers = nil)
610
+ response = list_next_async(next_page_link, custom_headers).value!
611
+ response.body unless response.nil?
612
+ end
613
+
614
+ #
615
+ # List policies in a given policy set.
616
+ #
617
+ # @param next_page_link [String] The NextLink from the previous successful
618
+ # call to List operation.
619
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
620
+ # will be added to the HTTP request.
621
+ #
622
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
623
+ #
624
+ def list_next_with_http_info(next_page_link, custom_headers = nil)
625
+ list_next_async(next_page_link, custom_headers).value!
626
+ end
627
+
628
+ #
629
+ # List policies in a given policy set.
630
+ #
631
+ # @param next_page_link [String] The NextLink from the previous successful
632
+ # call to List operation.
633
+ # @param [Hash{String => String}] A hash of custom headers that will be added
634
+ # to the HTTP request.
635
+ #
636
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
637
+ #
638
+ def list_next_async(next_page_link, custom_headers = nil)
639
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
640
+
641
+
642
+ request_headers = {}
643
+
644
+ # Set Headers
645
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
646
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
647
+ path_template = '{nextLink}'
648
+ options = {
649
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
650
+ skip_encoding_path_params: {'nextLink' => next_page_link},
651
+ headers: request_headers.merge(custom_headers || {})
652
+ }
653
+
654
+ request_url = @base_url || @client.base_url
655
+
656
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
657
+ promise = request.run_promise do |req|
658
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
659
+ end
660
+
661
+ promise = promise.then do |http_response|
662
+ status_code = http_response.status
663
+ response_content = http_response.body
664
+ unless status_code == 200
665
+ error_model = JSON.load(response_content)
666
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
667
+ end
668
+
669
+ # Create Result
670
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
671
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
672
+ # Deserialize Response
673
+ if status_code == 200
674
+ begin
675
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
676
+ result_mapper = ResponseWithContinuationPolicy.mapper()
677
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
678
+ rescue Exception => e
679
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
680
+ end
681
+ end
682
+
683
+ result
684
+ end
685
+
686
+ promise.execute
687
+ end
688
+
689
+ end
690
+ end