azure_mgmt_compute 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/azure_mgmt_compute.gemspec +3 -11
  3. data/lib/azure_mgmt_compute/availability_sets.rb +226 -241
  4. data/lib/azure_mgmt_compute/compute_management_client.rb +26 -11
  5. data/lib/azure_mgmt_compute/models/additional_unattend_content.rb +8 -11
  6. data/lib/azure_mgmt_compute/models/api_entity_reference.rb +58 -0
  7. data/lib/azure_mgmt_compute/models/api_error.rb +4 -6
  8. data/lib/azure_mgmt_compute/models/api_error_base.rb +1 -3
  9. data/lib/azure_mgmt_compute/models/availability_set.rb +1 -3
  10. data/lib/azure_mgmt_compute/models/availability_set_list_result.rb +4 -6
  11. data/lib/azure_mgmt_compute/models/availability_set_properties.rb +9 -11
  12. data/lib/azure_mgmt_compute/models/boot_diagnostics.rb +67 -0
  13. data/lib/azure_mgmt_compute/models/boot_diagnostics_instance_view.rb +65 -0
  14. data/lib/azure_mgmt_compute/models/caching_types.rb +1 -1
  15. data/lib/azure_mgmt_compute/models/component_names.rb +1 -1
  16. data/lib/azure_mgmt_compute/models/compute_long_running_operation_properties.rb +1 -3
  17. data/lib/azure_mgmt_compute/models/compute_long_running_operation_result.rb +3 -6
  18. data/lib/azure_mgmt_compute/models/compute_operation_status.rb +1 -1
  19. data/lib/azure_mgmt_compute/models/data_disk.rb +27 -26
  20. data/lib/azure_mgmt_compute/models/data_disk_image.rb +1 -3
  21. data/lib/azure_mgmt_compute/models/delete_operation_result.rb +6 -5
  22. data/lib/azure_mgmt_compute/models/diagnostics_profile.rb +62 -0
  23. data/lib/azure_mgmt_compute/models/disk_create_option_types.rb +1 -1
  24. data/lib/azure_mgmt_compute/models/disk_encryption_settings.rb +81 -0
  25. data/lib/azure_mgmt_compute/models/disk_instance_view.rb +4 -6
  26. data/lib/azure_mgmt_compute/models/hardware_profile.rb +15 -9
  27. data/lib/azure_mgmt_compute/models/image_reference.rb +1 -3
  28. data/lib/azure_mgmt_compute/models/inner_error.rb +1 -3
  29. data/lib/azure_mgmt_compute/models/instance_view_status.rb +3 -5
  30. data/lib/azure_mgmt_compute/models/key_vault_key_reference.rb +74 -0
  31. data/lib/azure_mgmt_compute/models/key_vault_secret_reference.rb +75 -0
  32. data/lib/azure_mgmt_compute/models/linux_configuration.rb +1 -3
  33. data/lib/azure_mgmt_compute/models/list_usages_result.rb +4 -6
  34. data/lib/azure_mgmt_compute/models/network_interface_reference.rb +1 -3
  35. data/lib/azure_mgmt_compute/models/network_interface_reference_properties.rb +1 -3
  36. data/lib/azure_mgmt_compute/models/network_profile.rb +4 -6
  37. data/lib/azure_mgmt_compute/models/operating_system_types.rb +1 -1
  38. data/lib/azure_mgmt_compute/models/operation_status.rb +1 -1
  39. data/lib/azure_mgmt_compute/models/osdisk.rb +54 -26
  40. data/lib/azure_mgmt_compute/models/osdisk_image.rb +4 -6
  41. data/lib/azure_mgmt_compute/models/osprofile.rb +4 -6
  42. data/lib/azure_mgmt_compute/models/pass_names.rb +1 -1
  43. data/lib/azure_mgmt_compute/models/plan.rb +1 -3
  44. data/lib/azure_mgmt_compute/models/protocol_types.rb +1 -1
  45. data/lib/azure_mgmt_compute/models/purchase_plan.rb +4 -4
  46. data/lib/azure_mgmt_compute/models/setting_names.rb +1 -1
  47. data/lib/azure_mgmt_compute/models/sku.rb +75 -0
  48. data/lib/azure_mgmt_compute/models/ssh_configuration.rb +4 -6
  49. data/lib/azure_mgmt_compute/models/ssh_public_key.rb +1 -3
  50. data/lib/azure_mgmt_compute/models/status_level_types.rb +1 -1
  51. data/lib/azure_mgmt_compute/models/storage_profile.rb +4 -6
  52. data/lib/azure_mgmt_compute/models/{usage_unit.rb → upgrade_mode.rb} +5 -4
  53. data/lib/azure_mgmt_compute/models/upgrade_policy.rb +60 -0
  54. data/lib/azure_mgmt_compute/models/usage.rb +7 -9
  55. data/lib/azure_mgmt_compute/models/usage_name.rb +1 -3
  56. data/lib/azure_mgmt_compute/models/vault_certificate.rb +1 -3
  57. data/lib/azure_mgmt_compute/models/vault_secret_group.rb +6 -8
  58. data/lib/azure_mgmt_compute/models/virtual_hard_disk.rb +1 -3
  59. data/lib/azure_mgmt_compute/models/virtual_machine.rb +4 -6
  60. data/lib/azure_mgmt_compute/models/virtual_machine_agent_instance_view.rb +7 -9
  61. data/lib/azure_mgmt_compute/models/virtual_machine_capture_parameters.rb +4 -4
  62. data/lib/azure_mgmt_compute/models/virtual_machine_capture_result.rb +68 -0
  63. data/lib/azure_mgmt_compute/models/virtual_machine_capture_result_properties.rb +56 -0
  64. data/lib/azure_mgmt_compute/models/virtual_machine_extension.rb +1 -3
  65. data/lib/azure_mgmt_compute/models/virtual_machine_extension_handler_instance_view.rb +1 -3
  66. data/lib/azure_mgmt_compute/models/virtual_machine_extension_image.rb +15 -15
  67. data/lib/azure_mgmt_compute/models/virtual_machine_extension_image_properties.rb +4 -4
  68. data/lib/azure_mgmt_compute/models/virtual_machine_extension_instance_view.rb +7 -9
  69. data/lib/azure_mgmt_compute/models/virtual_machine_extension_properties.rb +11 -3
  70. data/lib/azure_mgmt_compute/models/virtual_machine_image.rb +15 -15
  71. data/lib/azure_mgmt_compute/models/virtual_machine_image_properties.rb +4 -6
  72. data/lib/azure_mgmt_compute/models/virtual_machine_image_resource.rb +9 -9
  73. data/lib/azure_mgmt_compute/models/virtual_machine_instance_view.rb +28 -14
  74. data/lib/azure_mgmt_compute/models/virtual_machine_list_result.rb +4 -6
  75. data/lib/azure_mgmt_compute/models/virtual_machine_properties.rb +29 -5
  76. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set.rb +108 -0
  77. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_extension.rb +77 -0
  78. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_extension_profile.rb +77 -0
  79. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_extension_properties.rb +116 -0
  80. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_instance_view.rb +125 -0
  81. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_instance_view_statuses_summary.rb +79 -0
  82. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_ipconfiguration.rb +78 -0
  83. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_ipconfiguration_properties.rb +127 -0
  84. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_list_result.rb +77 -0
  85. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_list_skus_result.rb +77 -0
  86. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_list_with_link_result.rb +88 -0
  87. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_network_configuration.rb +80 -0
  88. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_network_configuration_properties.rb +89 -0
  89. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_network_profile.rb +77 -0
  90. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_osdisk.rb +129 -0
  91. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_osprofile.rb +147 -0
  92. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_properties.rb +89 -0
  93. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_sku.rb +88 -0
  94. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_sku_capacity.rb +90 -0
  95. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_sku_scale_type.rb +16 -0
  96. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_storage_profile.rb +78 -0
  97. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vm.rb +165 -0
  98. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vmextensions_summary.rb +87 -0
  99. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vminstance_ids.rb +57 -0
  100. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vminstance_required_ids.rb +59 -0
  101. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vminstance_view.rb +202 -0
  102. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vmlist_result.rb +77 -0
  103. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vmprofile.rb +114 -0
  104. data/lib/azure_mgmt_compute/models/virtual_machine_scale_set_vmproperties.rb +190 -0
  105. data/lib/azure_mgmt_compute/models/virtual_machine_size.rb +1 -3
  106. data/lib/azure_mgmt_compute/models/virtual_machine_size_list_result.rb +4 -6
  107. data/lib/azure_mgmt_compute/models/virtual_machine_size_types.rb +53 -45
  108. data/lib/azure_mgmt_compute/models/virtual_machine_status_code_count.rb +68 -0
  109. data/lib/azure_mgmt_compute/models/win_rmconfiguration.rb +4 -6
  110. data/lib/azure_mgmt_compute/models/win_rmlistener.rb +3 -5
  111. data/lib/azure_mgmt_compute/models/windows_configuration.rb +4 -6
  112. data/lib/azure_mgmt_compute/module_definition.rb +5 -3
  113. data/lib/azure_mgmt_compute/usage_operations.rb +75 -42
  114. data/lib/azure_mgmt_compute/version.rb +5 -3
  115. data/lib/azure_mgmt_compute/virtual_machine_extension_images.rb +71 -158
  116. data/lib/azure_mgmt_compute/virtual_machine_extensions.rb +66 -149
  117. data/lib/azure_mgmt_compute/virtual_machine_images.rb +121 -264
  118. data/lib/azure_mgmt_compute/virtual_machine_scale_set_vms.rb +750 -0
  119. data/lib/azure_mgmt_compute/virtual_machine_scale_sets.rb +1327 -0
  120. data/lib/azure_mgmt_compute/virtual_machine_sizes.rb +75 -42
  121. data/lib/azure_mgmt_compute/virtual_machines.rb +397 -623
  122. data/lib/azure_mgmt_compute.rb +57 -18
  123. metadata +50 -128
  124. data/.gitignore +0 -10
  125. data/.travis.yml +0 -3
  126. data/Gemfile +0 -17
