azure_mgmt_resources 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +13 -5
  2. data/README.md +1 -27
  3. data/azure_mgmt_resources.gemspec +2 -6
  4. data/lib/azure_mgmt_resources/deployment_operations.rb +161 -141
  5. data/lib/azure_mgmt_resources/deployments.rb +684 -310
  6. data/lib/azure_mgmt_resources/{Models → models}/basic_dependency.rb +1 -3
  7. data/lib/azure_mgmt_resources/models/debug_setting.rb +56 -0
  8. data/lib/azure_mgmt_resources/{Models → models}/dependency.rb +4 -6
  9. data/lib/azure_mgmt_resources/{Models → models}/deployment.rb +1 -3
  10. data/lib/azure_mgmt_resources/models/deployment_export_result.rb +56 -0
  11. data/lib/azure_mgmt_resources/{Models → models}/deployment_extended.rb +8 -9
  12. data/lib/azure_mgmt_resources/{Models → models}/deployment_extended_filter.rb +1 -3
  13. data/lib/azure_mgmt_resources/{Models → models}/deployment_list_result.rb +4 -6
  14. data/lib/azure_mgmt_resources/{Models → models}/deployment_mode.rb +2 -1
  15. data/lib/azure_mgmt_resources/{Models → models}/deployment_operation.rb +1 -3
  16. data/lib/azure_mgmt_resources/{Models → models}/deployment_operation_properties.rb +41 -2
  17. data/lib/azure_mgmt_resources/{Models → models}/deployment_operations_list_result.rb +4 -6
  18. data/lib/azure_mgmt_resources/{Models → models}/deployment_properties.rb +19 -4
  19. data/lib/azure_mgmt_resources/{Models → models}/deployment_properties_extended.rb +25 -10
  20. data/lib/azure_mgmt_resources/{Models → models}/deployment_validate_result.rb +1 -3
  21. data/lib/azure_mgmt_resources/models/export_template_request.rb +69 -0
  22. data/lib/azure_mgmt_resources/{Models → models}/generic_resource.rb +1 -3
  23. data/lib/azure_mgmt_resources/{Models → models}/generic_resource_filter.rb +1 -3
  24. data/lib/azure_mgmt_resources/models/http_message.rb +56 -0
  25. data/lib/azure_mgmt_resources/{Models → models}/parameters_link.rb +2 -4
  26. data/lib/azure_mgmt_resources/{Models → models}/plan.rb +1 -3
  27. data/lib/azure_mgmt_resources/{Models → models}/provider.rb +4 -6
  28. data/lib/azure_mgmt_resources/{Models → models}/provider_list_result.rb +4 -6
  29. data/lib/azure_mgmt_resources/{Models → models}/provider_resource_type.rb +1 -3
  30. data/lib/azure_mgmt_resources/{Models → models}/resource_group.rb +8 -9
  31. data/lib/azure_mgmt_resources/models/resource_group_export_result.rb +71 -0
  32. data/lib/azure_mgmt_resources/{Models → models}/resource_group_filter.rb +1 -3
  33. data/lib/azure_mgmt_resources/{Models → models}/resource_group_list_result.rb +11 -12
  34. data/lib/azure_mgmt_resources/{Models → models}/resource_group_properties.rb +1 -3
  35. data/lib/azure_mgmt_resources/{Models → models}/resource_list_result.rb +11 -12
  36. data/lib/azure_mgmt_resources/{Models → models}/resource_management_error_with_details.rb +29 -28
  37. data/lib/azure_mgmt_resources/{Models → models}/resource_provider_operation_definition.rb +1 -3
  38. data/lib/azure_mgmt_resources/{Models → models}/resource_provider_operation_detail_list_result.rb +4 -6
  39. data/lib/azure_mgmt_resources/{Models → models}/resource_provider_operation_display_properties.rb +1 -3
  40. data/lib/azure_mgmt_resources/{Models → models}/resources_move_info.rb +1 -3
  41. data/lib/azure_mgmt_resources/{Models → models}/tag_count.rb +1 -3
  42. data/lib/azure_mgmt_resources/{Models → models}/tag_details.rb +4 -6
  43. data/lib/azure_mgmt_resources/{Models → models}/tag_value.rb +1 -3
  44. data/lib/azure_mgmt_resources/{Models → models}/tags_list_result.rb +11 -12
  45. data/lib/azure_mgmt_resources/{Models → models}/target_resource.rb +1 -3
  46. data/lib/azure_mgmt_resources/{Models → models}/template_link.rb +2 -4
  47. data/lib/azure_mgmt_resources/module_definition.rb +5 -3
  48. data/lib/azure_mgmt_resources/providers.rb +265 -239
  49. data/lib/azure_mgmt_resources/resource_groups.rb +604 -465
  50. data/lib/azure_mgmt_resources/resource_management_client.rb +18 -11
  51. data/lib/azure_mgmt_resources/resource_provider_operation_details.rb +154 -47
  52. data/lib/azure_mgmt_resources/resources.rb +425 -380
  53. data/lib/azure_mgmt_resources/tags.rb +310 -288
  54. data/lib/azure_mgmt_resources/version.rb +5 -3
  55. data/lib/azure_mgmt_resources.rb +20 -19
  56. metadata +68 -126
  57. data/.travis.yml +0 -3
  58. data/Gemfile +0 -14
  59. data/lib/azure_mgmt_resources/Models/resource_group_extended.rb +0 -113
  60. data/lib/azure_mgmt_resources/Models/resource_group_extended_filter.rb +0 -63
  61. data/lib/azure_mgmt_resources/Models/resource_group_format_resource_properties.rb +0 -54
  62. data/lib/azure_mgmt_resources/Models/resource_management_error.rb +0 -77
