azure_mgmt_resources 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +14 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +106 -0
  8. data/Rakefile +5 -0
  9. data/azure_mgmt_resources.gemspec +38 -0
  10. data/lib/azure_mgmt_resources.rb +74 -0
  11. data/lib/azure_mgmt_resources/Models/basic_dependency.rb +76 -0
  12. data/lib/azure_mgmt_resources/Models/dependency.rb +105 -0
  13. data/lib/azure_mgmt_resources/Models/deployment.rb +64 -0
  14. data/lib/azure_mgmt_resources/Models/deployment_extended.rb +83 -0
  15. data/lib/azure_mgmt_resources/Models/deployment_extended_filter.rb +58 -0
  16. data/lib/azure_mgmt_resources/Models/deployment_list_result.rb +88 -0
  17. data/lib/azure_mgmt_resources/Models/deployment_mode.rb +15 -0
  18. data/lib/azure_mgmt_resources/Models/deployment_operation.rb +83 -0
  19. data/lib/azure_mgmt_resources/Models/deployment_operation_properties.rb +102 -0
  20. data/lib/azure_mgmt_resources/Models/deployment_operations_list_result.rb +88 -0
  21. data/lib/azure_mgmt_resources/Models/deployment_properties.rb +116 -0
  22. data/lib/azure_mgmt_resources/Models/deployment_properties_extended.rb +216 -0
  23. data/lib/azure_mgmt_resources/Models/deployment_validate_result.rb +82 -0
  24. data/lib/azure_mgmt_resources/Models/generic_resource.rb +103 -0
  25. data/lib/azure_mgmt_resources/Models/generic_resource_filter.rb +76 -0
  26. data/lib/azure_mgmt_resources/Models/parameters_link.rb +68 -0
  27. data/lib/azure_mgmt_resources/Models/plan.rb +85 -0
  28. data/lib/azure_mgmt_resources/Models/provider.rb +106 -0
  29. data/lib/azure_mgmt_resources/Models/provider_list_result.rb +87 -0
  30. data/lib/azure_mgmt_resources/Models/provider_resource_type.rb +88 -0
  31. data/lib/azure_mgmt_resources/Models/resource_group.rb +105 -0
  32. data/lib/azure_mgmt_resources/Models/resource_group_extended.rb +113 -0
  33. data/lib/azure_mgmt_resources/Models/resource_group_extended_filter.rb +63 -0
  34. data/lib/azure_mgmt_resources/Models/resource_group_filter.rb +67 -0
  35. data/lib/azure_mgmt_resources/Models/resource_group_format_resource_properties.rb +54 -0
  36. data/lib/azure_mgmt_resources/Models/resource_group_list_result.rb +88 -0
  37. data/lib/azure_mgmt_resources/Models/resource_group_properties.rb +58 -0
  38. data/lib/azure_mgmt_resources/Models/resource_list_result.rb +88 -0
  39. data/lib/azure_mgmt_resources/Models/resource_management_error.rb +77 -0
  40. data/lib/azure_mgmt_resources/Models/resource_management_error_with_details.rb +106 -0
  41. data/lib/azure_mgmt_resources/Models/resource_provider_operation_definition.rb +74 -0
  42. data/lib/azure_mgmt_resources/Models/resource_provider_operation_detail_list_result.rb +80 -0
  43. data/lib/azure_mgmt_resources/Models/resource_provider_operation_display_properties.rb +95 -0
  44. data/lib/azure_mgmt_resources/Models/resources_move_info.rb +67 -0
  45. data/lib/azure_mgmt_resources/Models/tag_count.rb +67 -0
  46. data/lib/azure_mgmt_resources/Models/tag_details.rb +112 -0
  47. data/lib/azure_mgmt_resources/Models/tag_value.rb +82 -0
  48. data/lib/azure_mgmt_resources/Models/tags_list_result.rb +87 -0
  49. data/lib/azure_mgmt_resources/Models/target_resource.rb +76 -0
  50. data/lib/azure_mgmt_resources/Models/template_link.rb +68 -0
  51. data/lib/azure_mgmt_resources/deployment_operations.rb +297 -0
  52. data/lib/azure_mgmt_resources/deployments.rb +601 -0
  53. data/lib/azure_mgmt_resources/module_definition.rb +6 -0
  54. data/lib/azure_mgmt_resources/providers.rb +461 -0
  55. data/lib/azure_mgmt_resources/resource_groups.rb +891 -0
  56. data/lib/azure_mgmt_resources/resource_management_client.rb +85 -0
  57. data/lib/azure_mgmt_resources/resource_provider_operation_details.rb +126 -0
  58. data/lib/azure_mgmt_resources/resources.rb +737 -0
  59. data/lib/azure_mgmt_resources/tags.rb +546 -0
  60. data/lib/azure_mgmt_resources/version.rb +6 -0
  61. metadata +235 -0
