azure_mgmt_resources 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/azure_mgmt_resources.gemspec +2 -7
  3. data/lib/azure_mgmt_resources.rb +21 -18
  4. data/lib/azure_mgmt_resources/deployment_operations.rb +54 -135
  5. data/lib/azure_mgmt_resources/deployments.rb +314 -305
  6. data/lib/azure_mgmt_resources/models/basic_dependency.rb +1 -3
  7. data/lib/azure_mgmt_resources/models/dependency.rb +4 -6
  8. data/lib/azure_mgmt_resources/models/deployment.rb +1 -3
  9. data/lib/azure_mgmt_resources/models/deployment_extended.rb +8 -9
  10. data/lib/azure_mgmt_resources/models/deployment_extended_filter.rb +1 -3
  11. data/lib/azure_mgmt_resources/models/deployment_list_result.rb +4 -6
  12. data/lib/azure_mgmt_resources/models/deployment_mode.rb +2 -1
  13. data/lib/azure_mgmt_resources/models/deployment_operation.rb +1 -3
  14. data/lib/azure_mgmt_resources/models/deployment_operation_properties.rb +1 -3
  15. data/lib/azure_mgmt_resources/models/deployment_operations_list_result.rb +4 -6
  16. data/lib/azure_mgmt_resources/models/deployment_properties.rb +3 -5
  17. data/lib/azure_mgmt_resources/models/deployment_properties_extended.rb +9 -11
  18. data/lib/azure_mgmt_resources/models/deployment_validate_result.rb +1 -3
  19. data/lib/azure_mgmt_resources/models/generic_resource.rb +1 -3
  20. data/lib/azure_mgmt_resources/models/generic_resource_filter.rb +1 -3
  21. data/lib/azure_mgmt_resources/models/parameters_link.rb +2 -4
  22. data/lib/azure_mgmt_resources/models/plan.rb +1 -3
  23. data/lib/azure_mgmt_resources/models/policy_assignment.rb +72 -0
  24. data/lib/azure_mgmt_resources/models/policy_assignment_list_result.rb +86 -0
  25. data/lib/azure_mgmt_resources/models/policy_assignment_properties.rb +74 -0
  26. data/lib/azure_mgmt_resources/models/policy_definition.rb +72 -0
  27. data/lib/azure_mgmt_resources/models/policy_definition_properties.rb +74 -0
  28. data/lib/azure_mgmt_resources/models/provider.rb +4 -6
  29. data/lib/azure_mgmt_resources/models/provider_list_result.rb +4 -6
  30. data/lib/azure_mgmt_resources/models/provider_resource_type.rb +1 -3
  31. data/lib/azure_mgmt_resources/models/resource_group.rb +8 -9
  32. data/lib/azure_mgmt_resources/models/resource_group_filter.rb +1 -3
  33. data/lib/azure_mgmt_resources/models/resource_group_list_result.rb +11 -12
  34. data/lib/azure_mgmt_resources/models/resource_group_properties.rb +1 -3
  35. data/lib/azure_mgmt_resources/models/resource_list_result.rb +11 -12
  36. data/lib/azure_mgmt_resources/models/resource_management_error.rb +3 -4
  37. data/lib/azure_mgmt_resources/models/resource_management_error_with_details.rb +23 -35
  38. data/lib/azure_mgmt_resources/models/resource_provider_operation_definition.rb +1 -3
  39. data/lib/azure_mgmt_resources/models/resource_provider_operation_detail_list_result.rb +4 -6
  40. data/lib/azure_mgmt_resources/models/resource_provider_operation_display_properties.rb +1 -3
  41. data/lib/azure_mgmt_resources/models/resources_move_info.rb +1 -3
  42. data/lib/azure_mgmt_resources/models/tag_count.rb +1 -3
  43. data/lib/azure_mgmt_resources/models/tag_details.rb +4 -6
  44. data/lib/azure_mgmt_resources/models/tag_value.rb +1 -3
  45. data/lib/azure_mgmt_resources/models/tags_list_result.rb +11 -12
  46. data/lib/azure_mgmt_resources/models/target_resource.rb +1 -3
  47. data/lib/azure_mgmt_resources/models/template_link.rb +2 -4
  48. data/lib/azure_mgmt_resources/module_definition.rb +5 -3
  49. data/lib/azure_mgmt_resources/policy_assignments.rb +922 -0
  50. data/lib/azure_mgmt_resources/policy_definitions.rb +208 -0
  51. data/lib/azure_mgmt_resources/providers.rb +90 -219
  52. data/lib/azure_mgmt_resources/resource_groups.rb +166 -434
  53. data/lib/azure_mgmt_resources/resource_management_client.rb +25 -10
  54. data/lib/azure_mgmt_resources/resource_provider_operation_details.rb +88 -43
  55. data/lib/azure_mgmt_resources/resources.rb +162 -366
  56. data/lib/azure_mgmt_resources/tags.rb +110 -264
  57. data/lib/azure_mgmt_resources/version.rb +5 -3
  58. metadata +12 -86
  59. data/.travis.yml +0 -3
  60. data/Gemfile +0 -14
  61. data/lib/azure_mgmt_resources/models/resource_group_extended.rb +0 -113
  62. data/lib/azure_mgmt_resources/models/resource_group_extended_filter.rb +0 -63
  63. data/lib/azure_mgmt_resources/models/resource_group_format_resource_properties.rb +0 -54
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
3
  # Changes may cause incorrect behavior and will be lost if the code is
