azure_mgmt_compute 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 +17 -0
- data/LICENSE.txt +21 -0
- data/README.md +139 -0
- data/Rakefile +5 -0
- data/azure_mgmt_compute.gemspec +39 -0
- data/lib/azure_mgmt_compute.rb +103 -0
- data/lib/azure_mgmt_compute/Models/additional_unattend_content.rb +108 -0
- data/lib/azure_mgmt_compute/Models/api_error.rb +121 -0
- data/lib/azure_mgmt_compute/Models/api_error_base.rb +76 -0
- data/lib/azure_mgmt_compute/Models/availability_set.rb +94 -0
- data/lib/azure_mgmt_compute/Models/availability_set_list_result.rb +79 -0
- data/lib/azure_mgmt_compute/Models/availability_set_properties.rb +130 -0
- data/lib/azure_mgmt_compute/Models/caching_types.rb +17 -0
- data/lib/azure_mgmt_compute/Models/component_names.rb +15 -0
- data/lib/azure_mgmt_compute/Models/compute_long_running_operation_properties.rb +58 -0
- data/lib/azure_mgmt_compute/Models/compute_long_running_operation_result.rb +126 -0
- data/lib/azure_mgmt_compute/Models/compute_operation_status.rb +18 -0
- data/lib/azure_mgmt_compute/Models/data_disk.rb +142 -0
- data/lib/azure_mgmt_compute/Models/data_disk_image.rb +62 -0
- data/lib/azure_mgmt_compute/Models/delete_operation_result.rb +109 -0
- data/lib/azure_mgmt_compute/Models/disk_create_option_types.rb +17 -0
- data/lib/azure_mgmt_compute/Models/disk_instance_view.rb +88 -0
- data/lib/azure_mgmt_compute/Models/hardware_profile.rb +67 -0
- data/lib/azure_mgmt_compute/Models/image_reference.rb +87 -0
- data/lib/azure_mgmt_compute/Models/inner_error.rb +68 -0
- data/lib/azure_mgmt_compute/Models/instance_view_status.rb +102 -0
- data/lib/azure_mgmt_compute/Models/linux_configuration.rb +75 -0
- data/lib/azure_mgmt_compute/Models/list_usages_result.rb +78 -0
- data/lib/azure_mgmt_compute/Models/network_interface_reference.rb +70 -0
- data/lib/azure_mgmt_compute/Models/network_interface_reference_properties.rb +59 -0
- data/lib/azure_mgmt_compute/Models/network_profile.rb +79 -0
- data/lib/azure_mgmt_compute/Models/operating_system_types.rb +16 -0
- data/lib/azure_mgmt_compute/Models/operation_status.rb +17 -0
- data/lib/azure_mgmt_compute/Models/osdisk.rb +135 -0
- data/lib/azure_mgmt_compute/Models/osdisk_image.rb +63 -0
- data/lib/azure_mgmt_compute/Models/osprofile.rb +149 -0
- data/lib/azure_mgmt_compute/Models/pass_names.rb +15 -0
- data/lib/azure_mgmt_compute/Models/plan.rb +85 -0
- data/lib/azure_mgmt_compute/Models/protocol_types.rb +16 -0
- data/lib/azure_mgmt_compute/Models/purchase_plan.rb +77 -0
- data/lib/azure_mgmt_compute/Models/setting_names.rb +16 -0
- data/lib/azure_mgmt_compute/Models/ssh_configuration.rb +79 -0
- data/lib/azure_mgmt_compute/Models/ssh_public_key.rb +72 -0
- data/lib/azure_mgmt_compute/Models/status_level_types.rb +17 -0
- data/lib/azure_mgmt_compute/Models/storage_profile.rb +110 -0
- data/lib/azure_mgmt_compute/Models/usage.rb +98 -0
- data/lib/azure_mgmt_compute/Models/usage_name.rb +68 -0
- data/lib/azure_mgmt_compute/Models/usage_unit.rb +15 -0
- data/lib/azure_mgmt_compute/Models/vault_certificate.rb +70 -0
- data/lib/azure_mgmt_compute/Models/vault_secret_group.rb +96 -0
- data/lib/azure_mgmt_compute/Models/virtual_hard_disk.rb +59 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine.rb +142 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_agent_instance_view.rb +119 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_capture_parameters.rb +78 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_extension.rb +94 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_extension_handler_instance_view.rb +85 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_extension_image.rb +99 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_extension_image_properties.rb +102 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_extension_instance_view.rb +139 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_extension_properties.rb +133 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_image.rb +99 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_image_properties.rb +110 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_image_resource.rb +83 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_instance_view.rb +188 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_list_result.rb +89 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_properties.rb +156 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_size.rb +111 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_size_list_result.rb +79 -0
- data/lib/azure_mgmt_compute/Models/virtual_machine_size_types.rb +34 -0
- data/lib/azure_mgmt_compute/Models/win_rmconfiguration.rb +79 -0
- data/lib/azure_mgmt_compute/Models/win_rmlistener.rb +73 -0
- data/lib/azure_mgmt_compute/Models/windows_configuration.rb +126 -0
- data/lib/azure_mgmt_compute/availability_sets.rb +473 -0
- data/lib/azure_mgmt_compute/compute_management_client.rb +85 -0
- data/lib/azure_mgmt_compute/module_definition.rb +6 -0
- data/lib/azure_mgmt_compute/usage_operations.rb +113 -0
- data/lib/azure_mgmt_compute/version.rb +6 -0
- data/lib/azure_mgmt_compute/virtual_machine_extension_images.rb +325 -0
- data/lib/azure_mgmt_compute/virtual_machine_extensions.rb +384 -0
- data/lib/azure_mgmt_compute/virtual_machine_images.rb +525 -0
- data/lib/azure_mgmt_compute/virtual_machine_sizes.rb +114 -0
- data/lib/azure_mgmt_compute/virtual_machines.rb +1412 -0
- metadata +303 -0
@@ -0,0 +1,384 @@
|
|
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::Compute
|
7
|
+
#
|
8
|
+
# VirtualMachineExtensions
|
9
|
+
#
|
10
|
+
class VirtualMachineExtensions
|
11
|
+
include Azure::ARM::Compute::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the VirtualMachineExtensions 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 ComputeManagementClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# The operation to create or update the extension.
|
27
|
+
# @param resource_group_name [String] The name of the resource group.
|
28
|
+
# @param vm_name [String] The name of the virtual machine where the extension
|
29
|
+
# should be create or updated.
|
30
|
+
# @param vm_extension_name [String] The name of the virtual machine extension.
|
31
|
+
# @param extension_parameters [VirtualMachineExtension] Parameters supplied to
|
32
|
+
# the Create Virtual Machine Extension operation.
|
33
|
+
# @param @client.api_version [String] Client Api Version.
|
34
|
+
# @param @client.subscription_id [String] Gets subscription credentials which
|
35
|
+
# uniquely identify Microsoft Azure subscription. The subscription ID forms
|
36
|
+
# part of the URI for every service call.
|
37
|
+
# @param @client.accept_language [String] Gets or sets the preferred language
|
38
|
+
# for the response.
|
39
|
+
#
|
40
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
41
|
+
# response.
|
42
|
+
#
|
43
|
+
def create_or_update(resource_group_name, vm_name, vm_extension_name, extension_parameters, custom_headers = nil)
|
44
|
+
# Send request
|
45
|
+
promise = begin_create_or_update(resource_group_name, vm_name, vm_extension_name, extension_parameters, custom_headers)
|
46
|
+
|
47
|
+
promise = promise.then do |response|
|
48
|
+
# Defining deserialization method.
|
49
|
+
deserialize_method = lambda do |parsed_response|
|
50
|
+
unless parsed_response.nil?
|
51
|
+
parsed_response = VirtualMachineExtension.deserialize_object(parsed_response)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Waiting for response.
|
56
|
+
@client.get_put_operation_result(response, custom_headers, deserialize_method)
|
57
|
+
end
|
58
|
+
|
59
|
+
promise
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# The operation to create or update the extension.
|
64
|
+
# @param resource_group_name [String] The name of the resource group.
|
65
|
+
# @param vm_name [String] The name of the virtual machine where the extension
|
66
|
+
# should be create or updated.
|
67
|
+
# @param vm_extension_name [String] The name of the virtual machine extension.
|
68
|
+
# @param extension_parameters [VirtualMachineExtension] Parameters supplied to
|
69
|
+
# the Create Virtual Machine Extension operation.
|
70
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
71
|
+
# applied to HTTP request.
|
72
|
+
#
|
73
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
74
|
+
# response.
|
75
|
+
#
|
76
|
+
def begin_create_or_update(resource_group_name, vm_name, vm_extension_name, extension_parameters, custom_headers = nil)
|
77
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
78
|
+
fail ArgumentError, 'vm_name is nil' if vm_name.nil?
|
79
|
+
fail ArgumentError, 'vm_extension_name is nil' if vm_extension_name.nil?
|
80
|
+
fail ArgumentError, 'extension_parameters is nil' if extension_parameters.nil?
|
81
|
+
extension_parameters.validate unless extension_parameters.nil?
|
82
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
83
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
84
|
+
# Construct URL
|
85
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"
|
86
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
87
|
+
path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
|
88
|
+
path['{vmExtensionName}'] = ERB::Util.url_encode(vm_extension_name) if path.include?('{vmExtensionName}')
|
89
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
90
|
+
url = URI.join(@client.base_url, path)
|
91
|
+
properties = {}
|
92
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
93
|
+
unless url.query.nil?
|
94
|
+
url.query.split('&').each do |url_item|
|
95
|
+
url_items_parts = url_item.split('=')
|
96
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
properties.reject!{ |key, value| value.nil? }
|
100
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
101
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
102
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
103
|
+
url = URI.parse(corrected_url)
|
104
|
+
|
105
|
+
connection = Faraday.new(:url => url) do |faraday|
|
106
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
107
|
+
faraday.use :cookie_jar
|
108
|
+
faraday.adapter Faraday.default_adapter
|
109
|
+
end
|
110
|
+
request_headers = Hash.new
|
111
|
+
|
112
|
+
# Set Headers
|
113
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
114
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
115
|
+
|
116
|
+
unless custom_headers.nil?
|
117
|
+
custom_headers.each do |key, value|
|
118
|
+
request_headers[key] = value
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Serialize Request
|
123
|
+
request_headers['Content-Type'] = 'application/json'
|
124
|
+
unless extension_parameters.nil?
|
125
|
+
extension_parameters = VirtualMachineExtension.serialize_object(extension_parameters)
|
126
|
+
end
|
127
|
+
request_content = JSON.generate(extension_parameters, quirks_mode: true)
|
128
|
+
|
129
|
+
# Send Request
|
130
|
+
promise = Concurrent::Promise.new do
|
131
|
+
connection.put do |request|
|
132
|
+
request.headers = request_headers
|
133
|
+
request.body = request_content
|
134
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
promise = promise.then do |http_response|
|
139
|
+
status_code = http_response.status
|
140
|
+
response_content = http_response.body
|
141
|
+
unless (status_code == 201 || status_code == 200)
|
142
|
+
error_model = JSON.load(response_content)
|
143
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Create Result
|
147
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
148
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
149
|
+
# Deserialize Response
|
150
|
+
if status_code == 201
|
151
|
+
begin
|
152
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
153
|
+
unless parsed_response.nil?
|
154
|
+
parsed_response = VirtualMachineExtension.deserialize_object(parsed_response)
|
155
|
+
end
|
156
|
+
result.body = parsed_response
|
157
|
+
rescue Exception => e
|
158
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
# Deserialize Response
|
162
|
+
if status_code == 200
|
163
|
+
begin
|
164
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
165
|
+
unless parsed_response.nil?
|
166
|
+
parsed_response = VirtualMachineExtension.deserialize_object(parsed_response)
|
167
|
+
end
|
168
|
+
result.body = parsed_response
|
169
|
+
rescue Exception => e
|
170
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
result
|
175
|
+
end
|
176
|
+
|
177
|
+
promise.execute
|
178
|
+
end
|
179
|
+
|
180
|
+
#
|
181
|
+
# The operation to delete the extension.
|
182
|
+
# @param resource_group_name [String] The name of the resource group.
|
183
|
+
# @param vm_name [String] The name of the virtual machine where the extension
|
184
|
+
# should be deleted.
|
185
|
+
# @param vm_extension_name [String] The name of the virtual machine extension.
|
186
|
+
# @return [Concurrent::Promise] promise which provides async access to http
|
187
|
+
# response.
|
188
|
+
#
|
189
|
+
def delete(resource_group_name, vm_name, vm_extension_name, custom_headers = nil)
|
190
|
+
# Send request
|
191
|
+
promise = begin_delete(resource_group_name, vm_name, vm_extension_name, custom_headers)
|
192
|
+
|
193
|
+
promise = promise.then do |response|
|
194
|
+
# Defining deserialization method.
|
195
|
+
deserialize_method = lambda do |parsed_response|
|
196
|
+
end
|
197
|
+
|
198
|
+
# Waiting for response.
|
199
|
+
@client.get_post_or_delete_operation_result(response, nil, deserialize_method)
|
200
|
+
end
|
201
|
+
|
202
|
+
promise
|
203
|
+
end
|
204
|
+
|
205
|
+
#
|
206
|
+
# The operation to delete the extension.
|
207
|
+
# @param resource_group_name [String] The name of the resource group.
|
208
|
+
# @param vm_name [String] The name of the virtual machine where the extension
|
209
|
+
# should be deleted.
|
210
|
+
# @param vm_extension_name [String] The name of the virtual machine extension.
|
211
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
212
|
+
# applied to HTTP request.
|
213
|
+
#
|
214
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
215
|
+
# response.
|
216
|
+
#
|
217
|
+
def begin_delete(resource_group_name, vm_name, vm_extension_name, custom_headers = nil)
|
218
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
219
|
+
fail ArgumentError, 'vm_name is nil' if vm_name.nil?
|
220
|
+
fail ArgumentError, 'vm_extension_name is nil' if vm_extension_name.nil?
|
221
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
222
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
223
|
+
# Construct URL
|
224
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"
|
225
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
226
|
+
path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
|
227
|
+
path['{vmExtensionName}'] = ERB::Util.url_encode(vm_extension_name) if path.include?('{vmExtensionName}')
|
228
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
229
|
+
url = URI.join(@client.base_url, path)
|
230
|
+
properties = {}
|
231
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
232
|
+
unless url.query.nil?
|
233
|
+
url.query.split('&').each do |url_item|
|
234
|
+
url_items_parts = url_item.split('=')
|
235
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
236
|
+
end
|
237
|
+
end
|
238
|
+
properties.reject!{ |key, value| value.nil? }
|
239
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
240
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
241
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
242
|
+
url = URI.parse(corrected_url)
|
243
|
+
|
244
|
+
connection = Faraday.new(:url => url) do |faraday|
|
245
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
246
|
+
faraday.use :cookie_jar
|
247
|
+
faraday.adapter Faraday.default_adapter
|
248
|
+
end
|
249
|
+
request_headers = Hash.new
|
250
|
+
|
251
|
+
# Set Headers
|
252
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
253
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
254
|
+
|
255
|
+
unless custom_headers.nil?
|
256
|
+
custom_headers.each do |key, value|
|
257
|
+
request_headers[key] = value
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
# Send Request
|
262
|
+
promise = Concurrent::Promise.new do
|
263
|
+
connection.delete do |request|
|
264
|
+
request.headers = request_headers
|
265
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
promise = promise.then do |http_response|
|
270
|
+
status_code = http_response.status
|
271
|
+
response_content = http_response.body
|
272
|
+
unless (status_code == 200 || status_code == 204 || status_code == 202)
|
273
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response)
|
274
|
+
end
|
275
|
+
|
276
|
+
# Create Result
|
277
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
278
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
279
|
+
|
280
|
+
result
|
281
|
+
end
|
282
|
+
|
283
|
+
promise.execute
|
284
|
+
end
|
285
|
+
|
286
|
+
#
|
287
|
+
# The operation to get the extension.
|
288
|
+
# @param resource_group_name [String] The name of the resource group.
|
289
|
+
# @param vm_name [String] The name of the virtual machine containing the
|
290
|
+
# extension.
|
291
|
+
# @param vm_extension_name [String] The name of the virtual machine extension.
|
292
|
+
# @param expand [String] Name of the property to expand. Allowed value is null
|
293
|
+
# or 'instanceView'.
|
294
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
295
|
+
# applied to HTTP request.
|
296
|
+
#
|
297
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
298
|
+
# response.
|
299
|
+
#
|
300
|
+
def get(resource_group_name, vm_name, vm_extension_name, expand = nil, custom_headers = nil)
|
301
|
+
fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
|
302
|
+
fail ArgumentError, 'vm_name is nil' if vm_name.nil?
|
303
|
+
fail ArgumentError, 'vm_extension_name is nil' if vm_extension_name.nil?
|
304
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
305
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
306
|
+
# Construct URL
|
307
|
+
path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"
|
308
|
+
path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
|
309
|
+
path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
|
310
|
+
path['{vmExtensionName}'] = ERB::Util.url_encode(vm_extension_name) if path.include?('{vmExtensionName}')
|
311
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
312
|
+
url = URI.join(@client.base_url, path)
|
313
|
+
properties = {}
|
314
|
+
properties['$expand'] = ERB::Util.url_encode(expand.to_s) unless expand.nil?
|
315
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
316
|
+
unless url.query.nil?
|
317
|
+
url.query.split('&').each do |url_item|
|
318
|
+
url_items_parts = url_item.split('=')
|
319
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
320
|
+
end
|
321
|
+
end
|
322
|
+
properties.reject!{ |key, value| value.nil? }
|
323
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
324
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
325
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
326
|
+
url = URI.parse(corrected_url)
|
327
|
+
|
328
|
+
connection = Faraday.new(:url => url) do |faraday|
|
329
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
330
|
+
faraday.use :cookie_jar
|
331
|
+
faraday.adapter Faraday.default_adapter
|
332
|
+
end
|
333
|
+
request_headers = Hash.new
|
334
|
+
|
335
|
+
# Set Headers
|
336
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
337
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
338
|
+
|
339
|
+
unless custom_headers.nil?
|
340
|
+
custom_headers.each do |key, value|
|
341
|
+
request_headers[key] = value
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
# Send Request
|
346
|
+
promise = Concurrent::Promise.new do
|
347
|
+
connection.get do |request|
|
348
|
+
request.headers = request_headers
|
349
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
promise = promise.then do |http_response|
|
354
|
+
status_code = http_response.status
|
355
|
+
response_content = http_response.body
|
356
|
+
unless (status_code == 200)
|
357
|
+
error_model = JSON.load(response_content)
|
358
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
359
|
+
end
|
360
|
+
|
361
|
+
# Create Result
|
362
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
363
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
364
|
+
# Deserialize Response
|
365
|
+
if status_code == 200
|
366
|
+
begin
|
367
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
368
|
+
unless parsed_response.nil?
|
369
|
+
parsed_response = VirtualMachineExtension.deserialize_object(parsed_response)
|
370
|
+
end
|
371
|
+
result.body = parsed_response
|
372
|
+
rescue Exception => e
|
373
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
result
|
378
|
+
end
|
379
|
+
|
380
|
+
promise.execute
|
381
|
+
end
|
382
|
+
|
383
|
+
end
|
384
|
+
end
|
@@ -0,0 +1,525 @@
|
|
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::Compute
|
7
|
+
#
|
8
|
+
# VirtualMachineImages
|
9
|
+
#
|
10
|
+
class VirtualMachineImages
|
11
|
+
include Azure::ARM::Compute::Models
|
12
|
+
include MsRestAzure
|
13
|
+
|
14
|
+
#
|
15
|
+
# Creates and initializes a new instance of the VirtualMachineImages 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 ComputeManagementClient
|
23
|
+
attr_reader :client
|
24
|
+
|
25
|
+
#
|
26
|
+
# Gets a virtual machine image.
|
27
|
+
# @param location [String]
|
28
|
+
# @param publisher_name [String]
|
29
|
+
# @param offer [String]
|
30
|
+
# @param skus [String]
|
31
|
+
# @param version [String]
|
32
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
33
|
+
# applied to HTTP request.
|
34
|
+
#
|
35
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
36
|
+
# response.
|
37
|
+
#
|
38
|
+
def get(location, publisher_name, offer, skus, version, custom_headers = nil)
|
39
|
+
fail ArgumentError, 'location is nil' if location.nil?
|
40
|
+
fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
|
41
|
+
fail ArgumentError, 'offer is nil' if offer.nil?
|
42
|
+
fail ArgumentError, 'skus is nil' if skus.nil?
|
43
|
+
fail ArgumentError, 'version is nil' if version.nil?
|
44
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
45
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
46
|
+
# Construct URL
|
47
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}"
|
48
|
+
path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
|
49
|
+
path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
|
50
|
+
path['{offer}'] = ERB::Util.url_encode(offer) if path.include?('{offer}')
|
51
|
+
path['{skus}'] = ERB::Util.url_encode(skus) if path.include?('{skus}')
|
52
|
+
path['{version}'] = ERB::Util.url_encode(version) if path.include?('{version}')
|
53
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
54
|
+
url = URI.join(@client.base_url, path)
|
55
|
+
properties = {}
|
56
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
57
|
+
unless url.query.nil?
|
58
|
+
url.query.split('&').each do |url_item|
|
59
|
+
url_items_parts = url_item.split('=')
|
60
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
properties.reject!{ |key, value| value.nil? }
|
64
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
65
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
66
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
67
|
+
url = URI.parse(corrected_url)
|
68
|
+
|
69
|
+
connection = Faraday.new(:url => url) do |faraday|
|
70
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
71
|
+
faraday.use :cookie_jar
|
72
|
+
faraday.adapter Faraday.default_adapter
|
73
|
+
end
|
74
|
+
request_headers = Hash.new
|
75
|
+
|
76
|
+
# Set Headers
|
77
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
78
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
79
|
+
|
80
|
+
unless custom_headers.nil?
|
81
|
+
custom_headers.each do |key, value|
|
82
|
+
request_headers[key] = value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Send Request
|
87
|
+
promise = Concurrent::Promise.new do
|
88
|
+
connection.get do |request|
|
89
|
+
request.headers = request_headers
|
90
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
promise = promise.then do |http_response|
|
95
|
+
status_code = http_response.status
|
96
|
+
response_content = http_response.body
|
97
|
+
unless (status_code == 200)
|
98
|
+
error_model = JSON.load(response_content)
|
99
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Create Result
|
103
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
104
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
105
|
+
# Deserialize Response
|
106
|
+
if status_code == 200
|
107
|
+
begin
|
108
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
109
|
+
unless parsed_response.nil?
|
110
|
+
parsed_response = VirtualMachineImage.deserialize_object(parsed_response)
|
111
|
+
end
|
112
|
+
result.body = parsed_response
|
113
|
+
rescue Exception => e
|
114
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
result
|
119
|
+
end
|
120
|
+
|
121
|
+
promise.execute
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Gets a list of virtual machine image offers.
|
126
|
+
# @param location [String]
|
127
|
+
# @param publisher_name [String]
|
128
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
129
|
+
# applied to HTTP request.
|
130
|
+
#
|
131
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
132
|
+
# response.
|
133
|
+
#
|
134
|
+
def list_offers(location, publisher_name, custom_headers = nil)
|
135
|
+
fail ArgumentError, 'location is nil' if location.nil?
|
136
|
+
fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
|
137
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
138
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
139
|
+
# Construct URL
|
140
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers"
|
141
|
+
path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
|
142
|
+
path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
|
143
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
144
|
+
url = URI.join(@client.base_url, path)
|
145
|
+
properties = {}
|
146
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
147
|
+
unless url.query.nil?
|
148
|
+
url.query.split('&').each do |url_item|
|
149
|
+
url_items_parts = url_item.split('=')
|
150
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
properties.reject!{ |key, value| value.nil? }
|
154
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
155
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
156
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
157
|
+
url = URI.parse(corrected_url)
|
158
|
+
|
159
|
+
connection = Faraday.new(:url => url) do |faraday|
|
160
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
161
|
+
faraday.use :cookie_jar
|
162
|
+
faraday.adapter Faraday.default_adapter
|
163
|
+
end
|
164
|
+
request_headers = Hash.new
|
165
|
+
|
166
|
+
# Set Headers
|
167
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
168
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
169
|
+
|
170
|
+
unless custom_headers.nil?
|
171
|
+
custom_headers.each do |key, value|
|
172
|
+
request_headers[key] = value
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Send Request
|
177
|
+
promise = Concurrent::Promise.new do
|
178
|
+
connection.get do |request|
|
179
|
+
request.headers = request_headers
|
180
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
promise = promise.then do |http_response|
|
185
|
+
status_code = http_response.status
|
186
|
+
response_content = http_response.body
|
187
|
+
unless (status_code == 200)
|
188
|
+
error_model = JSON.load(response_content)
|
189
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
190
|
+
end
|
191
|
+
|
192
|
+
# Create Result
|
193
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
194
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
195
|
+
# Deserialize Response
|
196
|
+
if status_code == 200
|
197
|
+
begin
|
198
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
199
|
+
unless parsed_response.nil?
|
200
|
+
deserializedArray = [];
|
201
|
+
parsed_response.each do |element|
|
202
|
+
unless element.nil?
|
203
|
+
element = VirtualMachineImageResource.deserialize_object(element)
|
204
|
+
end
|
205
|
+
deserializedArray.push(element);
|
206
|
+
end
|
207
|
+
parsed_response = deserializedArray;
|
208
|
+
end
|
209
|
+
result.body = parsed_response
|
210
|
+
rescue Exception => e
|
211
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
result
|
216
|
+
end
|
217
|
+
|
218
|
+
promise.execute
|
219
|
+
end
|
220
|
+
|
221
|
+
#
|
222
|
+
# Gets a list of virtual machine image publishers.
|
223
|
+
# @param location [String]
|
224
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
225
|
+
# applied to HTTP request.
|
226
|
+
#
|
227
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
228
|
+
# response.
|
229
|
+
#
|
230
|
+
def list_publishers(location, custom_headers = nil)
|
231
|
+
fail ArgumentError, 'location is nil' if location.nil?
|
232
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
233
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
234
|
+
# Construct URL
|
235
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers"
|
236
|
+
path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
|
237
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
238
|
+
url = URI.join(@client.base_url, path)
|
239
|
+
properties = {}
|
240
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
241
|
+
unless url.query.nil?
|
242
|
+
url.query.split('&').each do |url_item|
|
243
|
+
url_items_parts = url_item.split('=')
|
244
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
245
|
+
end
|
246
|
+
end
|
247
|
+
properties.reject!{ |key, value| value.nil? }
|
248
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
249
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
250
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
251
|
+
url = URI.parse(corrected_url)
|
252
|
+
|
253
|
+
connection = Faraday.new(:url => url) do |faraday|
|
254
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
255
|
+
faraday.use :cookie_jar
|
256
|
+
faraday.adapter Faraday.default_adapter
|
257
|
+
end
|
258
|
+
request_headers = Hash.new
|
259
|
+
|
260
|
+
# Set Headers
|
261
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
262
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
263
|
+
|
264
|
+
unless custom_headers.nil?
|
265
|
+
custom_headers.each do |key, value|
|
266
|
+
request_headers[key] = value
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
# Send Request
|
271
|
+
promise = Concurrent::Promise.new do
|
272
|
+
connection.get do |request|
|
273
|
+
request.headers = request_headers
|
274
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
promise = promise.then do |http_response|
|
279
|
+
status_code = http_response.status
|
280
|
+
response_content = http_response.body
|
281
|
+
unless (status_code == 200)
|
282
|
+
error_model = JSON.load(response_content)
|
283
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
284
|
+
end
|
285
|
+
|
286
|
+
# Create Result
|
287
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
288
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
289
|
+
# Deserialize Response
|
290
|
+
if status_code == 200
|
291
|
+
begin
|
292
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
293
|
+
unless parsed_response.nil?
|
294
|
+
deserializedArray = [];
|
295
|
+
parsed_response.each do |element|
|
296
|
+
unless element.nil?
|
297
|
+
element = VirtualMachineImageResource.deserialize_object(element)
|
298
|
+
end
|
299
|
+
deserializedArray.push(element);
|
300
|
+
end
|
301
|
+
parsed_response = deserializedArray;
|
302
|
+
end
|
303
|
+
result.body = parsed_response
|
304
|
+
rescue Exception => e
|
305
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
result
|
310
|
+
end
|
311
|
+
|
312
|
+
promise.execute
|
313
|
+
end
|
314
|
+
|
315
|
+
#
|
316
|
+
# Gets a list of virtual machine image skus.
|
317
|
+
# @param location [String]
|
318
|
+
# @param publisher_name [String]
|
319
|
+
# @param offer [String]
|
320
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
321
|
+
# applied to HTTP request.
|
322
|
+
#
|
323
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
324
|
+
# response.
|
325
|
+
#
|
326
|
+
def list_skus(location, publisher_name, offer, custom_headers = nil)
|
327
|
+
fail ArgumentError, 'location is nil' if location.nil?
|
328
|
+
fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
|
329
|
+
fail ArgumentError, 'offer is nil' if offer.nil?
|
330
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
331
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
332
|
+
# Construct URL
|
333
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus"
|
334
|
+
path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
|
335
|
+
path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
|
336
|
+
path['{offer}'] = ERB::Util.url_encode(offer) if path.include?('{offer}')
|
337
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
338
|
+
url = URI.join(@client.base_url, path)
|
339
|
+
properties = {}
|
340
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
341
|
+
unless url.query.nil?
|
342
|
+
url.query.split('&').each do |url_item|
|
343
|
+
url_items_parts = url_item.split('=')
|
344
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
345
|
+
end
|
346
|
+
end
|
347
|
+
properties.reject!{ |key, value| value.nil? }
|
348
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
349
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
350
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
351
|
+
url = URI.parse(corrected_url)
|
352
|
+
|
353
|
+
connection = Faraday.new(:url => url) do |faraday|
|
354
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
355
|
+
faraday.use :cookie_jar
|
356
|
+
faraday.adapter Faraday.default_adapter
|
357
|
+
end
|
358
|
+
request_headers = Hash.new
|
359
|
+
|
360
|
+
# Set Headers
|
361
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
362
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
363
|
+
|
364
|
+
unless custom_headers.nil?
|
365
|
+
custom_headers.each do |key, value|
|
366
|
+
request_headers[key] = value
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
# Send Request
|
371
|
+
promise = Concurrent::Promise.new do
|
372
|
+
connection.get do |request|
|
373
|
+
request.headers = request_headers
|
374
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
promise = promise.then do |http_response|
|
379
|
+
status_code = http_response.status
|
380
|
+
response_content = http_response.body
|
381
|
+
unless (status_code == 200)
|
382
|
+
error_model = JSON.load(response_content)
|
383
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
384
|
+
end
|
385
|
+
|
386
|
+
# Create Result
|
387
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
388
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
389
|
+
# Deserialize Response
|
390
|
+
if status_code == 200
|
391
|
+
begin
|
392
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
393
|
+
unless parsed_response.nil?
|
394
|
+
deserializedArray = [];
|
395
|
+
parsed_response.each do |element|
|
396
|
+
unless element.nil?
|
397
|
+
element = VirtualMachineImageResource.deserialize_object(element)
|
398
|
+
end
|
399
|
+
deserializedArray.push(element);
|
400
|
+
end
|
401
|
+
parsed_response = deserializedArray;
|
402
|
+
end
|
403
|
+
result.body = parsed_response
|
404
|
+
rescue Exception => e
|
405
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
result
|
410
|
+
end
|
411
|
+
|
412
|
+
promise.execute
|
413
|
+
end
|
414
|
+
|
415
|
+
#
|
416
|
+
# Gets a list of virtual machine images.
|
417
|
+
# @param location [String]
|
418
|
+
# @param publisher_name [String]
|
419
|
+
# @param offer [String]
|
420
|
+
# @param skus [String]
|
421
|
+
# @param filter [String] The filter to apply on the operation.
|
422
|
+
# @param top [Integer]
|
423
|
+
# @param orderby [String]
|
424
|
+
# @param [Hash{String => String}] The hash of custom headers need to be
|
425
|
+
# applied to HTTP request.
|
426
|
+
#
|
427
|
+
# @return [Concurrent::Promise] Promise object which allows to get HTTP
|
428
|
+
# response.
|
429
|
+
#
|
430
|
+
def list(location, publisher_name, offer, skus, filter = nil, top = nil, orderby = nil, custom_headers = nil)
|
431
|
+
fail ArgumentError, 'location is nil' if location.nil?
|
432
|
+
fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
|
433
|
+
fail ArgumentError, 'offer is nil' if offer.nil?
|
434
|
+
fail ArgumentError, 'skus is nil' if skus.nil?
|
435
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
436
|
+
fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
|
437
|
+
# Construct URL
|
438
|
+
path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions"
|
439
|
+
path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
|
440
|
+
path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
|
441
|
+
path['{offer}'] = ERB::Util.url_encode(offer) if path.include?('{offer}')
|
442
|
+
path['{skus}'] = ERB::Util.url_encode(skus) if path.include?('{skus}')
|
443
|
+
path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
|
444
|
+
url = URI.join(@client.base_url, path)
|
445
|
+
properties = {}
|
446
|
+
properties['$filter'] = ERB::Util.url_encode(filter.to_s) unless filter.nil?
|
447
|
+
properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
|
448
|
+
properties['$orderby'] = ERB::Util.url_encode(orderby.to_s) unless orderby.nil?
|
449
|
+
properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
|
450
|
+
unless url.query.nil?
|
451
|
+
url.query.split('&').each do |url_item|
|
452
|
+
url_items_parts = url_item.split('=')
|
453
|
+
properties[url_items_parts[0]] = url_items_parts[1]
|
454
|
+
end
|
455
|
+
end
|
456
|
+
properties.reject!{ |key, value| value.nil? }
|
457
|
+
url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
|
458
|
+
fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
|
459
|
+
corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
|
460
|
+
url = URI.parse(corrected_url)
|
461
|
+
|
462
|
+
connection = Faraday.new(:url => url) do |faraday|
|
463
|
+
faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
|
464
|
+
faraday.use :cookie_jar
|
465
|
+
faraday.adapter Faraday.default_adapter
|
466
|
+
end
|
467
|
+
request_headers = Hash.new
|
468
|
+
|
469
|
+
# Set Headers
|
470
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
471
|
+
request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
|
472
|
+
|
473
|
+
unless custom_headers.nil?
|
474
|
+
custom_headers.each do |key, value|
|
475
|
+
request_headers[key] = value
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
# Send Request
|
480
|
+
promise = Concurrent::Promise.new do
|
481
|
+
connection.get do |request|
|
482
|
+
request.headers = request_headers
|
483
|
+
@client.credentials.sign_request(request) unless @client.credentials.nil?
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
promise = promise.then do |http_response|
|
488
|
+
status_code = http_response.status
|
489
|
+
response_content = http_response.body
|
490
|
+
unless (status_code == 200)
|
491
|
+
error_model = JSON.load(response_content)
|
492
|
+
fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
|
493
|
+
end
|
494
|
+
|
495
|
+
# Create Result
|
496
|
+
result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
|
497
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
498
|
+
# Deserialize Response
|
499
|
+
if status_code == 200
|
500
|
+
begin
|
501
|
+
parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
|
502
|
+
unless parsed_response.nil?
|
503
|
+
deserializedArray = [];
|
504
|
+
parsed_response.each do |element|
|
505
|
+
unless element.nil?
|
506
|
+
element = VirtualMachineImageResource.deserialize_object(element)
|
507
|
+
end
|
508
|
+
deserializedArray.push(element);
|
509
|
+
end
|
510
|
+
parsed_response = deserializedArray;
|
511
|
+
end
|
512
|
+
result.body = parsed_response
|
513
|
+
rescue Exception => e
|
514
|
+
fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
result
|
519
|
+
end
|
520
|
+
|
521
|
+
promise.execute
|
522
|
+
end
|
523
|
+
|
524
|
+
end
|
525
|
+
end
|