@@ -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.17.0.0
3
3
  # Changes may cause incorrect behavior and will be lost if the code is
4
4
  # regenerated.
5
5
 
@@ -24,83 +24,88 @@ module Azure::ARM::Resources
24
24
 
25
25
  #
26
26
  # Unregisters provider from a subscription.
27
+ #
27
28
  # @param resource_provider_namespace [String] Namespace of the resource
28
29
  # provider.
29
- # @param [Hash{String => String}] The hash of custom headers need to be
30
- # applied to HTTP request.
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
31
32
  #
32
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
33
- # response.
33
+ # @return [Provider] operation results.
34
34
  #
35
35
  def unregister(resource_provider_namespace, custom_headers = nil)
36
+ response = unregister_async(resource_provider_namespace, custom_headers).value!
37
+ response.body unless response.nil?
38
+ end
39
+
40
+ #
41
+ # Unregisters provider from a subscription.
42
+ #
43
+ # @param resource_provider_namespace [String] Namespace of the resource
44
+ # provider.
45
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
46
+ # will be added to the HTTP request.
47
+ #
48
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
49
+ #
50
+ def unregister_with_http_info(resource_provider_namespace, custom_headers = nil)
51
+ unregister_async(resource_provider_namespace, custom_headers).value!
52
+ end
53
+
54
+ #
55
+ # Unregisters provider from a subscription.
56
+ #
57
+ # @param resource_provider_namespace [String] Namespace of the resource
58
+ # provider.
59
+ # @param [Hash{String => String}] A hash of custom headers that will be added
60
+ # to the HTTP request.
61
+ #
62
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
63
+ #
64
+ def unregister_async(resource_provider_namespace, custom_headers = nil)
36
65
  fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
37
66
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
38
67
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
39
- # Construct URL
40
- path = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"
41
- path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
42
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
43
- url = URI.join(@client.base_url, path)
44
- properties = {}
45
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
46
- unless url.query.nil?
47
- url.query.split('&').each do |url_item|
48
- url_items_parts = url_item.split('=')
49
- properties[url_items_parts[0]] = url_items_parts[1]
50
- end
51
- end
52
- properties.reject!{ |key, value| value.nil? }
53
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
54
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
55
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
56
- url = URI.parse(corrected_url)
57
-
58
- connection = Faraday.new(:url => url) do |faraday|
59
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
60
- faraday.use :cookie_jar
61
- faraday.adapter Faraday.default_adapter
62
- end
63
- request_headers = Hash.new
68
+ request_headers = {}
64
69
 
65
70
  # Set Headers
