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,891 @@
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
+ # ResourceGroups
9
+ #
10
+ class ResourceGroups
11
+ include Azure::ARM::Resources::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the ResourceGroups 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
+ # Get all of the resources under a subscription.
27
+ # @param resource_group_name [String] Query parameters. If null is passed
28
+ # returns all resource groups.
29
+ # @param filter [String] The filter to apply on the operation.
30
+ # @param top [Integer] Query parameters. If null is passed returns all
31
+ # resource groups.
32
+ # @param [Hash{String => String}] The hash of custom headers need to be
33
+ # applied to HTTP request.
34
+ #
35
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
36
+ # response.
37
+ #
38
+ def list_resources(resource_group_name, filter = nil, top = nil, custom_headers = nil)
39
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
40
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
41
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
42
+ # Construct URL
43
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"
44
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
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['$filter'] = ERB::Util.url_encode(filter.to_s) unless filter.nil?
49
+ properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
50
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
51
+ unless url.query.nil?
52
+ url.query.split('&').each do |url_item|
53
+ url_items_parts = url_item.split('=')
54
+ properties[url_items_parts[0]] = url_items_parts[1]
55
+ end
56
+ end
57
+ properties.reject!{ |key, value| value.nil? }
58
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
59
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
60
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
61
+ url = URI.parse(corrected_url)
62
+
63
+ connection = Faraday.new(:url => url) do |faraday|
64
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
65
+ faraday.use :cookie_jar
66
+ faraday.adapter Faraday.default_adapter
67
+ end
68
+ request_headers = Hash.new
69
+
70
+ # Set Headers
71
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
72
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
73
+
74
+ unless custom_headers.nil?
75
+ custom_headers.each do |key, value|
76
+ request_headers[key] = value
77
+ end
78
+ end
79
+
80
+ # Send Request
81
+ promise = Concurrent::Promise.new do
82
+ connection.get do |request|
83
+ request.headers = request_headers
84
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
85
+ end
86
+ end
87
+
88
+ promise = promise.then do |http_response|
89
+ status_code = http_response.status
90
+ response_content = http_response.body
91
+ unless (status_code == 200)
92
+ error_model = JSON.load(response_content)
93
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
94
+ end
95
+
96
+ # Create Result
97
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
98
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
99
+ # Deserialize Response
100
+ if status_code == 200
101
+ begin
102
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
103
+ unless parsed_response.nil?
104
+ parsed_response = ResourceListResult.deserialize_object(parsed_response)
105
+ end
106
+ result.body = parsed_response
107
+ rescue Exception => e
108
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
109
+ end
110
+ end
111
+
112
+ result
113
+ end
114
+
115
+ promise.execute
116
+ end
117
+
118
+ #
119
+ # Checks whether resource group exists.
120
+ # @param resource_group_name [String] The name of the resource group to check.
121
+ # The name is case insensitive.
122
+ # @param [Hash{String => String}] The hash of custom headers need to be
123
+ # applied to HTTP request.
124
+ #
125
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
126
+ # response.
127
+ #
128
+ def check_existence(resource_group_name, custom_headers = nil)
129
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
130
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
131
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
132
+ # Construct URL
133
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"
134
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
135
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
136
+ url = URI.join(@client.base_url, path)
137
+ properties = {}
138
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
139
+ unless url.query.nil?
140
+ url.query.split('&').each do |url_item|
141
+ url_items_parts = url_item.split('=')
142
+ properties[url_items_parts[0]] = url_items_parts[1]
143
+ end
144
+ end
145
+ properties.reject!{ |key, value| value.nil? }
146
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
147
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
148
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
149
+ url = URI.parse(corrected_url)
150
+
151
+ connection = Faraday.new(:url => url) do |faraday|
152
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
153
+ faraday.use :cookie_jar
154
+ faraday.adapter Faraday.default_adapter
155
+ end
156
+ request_headers = Hash.new
157
+
158
+ # Set Headers
159
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
160
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
161
+
162
+ unless custom_headers.nil?
163
+ custom_headers.each do |key, value|
164
+ request_headers[key] = value
165
+ end
166
+ end
167
+
168
+ # Send Request
169
+ promise = Concurrent::Promise.new do
170
+ connection.head do |request|
171
+ request.headers = request_headers
172
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
173
+ end
174
+ end
175
+
176
+ promise = promise.then do |http_response|
177
+ status_code = http_response.status
178
+ response_content = http_response.body
179
+ unless (status_code == 204 || status_code == 404)
180
+ error_model = JSON.load(response_content)
181
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
182
+ end
183
+
184
+ # Create Result
185
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
186
+ result.body = (status_code == 204)
187
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
188
+
189
+ result
190
+ end
191
+
192
+ promise.execute
193
+ end
194
+
195
+ #
196
+ # Create a resource group.
197
+ # @param resource_group_name [String] The name of the resource group to be
198
+ # created or updated.
199
+ # @param parameters [ResourceGroup] Parameters supplied to the create or
200
+ # update resource group service operation.
201
+ # @param @client.api_version [String] Client Api Version.
202
+ # @param @client.subscription_id [String] Gets subscription credentials which
203
+ # uniquely identify Microsoft Azure subscription. The subscription ID forms
204
+ # part of the URI for every service call.
205
+ # @param @client.accept_language [String] Gets or sets the preferred language
206
+ # for the response.
207
+ #
208
+ # @return [Concurrent::Promise] promise which provides async access to http
209
+ # response.
210
+ #
211
+ def create_or_update(resource_group_name, parameters, custom_headers = nil)
212
+ # Send request
213
+ promise = begin_create_or_update(resource_group_name, parameters, custom_headers)
214
+
215
+ promise = promise.then do |response|
216
+ # Defining deserialization method.
217
+ deserialize_method = lambda do |parsed_response|
218
+ unless parsed_response.nil?
219
+ parsed_response = ResourceGroup.deserialize_object(parsed_response)
220
+ end
221
+ end
222
+
223
+ # Waiting for response.
224
+ @client.get_put_operation_result(response, custom_headers, deserialize_method)
225
+ end
226
+
227
+ promise
228
+ end
229
+
230
+ #
231
+ # Create a resource group.
232
+ # @param resource_group_name [String] The name of the resource group to be
233
+ # created or updated.
234
+ # @param parameters [ResourceGroup] Parameters supplied to the create or
235
+ # update resource group service operation.
236
+ # @param [Hash{String => String}] The hash of custom headers need to be
237
+ # applied to HTTP request.
238
+ #
239
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
240
+ # response.
241
+ #
242
+ def begin_create_or_update(resource_group_name, parameters, custom_headers = nil)
243
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
244
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
245
+ parameters.validate unless parameters.nil?
246
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
247
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
248
+ # Construct URL
249
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"
250
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
251
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
252
+ url = URI.join(@client.base_url, path)
253
+ properties = {}
254
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
255
+ unless url.query.nil?
256
+ url.query.split('&').each do |url_item|
257
+ url_items_parts = url_item.split('=')
258
+ properties[url_items_parts[0]] = url_items_parts[1]
259
+ end
260
+ end
261
+ properties.reject!{ |key, value| value.nil? }
262
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
263
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
264
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
265
+ url = URI.parse(corrected_url)
266
+
267
+ connection = Faraday.new(:url => url) do |faraday|
268
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
269
+ faraday.use :cookie_jar
270
+ faraday.adapter Faraday.default_adapter
271
+ end
272
+ request_headers = Hash.new
273
+
274
+ # Set Headers
275
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
276
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
277
+
278
+ unless custom_headers.nil?
279
+ custom_headers.each do |key, value|
280
+ request_headers[key] = value
281
+ end
282
+ end
283
+
284
+ # Serialize Request
285
+ request_headers['Content-Type'] = 'application/json'
286
+ unless parameters.nil?
287
+ parameters = ResourceGroup.serialize_object(parameters)
288
+ end
289
+ request_content = JSON.generate(parameters, quirks_mode: true)
290
+
291
+ # Send Request
292
+ promise = Concurrent::Promise.new do
293
+ connection.put do |request|
294
+ request.headers = request_headers
295
+ request.body = request_content
296
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
297
+ end
298
+ end
299
+
300
+ promise = promise.then do |http_response|
301
+ status_code = http_response.status
302
+ response_content = http_response.body
303
+ unless (status_code == 201 || status_code == 200 || status_code == 202)
304
+ error_model = JSON.load(response_content)
305
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
306
+ end
307
+
308
+ # Create Result
309
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
310
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
311
+ # Deserialize Response
312
+ if status_code == 201
313
+ begin
314
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
315
+ unless parsed_response.nil?
316
+ parsed_response = ResourceGroup.deserialize_object(parsed_response)
317
+ end
318
+ result.body = parsed_response
319
+ rescue Exception => e
320
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
321
+ end
322
+ end
323
+ # Deserialize Response
324
+ if status_code == 200
325
+ begin
326
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
327
+ unless parsed_response.nil?
328
+ parsed_response = ResourceGroup.deserialize_object(parsed_response)
329
+ end
330
+ result.body = parsed_response
331
+ rescue Exception => e
332
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
333
+ end
334
+ end
335
+
336
+ result
337
+ end
338
+
339
+ promise.execute
340
+ end
341
+
342
+ #
343
+ # Begin deleting resource group.To determine whether the operation has
344
+ # finished processing the request, call GetLongRunningOperationStatus.
345
+ # @param resource_group_name [String] The name of the resource group to be
346
+ # deleted. The name is case insensitive.
347
+ # @return [Concurrent::Promise] promise which provides async access to http
348
+ # response.
349
+ #
350
+ def delete(resource_group_name, custom_headers = nil)
351
+ # Send request
352
+ promise = begin_delete(resource_group_name, custom_headers)
353
+
354
+ promise = promise.then do |response|
355
+ # Defining deserialization method.
356
+ deserialize_method = lambda do |parsed_response|
357
+ end
358
+
359
+ # Waiting for response.
360
+ @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
361
+ end
362
+
363
+ promise
364
+ end
365
+
366
+ #
367
+ # Begin deleting resource group.To determine whether the operation has
368
+ # finished processing the request, call GetLongRunningOperationStatus.
369
+ # @param resource_group_name [String] The name of the resource group to be
370
+ # deleted. The name is case insensitive.
371
+ # @param [Hash{String => String}] The hash of custom headers need to be
372
+ # applied to HTTP request.
373
+ #
374
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
375
+ # response.
376
+ #
377
+ def begin_delete(resource_group_name, custom_headers = nil)
378
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
379
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
380
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
381
+ # Construct URL
382
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"
383
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
384
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
385
+ url = URI.join(@client.base_url, path)
386
+ properties = {}
387
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
388
+ unless url.query.nil?
389
+ url.query.split('&').each do |url_item|
390
+ url_items_parts = url_item.split('=')
391
+ properties[url_items_parts[0]] = url_items_parts[1]
392
+ end
393
+ end
394
+ properties.reject!{ |key, value| value.nil? }
395
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
396
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
397
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
398
+ url = URI.parse(corrected_url)
399
+
400
+ connection = Faraday.new(:url => url) do |faraday|
401
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
402
+ faraday.use :cookie_jar
403
+ faraday.adapter Faraday.default_adapter
404
+ end
405
+ request_headers = Hash.new
406
+
407
+ # Set Headers
408
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
409
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
410
+
411
+ unless custom_headers.nil?
412
+ custom_headers.each do |key, value|
413
+ request_headers[key] = value
414
+ end
415
+ end
416
+
417
+ # Send Request
418
+ promise = Concurrent::Promise.new do
419
+ connection.delete do |request|
420
+ request.headers = request_headers
421
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
422
+ end
423
+ end
424
+
425
+ promise = promise.then do |http_response|
426
+ status_code = http_response.status
427
+ response_content = http_response.body
428
+ unless (status_code == 202 || status_code == 200)
429
+ fail MsRestAzure::AzureOperationError.new(connection, http_response)
430
+ end
431
+
432
+ # Create Result
433
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
434
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
435
+
436
+ result
437
+ end
438
+
439
+ promise.execute
440
+ end
441
+
442
+ #
443
+ # Get a resource group.
444
+ # @param resource_group_name [String] The name of the resource group to get.
445
+ # The name is case insensitive.
446
+ # @param [Hash{String => String}] The hash of custom headers need to be
447
+ # applied to HTTP request.
448
+ #
449
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
450
+ # response.
451
+ #
452
+ def get(resource_group_name, custom_headers = nil)
453
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
454
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
455
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
456
+ # Construct URL
457
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"
458
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
459
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
460
+ url = URI.join(@client.base_url, path)
461
+ properties = {}
462
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
463
+ unless url.query.nil?
464
+ url.query.split('&').each do |url_item|
465
+ url_items_parts = url_item.split('=')
466
+ properties[url_items_parts[0]] = url_items_parts[1]
467
+ end
468
+ end
469
+ properties.reject!{ |key, value| value.nil? }
470
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
471
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
472
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
473
+ url = URI.parse(corrected_url)
474
+
475
+ connection = Faraday.new(:url => url) do |faraday|
476
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
477
+ faraday.use :cookie_jar
478
+ faraday.adapter Faraday.default_adapter
479
+ end
480
+ request_headers = Hash.new
481
+
482
+ # Set Headers
483
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
484
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
485
+
486
+ unless custom_headers.nil?
487
+ custom_headers.each do |key, value|
488
+ request_headers[key] = value
489
+ end
490
+ end
491
+
492
+ # Send Request
493
+ promise = Concurrent::Promise.new do
494
+ connection.get do |request|
495
+ request.headers = request_headers
496
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
497
+ end
498
+ end
499
+
500
+ promise = promise.then do |http_response|
501
+ status_code = http_response.status
502
+ response_content = http_response.body
503
+ unless (status_code == 200)
504
+ error_model = JSON.load(response_content)
505
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
506
+ end
507
+
508
+ # Create Result
509
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
510
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
511
+ # Deserialize Response
512
+ if status_code == 200
513
+ begin
514
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
515
+ unless parsed_response.nil?
516
+ parsed_response = ResourceGroup.deserialize_object(parsed_response)
517
+ end
518
+ result.body = parsed_response
519
+ rescue Exception => e
520
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
521
+ end
522
+ end
523
+
524
+ result
525
+ end
526
+
527
+ promise.execute
528
+ end
529
+
530
+ #
531
+ # Resource groups can be updated through a simple PATCH operation to a group
532
+ # address. The format of the request is the same as that for creating a
533
+ # resource groups, though if a field is unspecified current value will be
534
+ # carried over.
535
+ # @param resource_group_name [String] The name of the resource group to be
536
+ # created or updated. The name is case insensitive.
537
+ # @param parameters [ResourceGroup] Parameters supplied to the update state
538
+ # resource group service operation.
539
+ # @param [Hash{String => String}] The hash of custom headers need to be
540
+ # applied to HTTP request.
541
+ #
542
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
543
+ # response.
544
+ #
545
+ def patch(resource_group_name, parameters, custom_headers = nil)
546
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
547
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
548
+ parameters.validate unless parameters.nil?
549
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
550
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
551
+ # Construct URL
552
+ path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"
553
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
554
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
555
+ url = URI.join(@client.base_url, path)
556
+ properties = {}
557
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
558
+ unless url.query.nil?
559
+ url.query.split('&').each do |url_item|
560
+ url_items_parts = url_item.split('=')
561
+ properties[url_items_parts[0]] = url_items_parts[1]
562
+ end
563
+ end
564
+ properties.reject!{ |key, value| value.nil? }
565
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
566
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
567
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
568
+ url = URI.parse(corrected_url)
569
+
570
+ connection = Faraday.new(:url => url) do |faraday|
571
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
572
+ faraday.use :cookie_jar
573
+ faraday.adapter Faraday.default_adapter
574
+ end
575
+ request_headers = Hash.new
576
+
577
+ # Set Headers
578
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
579
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
580
+
581
+ unless custom_headers.nil?
582
+ custom_headers.each do |key, value|
583
+ request_headers[key] = value
584
+ end
585
+ end
586
+
587
+ # Serialize Request
588
+ request_headers['Content-Type'] = 'application/json'
589
+ unless parameters.nil?
590
+ parameters = ResourceGroup.serialize_object(parameters)
591
+ end
592
+ request_content = JSON.generate(parameters, quirks_mode: true)
593
+
594
+ # Send Request
595
+ promise = Concurrent::Promise.new do
596
+ connection.patch do |request|
597
+ request.headers = request_headers
598
+ request.body = request_content
599
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
600
+ end
601
+ end
602
+
603
+ promise = promise.then do |http_response|
604
+ status_code = http_response.status
605
+ response_content = http_response.body
606
+ unless (status_code == 200)
607
+ error_model = JSON.load(response_content)
608
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
609
+ end
610
+
611
+ # Create Result
612
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
613
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
614
+ # Deserialize Response
615
+ if status_code == 200
616
+ begin
617
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
618
+ unless parsed_response.nil?
619
+ parsed_response = ResourceGroup.deserialize_object(parsed_response)
620
+ end
621
+ result.body = parsed_response
622
+ rescue Exception => e
623
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
624
+ end
625
+ end
626
+
627
+ result
628
+ end
629
+
630
+ promise.execute
631
+ end
632
+
633
+ #
634
+ # Gets a collection of resource groups.
635
+ # @param filter [String] The filter to apply on the operation.
636
+ # @param top [Integer] Query parameters. If null is passed returns all
637
+ # resource groups.
638
+ # @param [Hash{String => String}] The hash of custom headers need to be
639
+ # applied to HTTP request.
640
+ #
641
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
642
+ # response.
643
+ #
644
+ def list(filter = nil, top = nil, custom_headers = nil)
645
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
646
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
647
+ # Construct URL
648
+ path = "/subscriptions/{subscriptionId}/resourcegroups"
649
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
650
+ url = URI.join(@client.base_url, path)
651
+ properties = {}
652
+ properties['$filter'] = ERB::Util.url_encode(filter.to_s) unless filter.nil?
653
+ properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
654
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
655
+ unless url.query.nil?
656
+ url.query.split('&').each do |url_item|
657
+ url_items_parts = url_item.split('=')
658
+ properties[url_items_parts[0]] = url_items_parts[1]
659
+ end
660
+ end
661
+ properties.reject!{ |key, value| value.nil? }
662
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
663
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
664
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
665
+ url = URI.parse(corrected_url)
666
+
667
+ connection = Faraday.new(:url => url) do |faraday|
668
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
669
+ faraday.use :cookie_jar
670
+ faraday.adapter Faraday.default_adapter
671
+ end
672
+ request_headers = Hash.new
673
+
674
+ # Set Headers
675
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
676
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
677
+
678
+ unless custom_headers.nil?
679
+ custom_headers.each do |key, value|
680
+ request_headers[key] = value
681
+ end
682
+ end
683
+
684
+ # Send Request
685
+ promise = Concurrent::Promise.new do
686
+ connection.get do |request|
687
+ request.headers = request_headers
688
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
689
+ end
690
+ end
691
+
692
+ promise = promise.then do |http_response|
693
+ status_code = http_response.status
694
+ response_content = http_response.body
695
+ unless (status_code == 200)
696
+ error_model = JSON.load(response_content)
697
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
698
+ end
699
+
700
+ # Create Result
701
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
702
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
703
+ # Deserialize Response
704
+ if status_code == 200
705
+ begin
706
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
707
+ unless parsed_response.nil?
708
+ parsed_response = ResourceGroupListResult.deserialize_object(parsed_response)
709
+ end
710
+ result.body = parsed_response
711
+ rescue Exception => e
712
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
713
+ end
714
+ end
715
+
716
+ result
717
+ end
718
+
719
+ promise.execute
720
+ end
721
+
722
+ #
723
+ # Get all of the resources under a subscription.
724
+ # @param next_page_link [String] The NextLink from the previous successful
725
+ # call to List operation.
726
+ # @param [Hash{String => String}] The hash of custom headers need to be
727
+ # applied to HTTP request.
728
+ #
729
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
730
+ # response.
731
+ #
732
+ def list_resources_next(next_page_link, custom_headers = nil)
733
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
734
+ # Construct URL
735
+ path = "{nextLink}"
736
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
737
+ url = URI.parse(path)
738
+ properties = {}
739
+ unless url.query.nil?
740
+ url.query.split('&').each do |url_item|
741
+ url_items_parts = url_item.split('=')
742
+ properties[url_items_parts[0]] = url_items_parts[1]
743
+ end
744
+ end
745
+ properties.reject!{ |key, value| value.nil? }
746
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
747
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
748
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
749
+ url = URI.parse(corrected_url)
750
+
751
+ connection = Faraday.new(:url => url) do |faraday|
752
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
753
+ faraday.use :cookie_jar
754
+ faraday.adapter Faraday.default_adapter
755
+ end
756
+ request_headers = Hash.new
757
+
758
+ # Set Headers
759
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
760
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
761
+
762
+ unless custom_headers.nil?
763
+ custom_headers.each do |key, value|
764
+ request_headers[key] = value
765
+ end
766
+ end
767
+
768
+ # Send Request
769
+ promise = Concurrent::Promise.new do
770
+ connection.get do |request|
771
+ request.headers = request_headers
772
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
773
+ end
774
+ end
775
+
776
+ promise = promise.then do |http_response|
777
+ status_code = http_response.status
778
+ response_content = http_response.body
779
+ unless (status_code == 200)
780
+ error_model = JSON.load(response_content)
781
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
782
+ end
783
+
784
+ # Create Result
785
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
786
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
787
+ # Deserialize Response
788
+ if status_code == 200
789
+ begin
790
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
791
+ unless parsed_response.nil?
792
+ parsed_response = ResourceListResult.deserialize_object(parsed_response)
793
+ end
794
+ result.body = parsed_response
795
+ rescue Exception => e
796
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
797
+ end
798
+ end
799
+
800
+ result
801
+ end
802
+
803
+ promise.execute
804
+ end
805
+
806
+ #
807
+ # Gets a collection of resource groups.
808
+ # @param next_page_link [String] The NextLink from the previous successful
809
+ # call to List operation.
810
+ # @param [Hash{String => String}] The hash of custom headers need to be
811
+ # applied to HTTP request.
812
+ #
813
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
814
+ # response.
815
+ #
816
+ def list_next(next_page_link, custom_headers = nil)
817
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
818
+ # Construct URL
819
+ path = "{nextLink}"
820
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
821
+ url = URI.parse(path)
822
+ properties = {}
823
+ unless url.query.nil?
824
+ url.query.split('&').each do |url_item|
825
+ url_items_parts = url_item.split('=')
826
+ properties[url_items_parts[0]] = url_items_parts[1]
827
+ end
828
+ end
829
+ properties.reject!{ |key, value| value.nil? }
830
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
831
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
832
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
833
+ url = URI.parse(corrected_url)
834
+
835
+ connection = Faraday.new(:url => url) do |faraday|
836
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
837
+ faraday.use :cookie_jar
838
+ faraday.adapter Faraday.default_adapter
839
+ end
840
+ request_headers = Hash.new
841
+
842
+ # Set Headers
843
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
844
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
845
+
846
+ unless custom_headers.nil?
847
+ custom_headers.each do |key, value|
848
+ request_headers[key] = value
849
+ end
850
+ end
851
+
852
+ # Send Request
853
+ promise = Concurrent::Promise.new do
854
+ connection.get do |request|
855
+ request.headers = request_headers
856
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
857
+ end
858
+ end
859
+
860
+ promise = promise.then do |http_response|
861
+ status_code = http_response.status
862
+ response_content = http_response.body
863
+ unless (status_code == 200)
864
+ error_model = JSON.load(response_content)
865
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
866
+ end
867
+
868
+ # Create Result
869
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
870
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
871
+ # Deserialize Response
872
+ if status_code == 200
873
+ begin
874
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
875
+ unless parsed_response.nil?
876
+ parsed_response = ResourceGroupListResult.deserialize_object(parsed_response)
877
+ end
878
+ result.body = parsed_response
879
+ rescue Exception => e
880
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
881
+ end
882
+ end
883
+
884
+ result
885
+ end
886
+
887
+ promise.execute
888
+ end
889
+
890
+ end
891
+ end