@@ -1,11 +1,11 @@
1
1
  # encoding: utf-8
2
- # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
3
  # Changes may cause incorrect behavior and will be lost if the code is
4
4
  # regenerated.
5
5
 
6
6
  module Azure::ARM::Compute
7
7
  #
8
- # VirtualMachineImages
8
+ # The Compute Management Client.
9
9
  #
10
10
  class VirtualMachineImages
11
11
  include Azure::ARM::Compute::Models
@@ -24,6 +24,7 @@ module Azure::ARM::Compute
24
24
 
25
25
  #
26
26
  # Gets a virtual machine image.
27
+ #
27
28
  # @param location [String]
28
29
  # @param publisher_name [String]
29
30
  # @param offer [String]
@@ -43,75 +44,44 @@ module Azure::ARM::Compute
43
44
  fail ArgumentError, 'version is nil' if version.nil?
44
45
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
45
46
  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
47
+ request_headers = {}
75
48
 
76
49
  # Set Headers
77
50
  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
51
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
52
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}'
53
+ options = {
54
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
55
+ path_params: {'location' => location,'publisherName' => publisher_name,'offer' => offer,'skus' => skus,'version' => version,'subscriptionId' => @client.subscription_id},
56
+ query_params: {'api-version' => @client.api_version},
57
+ headers: request_headers.merge(custom_headers || {})
58
+ }
59
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
60
+ promise = request.run_promise do |req|
61
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
92
62
  end