66
71
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
67
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
68
-
69
- unless custom_headers.nil?
70
- custom_headers.each do |key, value|
71
- request_headers[key] = value
72
- end
73
- end
74
-
75
- # Send Request
76
- promise = Concurrent::Promise.new do
77
- connection.post do |request|
78
- request.headers = request_headers
79
- @client.credentials.sign_request(request) unless @client.credentials.nil?
80
- end
72
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
73
+ path_template = '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'
74
+ options = {
75
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
76
+ path_params: {'resourceProviderNamespace' => resource_provider_namespace,'subscriptionId' => @client.subscription_id},
77
+ query_params: {'api-version' => @client.api_version},
78
+ headers: request_headers.merge(custom_headers || {})
79
+ }
80
+
81
+ request_url = @base_url || @client.base_url
82
+
83
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
84
+ promise = request.run_promise do |req|
85
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
81
86
  end
82
87
 
83
88
  promise = promise.then do |http_response|
84
89
  status_code = http_response.status
85
90
  response_content = http_response.body
86
- unless (status_code == 200)
91
+ unless status_code == 200
87
92
  error_model = JSON.load(response_content)
88
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
93
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
89
94
  end
90
95
 
91
96
  # Create Result
92
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
97
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
93
98
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
94
99
  # Deserialize Response
95
100
  if status_code == 200
96
101
  begin
97
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
102
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
98
103
  unless parsed_response.nil?
99
104
  parsed_response = Provider.deserialize_object(parsed_response)
100
105
  end
101
106
  result.body = parsed_response
102
107
  rescue Exception => e
103
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
108
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
104
109
  end
105
110
  end
106
111
 
@@ -112,83 +117,88 @@ module Azure::ARM::Resources
112
117
 
113
118
  #
114
119
  # Registers provider to be used with a subscription.
120
+ #
115
121
  # @param resource_provider_namespace [String] Namespace of the resource
116
122
  # provider.
117
- # @param [Hash{String => String}] The hash of custom headers need to be
118
- # applied to HTTP request.
123
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
124
+ # will be added to the HTTP request.
119
125
  #
120
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
121
- # response.
126
+ # @return [Provider] operation results.
122
127
  #
123
128
  def register(resource_provider_namespace, custom_headers = nil)
129
+ response = register_async(resource_provider_namespace, custom_headers).value!
130
+ response.body unless response.nil?
131
+ end
132
+
133
+ #
134
+ # Registers provider to be used with a subscription.
135
+ #
136
+ # @param resource_provider_namespace [String] Namespace of the resource
137
+ # provider.
138
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
139
+ # will be added to the HTTP request.
140
+ #
141
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
142
+ #
143
+ def register_with_http_info(resource_provider_namespace, custom_headers = nil)
144
+ register_async(resource_provider_namespace, custom_headers).value!
145
+ end
146
+
147
+ #
148
+ # Registers provider to be used with a subscription.
149
+ #
150
+ # @param resource_provider_namespace [String] Namespace of the resource
151
+ # provider.
152
+ # @param [Hash{String => String}] A hash of custom headers that will be added
153
+ # to the HTTP request.
154
+ #
155
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
156
+ #
157
+ def register_async(resource_provider_namespace, custom_headers = nil)
124
158
  fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
125
159
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
126
160
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
127
- # Construct URL
128
- path = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"
129
- path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
130
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
131
- url = URI.join(@client.base_url, path)
132
- properties = {}
133
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
134
- unless url.query.nil?
135
- url.query.split('&').each do |url_item|
136
- url_items_parts = url_item.split('=')
137
- properties[url_items_parts[0]] = url_items_parts[1]
138
- end
139
- end
140
- properties.reject!{ |key, value| value.nil? }
141
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
142
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
143
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
144
- url = URI.parse(corrected_url)
145
-
146
- connection = Faraday.new(:url => url) do |faraday|
147
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
148
- faraday.use :cookie_jar
149
- faraday.adapter Faraday.default_adapter
150
- end
151
- request_headers = Hash.new
161
+ request_headers = {}
152
162
 
153
163
  # Set Headers
154
164
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
155
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
156
-
157
- unless custom_headers.nil?
158
- custom_headers.each do |key, value|
159
- request_headers[key] = value
160
- end
161
- end
162
-
163
- # Send Request
164
- promise = Concurrent::Promise.new do
165
- connection.post do |request|
166
- request.headers = request_headers
167
- @client.credentials.sign_request(request) unless @client.credentials.nil?
168
- end
165
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
166
+ path_template = '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'
167
+ options = {
168
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
169
+ path_params: {'resourceProviderNamespace' => resource_provider_namespace,'subscriptionId' => @client.subscription_id},
170
+ query_params: {'api-version' => @client.api_version},
171
+ headers: request_headers.merge(custom_headers || {})
172
+ }
173
+
174
+ request_url = @base_url || @client.base_url
175
+
176
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
177
+ promise = request.run_promise do |req|
178
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
169
179
  end
