azure_mgmt_compute 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +17 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +139 -0
  8. data/Rakefile +5 -0
  9. data/azure_mgmt_compute.gemspec +39 -0
  10. data/lib/azure_mgmt_compute.rb +103 -0
  11. data/lib/azure_mgmt_compute/Models/additional_unattend_content.rb +108 -0
  12. data/lib/azure_mgmt_compute/Models/api_error.rb +121 -0
  13. data/lib/azure_mgmt_compute/Models/api_error_base.rb +76 -0
  14. data/lib/azure_mgmt_compute/Models/availability_set.rb +94 -0
  15. data/lib/azure_mgmt_compute/Models/availability_set_list_result.rb +79 -0
  16. data/lib/azure_mgmt_compute/Models/availability_set_properties.rb +130 -0
  17. data/lib/azure_mgmt_compute/Models/caching_types.rb +17 -0
  18. data/lib/azure_mgmt_compute/Models/component_names.rb +15 -0
  19. data/lib/azure_mgmt_compute/Models/compute_long_running_operation_properties.rb +58 -0
  20. data/lib/azure_mgmt_compute/Models/compute_long_running_operation_result.rb +126 -0
  21. data/lib/azure_mgmt_compute/Models/compute_operation_status.rb +18 -0
  22. data/lib/azure_mgmt_compute/Models/data_disk.rb +142 -0
  23. data/lib/azure_mgmt_compute/Models/data_disk_image.rb +62 -0
  24. data/lib/azure_mgmt_compute/Models/delete_operation_result.rb +109 -0
  25. data/lib/azure_mgmt_compute/Models/disk_create_option_types.rb +17 -0
  26. data/lib/azure_mgmt_compute/Models/disk_instance_view.rb +88 -0
  27. data/lib/azure_mgmt_compute/Models/hardware_profile.rb +67 -0
  28. data/lib/azure_mgmt_compute/Models/image_reference.rb +87 -0
  29. data/lib/azure_mgmt_compute/Models/inner_error.rb +68 -0
  30. data/lib/azure_mgmt_compute/Models/instance_view_status.rb +102 -0
  31. data/lib/azure_mgmt_compute/Models/linux_configuration.rb +75 -0
  32. data/lib/azure_mgmt_compute/Models/list_usages_result.rb +78 -0
  33. data/lib/azure_mgmt_compute/Models/network_interface_reference.rb +70 -0
  34. data/lib/azure_mgmt_compute/Models/network_interface_reference_properties.rb +59 -0
  35. data/lib/azure_mgmt_compute/Models/network_profile.rb +79 -0
  36. data/lib/azure_mgmt_compute/Models/operating_system_types.rb +16 -0
  37. data/lib/azure_mgmt_compute/Models/operation_status.rb +17 -0
  38. data/lib/azure_mgmt_compute/Models/osdisk.rb +135 -0
  39. data/lib/azure_mgmt_compute/Models/osdisk_image.rb +63 -0
  40. data/lib/azure_mgmt_compute/Models/osprofile.rb +149 -0
  41. data/lib/azure_mgmt_compute/Models/pass_names.rb +15 -0
  42. data/lib/azure_mgmt_compute/Models/plan.rb +85 -0
  43. data/lib/azure_mgmt_compute/Models/protocol_types.rb +16 -0
  44. data/lib/azure_mgmt_compute/Models/purchase_plan.rb +77 -0
  45. data/lib/azure_mgmt_compute/Models/setting_names.rb +16 -0
  46. data/lib/azure_mgmt_compute/Models/ssh_configuration.rb +79 -0
  47. data/lib/azure_mgmt_compute/Models/ssh_public_key.rb +72 -0
  48. data/lib/azure_mgmt_compute/Models/status_level_types.rb +17 -0
  49. data/lib/azure_mgmt_compute/Models/storage_profile.rb +110 -0
  50. data/lib/azure_mgmt_compute/Models/usage.rb +98 -0
  51. data/lib/azure_mgmt_compute/Models/usage_name.rb +68 -0
  52. data/lib/azure_mgmt_compute/Models/usage_unit.rb +15 -0
  53. data/lib/azure_mgmt_compute/Models/vault_certificate.rb +70 -0
  54. data/lib/azure_mgmt_compute/Models/vault_secret_group.rb +96 -0
  55. data/lib/azure_mgmt_compute/Models/virtual_hard_disk.rb +59 -0
  56. data/lib/azure_mgmt_compute/Models/virtual_machine.rb +142 -0
  57. data/lib/azure_mgmt_compute/Models/virtual_machine_agent_instance_view.rb +119 -0
  58. data/lib/azure_mgmt_compute/Models/virtual_machine_capture_parameters.rb +78 -0
  59. data/lib/azure_mgmt_compute/Models/virtual_machine_extension.rb +94 -0
  60. data/lib/azure_mgmt_compute/Models/virtual_machine_extension_handler_instance_view.rb +85 -0
  61. data/lib/azure_mgmt_compute/Models/virtual_machine_extension_image.rb +99 -0
  62. data/lib/azure_mgmt_compute/Models/virtual_machine_extension_image_properties.rb +102 -0
  63. data/lib/azure_mgmt_compute/Models/virtual_machine_extension_instance_view.rb +139 -0
  64. data/lib/azure_mgmt_compute/Models/virtual_machine_extension_properties.rb +133 -0
  65. data/lib/azure_mgmt_compute/Models/virtual_machine_image.rb +99 -0
  66. data/lib/azure_mgmt_compute/Models/virtual_machine_image_properties.rb +110 -0
  67. data/lib/azure_mgmt_compute/Models/virtual_machine_image_resource.rb +83 -0
  68. data/lib/azure_mgmt_compute/Models/virtual_machine_instance_view.rb +188 -0
  69. data/lib/azure_mgmt_compute/Models/virtual_machine_list_result.rb +89 -0
  70. data/lib/azure_mgmt_compute/Models/virtual_machine_properties.rb +156 -0
  71. data/lib/azure_mgmt_compute/Models/virtual_machine_size.rb +111 -0
  72. data/lib/azure_mgmt_compute/Models/virtual_machine_size_list_result.rb +79 -0
  73. data/lib/azure_mgmt_compute/Models/virtual_machine_size_types.rb +34 -0
  74. data/lib/azure_mgmt_compute/Models/win_rmconfiguration.rb +79 -0
  75. data/lib/azure_mgmt_compute/Models/win_rmlistener.rb +73 -0
  76. data/lib/azure_mgmt_compute/Models/windows_configuration.rb +126 -0
  77. data/lib/azure_mgmt_compute/availability_sets.rb +473 -0
  78. data/lib/azure_mgmt_compute/compute_management_client.rb +85 -0
  79. data/lib/azure_mgmt_compute/module_definition.rb +6 -0
  80. data/lib/azure_mgmt_compute/usage_operations.rb +113 -0
  81. data/lib/azure_mgmt_compute/version.rb +6 -0
  82. data/lib/azure_mgmt_compute/virtual_machine_extension_images.rb +325 -0
  83. data/lib/azure_mgmt_compute/virtual_machine_extensions.rb +384 -0
  84. data/lib/azure_mgmt_compute/virtual_machine_images.rb +525 -0
  85. data/lib/azure_mgmt_compute/virtual_machine_sizes.rb +114 -0
  86. data/lib/azure_mgmt_compute/virtual_machines.rb +1412 -0
  87. metadata +303 -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::Compute