93
63
 
94
64
  promise = promise.then do |http_response|
95
65
  status_code = http_response.status
96
66
  response_content = http_response.body
97
- unless (status_code == 200)
67
+ unless status_code == 200
98
68
  error_model = JSON.load(response_content)
99
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
69
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
100
70
  end
101
71
 
102
72
  # Create Result
103
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
73
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
104
74
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
105
75
  # Deserialize Response
106
76
  if status_code == 200
107
77
  begin
108
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
78
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
109
79
  unless parsed_response.nil?
110
80
  parsed_response = VirtualMachineImage.deserialize_object(parsed_response)
111
81
  end
112
82
  result.body = parsed_response
113
83
  rescue Exception => e
114
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
84
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
115
85
  end
116
86
  end
117
87
 
@@ -122,93 +92,73 @@ module Azure::ARM::Compute
122
92
  end
123
93
 
124
94
  #
125
- # Gets a list of virtual machine image offers.
95
+ # Gets a list of virtual machine images.
96
+ #
126
97
  # @param location [String]
127
98
  # @param publisher_name [String]
99
+ # @param offer [String]
100
+ # @param skus [String]
101
+ # @param filter [String] The filter to apply on the operation.
102
+ # @param top [Integer]
103
+ # @param orderby [String]
128
104
  # @param [Hash{String => String}] The hash of custom headers need to be
129
105
  # applied to HTTP request.
130
106
  #
131
107
  # @return [Concurrent::Promise] Promise object which allows to get HTTP
132
108
  # response.
133
109
  #
134
- def list_offers(location, publisher_name, custom_headers = nil)
110
+ def list(location, publisher_name, offer, skus, filter = nil, top = nil, orderby = nil, custom_headers = nil)
135
111
  fail ArgumentError, 'location is nil' if location.nil?
136
112
  fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
113
+ fail ArgumentError, 'offer is nil' if offer.nil?
114
+ fail ArgumentError, 'skus is nil' if skus.nil?
137
115
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
138
116
  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