4
4
  # regenerated.
5
5
 
@@ -24,6 +24,7 @@ module Azure::ARM::Resources
24
24
 
25
25
  #
26
26
  # Get all of the resources under a subscription.
27
+ #
27
28
  # @param resource_group_name [String] Query parameters. If null is passed
28
29
  # returns all resource groups.
29
30
  # @param filter [String] The filter to apply on the operation.
@@ -39,73 +40,44 @@ module Azure::ARM::Resources
39
40
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
40
41
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
41
42
  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
43
+ request_headers = {}
69
44
 
70
45
  # Set Headers
71
46
  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
47
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
48
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'
49
+ options = {
50
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
51
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
52
+ query_params: {'$filter' => filter,'$top' => top,'api-version' => @client.api_version},
53
+ headers: request_headers.merge(custom_headers || {})
54
+ }
55
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
56
+ promise = request.run_promise do |req|
57
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
86
58
  end
87
59
 
88
60
  promise = promise.then do |http_response|
89
61
  status_code = http_response.status
90
62
  response_content = http_response.body
91
- unless (status_code == 200)
63
+ unless status_code == 200
92
64
  error_model = JSON.load(response_content)
93
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
65
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
94
66
  end
95
67
 
96
68
  # Create Result
97
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
69
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
98
70
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
99
71
  # Deserialize Response
100
72
  if status_code == 200
101
73
  begin
102
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
74
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
103
75
  unless parsed_response.nil?
104
76
  parsed_response = ResourceListResult.deserialize_object(parsed_response)
105
77
  end
106
78
  result.body = parsed_response
107
79
  rescue Exception => e
108
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
80
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
109
81
  end
110
82
  end
111
83
 
@@ -117,6 +89,7 @@ module Azure::ARM::Resources
117
89
 
118
90
  #
119
91
  # Checks whether resource group exists.
92
+ #
120
93
  # @param resource_group_name [String] The name of the resource group to check.
121
94
  # The name is case insensitive.
122
95
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -129,60 +102,33 @@ module Azure::ARM::Resources
129
102
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
130
103
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
131
104
  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
105
+ request_headers = {}
157
106
 
158
107
  # Set Headers
159
108
  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
109
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
110
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'
111
+ options = {
112
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
113
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
114
+ query_params: {'api-version' => @client.api_version},
115
+ headers: request_headers.merge(custom_headers || {})
116
+ }
117
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :head, options)
118
+ promise = request.run_promise do |req|
119
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
174
120
  end
175
121
 
176
122
  promise = promise.then do |http_response|
177
123
  status_code = http_response.status
178
124
  response_content = http_response.body
179
- unless (status_code == 204 || status_code == 404)
125
+ unless status_code == 204 || status_code == 404
180
126
  error_model = JSON.load(response_content)
181
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
127
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
182
128
  end
183
129
 
184
130
  # Create Result
185
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
131
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
186
132
  result.body = (status_code == 204)
187
133
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
188
134
 
@@ -194,41 +140,7 @@ module Azure::ARM::Resources
194
140
 
195
141
  #
196
142
  # 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
143
  #
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
144
  # @param resource_group_name [String] The name of the resource group to be
233
145
  # created or updated.