7
+ #
8
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class ComputeManagementClient < MsRestAzure::AzureServiceClient
11
+ include Azure::ARM::Compute::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 availability_sets
39
+ attr_reader :availability_sets
40
+
41
+ # @return virtual_machine_images
42
+ attr_reader :virtual_machine_images
43
+
44
+ # @return virtual_machine_extension_images
45
+ attr_reader :virtual_machine_extension_images
46
+
47
+ # @return virtual_machine_extensions
48
+ attr_reader :virtual_machine_extensions
49
+
50
+ # @return usage_operations
51
+ attr_reader :usage_operations
52
+
53
+ # @return virtual_machine_sizes
54
+ attr_reader :virtual_machine_sizes
55
+
56
+ # @return virtual_machines
57
+ attr_reader :virtual_machines
58
+
59
+ #
60
+ # Creates initializes a new instance of the ComputeManagementClient 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
+ @availability_sets = AvailabilitySets.new(self)
74
+ @virtual_machine_images = VirtualMachineImages.new(self)
75
+ @virtual_machine_extension_images = VirtualMachineExtensionImages.new(self)
76
+ @virtual_machine_extensions = VirtualMachineExtensions.new(self)
77
+ @usage_operations = UsageOperations.new(self)
78
+ @virtual_machine_sizes = VirtualMachineSizes.new(self)
79
+ @virtual_machines = VirtualMachines.new(self)
80
+ @api_version = "2015-06-15"
81
+ @accept_language = "en-US"
82
+ end
83
+
84
+ end
85
+ end
@@ -0,0 +1,6 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License. See License.txt in the project root for license information.
3
+
4
+ module Azure end
5
+ module Azure::ARM end
6
+ module Azure::ARM::Compute end
@@ -0,0 +1,113 @@
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
+ # UsageOperations
9
+ #
10
+ class UsageOperations
11
+ include Azure::ARM::Compute::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the UsageOperations 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
+ # Lists compute usages for a subscription.
27
+ # @param location [String] The location upon which resource usage is queried.
28
+ # @param [Hash{String => String}] The hash of custom headers need to be
29
+ # applied to HTTP request.
30
+ #
31
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
32
+ # response.
33
+ #
34
+ def list(location, custom_headers = nil)
35
+ fail ArgumentError, 'location is nil' if location.nil?
36
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
37
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
38
+ # Construct URL
39
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages"
40
+ path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
41
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
42
+ url = URI.join(@client.base_url, path)
43
+ properties = {}
44
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
45
+ unless url.query.nil?
46
+ url.query.split('&').each do |url_item|
47
+ url_items_parts = url_item.split('=')
48
+ properties[url_items_parts[0]] = url_items_parts[1]
49
+ end
50
+ end
51
+ properties.reject!{ |key, value| value.nil? }
52
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
53
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
54
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
55
+ url = URI.parse(corrected_url)
56
+
57
+ connection = Faraday.new(:url => url) do |faraday|
58
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
59
+ faraday.use :cookie_jar
60
+ faraday.adapter Faraday.default_adapter
61
+ end
62
+ request_headers = Hash.new
63
+
64
+ # Set Headers
65
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
66
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
67
+
68
+ unless custom_headers.nil?
69
+ custom_headers.each do |key, value|
70
+ request_headers[key] = value
71
+ end
72
+ end
73
+
74
+ # Send Request
75
+ promise = Concurrent::Promise.new do
76
+ connection.get do |request|
77
+ request.headers = request_headers
78
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
79
+ end
80
+ end
81
+
82
+ promise = promise.then do |http_response|
83
+ status_code = http_response.status
84
+ response_content = http_response.body
85
+ unless (status_code == 200)
86
+ error_model = JSON.load(response_content)
87
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
88
+ end
89
+
90
+ # Create Result
91
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
92
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
93
+ # Deserialize Response
94
+ if status_code == 200
95
+ begin
96
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
97
+ unless parsed_response.nil?
98
+ parsed_response = ListUsagesResult.deserialize_object(parsed_response)
99
+ end
100
+ result.body = parsed_response
101
+ rescue Exception => e
102
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
103
+ end
104
+ end
105
+
106
+ result
107
+ end
108
+
109
+ promise.execute
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,6 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License. See License.txt in the project root for license information.
3
+
4
+ module Azure::ARM::Compute
5
+ VERSION = '0.1.0'
6
+ end
@@ -0,0 +1,325 @@
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
+ # VirtualMachineExtensionImages
9
+ #
10
+ class VirtualMachineExtensionImages
11
+ include Azure::ARM::Compute::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the VirtualMachineExtensionImages 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 extension image.
27
+ # @param location [String]
28
+ # @param publisher_name [String]
29
+ # @param type [String]
30
+ # @param version [String]
31
+ # @param [Hash{String => String}] The hash of custom headers need to be
32
+ # applied to HTTP request.
33
+ #
34
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
35
+ # response.
36
+ #
37
+ def get(location, publisher_name, type, version, custom_headers = nil)
38
+ fail ArgumentError, 'location is nil' if location.nil?
39
+ fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
40
+ fail ArgumentError, 'type is nil' if type.nil?
41
+ fail ArgumentError, 'version is nil' if version.nil?
42
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
43
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
44
+ # Construct URL
45
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}"
46
+ path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
47
+ path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
48
+ path['{type}'] = ERB::Util.url_encode(type) if path.include?('{type}')
49
+ path['{version}'] = ERB::Util.url_encode(version) if path.include?('{version}')
50
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
51
+ url = URI.join(@client.base_url, path)
52
+ properties = {}
53
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
54
+ unless url.query.nil?
55
+ url.query.split('&').each do |url_item|
56
+ url_items_parts = url_item.split('=')
57
+ properties[url_items_parts[0]] = url_items_parts[1]
58
+ end
59
+ end
60
+ properties.reject!{ |key, value| value.nil? }
61
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
62
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
63
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
64
+ url = URI.parse(corrected_url)
65
+
66
+ connection = Faraday.new(:url => url) do |faraday|
67
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
68
+ faraday.use :cookie_jar
69
+ faraday.adapter Faraday.default_adapter
70
+ end
71
+ request_headers = Hash.new
72
+
73
+ # Set Headers
74
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
75
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
76
+
77
+ unless custom_headers.nil?
78
+ custom_headers.each do |key, value|
79
+ request_headers[key] = value
80
+ end
81
+ end
82
+
83
+ # Send Request
84
+ promise = Concurrent::Promise.new do
85
+ connection.get do |request|
86
+ request.headers = request_headers
87
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
88
+ end
89
+ end
90
+
91
+ promise = promise.then do |http_response|
92
+ status_code = http_response.status
93
+ response_content = http_response.body
94
+ unless (status_code == 200)
95
+ error_model = JSON.load(response_content)
96
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
97
+ end
98
+
99
+ # Create Result
100
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
101
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
102
+ # Deserialize Response
103
+ if status_code == 200
104
+ begin
105
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
106
+ unless parsed_response.nil?
107
+ parsed_response = VirtualMachineExtensionImage.deserialize_object(parsed_response)
108
+ end
109
+ result.body = parsed_response
110
+ rescue Exception => e
111
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
112
+ end
113
+ end
114
+
115
+ result
116
+ end
117
+
118
+ promise.execute
119
+ end
120
+
121
+ #
122
+ # Gets a list of virtual machine extension image versions.
123
+ # @param location [String]
124
+ # @param publisher_name [String]
125
+ # @param type [String]
126
+ # @param filter [String] The filter to apply on the operation.
127
+ # @param top [Integer]
128
+ # @param orderby [String]
129
+ # @param [Hash{String => String}] The hash of custom headers need to be
130
+ # applied to HTTP request.
131
+ #
132
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
133
+ # response.
134
+ #
135
+ def list_versions(location, publisher_name, type, filter = nil, top = nil, orderby = nil, custom_headers = nil)
136
+ fail ArgumentError, 'location is nil' if location.nil?
137
+ fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
138
+ fail ArgumentError, 'type is nil' if type.nil?
139
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
140
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
141
+ # Construct URL
142
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions"
143
+ path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
144
+ path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
145
+ path['{type}'] = ERB::Util.url_encode(type) if path.include?('{type}')
146
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
147
+ url = URI.join(@client.base_url, path)
148
+ properties = {}
149
+ properties['$filter'] = ERB::Util.url_encode(filter.to_s) unless filter.nil?
150
+ properties['$top'] = ERB::Util.url_encode(top.to_s) unless top.nil?
151
+ properties['$orderby'] = ERB::Util.url_encode(orderby.to_s) unless orderby.nil?
152
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
153
+ unless url.query.nil?
154
+ url.query.split('&').each do |url_item|
155
+ url_items_parts = url_item.split('=')
156
+ properties[url_items_parts[0]] = url_items_parts[1]
157
+ end
158
+ end
159
+ properties.reject!{ |key, value| value.nil? }
160
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
161
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
162
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
163
+ url = URI.parse(corrected_url)
164
+
165
+ connection = Faraday.new(:url => url) do |faraday|
166
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
167
+ faraday.use :cookie_jar
168
+ faraday.adapter Faraday.default_adapter
169
+ end
170
+ request_headers = Hash.new
171
+
172
+ # Set Headers
173
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
174
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
175
+
176
+ unless custom_headers.nil?
177
+ custom_headers.each do |key, value|
178
+ request_headers[key] = value
179
+ end
180
+ end
181
+
182
+ # Send Request
183
+ promise = Concurrent::Promise.new do
184
+ connection.get do |request|
185
+ request.headers = request_headers
186
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
187
+ end
188
+ end
189
+
190
+ promise = promise.then do |http_response|
191
+ status_code = http_response.status
192
+ response_content = http_response.body
193
+ unless (status_code == 200)
194
+ error_model = JSON.load(response_content)
195
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
196
+ end
197
+
198
+ # Create Result
199
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
200
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
201
+ # Deserialize Response
202
+ if status_code == 200
203
+ begin
204
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
205
+ unless parsed_response.nil?
206
+ deserializedArray = [];
207
+ parsed_response.each do |element|
208
+ unless element.nil?
209
+ element = VirtualMachineImageResource.deserialize_object(element)
210
+ end
211
+ deserializedArray.push(element);
212
+ end
213
+ parsed_response = deserializedArray;
214
+ end
215
+ result.body = parsed_response
216
+ rescue Exception => e
217
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
218
+ end
219
+ end
220
+
221
+ result
222
+ end
223
+
224
+ promise.execute
225
+ end
226
+
227
+ #
228
+ # Gets a list of virtual machine extension image types.
229
+ # @param location [String]
230
+ # @param publisher_name [String]
231
+ # @param [Hash{String => String}] The hash of custom headers need to be
232
+ # applied to HTTP request.
233
+ #
234
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
235
+ # response.
236
+ #
237
+ def list_types(location, publisher_name, custom_headers = nil)
238
+ fail ArgumentError, 'location is nil' if location.nil?
239
+ fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
240
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
241
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
242
+ # Construct URL
243
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types"
244
+ path['{location}'] = ERB::Util.url_encode(location) if path.include?('{location}')
245
+ path['{publisherName}'] = ERB::Util.url_encode(publisher_name) if path.include?('{publisherName}')
246
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
247
+ url = URI.join(@client.base_url, path)
248
+ properties = {}
249
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
250
+ unless url.query.nil?
251
+ url.query.split('&').each do |url_item|
252
+ url_items_parts = url_item.split('=')
253
+ properties[url_items_parts[0]] = url_items_parts[1]
254
+ end
255
+ end
256
+ properties.reject!{ |key, value| value.nil? }
257
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
258
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
259
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
260
+ url = URI.parse(corrected_url)
261
+
262
+ connection = Faraday.new(:url => url) do |faraday|
263
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
264
+ faraday.use :cookie_jar
265
+ faraday.adapter Faraday.default_adapter
266
+ end
267
+ request_headers = Hash.new
268
+
269
+ # Set Headers
270
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
271
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
272
+
273
+ unless custom_headers.nil?
274
+ custom_headers.each do |key, value|
275
+ request_headers[key] = value
276
+ end
277
+ end
278
+
279
+ # Send Request
280
+ promise = Concurrent::Promise.new do
281
+ connection.get do |request|
282
+ request.headers = request_headers
283
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
284
+ end
285
+ end
286
+
287
+ promise = promise.then do |http_response|
288
+ status_code = http_response.status
289
+ response_content = http_response.body
290
+ unless (status_code == 200)
291
+ error_model = JSON.load(response_content)
292
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
293
+ end
294
+
295
+ # Create Result
296
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
297
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
298
+ # Deserialize Response
299
+ if status_code == 200
300
+ begin
301
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
302
+ unless parsed_response.nil?
303
+ deserializedArray = [];
304
+ parsed_response.each do |element|
305
+ unless element.nil?
306
+ element = VirtualMachineImageResource.deserialize_object(element)
307
+ end
308
+ deserializedArray.push(element);
309
+ end
310
+ parsed_response = deserializedArray;
311
+ end
312
+ result.body = parsed_response
313
+ rescue Exception => e
314
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
315
+ end
316
+ end
317
+
318
+ result
319
+ end
320
+
321
+ promise.execute
322
+ end
323
+
324
+ end
325
+ end