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
  # Delete a subscription resource tag value.
27
+ #
27
28
  # @param tag_name [String] The name of the tag.
28
29
  # @param tag_value [String] The value of the tag.
29
30
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -37,60 +38,33 @@ module Azure::ARM::Resources
37
38
  fail ArgumentError, 'tag_value is nil' if tag_value.nil?
38
39
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
39
40
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
40
- # Construct URL
41
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"
42
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
43
- path['{tagValue}'] = ERB::Util.url_encode(tag_value) if path.include?('{tagValue}')
44
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
45
- url = URI.join(@client.base_url, path)
46
- properties = {}
47
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
48
- unless url.query.nil?
49
- url.query.split('&').each do |url_item|
50
- url_items_parts = url_item.split('=')
51
- properties[url_items_parts[0]] = url_items_parts[1]
52
- end
53
- end
54
- properties.reject!{ |key, value| value.nil? }
55
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
56
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
57
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
58
- url = URI.parse(corrected_url)
59
-
60
- connection = Faraday.new(:url => url) do |faraday|
61
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
62
- faraday.use :cookie_jar
63
- faraday.adapter Faraday.default_adapter
64
- end
65
- request_headers = Hash.new
41
+ request_headers = {}
66
42
 
67
43
  # Set Headers
68
44
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
69
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
70
-
71
- unless custom_headers.nil?
72
- custom_headers.each do |key, value|
73
- request_headers[key] = value
74
- end
75
- end
76
-
77
- # Send Request
78
- promise = Concurrent::Promise.new do
79
- connection.delete do |request|
80
- request.headers = request_headers
81
- @client.credentials.sign_request(request) unless @client.credentials.nil?
82
- end
45
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
46
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'
47
+ options = {
48
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
49
+ path_params: {'tagName' => tag_name,'tagValue' => tag_value,'subscriptionId' => @client.subscription_id},
50
+ query_params: {'api-version' => @client.api_version},
51
+ headers: request_headers.merge(custom_headers || {})
52
+ }
53
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
54
+ promise = request.run_promise do |req|
55
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
83
56
  end
84
57
 
85
58
  promise = promise.then do |http_response|
86
59
  status_code = http_response.status
87
60
  response_content = http_response.body
88
- unless (status_code == 200 || status_code == 204)
89
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
61
+ unless status_code == 200 || status_code == 204
62
+ error_model = JSON.load(response_content)
63
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
90
64
  end
91
65
 
92
66
  # Create Result
93
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
67
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
94
68
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
95
69
 
96
70
  result
@@ -101,6 +75,7 @@ module Azure::ARM::Resources
101
75
 
102
76
  #
103
77
  # Create a subscription resource tag value.
78
+ #
104
79
  # @param tag_name [String] The name of the tag.
105
80
  # @param tag_value [String] The value of the tag.
106
81
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -114,84 +89,56 @@ module Azure::ARM::Resources
114
89
  fail ArgumentError, 'tag_value is nil' if tag_value.nil?
115
90
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
116
91
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
117
- # Construct URL
118
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"
119
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
120
- path['{tagValue}'] = ERB::Util.url_encode(tag_value) if path.include?('{tagValue}')
121
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
122
- url = URI.join(@client.base_url, path)
123
- properties = {}
124
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
125
- unless url.query.nil?
126
- url.query.split('&').each do |url_item|
127
- url_items_parts = url_item.split('=')
128
- properties[url_items_parts[0]] = url_items_parts[1]
129
- end
130
- end
131
- properties.reject!{ |key, value| value.nil? }
132
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
133
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
134
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
135
- url = URI.parse(corrected_url)
136
-
137
- connection = Faraday.new(:url => url) do |faraday|
138
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
139
- faraday.use :cookie_jar
140
- faraday.adapter Faraday.default_adapter
141
- end
142
- request_headers = Hash.new
92
+ request_headers = {}
143
93
 
144
94
  # Set Headers
145
95
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
146
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
147
-
148
- unless custom_headers.nil?
149
- custom_headers.each do |key, value|
150
- request_headers[key] = value
151
- end
152
- end
153
-
154
- # Send Request
155
- promise = Concurrent::Promise.new do
156
- connection.put do |request|
157
- request.headers = request_headers
158
- @client.credentials.sign_request(request) unless @client.credentials.nil?
159
- end
96
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
97
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'
98
+ options = {
99
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
100
+ path_params: {'tagName' => tag_name,'tagValue' => tag_value,'subscriptionId' => @client.subscription_id},
101
+ query_params: {'api-version' => @client.api_version},
102
+ headers: request_headers.merge(custom_headers || {})
103
+ }
104
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
105
+ promise = request.run_promise do |req|
106
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
160
107
  end