117
+ request_headers = {}
165
118
 
166
119
  # Set Headers
167
120
  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
121
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
122
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions'
123
+ options = {
124
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
125
+ path_params: {'location' => location,'publisherName' => publisher_name,'offer' => offer,'skus' => skus,'subscriptionId' => @client.subscription_id},
126
+ query_params: {'$filter' => filter,'$top' => top,'$orderby' => orderby,'api-version' => @client.api_version},
127
+ headers: request_headers.merge(custom_headers || {})
128
+ }
129
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
130
+ promise = request.run_promise do |req|
131
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
182
132
  end
183
133
 
184
134
  promise = promise.then do |http_response|
185
135
  status_code = http_response.status
186
136
  response_content = http_response.body
187
- unless (status_code == 200)
137
+ unless status_code == 200
188
138
  error_model = JSON.load(response_content)
189
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
139
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
190
140
  end
191
141
 
192
142
  # Create Result
193
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
143
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
194
144
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
195
145
  # Deserialize Response
196
146
  if status_code == 200
197
147
  begin
198
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
148
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
199
149
  unless parsed_response.nil?
200
- deserializedArray = [];
150
+ deserialized_array = []
201
151
  parsed_response.each do |element|
202
152
  unless element.nil?
203
153
  element = VirtualMachineImageResource.deserialize_object(element)
204
154
  end
205
- deserializedArray.push(element);
155
+ deserialized_array.push(element)
206
156
  end
207
- parsed_response = deserializedArray;
157
+ parsed_response = deserialized_array
208
158
  end
209
159
  result.body = parsed_response
210
160
  rescue Exception => e
211
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
161
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
212
162
  end
213
163
  end
214
164
 
@@ -219,90 +169,66 @@ module Azure::ARM::Compute
219
169
  end
220
170
 
221
171
  #
222
- # Gets a list of virtual machine image publishers.
172
+ # Gets a list of virtual machine image offers.
173
+ #
223
174
  # @param location [String]
175
+ # @param publisher_name [String]
224
176
  # @param [Hash{String => String}] The hash of custom headers need to be
225
177
  # applied to HTTP request.
226
178
  #
227
179
  # @return [Concurrent::Promise] Promise object which allows to get HTTP
228
180
  # response.
229
181
  #
230
- def list_publishers(location, custom_headers = nil)
182
+ def list_offers(location, publisher_name, custom_headers = nil)
231
183
  fail ArgumentError, 'location is nil' if location.nil?
184
+ fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
232
185
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
233
186
  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
187
+ request_headers = {}
259
188
 
260
189
  # Set Headers
261
190
  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
191
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
192
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers'
193
+ options = {
194
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
195
+ path_params: {'location' => location,'publisherName' => publisher_name,'subscriptionId' => @client.subscription_id},
196
+ query_params: {'api-version' => @client.api_version},
197
+ headers: request_headers.merge(custom_headers || {})
198
+ }
199
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
200
+ promise = request.run_promise do |req|
201
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
276
202
  end
277
203
 
278
204
  promise = promise.then do |http_response|
279
205
  status_code = http_response.status
280
206
  response_content = http_response.body
281
- unless (status_code == 200)
207
+ unless status_code == 200
282
208
  error_model = JSON.load(response_content)
283
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
209
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
284
210
  end
285
211
 
286
212
  # Create Result
287
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
213
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
288
214
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
289
215
  # Deserialize Response
290
216
  if status_code == 200
291
217
  begin
292
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
218
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
293
219
  unless parsed_response.nil?
294
- deserializedArray = [];
220
+ deserialized_array = []
295
221
  parsed_response.each do |element|
296
222
  unless element.nil?
297
223
  element = VirtualMachineImageResource.deserialize_object(element)
298
224
  end
299
- deserializedArray.push(element);
225
+ deserialized_array.push(element)
300
226
  end
301
- parsed_response = deserializedArray;
227
+ parsed_response = deserialized_array
302
228
  end
303
229
  result.body = parsed_response
304
230
  rescue Exception => e
305
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
231
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
306
232
  end
307
233
  end
308
234
 
@@ -313,96 +239,64 @@ module Azure::ARM::Compute
313
239
  end
314
240
 
315
241
  #
316
- # Gets a list of virtual machine image skus.
242
+ # Gets a list of virtual machine image publishers.
243
+ #
317
244
  # @param location [String]
318
- # @param publisher_name [String]
319
- # @param offer [String]
320
245
  # @param [Hash{String => String}] The hash of custom headers need to be
321
246
  # applied to HTTP request.
322
247
  #