170
180
 
171
181
  promise = promise.then do |http_response|
172
182
  status_code = http_response.status
173
183
  response_content = http_response.body
174
- unless (status_code == 200)
184
+ unless status_code == 200
175
185
  error_model = JSON.load(response_content)
176
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
186
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
177
187
  end
178
188
 
179
189
  # Create Result
180
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
190
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
181
191
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
182
192
  # Deserialize Response
183
193
  if status_code == 200
184
194
  begin
185
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
195
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
186
196
  unless parsed_response.nil?
187
197
  parsed_response = Provider.deserialize_object(parsed_response)
188
198
  end
189
199
  result.body = parsed_response
190
200
  rescue Exception => e
191
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
201
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
192
202
  end
193
203
  end
194
204
 
@@ -200,82 +210,87 @@ module Azure::ARM::Resources
200
210
 
201
211
  #
202
212
  # Gets a list of resource providers.
213
+ #
203
214
  # @param top [Integer] Query parameters. If null is passed returns all
204
215
  # deployments.
205
- # @param [Hash{String => String}] The hash of custom headers need to be
206
- # applied to HTTP request.
216
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
217
+ # will be added to the HTTP request.
207
218
  #
208
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
209
- # response.
219
+ # @return [ProviderListResult] operation results.
210
220
  #
211
221
  def list(top = nil, custom_headers = nil)
222
+ response = list_async(top, custom_headers).value!
223
+ response.body unless response.nil?
224
+ end
225
+
226
+ #
227
+ # Gets a list of resource providers.
228
+ #
229
+ # @param top [Integer] Query parameters. If null is passed returns all
230
+ # deployments.
231
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
232
+ # will be added to the HTTP request.
233
+ #
234
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
235
+ #
236
+ def list_with_http_info(top = nil, custom_headers = nil)
237
+ list_async(top, custom_headers).value!
238
+ end
239
+
240
+ #
241
+ # Gets a list of resource providers.
242
+ #
243
+ # @param top [Integer] Query parameters. If null is passed returns all
244
+ # deployments.
245
+ # @param [Hash{String => String}] A hash of custom headers that will be added
246
+ # to the HTTP request.
247
+ #
248
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
249
+ #
250
+ def list_async(top = nil, custom_headers = nil)
212
251
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
213
252
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
214
- # Construct URL
215
- path = "/subscriptions/{subscriptionId}/providers"
216
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
217
- url = URI.join(@client.base_url, path)
218
- properties = {}
219
- properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
220
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
221
- unless url.query.nil?
222
- url.query.split('&').each do |url_item|
223
- url_items_parts = url_item.split('=')
224
- properties[url_items_parts[0]] = url_items_parts[1]
225
- end
226
- end
227
- properties.reject!{ |key, value| value.nil? }
228
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
229
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
230
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
231
- url = URI.parse(corrected_url)
232
-
233
- connection = Faraday.new(:url => url) do |faraday|
234
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
235
- faraday.use :cookie_jar
236
- faraday.adapter Faraday.default_adapter
237
- end
238
- request_headers = Hash.new
253
+ request_headers = {}
239
254
 
240
255
  # Set Headers
241
256
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
242
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
243
-
244
- unless custom_headers.nil?
245
- custom_headers.each do |key, value|
246
- request_headers[key] = value
247
- end
248
- end
249
-
250
- # Send Request
251
- promise = Concurrent::Promise.new do
252
- connection.get do |request|
253
- request.headers = request_headers
254
- @client.credentials.sign_request(request) unless @client.credentials.nil?
255
- end
257
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
258
+ path_template = '/subscriptions/{subscriptionId}/providers'
259
+ options = {
260
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
261
+ path_params: {'subscriptionId' => @client.subscription_id},
262
+ query_params: {'$top' => top,'api-version' => @client.api_version},
263
+ headers: request_headers.merge(custom_headers || {})
264
+ }
265
+
266
+ request_url = @base_url || @client.base_url
267
+
268
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
269
+ promise = request.run_promise do |req|
270
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
256
271
  end
257
272
 
258
273
  promise = promise.then do |http_response|
259
274
  status_code = http_response.status