161
108
 
162
109
  promise = promise.then do |http_response|
163
110
  status_code = http_response.status
164
111
  response_content = http_response.body
165
- unless (status_code == 200 || status_code == 201)
112
+ unless status_code == 200 || status_code == 201
166
113
  error_model = JSON.load(response_content)
167
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
114
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
168
115
  end
169
116
 
170
117
  # Create Result
171
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
118
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
172
119
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
173
120
  # Deserialize Response
174
121
  if status_code == 200
175
122
  begin
176
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
123
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
177
124
  unless parsed_response.nil?
178
125
  parsed_response = TagValue.deserialize_object(parsed_response)
179
126
  end
180
127
  result.body = parsed_response
181
128
  rescue Exception => e
182
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
129
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
183
130
  end
184
131
  end
185
132
  # Deserialize Response
186
133
  if status_code == 201
187
134
  begin
188
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
135
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
189
136
  unless parsed_response.nil?
190
137
  parsed_response = TagValue.deserialize_object(parsed_response)
191
138
  end
192
139
  result.body = parsed_response
193
140
  rescue Exception => e
194
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
141
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
195
142
  end
196
143
  end
197
144
 
@@ -203,6 +150,7 @@ module Azure::ARM::Resources
203
150
 
204
151
  #
205
152
  # Create a subscription resource tag.
153
+ #
206
154
  # @param tag_name [String] The name of the tag.
207
155
  # @param [Hash{String => String}] The hash of custom headers need to be
208
156
  # applied to HTTP request.
@@ -214,83 +162,56 @@ module Azure::ARM::Resources
214
162
  fail ArgumentError, 'tag_name is nil' if tag_name.nil?
215
163
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
216
164
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
217
- # Construct URL
218
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}"
219
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
220
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
221
- url = URI.join(@client.base_url, path)
222
- properties = {}
223
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
224
- unless url.query.nil?
225
- url.query.split('&').each do |url_item|
226
- url_items_parts = url_item.split('=')
227
- properties[url_items_parts[0]] = url_items_parts[1]
228
- end
229
- end
230
- properties.reject!{ |key, value| value.nil? }
231
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
232
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
233
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
234
- url = URI.parse(corrected_url)
235
-
236
- connection = Faraday.new(:url => url) do |faraday|
237
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
238
- faraday.use :cookie_jar
239
- faraday.adapter Faraday.default_adapter
240
- end
241
- request_headers = Hash.new
165
+ request_headers = {}
242
166
 
243
167
  # Set Headers
244
168
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
245
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
246
-
247
- unless custom_headers.nil?
248
- custom_headers.each do |key, value|
249
- request_headers[key] = value
250
- end
251
- end
252
-
253
- # Send Request
254
- promise = Concurrent::Promise.new do
255
- connection.put do |request|
256
- request.headers = request_headers
257
- @client.credentials.sign_request(request) unless @client.credentials.nil?
258
- end
169
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
170
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}'
171
+ options = {
172
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
173
+ path_params: {'tagName' => tag_name,'subscriptionId' => @client.subscription_id},
174
+ query_params: {'api-version' => @client.api_version},
175
+ headers: request_headers.merge(custom_headers || {})
176
+ }
177
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
178
+ promise = request.run_promise do |req|
179
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
259
180
  end
260
181
 
261
182
  promise = promise.then do |http_response|
262
183
  status_code = http_response.status
263
184
  response_content = http_response.body
264
- unless (status_code == 200 || status_code == 201)
185
+ unless status_code == 200 || status_code == 201
265
186
  error_model = JSON.load(response_content)
266
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
187
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
267
188
  end
268
189
 
269
190
  # Create Result
270
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
191
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
271
192
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
272
193
  # Deserialize Response
273
194
  if status_code == 200
274
195
  begin
275
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
196
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
276
197
  unless parsed_response.nil?
277
198
  parsed_response = TagDetails.deserialize_object(parsed_response)
278
199
  end
279
200
  result.body = parsed_response
280
201
  rescue Exception => e
281
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
202
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
282
203
  end
283
204
  end