323
248
  # @return [Concurrent::Promise] Promise object which allows to get HTTP
324
249
  # response.
325
250
  #
326
- def list_skus(location, publisher_name, offer, custom_headers = nil)
251
+ def list_publishers(location, custom_headers = nil)
327
252
  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
253
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
331
254
  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
255
+ request_headers = {}
359
256
 
360
257
  # Set Headers
361
258
  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
259
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
260
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers'
261
+ options = {
262
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
263
+ path_params: {'location' => location,'subscriptionId' => @client.subscription_id},
264
+ query_params: {'api-version' => @client.api_version},
265
+ headers: request_headers.merge(custom_headers || {})
266
+ }
267
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
268
+ promise = request.run_promise do |req|
269
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
376
270
  end
377
271
 
378
272
  promise = promise.then do |http_response|
379
273
  status_code = http_response.status
380
274
  response_content = http_response.body
381
- unless (status_code == 200)
275
+ unless status_code == 200
382
276
  error_model = JSON.load(response_content)
383
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
277
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
384
278
  end
385
279
 
386
280
  # Create Result
387
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
281
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
388
282
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
389
283
  # Deserialize Response
390
284
  if status_code == 200
391
285
  begin
392
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
286
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
393
287
  unless parsed_response.nil?
394
- deserializedArray = [];
288
+ deserialized_array = []
395
289
  parsed_response.each do |element|
396
290
  unless element.nil?
397
291
  element = VirtualMachineImageResource.deserialize_object(element)
398
292
  end
399
- deserializedArray.push(element);
293
+ deserialized_array.push(element)
400
294
  end
401
- parsed_response = deserializedArray;
295
+ parsed_response = deserialized_array
402
296
  end
403
297
  result.body = parsed_response
404
298
  rescue Exception => e
405
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
299
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
406
300
  end
407
301
  end
408
302
 
@@ -413,105 +307,68 @@ module Azure::ARM::Compute
413
307
  end
414
308
 
415
309
  #
416
- # Gets a list of virtual machine images.
310
+ # Gets a list of virtual machine image skus.
311
+ #
417
312
  # @param location [String]
418
313
  # @param publisher_name [String]
419
314
  # @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
315
  # @param [Hash{String => String}] The hash of custom headers need to be
425
316
  # applied to HTTP request.
426
317
  #
427
318
  # @return [Concurrent::Promise] Promise object which allows to get HTTP
428
319
  # response.
429
320
  #
430
- def list(location, publisher_name, offer, skus, filter = nil, top = nil, orderby = nil, custom_headers = nil)
321
+ def list_skus(location, publisher_name, offer, custom_headers = nil)
431
322
  fail ArgumentError, 'location is nil' if location.nil?
432
323
  fail ArgumentError, 'publisher_name is nil' if publisher_name.nil?
433
324
  fail ArgumentError, 'offer is nil' if offer.nil?
434
- fail ArgumentError, 'skus is nil' if skus.nil?
435
325
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
436
326
  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
327
+ request_headers = {}
468
328
 
469
329
  # Set Headers
470
330
  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
331
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
332
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus'
333
+ options = {
334
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
335
+ path_params: {'location' => location,'publisherName' => publisher_name,'offer' => offer,'subscriptionId' => @client.subscription_id},
336
+ query_params: {'api-version' => @client.api_version},
337
+ headers: request_headers.merge(custom_headers || {})
338
+ }
339
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
340
+ promise = request.run_promise do |req|
341
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
485
342
  end
486
343
 
487
344
  promise = promise.then do |http_response|
488
345
  status_code = http_response.status
489
346
  response_content = http_response.body
490
- unless (status_code == 200)
347
+ unless status_code == 200
491
348
  error_model = JSON.load(response_content)
492
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
349
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
493
350
  end
494
351
 
495
352
  # Create Result
496
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
353
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
497
354
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
498
355
  # Deserialize Response
499
356
  if status_code == 200
500
357
  begin
501
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
358
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
502
359
  unless parsed_response.nil?
503
- deserializedArray = [];
360
+ deserialized_array = []
504
361
  parsed_response.each do |element|
505
362
  unless element.nil?
506
363
  element = VirtualMachineImageResource.deserialize_object(element)
507
364
  end
508
- deserializedArray.push(element);
365
+ deserialized_array.push(element)
509
366
  end
510
- parsed_response = deserializedArray;
367
+ parsed_response = deserialized_array
511
368
  end
512
369
  result.body = parsed_response
513
370
  rescue Exception => e
514
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
371
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
515
372
  end
516
373
  end
517
374