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,85 @@
|
|
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
|
+
# A service client - single point of access to the REST API.
|
9
|
+
#
|
10
|
+
class ResourceManagementClient < MsRestAzure::AzureServiceClient
|
11
|
+
include Azure::ARM::Resources::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
# @return [String] the base URI of the service.
|
15
|
+
attr_accessor :base_url
|
16
|
+
|
17
|
+
# @return [ServiceClientCredentials] The management credentials for Azure.
|
18
|
+
attr_reader :credentials
|
19
|
+
|
20
|
+
# @return [String] Gets subscription credentials which uniquely identify
|
21
|
+
# Microsoft Azure subscription. The subscription ID forms part of the URI
|
22
|
+
# for every service call.
|
23
|
+
attr_accessor :subscription_id
|
24
|
+
|
25
|
+
# @return [String] Client Api Version.
|
26
|
+
attr_reader :api_version
|
27
|
+
|
28
|
+
# @return [String] Gets or sets the preferred language for the response.
|
29
|
+
attr_accessor :accept_language
|
30
|
+
|
31
|
+
# @return [Integer] The retry timeout for Long Running Operations.
|
32
|
+
attr_accessor :long_running_operation_retry_timeout
|
33
|
+
|
34
|
+
# @return [ServiceClient] Subscription credentials which uniquely identify
|
35
|
+
# client subscription.
|
36
|
+
attr_accessor :credentials
|
37
|
+
|
38
|
+
# @return providers
|
39
|
+
attr_reader :providers
|
40
|
+
|
41
|
+
# @return resource_groups
|
42
|
+
attr_reader :resource_groups
|
43
|
+
|
44
|
+
# @return resources
|
45
|
+
attr_reader :resources
|
46
|
+
|
47
|
+
# @return tags
|
48
|
+
attr_reader :tags
|
49
|
+
|
50
|
+
# @return deployment_operations
|
51
|
+
attr_reader :deployment_operations
|
52
|
+
|
53
|
+
# @return resource_provider_operation_details
|
54
|
+
attr_reader :resource_provider_operation_details
|
55
|
+
|
56
|
+
# @return deployments
|
57
|
+
attr_reader :deployments
|
58
|
+
|
59
|
+
#
|
60
|
+
# Creates initializes a new instance of the ResourceManagementClient class.
|
61
|
+
# @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
|
62
|
+
# @param base_url [String] the base URI of the service.
|
63
|
+
# @param options [Array] filters to be applied to the HTTP requests.
|
64
|
+
#
|
65
|
+
def initialize(credentials, base_url = nil, options = nil)
|
66
|
+
super(credentials, options)
|
67
|
+
@base_url = base_url || 'https://management.azure.com'
|
68
|
+
|
69
|
+
fail ArgumentError, 'credentials is nil' if credentials.nil?
|
70
|
+
fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials)
|
71
|
+
@credentials = credentials
|
72
|
+
|
73
|
+
@providers = Providers.new(self)
|
74
|
+
@resource_groups = ResourceGroups.new(self)
|
75
|
+
@resources = Resources.new(self)
|
76
|
+
@tags = Tags.new(self)
|
77
|
+
@deployment_operations = DeploymentOperations.new(self)
|
78
|
+
@resource_provider_operation_details = ResourceProviderOperationDetails.new(self)
|
79
|
+
@deployments = Deployments.new(self)
|
80
|
+
@api_version = "2014-04-01-preview"
|
81
|
+
@accept_language = "en-US"
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,126 @@
|
|
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
|
+
# ResourceProviderOperationDetails
|
9
|
+
#
|
10
|
+
class ResourceProviderOperationDetails
|
11
|
+
include Azure::ARM::Resources::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the ResourceProviderOperationDetails 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
|
+
# Gets a list of resource providers.
|
27
|
+
# @param resource_provider_namespace [String] Resource identity.
|
28
|
+
# @param api_version [String]
|
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 list(resource_provider_namespace, api_version, custom_headers = nil)
|
36
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
37
|
+
fail ArgumentError, 'api_version is nil' if api_version.nil?
|
38
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
39
|
+
# Construct URL
|
40
|
+
path = "/providers/{resourceProviderNamespace}/operations"
|
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(api_version.to_s) unless 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.get 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 || status_code == 204)
|
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 = ResourceProviderOperationDetailListResult.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
|
+
# Deserialize Response
|
107
|
+
if status_code == 204
|
108
|
+
begin
|
109
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
110
|
+
unless parsed_response.nil?
|
111
|
+
parsed_response = ResourceProviderOperationDetailListResult.deserialize_object(parsed_response)
|
112
|
+
end
|
113
|
+
result.body = parsed_response
|
114
|
+
rescue Exception => e
|
115
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
result
|
120
|
+
end
|
121
|
+
|
122
|
+
promise.execute
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,737 @@
|
|
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
|
+
# Resources
|
9
|
+
#
|
10
|
+
class Resources
|
11
|
+
include Azure::ARM::Resources::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the Resources 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
|
+
# Move resources within or across subscriptions.
|
27
|
+
# @param source_resource_group_name [String] Source resource group name.
|
28
|
+
# @param parameters [ResourcesMoveInfo] move resources' parameters.
|
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 move_resources(source_resource_group_name, parameters, custom_headers = nil)
|
36
|
+
fail ArgumentError, 'source_resource_group_name is nil' if source_resource_group_name.nil?
|
37
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
38
|
+
parameters.validate unless parameters.nil?
|
39
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
40
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
41
|
+
# Construct URL
|
42
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"
|
43
|
+
path['{sourceResourceGroupName}'] = ERB::Util.url_encode(source_resource_group_name) if path.include?('{sourceResourceGroupName}')
|
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
|
66
|
+
|
67
|
+
# Set Headers
|
68
|
+
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
|
+
# Serialize Request
|
78
|
+
request_headers['Content-Type'] = 'application/json'
|
79
|
+
unless parameters.nil?
|
80
|
+
parameters = ResourcesMoveInfo.serialize_object(parameters)
|
81
|
+
end
|
82
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
83
|
+
|
84
|
+
# Send Request
|
85
|
+
promise = Concurrent::Promise.new do
|
86
|
+
connection.post do |request|
|
87
|
+
request.headers = request_headers
|
88
|
+
request.body = request_content
|
89
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
promise = promise.then do |http_response|
|
94
|
+
status_code = http_response.status
|
95
|
+
response_content = http_response.body
|
96
|
+
unless (status_code == 202)
|
97
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Create Result
|
101
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
102
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
103
|
+
|
104
|
+
result
|
105
|
+
end
|
106
|
+
|
107
|
+
promise.execute
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Get all of the resources under a subscription.
|
112
|
+
# @param filter [String] The filter to apply on the operation.
|
113
|
+
# @param top [Integer] Query parameters. If null is passed returns all
|
114
|
+
# resource groups.
|
115
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
116
|
+
# applied to HTTP request.
|
117
|
+
#
|
118
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
119
|
+
# response.
|
120
|
+
#
|
121
|
+
def list(filter = nil, top = nil, custom_headers = nil)
|
122
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
123
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
124
|
+
# Construct URL
|
125
|
+
path = "/subscriptions/{subscriptionId}/resources"
|
126
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
127
|
+
url = URI.join(@client.base_url, path)
|
128
|
+
properties = {}
|
129
|
+
properties['$filter'] = ERB::Util.url_encode(filter.to_s) unless filter.nil?
|
130
|
+
properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
|
131
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
132
|
+
unless url.query.nil?
|
133
|
+
url.query.split('&').each do |url_item|
|
134
|
+
url_items_parts = url_item.split('=')
|
135
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
properties.reject!{ |key, value| value.nil? }
|
139
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
140
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
141
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
142
|
+
url = URI.parse(corrected_url)
|
143
|
+
|
144
|
+
connection = Faraday.new(:url => url) do |faraday|
|
145
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
146
|
+
faraday.use :cookie_jar
|
147
|
+
faraday.adapter Faraday.default_adapter
|
148
|
+
end
|
149
|
+
request_headers = Hash.new
|
150
|
+
|
151
|
+
# Set Headers
|
152
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
153
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
154
|
+
|
155
|
+
unless custom_headers.nil?
|
156
|
+
custom_headers.each do |key, value|
|
157
|
+
request_headers[key] = value
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Send Request
|
162
|
+
promise = Concurrent::Promise.new do
|
163
|
+
connection.get do |request|
|
164
|
+
request.headers = request_headers
|
165
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
promise = promise.then do |http_response|
|
170
|
+
status_code = http_response.status
|
171
|
+
response_content = http_response.body
|
172
|
+
unless (status_code == 200)
|
173
|
+
error_model = JSON.load(response_content)
|
174
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Create Result
|
178
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
179
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
180
|
+
# Deserialize Response
|
181
|
+
if status_code == 200
|
182
|
+
begin
|
183
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
184
|
+
unless parsed_response.nil?
|
185
|
+
parsed_response = ResourceListResult.deserialize_object(parsed_response)
|
186
|
+
end
|
187
|
+
result.body = parsed_response
|
188
|
+
rescue Exception => e
|
189
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
result
|
194
|
+
end
|
195
|
+
|
196
|
+
promise.execute
|
197
|
+
end
|
198
|
+
|
199
|
+
#
|
200
|
+
# Checks whether resource exists.
|
201
|
+
# @param resource_group_name [String] The name of the resource group. The name
|
202
|
+
# is case insensitive.
|
203
|
+
# @param resource_provider_namespace [String] Resource identity.
|
204
|
+
# @param parent_resource_path [String] Resource identity.
|
205
|
+
# @param resource_type [String] Resource identity.
|
206
|
+
# @param resource_name [String] Resource identity.
|
207
|
+
# @param api_version [String]
|
208
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
209
|
+
# applied to HTTP request.
|
210
|
+
#
|
211
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
212
|
+
# response.
|
213
|
+
#
|
214
|
+
def check_existence(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers = nil)
|
215
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
216
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
217
|
+
fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
|
218
|
+
fail ArgumentError, 'resource_type is nil' if resource_type.nil?
|
219
|
+
fail ArgumentError, 'resource_name is nil' if resource_name.nil?
|
220
|
+
fail ArgumentError, 'api_version is nil' if api_version.nil?
|
221
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
222
|
+
# Construct URL
|
223
|
+
path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"
|
224
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
225
|
+
path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
|
226
|
+
path['{parentResourcePath}'] = parent_resource_path if path.include?('{parentResourcePath}')
|
227
|
+
path['{resourceType}'] = resource_type if path.include?('{resourceType}')
|
228
|
+
path['{resourceName}'] = ERB::Util.url_encode(resource_name) if path.include?('{resourceName}')
|
229
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
230
|
+
url = URI.join(@client.base_url, path)
|
231
|
+
properties = {}
|
232
|
+
properties['api-version'] = ERB::Util.url_encode(api_version.to_s) unless api_version.nil?
|
233
|
+
unless url.query.nil?
|
234
|
+
url.query.split('&').each do |url_item|
|
235
|
+
url_items_parts = url_item.split('=')
|
236
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
237
|
+
end
|
238
|
+
end
|
239
|
+
properties.reject!{ |key, value| value.nil? }
|
240
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
241
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
242
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
243
|
+
url = URI.parse(corrected_url)
|
244
|
+
|
245
|
+
connection = Faraday.new(:url => url) do |faraday|
|
246
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
247
|
+
faraday.use :cookie_jar
|
248
|
+
faraday.adapter Faraday.default_adapter
|
249
|
+
end
|
250
|
+
request_headers = Hash.new
|
251
|
+
|
252
|
+
# Set Headers
|
253
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
254
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
255
|
+
|
256
|
+
unless custom_headers.nil?
|
257
|
+
custom_headers.each do |key, value|
|
258
|
+
request_headers[key] = value
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
# Send Request
|
263
|
+
promise = Concurrent::Promise.new do
|
264
|
+
connection.head do |request|
|
265
|
+
request.headers = request_headers
|
266
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
promise = promise.then do |http_response|
|
271
|
+
status_code = http_response.status
|
272
|
+
response_content = http_response.body
|
273
|
+
unless (status_code == 204 || status_code == 404)
|
274
|
+
error_model = JSON.load(response_content)
|
275
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
276
|
+
end
|
277
|
+
|
278
|
+
# Create Result
|
279
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
280
|
+
result.body = (status_code == 204)
|
281
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
282
|
+
|
283
|
+
result
|
284
|
+
end
|
285
|
+
|
286
|
+
promise.execute
|
287
|
+
end
|
288
|
+
|
289
|
+
#
|
290
|
+
# Delete resource and all of its resources.
|
291
|
+
# @param resource_group_name [String] The name of the resource group. The name
|
292
|
+
# is case insensitive.
|
293
|
+
# @param resource_provider_namespace [String] Resource identity.
|
294
|
+
# @param parent_resource_path [String] Resource identity.
|
295
|
+
# @param resource_type [String] Resource identity.
|
296
|
+
# @param resource_name [String] Resource identity.
|
297
|
+
# @param api_version [String]
|
298
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
299
|
+
# applied to HTTP request.
|
300
|
+
#
|
301
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
302
|
+
# response.
|
303
|
+
#
|
304
|
+
def delete(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers = nil)
|
305
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
306
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
307
|
+
fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
|
308
|
+
fail ArgumentError, 'resource_type is nil' if resource_type.nil?
|
309
|
+
fail ArgumentError, 'resource_name is nil' if resource_name.nil?
|
310
|
+
fail ArgumentError, 'api_version is nil' if api_version.nil?
|
311
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
312
|
+
# Construct URL
|
313
|
+
path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"
|
314
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
315
|
+
path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
|
316
|
+
path['{parentResourcePath}'] = parent_resource_path if path.include?('{parentResourcePath}')
|
317
|
+
path['{resourceType}'] = resource_type if path.include?('{resourceType}')
|
318
|
+
path['{resourceName}'] = ERB::Util.url_encode(resource_name) if path.include?('{resourceName}')
|
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(api_version.to_s) unless 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
|
341
|
+
|
342
|
+
# Set Headers
|
343
|
+
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
|
358
|
+
end
|
359
|
+
|
360
|
+
promise = promise.then do |http_response|
|
361
|
+
status_code = http_response.status
|
362
|
+
response_content = http_response.body
|
363
|
+
unless (status_code == 200 || status_code == 204 || status_code == 202)
|
364
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response)
|
365
|
+
end
|
366
|
+
|
367
|
+
# Create Result
|
368
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
369
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
370
|
+
|
371
|
+
result
|
372
|
+
end
|
373
|
+
|
374
|
+
promise.execute
|
375
|
+
end
|
376
|
+
|
377
|
+
#
|
378
|
+
# Create a resource.
|
379
|
+
# @param resource_group_name [String] The name of the resource group. The name
|
380
|
+
# is case insensitive.
|
381
|
+
# @param resource_provider_namespace [String] Resource identity.
|
382
|
+
# @param parent_resource_path [String] Resource identity.
|
383
|
+
# @param resource_type [String] Resource identity.
|
384
|
+
# @param resource_name [String] Resource identity.
|
385
|
+
# @param api_version [String]
|
386
|
+
# @param parameters [GenericResource] Create or update resource parameters.
|
387
|
+
# @param @client.subscription_id [String] Gets subscription credentials which
|
388
|
+
# uniquely identify Microsoft Azure subscription. The subscription ID forms
|
389
|
+
# part of the URI for every service call.
|
390
|
+
# @param @client.accept_language [String] Gets or sets the preferred language
|
391
|
+
# for the response.
|
392
|
+
#
|
393
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
394
|
+
# response.
|
395
|
+
#
|
396
|
+
def create_or_update(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers = nil)
|
397
|
+
# Send request
|
398
|
+
promise = begin_create_or_update(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers)
|
399
|
+
|
400
|
+
promise = promise.then do |response|
|
401
|
+
# Defining deserialization method.
|
402
|
+
deserialize_method = lambda do |parsed_response|
|
403
|
+
unless parsed_response.nil?
|
404
|
+
parsed_response = GenericResource.deserialize_object(parsed_response)
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
# Waiting for response.
|
409
|
+
@client.get_put_operation_result(response, custom_headers, deserialize_method)
|
410
|
+
end
|
411
|
+
|
412
|
+
promise
|
413
|
+
end
|
414
|
+
|
415
|
+
#
|
416
|
+
# Create a resource.
|
417
|
+
# @param resource_group_name [String] The name of the resource group. The name
|
418
|
+
# is case insensitive.
|
419
|
+
# @param resource_provider_namespace [String] Resource identity.
|
420
|
+
# @param parent_resource_path [String] Resource identity.
|
421
|
+
# @param resource_type [String] Resource identity.
|
422
|
+
# @param resource_name [String] Resource identity.
|
423
|
+
# @param api_version [String]
|
424
|
+
# @param parameters [GenericResource] Create or update resource parameters.
|
425
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
426
|
+
# applied to HTTP request.
|
427
|
+
#
|
428
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
429
|
+
# response.
|
430
|
+
#
|
431
|
+
def begin_create_or_update(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers = nil)
|
432
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
433
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
434
|
+
fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
|
435
|
+
fail ArgumentError, 'resource_type is nil' if resource_type.nil?
|
436
|
+
fail ArgumentError, 'resource_name is nil' if resource_name.nil?
|
437
|
+
fail ArgumentError, 'api_version is nil' if api_version.nil?
|
438
|
+
fail ArgumentError, 'parameters is nil' if parameters.nil?
|
439
|
+
parameters.validate unless parameters.nil?
|
440
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
441
|
+
# Construct URL
|
442
|
+
path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"
|
443
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
444
|
+
path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
|
445
|
+
path['{parentResourcePath}'] = parent_resource_path if path.include?('{parentResourcePath}')
|
446
|
+
path['{resourceType}'] = resource_type if path.include?('{resourceType}')
|
447
|
+
path['{resourceName}'] = ERB::Util.url_encode(resource_name) if path.include?('{resourceName}')
|
448
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
449
|
+
url = URI.join(@client.base_url, path)
|
450
|
+
properties = {}
|
451
|
+
properties['api-version'] = ERB::Util.url_encode(api_version.to_s) unless api_version.nil?
|
452
|
+
unless url.query.nil?
|
453
|
+
url.query.split('&').each do |url_item|
|
454
|
+
url_items_parts = url_item.split('=')
|
455
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
456
|
+
end
|
457
|
+
end
|
458
|
+
properties.reject!{ |key, value| value.nil? }
|
459
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
460
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
461
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
462
|
+
url = URI.parse(corrected_url)
|
463
|
+
|
464
|
+
connection = Faraday.new(:url => url) do |faraday|
|
465
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
466
|
+
faraday.use :cookie_jar
|
467
|
+
faraday.adapter Faraday.default_adapter
|
468
|
+
end
|
469
|
+
request_headers = Hash.new
|
470
|
+
|
471
|
+
# Set Headers
|
472
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
473
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
474
|
+
|
475
|
+
unless custom_headers.nil?
|
476
|
+
custom_headers.each do |key, value|
|
477
|
+
request_headers[key] = value
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
# Serialize Request
|
482
|
+
request_headers['Content-Type'] = 'application/json'
|
483
|
+
unless parameters.nil?
|
484
|
+
parameters = GenericResource.serialize_object(parameters)
|
485
|
+
end
|
486
|
+
request_content = JSON.generate(parameters, quirks_mode: true)
|
487
|
+
|
488
|
+
# Send Request
|
489
|
+
promise = Concurrent::Promise.new do
|
490
|
+
connection.put do |request|
|
491
|
+
request.headers = request_headers
|
492
|
+
request.body = request_content
|
493
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
promise = promise.then do |http_response|
|
498
|
+
status_code = http_response.status
|
499
|
+
response_content = http_response.body
|
500
|
+
unless (status_code == 201 || status_code == 202 || status_code == 200)
|
501
|
+
error_model = JSON.load(response_content)
|
502
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
503
|
+
end
|
504
|
+
|
505
|
+
# Create Result
|
506
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
507
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
508
|
+
# Deserialize Response
|
509
|
+
if status_code == 201
|
510
|
+
begin
|
511
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
512
|
+
unless parsed_response.nil?
|
513
|
+
parsed_response = GenericResource.deserialize_object(parsed_response)
|
514
|
+
end
|
515
|
+
result.body = parsed_response
|
516
|
+
rescue Exception => e
|
517
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
# Deserialize Response
|
521
|
+
if status_code == 200
|
522
|
+
begin
|
523
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
524
|
+
unless parsed_response.nil?
|
525
|
+
parsed_response = GenericResource.deserialize_object(parsed_response)
|
526
|
+
end
|
527
|
+
result.body = parsed_response
|
528
|
+
rescue Exception => e
|
529
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
result
|
534
|
+
end
|
535
|
+
|
536
|
+
promise.execute
|
537
|
+
end
|
538
|
+
|
539
|
+
#
|
540
|
+
# Returns a resource belonging to a resource group.
|
541
|
+
# @param resource_group_name [String] The name of the resource group. The name
|
542
|
+
# is case insensitive.
|
543
|
+
# @param resource_provider_namespace [String] Resource identity.
|
544
|
+
# @param parent_resource_path [String] Resource identity.
|
545
|
+
# @param resource_type [String] Resource identity.
|
546
|
+
# @param resource_name [String] Resource identity.
|
547
|
+
# @param api_version [String]
|
548
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
549
|
+
# applied to HTTP request.
|
550
|
+
#
|
551
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
552
|
+
# response.
|
553
|
+
#
|
554
|
+
def get(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers = nil)
|
555
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
556
|
+
fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
|
557
|
+
fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
|
558
|
+
fail ArgumentError, 'resource_type is nil' if resource_type.nil?
|
559
|
+
fail ArgumentError, 'resource_name is nil' if resource_name.nil?
|
560
|
+
fail ArgumentError, 'api_version is nil' if api_version.nil?
|
561
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
562
|
+
# Construct URL
|
563
|
+
path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"
|
564
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
565
|
+
path['{resourceProviderNamespace}'] = ERB::Util.url_encode(resource_provider_namespace) if path.include?('{resourceProviderNamespace}')
|
566
|
+
path['{parentResourcePath}'] = parent_resource_path if path.include?('{parentResourcePath}')
|
567
|
+
path['{resourceType}'] = resource_type if path.include?('{resourceType}')
|
568
|
+
path['{resourceName}'] = ERB::Util.url_encode(resource_name) if path.include?('{resourceName}')
|
569
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
570
|
+
url = URI.join(@client.base_url, path)
|
571
|
+
properties = {}
|
572
|
+
properties['api-version'] = ERB::Util.url_encode(api_version.to_s) unless api_version.nil?
|
573
|
+
unless url.query.nil?
|
574
|
+
url.query.split('&').each do |url_item|
|
575
|
+
url_items_parts = url_item.split('=')
|
576
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
577
|
+
end
|
578
|
+
end
|
579
|
+
properties.reject!{ |key, value| value.nil? }
|
580
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
581
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
582
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
583
|
+
url = URI.parse(corrected_url)
|
584
|
+
|
585
|
+
connection = Faraday.new(:url => url) do |faraday|
|
586
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
587
|
+
faraday.use :cookie_jar
|
588
|
+
faraday.adapter Faraday.default_adapter
|
589
|
+
end
|
590
|
+
request_headers = Hash.new
|
591
|
+
|
592
|
+
# Set Headers
|
593
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
594
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
595
|
+
|
596
|
+
unless custom_headers.nil?
|
597
|
+
custom_headers.each do |key, value|
|
598
|
+
request_headers[key] = value
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
# Send Request
|
603
|
+
promise = Concurrent::Promise.new do
|
604
|
+
connection.get do |request|
|
605
|
+
request.headers = request_headers
|
606
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
promise = promise.then do |http_response|
|
611
|
+
status_code = http_response.status
|
612
|
+
response_content = http_response.body
|
613
|
+
unless (status_code == 200 || status_code == 204)
|
614
|
+
error_model = JSON.load(response_content)
|
615
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
616
|
+
end
|
617
|
+
|
618
|
+
# Create Result
|
619
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
620
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
621
|
+
# Deserialize Response
|
622
|
+
if status_code == 200
|
623
|
+
begin
|
624
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
625
|
+
unless parsed_response.nil?
|
626
|
+
parsed_response = GenericResource.deserialize_object(parsed_response)
|
627
|
+
end
|
628
|
+
result.body = parsed_response
|
629
|
+
rescue Exception => e
|
630
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
631
|
+
end
|
632
|
+
end
|
633
|
+
# Deserialize Response
|
634
|
+
if status_code == 204
|
635
|
+
begin
|
636
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
637
|
+
unless parsed_response.nil?
|
638
|
+
parsed_response = GenericResource.deserialize_object(parsed_response)
|
639
|
+
end
|
640
|
+
result.body = parsed_response
|
641
|
+
rescue Exception => e
|
642
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
643
|
+
end
|
644
|
+
end
|
645
|
+
|
646
|
+
result
|
647
|
+
end
|
648
|
+
|
649
|
+
promise.execute
|
650
|
+
end
|
651
|
+
|
652
|
+
#
|
653
|
+
# Get all of the resources under a subscription.
|
654
|
+
# @param next_page_link [String] The NextLink from the previous successful
|
655
|
+
# call to List operation.
|
656
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
657
|
+
# applied to HTTP request.
|
658
|
+
#
|
659
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
660
|
+
# response.
|
661
|
+
#
|
662
|
+
def list_next(next_page_link, custom_headers = nil)
|
663
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
664
|
+
# Construct URL
|
665
|
+
path = "{nextLink}"
|
666
|
+
path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
|
667
|
+
url = URI.parse(path)
|
668
|
+
properties = {}
|
669
|
+
unless url.query.nil?
|
670
|
+
url.query.split('&').each do |url_item|
|
671
|
+
url_items_parts = url_item.split('=')
|
672
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
673
|
+
end
|
674
|
+
end
|
675
|
+
properties.reject!{ |key, value| value.nil? }
|
676
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
677
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
678
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
679
|
+
url = URI.parse(corrected_url)
|
680
|
+
|
681
|
+
connection = Faraday.new(:url => url) do |faraday|
|
682
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
683
|
+
faraday.use :cookie_jar
|
684
|
+
faraday.adapter Faraday.default_adapter
|
685
|
+
end
|
686
|
+
request_headers = Hash.new
|
687
|
+
|
688
|
+
# Set Headers
|
689
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
690
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
691
|
+
|
692
|
+
unless custom_headers.nil?
|
693
|
+
custom_headers.each do |key, value|
|
694
|
+
request_headers[key] = value
|
695
|
+
end
|
696
|
+
end
|
697
|
+
|
698
|
+
# Send Request
|
699
|
+
promise = Concurrent::Promise.new do
|
700
|
+
connection.get do |request|
|
701
|
+
request.headers = request_headers
|
702
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
703
|
+
end
|
704
|
+
end
|
705
|
+
|
706
|
+
promise = promise.then do |http_response|
|
707
|
+
status_code = http_response.status
|
708
|
+
response_content = http_response.body
|
709
|
+
unless (status_code == 200)
|
710
|
+
error_model = JSON.load(response_content)
|
711
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
712
|
+
end
|
713
|
+
|
714
|
+
# Create Result
|
715
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
716
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
717
|
+
# Deserialize Response
|
718
|
+
if status_code == 200
|
719
|
+
begin
|
720
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
721
|
+
unless parsed_response.nil?
|
722
|
+
parsed_response = ResourceListResult.deserialize_object(parsed_response)
|
723
|
+
end
|
724
|
+
result.body = parsed_response
|
725
|
+
rescue Exception => e
|
726
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
727
|
+
end
|
728
|
+
end
|
729
|
+
|
730
|
+
result
|
731
|
+
end
|
732
|
+
|
733
|
+
promise.execute
|
734
|
+
end
|
735
|
+
|
736
|
+
end
|
737
|
+
end
|