260
275
  response_content = http_response.body
261
- unless (status_code == 200)
276
+ unless status_code == 200
262
277
  error_model = JSON.load(response_content)
263
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
278
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
264
279
  end
265
280
 
266
281
  # Create Result
267
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
282
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
268
283
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
269
284
  # Deserialize Response
270
285
  if status_code == 200
271
286
  begin
272
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
287
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
273
288
  unless parsed_response.nil?
274
289
  parsed_response = ProviderListResult.deserialize_object(parsed_response)
275
290
  end
276
291
  result.body = parsed_response
277
292
  rescue Exception => e
278
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
293
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
279
294
  end
280
295
  end
281
296
 
@@ -287,83 +302,88 @@ module Azure::ARM::Resources
287
302
 
288
303
  #
289
304
  # Gets a resource provider.
305
+ #
290
306
  # @param resource_provider_namespace [String] Namespace of the resource
291
307
  # provider.
292
- # @param [Hash{String => String}] The hash of custom headers need to be
293
- # applied to HTTP request.
308
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
309
+ # will be added to the HTTP request.
294
310
  #
295
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
296
- # response.
311
+ # @return [Provider] operation results.
297
312
  #
298
313
  def get(resource_provider_namespace, custom_headers = nil)
314
+ response = get_async(resource_provider_namespace, custom_headers).value!
315
+ response.body unless response.nil?
316
+ end
317
+
318
+ #
319
+ # Gets a resource provider.
320
+ #
321
+ # @param resource_provider_namespace [String] Namespace of the resource
322
+ # provider.
323
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
324
+ # will be added to the HTTP request.
325
+ #
326
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
327
+ #
328
+ def get_with_http_info(resource_provider_namespace, custom_headers = nil)
329
+ get_async(resource_provider_namespace, custom_headers).value!
330
+ end
331
+
332
+ #
333
+ # Gets a resource provider.
334
+ #
335
+ # @param resource_provider_namespace [String] Namespace of the resource
336
+ # provider.
337
+ # @param [Hash{String => String}] A hash of custom headers that will be added
338
+ # to the HTTP request.
339
+ #
340
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
341
+ #
342
+ def get_async(resource_provider_namespace, custom_headers = nil)
299
343
  fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
300
344
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
301
345
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
302
- # Construct URL
303
- path = "/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"
304
- path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
305
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
306
- url = URI.join(@client.base_url, path)
307
- properties = {}
308
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
309
- unless url.query.nil?
310
- url.query.split('&').each do |url_item|
311
- url_items_parts = url_item.split('=')
312
- properties[url_items_parts[0]] = url_items_parts[1]
313
- end
314
- end
315
- properties.reject!{ |key, value| value.nil? }
316
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
317
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
318
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
319
- url = URI.parse(corrected_url)
320
-
321
- connection = Faraday.new(:url => url) do |faraday|
322
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
323
- faraday.use :cookie_jar
324
- faraday.adapter Faraday.default_adapter
325
- end
326
- request_headers = Hash.new
346
+ request_headers = {}
327
347
 
328
348
  # Set Headers
329
349
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
330
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
331
-
332
- unless custom_headers.nil?
333
- custom_headers.each do |key, value|
334
- request_headers[key] = value
335
- end
336
- end
337
-
338
- # Send Request
339
- promise = Concurrent::Promise.new do
340
- connection.get do |request|
341
- request.headers = request_headers
342
- @client.credentials.sign_request(request) unless @client.credentials.nil?
343
- end
350
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
351
+ path_template = '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'
352
+ options = {
353
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
354
+ path_params: {'resourceProviderNamespace' => resource_provider_namespace,'subscriptionId' => @client.subscription_id},
355
+ query_params: {'api-version' => @client.api_version},
356
+ headers: request_headers.merge(custom_headers || {})
357
+ }
358
+
359
+ request_url = @base_url || @client.base_url
360
+
361
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
362
+ promise = request.run_promise do |req|
363
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
344
364
  end
345
365
 
346
366
  promise = promise.then do |http_response|
347
367
  status_code = http_response.status
348
368
  response_content = http_response.body
349
- unless (status_code == 200)
369
+ unless status_code == 200
350
370
  error_model = JSON.load(response_content)
351
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
371
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
352
372
  end
353
373
 
354
374
  # Create Result
355
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
375
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
356
376
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
357
377
  # Deserialize Response
