azure_mgmt_resources 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +3 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +106 -0
- data/Rakefile +5 -0
- data/azure_mgmt_resources.gemspec +38 -0
- data/lib/azure_mgmt_resources.rb +74 -0
- data/lib/azure_mgmt_resources/Models/basic_dependency.rb +76 -0
- data/lib/azure_mgmt_resources/Models/dependency.rb +105 -0
- data/lib/azure_mgmt_resources/Models/deployment.rb +64 -0
- data/lib/azure_mgmt_resources/Models/deployment_extended.rb +83 -0
- data/lib/azure_mgmt_resources/Models/deployment_extended_filter.rb +58 -0
- data/lib/azure_mgmt_resources/Models/deployment_list_result.rb +88 -0
- data/lib/azure_mgmt_resources/Models/deployment_mode.rb +15 -0
- data/lib/azure_mgmt_resources/Models/deployment_operation.rb +83 -0
- data/lib/azure_mgmt_resources/Models/deployment_operation_properties.rb +102 -0
- data/lib/azure_mgmt_resources/Models/deployment_operations_list_result.rb +88 -0
- data/lib/azure_mgmt_resources/Models/deployment_properties.rb +116 -0
- data/lib/azure_mgmt_resources/Models/deployment_properties_extended.rb +216 -0
- data/lib/azure_mgmt_resources/Models/deployment_validate_result.rb +82 -0
- data/lib/azure_mgmt_resources/Models/generic_resource.rb +103 -0
- data/lib/azure_mgmt_resources/Models/generic_resource_filter.rb +76 -0
- data/lib/azure_mgmt_resources/Models/parameters_link.rb +68 -0
- data/lib/azure_mgmt_resources/Models/plan.rb +85 -0
- data/lib/azure_mgmt_resources/Models/provider.rb +106 -0
- data/lib/azure_mgmt_resources/Models/provider_list_result.rb +87 -0
- data/lib/azure_mgmt_resources/Models/provider_resource_type.rb +88 -0
- data/lib/azure_mgmt_resources/Models/resource_group.rb +105 -0
- data/lib/azure_mgmt_resources/Models/resource_group_extended.rb +113 -0
- data/lib/azure_mgmt_resources/Models/resource_group_extended_filter.rb +63 -0
- data/lib/azure_mgmt_resources/Models/resource_group_filter.rb +67 -0
- data/lib/azure_mgmt_resources/Models/resource_group_format_resource_properties.rb +54 -0
- data/lib/azure_mgmt_resources/Models/resource_group_list_result.rb +88 -0
- data/lib/azure_mgmt_resources/Models/resource_group_properties.rb +58 -0
- data/lib/azure_mgmt_resources/Models/resource_list_result.rb +88 -0
- data/lib/azure_mgmt_resources/Models/resource_management_error.rb +77 -0
- data/lib/azure_mgmt_resources/Models/resource_management_error_with_details.rb +106 -0
- data/lib/azure_mgmt_resources/Models/resource_provider_operation_definition.rb +74 -0
- data/lib/azure_mgmt_resources/Models/resource_provider_operation_detail_list_result.rb +80 -0
- data/lib/azure_mgmt_resources/Models/resource_provider_operation_display_properties.rb +95 -0
- data/lib/azure_mgmt_resources/Models/resources_move_info.rb +67 -0
- data/lib/azure_mgmt_resources/Models/tag_count.rb +67 -0
- data/lib/azure_mgmt_resources/Models/tag_details.rb +112 -0
- data/lib/azure_mgmt_resources/Models/tag_value.rb +82 -0
- data/lib/azure_mgmt_resources/Models/tags_list_result.rb +87 -0
- data/lib/azure_mgmt_resources/Models/target_resource.rb +76 -0
- data/lib/azure_mgmt_resources/Models/template_link.rb +68 -0
- data/lib/azure_mgmt_resources/deployment_operations.rb +297 -0
- data/lib/azure_mgmt_resources/deployments.rb +601 -0
- data/lib/azure_mgmt_resources/module_definition.rb +6 -0
- data/lib/azure_mgmt_resources/providers.rb +461 -0
- data/lib/azure_mgmt_resources/resource_groups.rb +891 -0
- data/lib/azure_mgmt_resources/resource_management_client.rb +85 -0
- data/lib/azure_mgmt_resources/resource_provider_operation_details.rb +126 -0
- data/lib/azure_mgmt_resources/resources.rb +737 -0
- data/lib/azure_mgmt_resources/tags.rb +546 -0
- data/lib/azure_mgmt_resources/version.rb +6 -0
- metadata +235 -0
@@ -0,0 +1,461 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::ARM::Resources
|
7
|
+
#
|
8
|
+
# Providers
|
9
|
+
#
|
10
|
+
class Providers
|
11
|
+
include Azure::ARM::Resources::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the Providers class.
|
16
|
+
# @param client service class for accessing basic functionality.
|
17
|
+
#
|
18
|
+
def initialize(client)
|
19
|
+
@client = client
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return reference to the ResourceManagementClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# Unregisters provider from a subscription.
|
27
|
+
# @param resource_provider_namespace [String] Namespace of the resource
|
28
|
+
# provider.
|
29
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
30
|
+
# applied to HTTP request.
|
31
|
+
#
|
32
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
33
|
+
# response.
|
34
|
+
#
|
35
|
+
def unregister(resource_provider_namespace, custom_headers = nil)
|
36
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
37
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
38
|
+
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
|
64
|
+
|
65
|
+
# Set Headers
|
66
|
+
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
|
81
|
+
end
|
82
|
+
|
83
|
+
promise = promise.then do |http_response|
|
84
|
+
status_code = http_response.status
|
85
|
+
response_content = http_response.body
|
86
|
+
unless (status_code == 200)
|
87
|
+
error_model = JSON.load(response_content)
|
88
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Create Result
|
92
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
93
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
94
|
+
# Deserialize Response
|
95
|
+
if status_code == 200
|
96
|
+
begin
|
97
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
98
|
+
unless parsed_response.nil?
|
99
|
+
parsed_response = Provider.deserialize_object(parsed_response)
|
100
|
+
end
|
101
|
+
result.body = parsed_response
|
102
|
+
rescue Exception => e
|
103
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
promise.execute
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Registers provider to be used with a subscription.
|
115
|
+
# @param resource_provider_namespace [String] Namespace of the resource
|
116
|
+
# provider.
|
117
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
118
|
+
# applied to HTTP request.
|
119
|
+
#
|
120
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
121
|
+
# response.
|
122
|
+
#
|
123
|
+
def register(resource_provider_namespace, custom_headers = nil)
|
124
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
125
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
126
|
+
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
|
152
|
+
|
153
|
+
# Set Headers
|
154
|
+
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
|
169
|
+
end
|
170
|
+
|
171
|
+
promise = promise.then do |http_response|
|
172
|
+
status_code = http_response.status
|
173
|
+
response_content = http_response.body
|
174
|
+
unless (status_code == 200)
|
175
|
+
error_model = JSON.load(response_content)
|
176
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Create Result
|
180
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
181
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
182
|
+
# Deserialize Response
|
183
|
+
if status_code == 200
|
184
|
+
begin
|
185
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
186
|
+
unless parsed_response.nil?
|
187
|
+
parsed_response = Provider.deserialize_object(parsed_response)
|
188
|
+
end
|
189
|
+
result.body = parsed_response
|
190
|
+
rescue Exception => e
|
191
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
result
|
196
|
+
end
|
197
|
+
|
198
|
+
promise.execute
|
199
|
+
end
|
200
|
+
|
201
|
+
#
|
202
|
+
# Gets a list of resource providers.
|
203
|
+
# @param top [Integer] Query parameters. If null is passed returns all
|
204
|
+
# deployments.
|
205
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
206
|
+
# applied to HTTP request.
|
207
|
+
#
|
208
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
209
|
+
# response.
|
210
|
+
#
|
211
|
+
def list(top = nil, custom_headers = nil)
|
212
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
213
|
+
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
|
239
|
+
|
240
|
+
# Set Headers
|
241
|
+
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
|
256
|
+
end
|
257
|
+
|
258
|
+
promise = promise.then do |http_response|
|
259
|
+
status_code = http_response.status
|
260
|
+
response_content = http_response.body
|
261
|
+
unless (status_code == 200)
|
262
|
+
error_model = JSON.load(response_content)
|
263
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
264
|
+
end
|
265
|
+
|
266
|
+
# Create Result
|
267
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
268
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
269
|
+
# Deserialize Response
|
270
|
+
if status_code == 200
|
271
|
+
begin
|
272
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
273
|
+
unless parsed_response.nil?
|
274
|
+
parsed_response = ProviderListResult.deserialize_object(parsed_response)
|
275
|
+
end
|
276
|
+
result.body = parsed_response
|
277
|
+
rescue Exception => e
|
278
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
result
|
283
|
+
end
|
284
|
+
|
285
|
+
promise.execute
|
286
|
+
end
|
287
|
+
|
288
|
+
#
|
289
|
+
# Gets a resource provider.
|
290
|
+
# @param resource_provider_namespace [String] Namespace of the resource
|
291
|
+
# provider.
|
292
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
293
|
+
# applied to HTTP request.
|
294
|
+
#
|
295
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
296
|
+
# response.
|
297
|
+
#
|
298
|
+
def get(resource_provider_namespace, custom_headers = nil)
|
299
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
300
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
301
|
+
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
|
327
|
+
|
328
|
+
# Set Headers
|
329
|
+
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
|
344
|
+
end
|
345
|
+
|
346
|
+
promise = promise.then do |http_response|
|
347
|
+
status_code = http_response.status
|
348
|
+
response_content = http_response.body
|
349
|
+
unless (status_code == 200)
|
350
|
+
error_model = JSON.load(response_content)
|
351
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
352
|
+
end
|
353
|
+
|
354
|
+
# Create Result
|
355
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
356
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
357
|
+
# Deserialize Response
|
358
|
+
if status_code == 200
|
359
|
+
begin
|
360
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
361
|
+
unless parsed_response.nil?
|
362
|
+
parsed_response = Provider.deserialize_object(parsed_response)
|
363
|
+
end
|
364
|
+
result.body = parsed_response
|
365
|
+
rescue Exception => e
|
366
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
result
|
371
|
+
end
|
372
|
+
|
373
|
+
promise.execute
|
374
|
+
end
|
375
|
+
|
376
|
+
#
|
377
|
+
# Gets a list of resource providers.
|
378
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
379
|
+
# call to List operation.
|
380
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
381
|
+
# applied to HTTP request.
|
382
|
+
#
|
383
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
384
|
+
# response.
|
385
|
+
#
|
386
|
+
def list_next(next_page_link, custom_headers = nil)
|
387
|
+
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
|
411
|
+
|
412
|
+
# Set Headers
|
413
|
+
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
|
428
|
+
end
|
429
|
+
|
430
|
+
promise = promise.then do |http_response|
|
431
|
+
status_code = http_response.status
|
432
|
+
response_content = http_response.body
|
433
|
+
unless (status_code == 200)
|
434
|
+
error_model = JSON.load(response_content)
|
435
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
436
|
+
end
|
437
|
+
|
438
|
+
# Create Result
|
439
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
440
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
441
|
+
# Deserialize Response
|
442
|
+
if status_code == 200
|
443
|
+
begin
|
444
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
445
|
+
unless parsed_response.nil?
|
446
|
+
parsed_response = ProviderListResult.deserialize_object(parsed_response)
|
447
|
+
end
|
448
|
+
result.body = parsed_response
|
449
|
+
rescue Exception => e
|
450
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
result
|
455
|
+
end
|
456
|
+
|
457
|
+
promise.execute
|
458
|
+
end
|
459
|
+
|
460
|
+
end
|
461
|
+
end
|