284
205
  # Deserialize Response
285
206
  if status_code == 201
286
207
  begin
287
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
208
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
288
209
  unless parsed_response.nil?
289
210
  parsed_response = TagDetails.deserialize_object(parsed_response)
290
211
  end
291
212
  result.body = parsed_response
292
213
  rescue Exception => e
293
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
214
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
294
215
  end
295
216
  end
296
217
 
@@ -302,6 +223,7 @@ module Azure::ARM::Resources
302
223
 
303
224
  #
304
225
  # Delete a subscription resource tag.
226
+ #
305
227
  # @param tag_name [String] The name of the tag.
306
228
  # @param [Hash{String => String}] The hash of custom headers need to be
307
229
  # applied to HTTP request.
@@ -313,59 +235,33 @@ module Azure::ARM::Resources
313
235
  fail ArgumentError, 'tag_name is nil' if tag_name.nil?
314
236
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
315
237
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
316
- # Construct URL
317
- path = "/subscriptions/{subscriptionId}/tagNames/{tagName}"
318
- path['{tagName}'] = ERB::Util.url_encode(tag_name) if path.include?('{tagName}')
319
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
320
- url = URI.join(@client.base_url, path)
321
- properties = {}
322
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
323
- unless url.query.nil?
324
- url.query.split('&').each do |url_item|
325
- url_items_parts = url_item.split('=')
326
- properties[url_items_parts[0]] = url_items_parts[1]
327
- end
328
- end
329
- properties.reject!{ |key, value| value.nil? }
330
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
331
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
332
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
333
- url = URI.parse(corrected_url)
334
-
335
- connection = Faraday.new(:url => url) do |faraday|
336
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
337
- faraday.use :cookie_jar
338
- faraday.adapter Faraday.default_adapter
339
- end
340
- request_headers = Hash.new
238
+ request_headers = {}
341
239
 
342
240
  # Set Headers
343
241
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
344
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
345
-
346
- unless custom_headers.nil?
347
- custom_headers.each do |key, value|
348
- request_headers[key] = value
349
- end
350
- end
351
-
352
- # Send Request
353
- promise = Concurrent::Promise.new do
354
- connection.delete do |request|
355
- request.headers = request_headers
356
- @client.credentials.sign_request(request) unless @client.credentials.nil?
357
- end
242
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
243
+ path_template = '/subscriptions/{subscriptionId}/tagNames/{tagName}'
244
+ options = {
245
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
246
+ path_params: {'tagName' => tag_name,'subscriptionId' => @client.subscription_id},
247
+ query_params: {'api-version' => @client.api_version},
248
+ headers: request_headers.merge(custom_headers || {})
249
+ }
250
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
251
+ promise = request.run_promise do |req|
252
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
358
253
  end
359
254
 
360
255
  promise = promise.then do |http_response|
361
256
  status_code = http_response.status
362
257
  response_content = http_response.body
363
- unless (status_code == 200 || status_code == 204)
364
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
258
+ unless status_code == 200 || status_code == 204
259
+ error_model = JSON.load(response_content)
260
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
365
261
  end
366
262
 
367
263
  # Create Result
368
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
264
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
369
265
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
370
266
 
371
267
  result
@@ -376,6 +272,7 @@ module Azure::ARM::Resources
376
272
 
377
273
  #
378
274
  # Get a list of subscription resource tags.
275
+ #
379
276
  # @param [Hash{String => String}] The hash of custom headers need to be
380
277
  # applied to HTTP request.
381
278
  #
@@ -385,70 +282,44 @@ module Azure::ARM::Resources
385
282
  def list(custom_headers = nil)
386
283
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
387
284
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
388
- # Construct URL
389
- path = "/subscriptions/{subscriptionId}/tagNames"
390
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
391
- url = URI.join(@client.base_url, path)
392
- properties = {}
393
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
394
- unless url.query.nil?
395
- url.query.split('&').each do |url_item|
396
- url_items_parts = url_item.split('=')
397
- properties[url_items_parts[0]] = url_items_parts[1]
398
- end
399
- end
400
- properties.reject!{ |key, value| value.nil? }
401
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
402
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
403
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
404
- url = URI.parse(corrected_url)
405
-
406
- connection = Faraday.new(:url => url) do |faraday|
407
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
408
- faraday.use :cookie_jar
409
- faraday.adapter Faraday.default_adapter
410
- end
411
- request_headers = Hash.new
285
+ request_headers = {}
412
286
 