@@ -0,0 +1,601 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Resources
7
+ #
8
+ # Deployments
9
+ #
10
+ class Deployments
11
+ include Azure::ARM::Resources::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the Deployments 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 ResourceManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Cancel a currently running template deployment.
27
+ # @param resource_group_name [String] The name of the resource group. The name
28
+ # is case insensitive.
29
+ # @param deployment_name [String] The name of the deployment.
30
+ # @param [Hash{String => String}] The hash of custom headers need to be
31
+ # applied to HTTP request.
32
+ #
33
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
34
+ # response.
35
+ #
36
+ def cancel(resource_group_name, deployment_name, custom_headers = nil)
37
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
38
+ fail ArgumentError, 'deployment_name is nil' if deployment_name.nil?
39
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
40
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
41
+ # Construct URL
42
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/cancel"
43
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
44
+ path['{deploymentName}'] = ERB::Util.url_encode(deployment_name) if path.include?('{deploymentName}')
45
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
46
+ url = URI.join(@client.base_url, path)
47
+ properties = {}
48
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
49
+ unless url.query.nil?
50
+ url.query.split('&').each do |url_item|
51
+ url_items_parts = url_item.split('=')
52
+ properties[url_items_parts[0]] = url_items_parts[1]
53
+ end
54
+ end
55
+ properties.reject!{ |key, value| value.nil? }
56
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
57
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
58
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
59
+ url = URI.parse(corrected_url)
60
+
61
+ connection = Faraday.new(:url => url) do |faraday|
62
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
63
+ faraday.use :cookie_jar
64
+ faraday.adapter Faraday.default_adapter
65
+ end
66
+ request_headers = Hash.new
67
+
68
+ # Set Headers
69
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
70
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
71
+
72
+ unless custom_headers.nil?
73
+ custom_headers.each do |key, value|
74
+ request_headers[key] = value
75
+ end
76
+ end
77
+
78
+ # Send Request
79
+ promise = Concurrent::Promise.new do
80
+ connection.post do |request|
81
+ request.headers = request_headers
82
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
83
+ end
84
+ end
85
+
86
+ promise = promise.then do |http_response|
87
+ status_code = http_response.status
88
+ response_content = http_response.body
89
+ unless (status_code == 204)
90
+ fail MsRestAzure::AzureOperationError.new(connection, http_response)
91
+ end
92
+
93
+ # Create Result
94
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
95
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
96
+
97
+ result
98
+ end
99
+
100
+ promise.execute
101
+ end
102
+
103
+ #
104
+ # Validate a deployment template.
105
+ # @param resource_group_name [String] The name of the resource group. The name
106
+ # is case insensitive.
107
+ # @param deployment_name [String] The name of the deployment.
108
+ # @param parameters [Deployment] Deployment to validate.
109
+ # @param [Hash{String => String}] The hash of custom headers need to be
110
+ # applied to HTTP request.
111
+ #
112
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
113
+ # response.
114
+ #
115
+ def validate(resource_group_name, deployment_name, parameters, custom_headers = nil)
116
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
117
+ fail ArgumentError, 'deployment_name is nil' if deployment_name.nil?
118
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
119
+ parameters.validate unless parameters.nil?
120
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
121
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
122
+ # Construct URL
123
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.resources/deployments/{deploymentName}/validate"
124
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
125
+ path['{deploymentName}'] = ERB::Util.url_encode(deployment_name) if path.include?('{deploymentName}')
126
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
127
+ url = URI.join(@client.base_url, path)
128
+ properties = {}
129
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
130
+ unless url.query.nil?
131
+ url.query.split('&').each do |url_item|
132
+ url_items_parts = url_item.split('=')
133
+ properties[url_items_parts[0]] = url_items_parts[1]
134
+ end
135
+ end
136
+ properties.reject!{ |key, value| value.nil? }
137
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
138
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
139
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
140
+ url = URI.parse(corrected_url)
141
+
142
+ connection = Faraday.new(:url => url) do |faraday|
143
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
144
+ faraday.use :cookie_jar
145
+ faraday.adapter Faraday.default_adapter
146
+ end
147
+ request_headers = Hash.new
148
+
149
+ # Set Headers
150
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
151
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
152
+
153
+ unless custom_headers.nil?
154
+ custom_headers.each do |key, value|
155
+ request_headers[key] = value
156
+ end
157
+ end
158
+
159
+ # Serialize Request
160
+ request_headers['Content-Type'] = 'application/json'
161
+ unless parameters.nil?
162
+ parameters = Deployment.serialize_object(parameters)
163
+ end
164
+ request_content = JSON.generate(parameters, quirks_mode: true)
165
+
166
+ # Send Request
167
+ promise = Concurrent::Promise.new do
168
+ connection.post do |request|
169
+ request.headers = request_headers
170
+ request.body = request_content
171
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
172
+ end
173
+ end
174
+
175
+ promise = promise.then do |http_response|
176
+ status_code = http_response.status
177
+ response_content = http_response.body
178
+ unless (status_code == 200 || status_code == 400)
179
+ error_model = JSON.load(response_content)
180
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
181
+ end
182
+
183
+ # Create Result
184
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
185
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
186
+ # Deserialize Response
187
+ if status_code == 200
188
+ begin
189
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
190
+ unless parsed_response.nil?
191
+ parsed_response = DeploymentValidateResult.deserialize_object(parsed_response)
192
+ end
193
+ result.body = parsed_response
194
+ rescue Exception => e
195
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
196
+ end
197
+ end
198
+ # Deserialize Response
199
+ if status_code == 400
200
+ begin
201
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
202
+ unless parsed_response.nil?
203
+ parsed_response = DeploymentValidateResult.deserialize_object(parsed_response)
204
+ end
205
+ result.body = parsed_response
206
+ rescue Exception => e
207
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
208
+ end
209
+ end
210
+
211
+ result
212
+ end
213
+
214
+ promise.execute
215
+ end
216
+
217
+ #
218
+ # Create a named template deployment using a template.
219
+ # @param resource_group_name [String] The name of the resource group. The name
220
+ # is case insensitive.
221
+ # @param deployment_name [String] The name of the deployment.
222
+ # @param parameters [Deployment] Additional parameters supplied to the
223
+ # operation.
224
+ # @param [Hash{String => String}] The hash of custom headers need to be
225
+ # applied to HTTP request.
226
+ #
227
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
228
+ # response.
229
+ #
230
+ def create_or_update(resource_group_name, deployment_name, parameters, custom_headers = nil)
231
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
232
+ fail ArgumentError, 'deployment_name is nil' if deployment_name.nil?
233
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
234
+ parameters.validate unless parameters.nil?
235
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
236
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
237
+ # Construct URL
238
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}"
239
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
240
+ path['{deploymentName}'] = ERB::Util.url_encode(deployment_name) if path.include?('{deploymentName}')
241
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
242
+ url = URI.join(@client.base_url, path)
243
+ properties = {}
244
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
245
+ unless url.query.nil?
246
+ url.query.split('&').each do |url_item|
247
+ url_items_parts = url_item.split('=')
248
+ properties[url_items_parts[0]] = url_items_parts[1]
249
+ end
250
+ end
251
+ properties.reject!{ |key, value| value.nil? }
252
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
253
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
254
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
255
+ url = URI.parse(corrected_url)
256
+
257
+ connection = Faraday.new(:url => url) do |faraday|
258
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
259
+ faraday.use :cookie_jar
260
+ faraday.adapter Faraday.default_adapter
261
+ end
262
+ request_headers = Hash.new
263
+
264
+ # Set Headers
265
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
266
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
267
+
268
+ unless custom_headers.nil?
269
+ custom_headers.each do |key, value|
270
+ request_headers[key] = value
271
+ end
272
+ end
273
+
274
+ # Serialize Request
275
+ request_headers['Content-Type'] = 'application/json'
276
+ unless parameters.nil?
277
+ parameters = Deployment.serialize_object(parameters)
278
+ end
279
+ request_content = JSON.generate(parameters, quirks_mode: true)
280
+
281
+ # Send Request
282
+ promise = Concurrent::Promise.new do
283
+ connection.put do |request|
284
+ request.headers = request_headers
285
+ request.body = request_content
286
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
287
+ end
288
+ end
289
+
290
+ promise = promise.then do |http_response|
291
+ status_code = http_response.status
292
+ response_content = http_response.body
293
+ unless (status_code == 200 || status_code == 201)
294
+ error_model = JSON.load(response_content)
295
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
296
+ end
297
+
298
+ # Create Result
299
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
300
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
301
+ # Deserialize Response
302
+ if status_code == 200
303
+ begin
304
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
305
+ unless parsed_response.nil?
306
+ parsed_response = DeploymentExtended.deserialize_object(parsed_response)
307
+ end
308
+ result.body = parsed_response
309
+ rescue Exception => e
310
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
311
+ end
312
+ end
313
+ # Deserialize Response
314
+ if status_code == 201
315
+ begin
316
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
317
+ unless parsed_response.nil?
318
+ parsed_response = DeploymentExtended.deserialize_object(parsed_response)
319
+ end
320
+ result.body = parsed_response
321
+ rescue Exception => e
322
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
323
+ end
324
+ end
325
+
326
+ result
327
+ end
328
+
329
+ promise.execute
330
+ end
331
+
332
+ #
333
+ # Get a deployment.
334
+ # @param resource_group_name [String] The name of the resource group to get.
335
+ # The name is case insensitive.
336
+ # @param deployment_name [String] The name of the deployment.
337
+ # @param [Hash{String => String}] The hash of custom headers need to be
338
+ # applied to HTTP request.
339
+ #
340
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
341
+ # response.
342
+ #
343
+ def get(resource_group_name, deployment_name, custom_headers = nil)
344
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
345
+ fail ArgumentError, 'deployment_name is nil' if deployment_name.nil?
346
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
347
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
348
+ # Construct URL
349
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}"
350
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
351
+ path['{deploymentName}'] = ERB::Util.url_encode(deployment_name) if path.include?('{deploymentName}')
352
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
353
+ url = URI.join(@client.base_url, path)
354
+ properties = {}
355
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
356
+ unless url.query.nil?
357
+ url.query.split('&').each do |url_item|
358
+ url_items_parts = url_item.split('=')
359
+ properties[url_items_parts[0]] = url_items_parts[1]
360
+ end
361
+ end
362
+ properties.reject!{ |key, value| value.nil? }
363
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
364
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
365
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
366
+ url = URI.parse(corrected_url)
367
+
368
+ connection = Faraday.new(:url => url) do |faraday|
369
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
370
+ faraday.use :cookie_jar
371
+ faraday.adapter Faraday.default_adapter
372
+ end
373
+ request_headers = Hash.new
374
+
375
+ # Set Headers
376
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
377
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
378
+
379
+ unless custom_headers.nil?
380
+ custom_headers.each do |key, value|
381
+ request_headers[key] = value
382
+ end
383
+ end
384
+
385
+ # Send Request
386
+ promise = Concurrent::Promise.new do
387
+ connection.get do |request|
388
+ request.headers = request_headers
389
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
390
+ end
391
+ end
392
+
393
+ promise = promise.then do |http_response|
394
+ status_code = http_response.status
395
+ response_content = http_response.body
396
+ unless (status_code == 200)
397
+ error_model = JSON.load(response_content)
398
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
399
+ end
400
+
401
+ # Create Result
402
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
403
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
404
+ # Deserialize Response
405
+ if status_code == 200
406
+ begin
407
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
408
+ unless parsed_response.nil?
409
+ parsed_response = DeploymentExtended.deserialize_object(parsed_response)
410
+ end
411
+ result.body = parsed_response
412
+ rescue Exception => e
413
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
414
+ end
415
+ end
416
+
417
+ result
418
+ end
419
+
420
+ promise.execute
421
+ end
422
+
423
+ #
424
+ # Get a list of deployments.
425
+ # @param resource_group_name [String] The name of the resource group to filter
426
+ # by. The name is case insensitive.
427
+ # @param filter [String] The filter to apply on the operation.
428
+ # @param top [Integer] Query parameters. If null is passed returns all
429
+ # deployments.
430
+ # @param [Hash{String => String}] The hash of custom headers need to be
431
+ # applied to HTTP request.
432
+ #
433
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
434
+ # response.
435
+ #
436
+ def list(resource_group_name, filter = nil, top = nil, custom_headers = nil)
437
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
438
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
439
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
440
+ # Construct URL
441
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/"
442
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
443
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
444
+ url = URI.join(@client.base_url, path)
445
+ properties = {}
446
+ properties['$filter'] = ERB::Util.url_encode(filter.to_s) unless filter.nil?
447
+ properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
448
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
449
+ unless url.query.nil?
450
+ url.query.split('&').each do |url_item|
451
+ url_items_parts = url_item.split('=')
452
+ properties[url_items_parts[0]] = url_items_parts[1]
453
+ end
454
+ end
455
+ properties.reject!{ |key, value| value.nil? }
456
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
457
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
458
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
459
+ url = URI.parse(corrected_url)
460
+
461
+ connection = Faraday.new(:url => url) do |faraday|
462
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
463
+ faraday.use :cookie_jar
464
+ faraday.adapter Faraday.default_adapter
465
+ end
466
+ request_headers = Hash.new
467
+
468
+ # Set Headers
469
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
470
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
471
+
472
+ unless custom_headers.nil?
473
+ custom_headers.each do |key, value|
474
+ request_headers[key] = value
475
+ end
476
+ end
477
+
478
+ # Send Request
479
+ promise = Concurrent::Promise.new do
480
+ connection.get do |request|
481
+ request.headers = request_headers
482
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
483
+ end
484
+ end
485
+
486
+ promise = promise.then do |http_response|
487
+ status_code = http_response.status
488
+ response_content = http_response.body
489
+ unless (status_code == 200)
490
+ error_model = JSON.load(response_content)
491
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
492
+ end
493
+
494
+ # Create Result
495
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
496
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
497
+ # Deserialize Response
498
+ if status_code == 200
499
+ begin
500
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
501
+ unless parsed_response.nil?
502
+ parsed_response = DeploymentListResult.deserialize_object(parsed_response)
503
+ end
504
+ result.body = parsed_response
505
+ rescue Exception => e
506
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
507
+ end
508
+ end
509
+
510
+ result
511
+ end
512
+
513
+ promise.execute
514
+ end
515
+
516
+ #
517
+ # Get a list of deployments.
518
+ # @param next_page_link [String] The NextLink from the previous successful
519
+ # call to List operation.
520
+ # @param [Hash{String => String}] The hash of custom headers need to be
521
+ # applied to HTTP request.
522
+ #
523
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
524
+ # response.
525
+ #
526
+ def list_next(next_page_link, custom_headers = nil)
527
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
528
+ # Construct URL
529
+ path = "{nextLink}"
530
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
531
+ url = URI.parse(path)
532
+ properties = {}
533
+ unless url.query.nil?
534
+ url.query.split('&').each do |url_item|
535
+ url_items_parts = url_item.split('=')
536
+ properties[url_items_parts[0]] = url_items_parts[1]
537
+ end
538
+ end
539
+ properties.reject!{ |key, value| value.nil? }
540
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
541
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
542
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
543
+ url = URI.parse(corrected_url)
544
+
545
+ connection = Faraday.new(:url => url) do |faraday|
546
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
547
+ faraday.use :cookie_jar
548
+ faraday.adapter Faraday.default_adapter
549
+ end
550
+ request_headers = Hash.new
551
+
552
+ # Set Headers
553
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
554
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
555
+
556
+ unless custom_headers.nil?
557
+ custom_headers.each do |key, value|
558
+ request_headers[key] = value
559
+ end
560
+ end
561
+
562
+ # Send Request
563
+ promise = Concurrent::Promise.new do
564
+ connection.get do |request|
565
+ request.headers = request_headers
566
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
567
+ end
568
+ end
569
+
570
+ promise = promise.then do |http_response|
571
+ status_code = http_response.status
572
+ response_content = http_response.body
573
+ unless (status_code == 200)
574
+ error_model = JSON.load(response_content)
575
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
576
+ end
577
+
578
+ # Create Result
579
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
580
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
581
+ # Deserialize Response
582
+ if status_code == 200
583
+ begin
584
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
585
+ unless parsed_response.nil?
586
+ parsed_response = DeploymentListResult.deserialize_object(parsed_response)
587
+ end
588
+ result.body = parsed_response
589
+ rescue Exception => e
590
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
591
+ end
592
+ end
593
+
594
+ result
595
+ end
596
+
597
+ promise.execute
598
+ end
599
+
600
+ end
601
+ end