234
146
  # @param parameters [ResourceGroup] Parameters supplied to the create or
@@ -239,97 +151,70 @@ module Azure::ARM::Resources
239
151
  # @return [Concurrent::Promise] Promise object which allows to get HTTP
240
152
  # response.
241
153
  #
242
- def begin_create_or_update(resource_group_name, parameters, custom_headers = nil)
154
+ def create_or_update(resource_group_name, parameters, custom_headers = nil)
243
155
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
244
156
  fail ArgumentError, 'parameters is nil' if parameters.nil?
245
157
  parameters.validate unless parameters.nil?
246
158
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
247
159
  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
160
+ request_headers = {}
273
161
 
274
162
  # Set Headers
275
163
  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
164
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
283
165
 
284
166
  # Serialize Request
285
- request_headers['Content-Type'] = 'application/json'
167
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
286
168
  unless parameters.nil?
287
169
  parameters = ResourceGroup.serialize_object(parameters)
288
170
  end
289
171
  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
172
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'
173
+ options = {
174
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
175
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
176
+ query_params: {'api-version' => @client.api_version},
177
+ body: request_content,
178
+ headers: request_headers.merge(custom_headers || {})
179
+ }
180
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
181
+ promise = request.run_promise do |req|
182
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
298
183
  end
299
184
 
300
185
  promise = promise.then do |http_response|
301
186
  status_code = http_response.status
302
187
  response_content = http_response.body
303
- unless (status_code == 201 || status_code == 200 || status_code == 202)
188
+ unless status_code == 201 || status_code == 200
304
189
  error_model = JSON.load(response_content)
305
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
190
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
306
191
  end
307
192
 
308
193
  # Create Result
309
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
194
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
310
195
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
311
196
  # Deserialize Response
312
197
  if status_code == 201
313
198
  begin
314
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
199
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
315
200
  unless parsed_response.nil?
316
201
  parsed_response = ResourceGroup.deserialize_object(parsed_response)
317
202
  end
318
203
  result.body = parsed_response
319
204
  rescue Exception => e
320
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
205
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
321
206
  end
322
207
  end
323
208
  # Deserialize Response
324
209
  if status_code == 200
325
210
  begin
326
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
211
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
327
212
  unless parsed_response.nil?
328
213
  parsed_response = ResourceGroup.deserialize_object(parsed_response)
329
214
  end
330
215
  result.body = parsed_response
331
216
  rescue Exception => e
332
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
217
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
333
218
  end
334
219
  end
335
220
 
@@ -342,6 +227,7 @@ module Azure::ARM::Resources
342
227
  #
343
228
  # Begin deleting resource group.To determine whether the operation has
344
229
  # finished processing the request, call GetLongRunningOperationStatus.
230
+ #
345
231
  # @param resource_group_name [String] The name of the resource group to be
346
232
  # deleted. The name is case insensitive.
347
233
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -357,7 +243,7 @@ module Azure::ARM::Resources
357
243
  end
358
244
 
359
245
  # Waiting for response.
360
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
246
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
361
247
  end
362
248
 
363
249
  promise
@@ -366,6 +252,7 @@ module Azure::ARM::Resources
366
252
  #
367
253
  # Begin deleting resource group.To determine whether the operation has
368
254
  # finished processing the request, call GetLongRunningOperationStatus.
255
+ #
369
256
  # @param resource_group_name [String] The name of the resource group to be
370
257
  # deleted. The name is case insensitive.
371
258
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -378,59 +265,33 @@ module Azure::ARM::Resources
378
265
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
379
266
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
380
267
  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
268
+ request_headers = {}
406
269
 
407
270
  # Set Headers
408
271
  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
272
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
273
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'
274
+ options = {
275
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
276
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
277
+ query_params: {'api-version' => @client.api_version},
278
+ headers: request_headers.merge(custom_headers || {})
279
+ }
280
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
281
+ promise = request.run_promise do |req|
282
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
423
283
  end
424
284
 
425
285
  promise = promise.then do |http_response|
426
286
  status_code = http_response.status
427
287
  response_content = http_response.body
428
- unless (status_code == 202 || status_code == 200)
429
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
288
+ unless status_code == 202 || status_code == 200
289
+ error_model = JSON.load(response_content)
290
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
430
291
  end
431
292
 
432
293
  # Create Result
433
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
294
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
434
295
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
435
296
 