358
378
  if status_code == 200
359
379
  begin
360
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
380
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
361
381
  unless parsed_response.nil?
362
382
  parsed_response = Provider.deserialize_object(parsed_response)
363
383
  end
364
384
  result.body = parsed_response
365
385
  rescue Exception => e
366
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
386
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
367
387
  end
368
388
  end
369
389
 
@@ -375,79 +395,85 @@ module Azure::ARM::Resources
375
395
 
376
396
  #
377
397
  # Gets a list of resource providers.
398
+ #
378
399
  # @param next_page_link [String] The NextLink from the previous successful
379
400
  # call to List operation.
380
- # @param [Hash{String => String}] The hash of custom headers need to be
381
- # applied to HTTP request.
401
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
402
+ # will be added to the HTTP request.
382
403
  #
383
- # @return [Concurrent::Promise] Promise object which allows to get HTTP
384
- # response.
404
+ # @return [ProviderListResult] operation results.
385
405
  #
386
406
  def list_next(next_page_link, custom_headers = nil)
407
+ response = list_next_async(next_page_link, custom_headers).value!
408
+ response.body unless response.nil?
409
+ end
410
+
411
+ #
412
+ # Gets a list of resource providers.
413
+ #
414
+ # @param next_page_link [String] The NextLink from the previous successful
415
+ # call to List operation.
416
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
417
+ # will be added to the HTTP request.
418
+ #
419
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
420
+ #
421
+ def list_next_with_http_info(next_page_link, custom_headers = nil)
422
+ list_next_async(next_page_link, custom_headers).value!
423
+ end
424
+
425
+ #
426
+ # Gets a list of resource providers.
427
+ #
428
+ # @param next_page_link [String] The NextLink from the previous successful
429
+ # call to List operation.
430
+ # @param [Hash{String => String}] A hash of custom headers that will be added
431
+ # to the HTTP request.
432
+ #
433
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
434
+ #
435
+ def list_next_async(next_page_link, custom_headers = nil)
387
436
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
388
- # Construct URL
389
- path = "{nextLink}"
390
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
391
- url = URI.parse(path)
392
- properties = {}
393
- unless url.query.nil?
394
- url.query.split('&').each do |url_item|
395
- url_items_parts = url_item.split('=')
396
- properties[url_items_parts[0]] = url_items_parts[1]
397
- end
398
- end
399
- properties.reject!{ |key, value| value.nil? }
400
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
401
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
402
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
403
- url = URI.parse(corrected_url)
404
-
405
- connection = Faraday.new(:url => url) do |faraday|
406
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
407
- faraday.use :cookie_jar
408
- faraday.adapter Faraday.default_adapter
409
- end
410
- request_headers = Hash.new
437
+ request_headers = {}
411
438
 
412
439
  # Set Headers
413
440
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
414
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
415
-
416
- unless custom_headers.nil?
417
- custom_headers.each do |key, value|
418
- request_headers[key] = value
419
- end
420
- end
421
-
422
- # Send Request
423
- promise = Concurrent::Promise.new do
424
- connection.get do |request|
425
- request.headers = request_headers
426
- @client.credentials.sign_request(request) unless @client.credentials.nil?
427
- end
441
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
442
+ path_template = '{nextLink}'
443
+ options = {
444
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
445
+ skip_encoding_path_params: {'nextLink' => next_page_link},
446
+ headers: request_headers.merge(custom_headers || {})
447
+ }
448
+
449
+ request_url = @base_url || @client.base_url
450
+
451
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
452
+ promise = request.run_promise do |req|
453
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
428
454
  end
429
455
 
430
456
  promise = promise.then do |http_response|
431
457
  status_code = http_response.status
432
458
  response_content = http_response.body
433
- unless (status_code == 200)
459
+ unless status_code == 200
434
460
  error_model = JSON.load(response_content)
435
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
461
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
436
462
  end
437
463
 
438
464
  # Create Result
439
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
465
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
440
466
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
441
467
  # Deserialize Response
442
468
  if status_code == 200
443
469
  begin
444
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
470
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
445
471
  unless parsed_response.nil?
446
472
  parsed_response = ProviderListResult.deserialize_object(parsed_response)
447
473
  end
448
474
  result.body = parsed_response
449
475
  rescue Exception => e
450
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
476
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
451
477
  end
452
478
  end
453
479