413
287
  # Set Headers
414
288
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
415
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
416
-
417
- unless custom_headers.nil?
418
- custom_headers.each do |key, value|
419
- request_headers[key] = value
420
- end
421
- end
422
-
423
- # Send Request
424
- promise = Concurrent::Promise.new do
425
- connection.get do |request|
426
- request.headers = request_headers
427
- @client.credentials.sign_request(request) unless @client.credentials.nil?
428
- end
289
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
290
+ path_template = '/subscriptions/{subscriptionId}/tagNames'
291
+ options = {
292
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
293
+ path_params: {'subscriptionId' => @client.subscription_id},
294
+ query_params: {'api-version' => @client.api_version},
295
+ headers: request_headers.merge(custom_headers || {})
296
+ }
297
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
298
+ promise = request.run_promise do |req|
299
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
429
300
  end
430
301
 
431
302
  promise = promise.then do |http_response|
432
303
  status_code = http_response.status
433
304
  response_content = http_response.body
434
- unless (status_code == 200)
305
+ unless status_code == 200
435
306
  error_model = JSON.load(response_content)
436
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
307
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
437
308
  end
438
309
 
439
310
  # Create Result
440
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
311
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
441
312
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
442
313
  # Deserialize Response
443
314
  if status_code == 200
444
315
  begin
445
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
316
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
446
317
  unless parsed_response.nil?
447
318
  parsed_response = TagsListResult.deserialize_object(parsed_response)
448
319
  end
449
320
  result.body = parsed_response
450
321
  rescue Exception => e
451
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
322
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
452
323
  end
453
324
  end
454
325
 
@@ -460,6 +331,7 @@ module Azure::ARM::Resources
460
331
 
461
332
  #
462
333
  # Get a list of subscription resource tags.
334
+ #
463
335
  # @param next_page_link [String] The NextLink from the previous successful
464
336
  # call to List operation.
465
337
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -470,69 +342,43 @@ module Azure::ARM::Resources
470
342
  #
471
343
  def list_next(next_page_link, custom_headers = nil)
472
344
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
473
- # Construct URL
474
- path = "{nextLink}"
475
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
476
- url = URI.parse(path)
477
- properties = {}
478
- unless url.query.nil?
479
- url.query.split('&').each do |url_item|
480
- url_items_parts = url_item.split('=')
481
- properties[url_items_parts[0]] = url_items_parts[1]
482
- end
483
- end
484
- properties.reject!{ |key, value| value.nil? }
485
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
486
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
487
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
488
- url = URI.parse(corrected_url)
489
-
490
- connection = Faraday.new(:url => url) do |faraday|
491
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
492
- faraday.use :cookie_jar
493
- faraday.adapter Faraday.default_adapter
494
- end
495
- request_headers = Hash.new
345
+ request_headers = {}
496
346
 
497
347
  # Set Headers
498
348
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
499
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
500
-
501
- unless custom_headers.nil?
502
- custom_headers.each do |key, value|
503
- request_headers[key] = value
504
- end
505
- end
506
-
507
- # Send Request
508
- promise = Concurrent::Promise.new do
509
- connection.get do |request|
510
- request.headers = request_headers
511
- @client.credentials.sign_request(request) unless @client.credentials.nil?
512
- end
349
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
350
+ path_template = '{nextLink}'
351
+ options = {
352
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
353
+ skip_encoding_path_params: {'nextLink' => next_page_link},
354
+ headers: request_headers.merge(custom_headers || {})
355
+ }
356
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
357
+ promise = request.run_promise do |req|
358
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
513
359
  end
514
360
 
515
361
  promise = promise.then do |http_response|
516
362
  status_code = http_response.status
517
363
  response_content = http_response.body
518
- unless (status_code == 200)
364
+ unless status_code == 200
519
365
  error_model = JSON.load(response_content)
520
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
366
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
521
367
  end
522
368
 
523
369
  # Create Result
524
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
370
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
525
371
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
526
372
  # Deserialize Response
527
373
  if status_code == 200
528
374
  begin
529
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
375
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
530
376
  unless parsed_response.nil?
531
377
  parsed_response = TagsListResult.deserialize_object(parsed_response)
532
378
  end
533
379
  result.body = parsed_response
534
380
  rescue Exception => e
535
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
381
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
536
382
  end
537
383
  end
538
384