436
297
  result
@@ -441,6 +302,7 @@ module Azure::ARM::Resources
441
302
 
442
303
  #
443
304
  # Get a resource group.
305
+ #
444
306
  # @param resource_group_name [String] The name of the resource group to get.
445
307
  # The name is case insensitive.
446
308
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -453,71 +315,44 @@ module Azure::ARM::Resources
453
315
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
454
316
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
455
317
  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
318
+ request_headers = {}
481
319
 
482
320
  # Set Headers
483
321
  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
322
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
323
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'
324
+ options = {
325
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
326
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
327
+ query_params: {'api-version' => @client.api_version},
328
+ headers: request_headers.merge(custom_headers || {})
329
+ }
330
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
331
+ promise = request.run_promise do |req|
332
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
498
333
  end
499
334
 
500
335
  promise = promise.then do |http_response|
501
336
  status_code = http_response.status
502
337
  response_content = http_response.body
503
- unless (status_code == 200)
338
+ unless status_code == 200
504
339
  error_model = JSON.load(response_content)
505
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
340
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
506
341
  end
507
342
 
508
343
  # Create Result
509
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
344
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
510
345
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
511
346
  # Deserialize Response
512
347
  if status_code == 200
513
348
  begin
514
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
349
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
515
350
  unless parsed_response.nil?
516
351
  parsed_response = ResourceGroup.deserialize_object(parsed_response)
517
352
  end
518
353
  result.body = parsed_response
519
354
  rescue Exception => e
520
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
355
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
521
356
  end
522
357
  end
523
358
 
@@ -532,6 +367,7 @@ module Azure::ARM::Resources
532
367
  # address. The format of the request is the same as that for creating a
533
368
  # resource groups, though if a field is unspecified current value will be
534
369
  # carried over.
370
+ #
535
371
  # @param resource_group_name [String] The name of the resource group to be
536
372
  # created or updated. The name is case insensitive.
537
373
  # @param parameters [ResourceGroup] Parameters supplied to the update state
@@ -548,79 +384,52 @@ module Azure::ARM::Resources
548
384
  parameters.validate unless parameters.nil?
549
385
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
550
386
  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
387
+ request_headers = {}
576
388
 
577
389
  # Set Headers
578
390
  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
391
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
586
392
 
587
393
  # Serialize Request
588
- request_headers['Content-Type'] = 'application/json'
394
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
589
395
  unless parameters.nil?
590
396
  parameters = ResourceGroup.serialize_object(parameters)
591
397
  end
592
398
  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
399
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'
400
+ options = {
401
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
402
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
403
+ query_params: {'api-version' => @client.api_version},
404
+ body: request_content,
405
+ headers: request_headers.merge(custom_headers || {})
406
+ }
407
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :patch, options)
408
+ promise = request.run_promise do |req|
409
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
601
410
  end
602
411
 
603
412
  promise = promise.then do |http_response|
604
413
  status_code = http_response.status
605
414
  response_content = http_response.body
606
- unless (status_code == 200)
415
+ unless status_code == 200
607
416
  error_model = JSON.load(response_content)
608
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
417
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
609
418
  end
610
419
 
611
420
  # Create Result
612
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
421
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
613
422
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
614
423
  # Deserialize Response
615
424
  if status_code == 200
616
425
  begin
617
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
426
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
618
427
  unless parsed_response.nil?
619
428
  parsed_response = ResourceGroup.deserialize_object(parsed_response)
620
429
  end
621
430
  result.body = parsed_response
622
431
  rescue Exception => e
623
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
432
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
624
433
  end
625
434
  end
626
435
 
@@ -632,6 +441,7 @@ module Azure::ARM::Resources
632
441
 
633
442
  #
634
443
  # Gets a collection of resource groups.
444
+ #
635
445
  # @param filter [String] The filter to apply on the operation.
636
446
  # @param top [Integer] Query parameters. If null is passed returns all
637
447
  # resource groups.
@@ -644,72 +454,44 @@ module Azure::ARM::Resources
644
454
  def list(filter = nil, top = nil, custom_headers = nil)
645
455
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
646
456
  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
457
+ request_headers = {}
673
458
 
674
459
  # Set Headers
675
460
  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
461
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
462
+ path_template = '/subscriptions/{subscriptionId}/resourcegroups'
463
+ options = {
464
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
465
+ path_params: {'subscriptionId' => @client.subscription_id},
466
+ query_params: {'$filter' => filter,'$top' => top,'api-version' => @client.api_version},
467
+ headers: request_headers.merge(custom_headers || {})
468
+ }
469
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
470
+ promise = request.run_promise do |req|
471
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
690
472
  end
691
473
 
692
474
  promise = promise.then do |http_response|
693
475
  status_code = http_response.status
694
476
  response_content = http_response.body
695
- unless (status_code == 200)
477
+ unless status_code == 200
696
478
  error_model = JSON.load(response_content)
697
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
479
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
698
480
  end
699
481
 
700
482
  # Create Result
701
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
483
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
702
484
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
703
485
  # Deserialize Response
704
486
  if status_code == 200
705
487
  begin
706
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
488
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
707
489
  unless parsed_response.nil?
708
490
  parsed_response = ResourceGroupListResult.deserialize_object(parsed_response)
709
491
  end
710
492
  result.body = parsed_response
711
493
  rescue Exception => e
712
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
494
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
713
495
  end
714
496
  end
715
497
 
@@ -721,6 +503,7 @@ module Azure::ARM::Resources
721
503
 
722
504
  #
723
505
  # Get all of the resources under a subscription.
506
+ #
724
507
  # @param next_page_link [String] The NextLink from the previous successful
725
508
  # call to List operation.
726
509
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -731,69 +514,43 @@ module Azure::ARM::Resources
731
514
  #
732
515
  def list_resources_next(next_page_link, custom_headers = nil)
733
516
  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
517
+ request_headers = {}
757
518
 
758
519
  # Set Headers
759
520
  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
521
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
522
+ path_template = '{nextLink}'
523
+ options = {
524
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
525
+ skip_encoding_path_params: {'nextLink' => next_page_link},
526
+ headers: request_headers.merge(custom_headers || {})
527
+ }
528
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
529
+ promise = request.run_promise do |req|
530
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
774
531
  end
775
532
 
776
533
  promise = promise.then do |http_response|
777
534
  status_code = http_response.status
778
535
  response_content = http_response.body
779
- unless (status_code == 200)
536
+ unless status_code == 200
780
537
  error_model = JSON.load(response_content)
781
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
538
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
782
539
  end
783
540
 
784
541
  # Create Result
785
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
542
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
786
543
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
787
544
  # Deserialize Response
788
545
  if status_code == 200
789
546
  begin
790
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
547
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
791
548
  unless parsed_response.nil?
792
549
  parsed_response = ResourceListResult.deserialize_object(parsed_response)
793
550
  end
794
551
  result.body = parsed_response
795
552
  rescue Exception => e
796
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
553
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
797
554
  end
798
555
  end
799
556
 
@@ -805,6 +562,7 @@ module Azure::ARM::Resources
805
562
 
806
563
  #
807
564
  # Gets a collection of resource groups.
565
+ #
808
566
  # @param next_page_link [String] The NextLink from the previous successful
809
567
  # call to List operation.
810
568
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -815,69 +573,43 @@ module Azure::ARM::Resources
815
573
  #
816
574
  def list_next(next_page_link, custom_headers = nil)
817
575
  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
576
+ request_headers = {}
841
577
 
842
578
  # Set Headers
843
579
  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
580
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
581
+ path_template = '{nextLink}'
582
+ options = {
583
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
584
+ skip_encoding_path_params: {'nextLink' => next_page_link},
585
+ headers: request_headers.merge(custom_headers || {})
586
+ }
587
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
588
+ promise = request.run_promise do |req|
589
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
858
590
  end
859
591
 
860
592
  promise = promise.then do |http_response|
861
593
  status_code = http_response.status
862
594
  response_content = http_response.body
863
- unless (status_code == 200)
595
+ unless status_code == 200
864
596
  error_model = JSON.load(response_content)
865
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
597
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
866
598
  end
867
599
 
868
600
  # Create Result
869
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
601
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
870
602
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
871
603
  # Deserialize Response
872
604
  if status_code == 200
873
605
  begin
874
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
606
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
875
607
  unless parsed_response.nil?
876
608
  parsed_response = ResourceGroupListResult.deserialize_object(parsed_response)
877
609
  end
878
610
  result.body = parsed_response
879
611
  rescue Exception => e
880
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
612
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
881
613
  end
882
614
  end
883
615