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
- # VirtualMachines
8
+ # The Compute Management Client.
9
9
  #
10
10
  class VirtualMachines
11
11
  include Azure::ARM::Compute::Models
@@ -25,6 +25,7 @@ module Azure::ARM::Compute
25
25
  #
26
26
  # Captures the VM by copying VirtualHardDisks of the VM and outputs a template
27
27
  # that can be used to create similar VMs.
28
+ #
28
29
  # @param resource_group_name [String] The name of the resource group.
29
30
  # @param vm_name [String] The name of the virtual machine.
30
31
  # @param parameters [VirtualMachineCaptureParameters] Parameters supplied to
@@ -40,12 +41,12 @@ module Azure::ARM::Compute
40
41
  # Defining deserialization method.
41
42
  deserialize_method = lambda do |parsed_response|
42
43
  unless parsed_response.nil?
43
- parsed_response = ComputeLongRunningOperationResult.deserialize_object(parsed_response)
44
+ parsed_response = VirtualMachineCaptureResult.deserialize_object(parsed_response)
44
45
  end
45
46
  end
46
47
 
47
48
  # Waiting for response.
48
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
49
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
49
50
  end
50
51
 
51
52
  promise
@@ -54,6 +55,7 @@ module Azure::ARM::Compute
54
55
  #
55
56
  # Captures the VM by copying VirtualHardDisks of the VM and outputs a template
56
57
  # that can be used to create similar VMs.
58
+ #
57
59
  # @param resource_group_name [String] The name of the resource group.
58
60
  # @param vm_name [String] The name of the virtual machine.
59
61
  # @param parameters [VirtualMachineCaptureParameters] Parameters supplied to
@@ -71,80 +73,52 @@ module Azure::ARM::Compute
71
73
  parameters.validate unless parameters.nil?
72
74
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
73
75
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
74
- # Construct URL
75
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture"
76
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
77
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
78
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
79
- url = URI.join(@client.base_url, path)
80
- properties = {}
81
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
82
- unless url.query.nil?
83
- url.query.split('&').each do |url_item|
84
- url_items_parts = url_item.split('=')
85
- properties[url_items_parts[0]] = url_items_parts[1]
86
- end
87
- end
88
- properties.reject!{ |key, value| value.nil? }
89
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
90
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
91
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
92
- url = URI.parse(corrected_url)
93
-
94
- connection = Faraday.new(:url => url) do |faraday|
95
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
96
- faraday.use :cookie_jar
97
- faraday.adapter Faraday.default_adapter
98
- end
99
- request_headers = Hash.new
76
+ request_headers = {}
100
77
 
101
78
  # Set Headers
102
79
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
103
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
104
-
105
- unless custom_headers.nil?
106
- custom_headers.each do |key, value|
107
- request_headers[key] = value
108
- end
109
- end
80
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
110
81
 
111
82
  # Serialize Request
112
- request_headers['Content-Type'] = 'application/json'
83
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
113
84
  unless parameters.nil?
114
85
  parameters = VirtualMachineCaptureParameters.serialize_object(parameters)
115
86
  end
116
87
  request_content = JSON.generate(parameters, quirks_mode: true)
117
-
118
- # Send Request
119
- promise = Concurrent::Promise.new do
120
- connection.post do |request|
121
- request.headers = request_headers
122
- request.body = request_content
123
- @client.credentials.sign_request(request) unless @client.credentials.nil?
124
- end
88
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture'
89
+ options = {
90
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
91
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
92
+ query_params: {'api-version' => @client.api_version},
93
+ body: request_content,
94
+ headers: request_headers.merge(custom_headers || {})
95
+ }
96
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
97
+ promise = request.run_promise do |req|
98
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
125
99
  end
126
100
 
127
101
  promise = promise.then do |http_response|
128
102
  status_code = http_response.status
129
103
  response_content = http_response.body
130
- unless (status_code == 200 || status_code == 202)
104
+ unless status_code == 200 || status_code == 202
131
105
  error_model = JSON.load(response_content)
132
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
106
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
133
107
  end
134
108
 
135
109
  # Create Result
136
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
110
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
137
111
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
138
112
  # Deserialize Response
139
113
  if status_code == 200
140
114
  begin
141
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
115
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
142
116
  unless parsed_response.nil?
143
- parsed_response = ComputeLongRunningOperationResult.deserialize_object(parsed_response)
117
+ parsed_response = VirtualMachineCaptureResult.deserialize_object(parsed_response)
144
118
  end
145
119
  result.body = parsed_response
146
120
  rescue Exception => e
147
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
121
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
148
122
  end
149
123
  end
150
124
 
@@ -156,6 +130,7 @@ module Azure::ARM::Compute
156
130
 
157
131
  #
158
132
  # The operation to create or update a virtual machine.
133
+ #
159
134
  # @param resource_group_name [String] The name of the resource group.
160
135
  # @param vm_name [String] The name of the virtual machine.
161
136
  # @param parameters [VirtualMachine] Parameters supplied to the Create Virtual
@@ -183,7 +158,7 @@ module Azure::ARM::Compute
183
158
  end
184
159
 
185
160
  # Waiting for response.
186
- @client.get_put_operation_result(response, custom_headers, deserialize_method)
161
+ @client.get_put_operation_result(response, deserialize_method)
187
162
  end
188
163
 
189
164
  promise
@@ -191,6 +166,7 @@ module Azure::ARM::Compute
191
166
 
192
167
  #
193
168
  # The operation to create or update a virtual machine.
169
+ #
194
170
  # @param resource_group_name [String] The name of the resource group.
195
171
  # @param vm_name [String] The name of the virtual machine.
196
172
  # @param parameters [VirtualMachine] Parameters supplied to the Create Virtual
@@ -208,92 +184,64 @@ module Azure::ARM::Compute
208
184
  parameters.validate unless parameters.nil?
209
185
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
210
186
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
211
- # Construct URL
212
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"
213
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
214
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
215
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
216
- url = URI.join(@client.base_url, path)
217
- properties = {}
218
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
219
- unless url.query.nil?
220
- url.query.split('&').each do |url_item|
221
- url_items_parts = url_item.split('=')
222
- properties[url_items_parts[0]] = url_items_parts[1]
223
- end
224
- end
225
- properties.reject!{ |key, value| value.nil? }
226
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
227
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
228
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
229
- url = URI.parse(corrected_url)
230
-
231
- connection = Faraday.new(:url => url) do |faraday|
232
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
233
- faraday.use :cookie_jar
234
- faraday.adapter Faraday.default_adapter
235
- end
236
- request_headers = Hash.new
187
+ request_headers = {}
237
188
 
238
189
  # Set Headers
239
190
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
240
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
241
-
242
- unless custom_headers.nil?
243
- custom_headers.each do |key, value|
244
- request_headers[key] = value
245
- end
246
- end
191
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
247
192
 
248
193
  # Serialize Request
249
- request_headers['Content-Type'] = 'application/json'
194
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
250
195
  unless parameters.nil?
251
196
  parameters = VirtualMachine.serialize_object(parameters)
252
197
  end
253
198
  request_content = JSON.generate(parameters, quirks_mode: true)
254
-
255
- # Send Request
256
- promise = Concurrent::Promise.new do
257
- connection.put do |request|
258
- request.headers = request_headers
259
- request.body = request_content
260
- @client.credentials.sign_request(request) unless @client.credentials.nil?
261
- end
199
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}'
200
+ options = {
201
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
202
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
203
+ query_params: {'api-version' => @client.api_version},
204
+ body: request_content,
205
+ headers: request_headers.merge(custom_headers || {})
206
+ }
207
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
208
+ promise = request.run_promise do |req|
209
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
262
210
  end
263
211
 
264
212
  promise = promise.then do |http_response|
265
213
  status_code = http_response.status
266
214
  response_content = http_response.body
267
- unless (status_code == 201 || status_code == 200)
215
+ unless status_code == 200 || status_code == 201
268
216
  error_model = JSON.load(response_content)
269
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
217
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
270
218
  end
271
219
 
272
220
  # Create Result
273
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
221
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
274
222
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
275
223
  # Deserialize Response
276
- if status_code == 201
224
+ if status_code == 200
277
225
  begin
278
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
226
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
279
227
  unless parsed_response.nil?
280
228
  parsed_response = VirtualMachine.deserialize_object(parsed_response)
281
229
  end
282
230
  result.body = parsed_response
283
231
  rescue Exception => e
284
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
232
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
285
233
  end
286
234
  end
287
235
  # Deserialize Response
288
- if status_code == 200
236
+ if status_code == 201
289
237
  begin
290
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
238
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
291
239
  unless parsed_response.nil?
292
240
  parsed_response = VirtualMachine.deserialize_object(parsed_response)
293
241
  end
294
242
  result.body = parsed_response
295
243
  rescue Exception => e
296
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
244
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
297
245
  end
298
246
  end
299
247
 
@@ -305,6 +253,7 @@ module Azure::ARM::Compute
305
253
 
306
254
  #
307
255
  # The operation to delete a virtual machine.
256
+ #
308
257
  # @param resource_group_name [String] The name of the resource group.
309
258
  # @param vm_name [String] The name of the virtual machine.
310
259
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -320,7 +269,7 @@ module Azure::ARM::Compute
320
269
  end
321
270
 
322
271
  # Waiting for response.
323
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
272
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
324
273
  end
325
274
 
326
275
  promise
@@ -328,6 +277,7 @@ module Azure::ARM::Compute
328
277
 
329
278
  #
330
279
  # The operation to delete a virtual machine.
280
+ #
331
281
  # @param resource_group_name [String] The name of the resource group.
332
282
  # @param vm_name [String] The name of the virtual machine.
333
283
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -341,60 +291,33 @@ module Azure::ARM::Compute
341
291
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
342
292
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
343
293
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
344
- # Construct URL
345
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"
346
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
347
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
348
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
349
- url = URI.join(@client.base_url, path)
350
- properties = {}
351
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
352
- unless url.query.nil?
353
- url.query.split('&').each do |url_item|
354
- url_items_parts = url_item.split('=')
355
- properties[url_items_parts[0]] = url_items_parts[1]
356
- end
357
- end
358
- properties.reject!{ |key, value| value.nil? }
359
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
360
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
361
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
362
- url = URI.parse(corrected_url)
363
-
364
- connection = Faraday.new(:url => url) do |faraday|
365
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
366
- faraday.use :cookie_jar
367
- faraday.adapter Faraday.default_adapter
368
- end
369
- request_headers = Hash.new
294
+ request_headers = {}
370
295
 
371
296
  # Set Headers
372
297
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
373
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
374
-
375
- unless custom_headers.nil?
376
- custom_headers.each do |key, value|
377
- request_headers[key] = value
378
- end
379
- end
380
-
381
- # Send Request
382
- promise = Concurrent::Promise.new do
383
- connection.delete do |request|
384
- request.headers = request_headers
385
- @client.credentials.sign_request(request) unless @client.credentials.nil?
386
- end
298
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
299
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}'
300
+ options = {
301
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
302
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
303
+ query_params: {'api-version' => @client.api_version},
304
+ headers: request_headers.merge(custom_headers || {})
305
+ }
306
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
307
+ promise = request.run_promise do |req|
308
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
387
309
  end
388
310
 
389
311
  promise = promise.then do |http_response|
390
312
  status_code = http_response.status
391
313
  response_content = http_response.body
392
- unless (status_code == 200 || status_code == 204 || status_code == 202)
393
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
314
+ unless status_code == 200 || status_code == 202 || status_code == 204
315
+ error_model = JSON.load(response_content)
316
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
394
317
  end
395
318
 
396
319
  # Create Result
397
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
320
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
398
321
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
399
322
 
400
323
  result
@@ -405,10 +328,10 @@ module Azure::ARM::Compute
405
328
 
406
329
  #
407
330
  # The operation to get a virtual machine.
331
+ #
408
332
  # @param resource_group_name [String] The name of the resource group.
409
333
  # @param vm_name [String] The name of the virtual machine.
410
- # @param expand [String] Name of the property to expand. Allowed value is null
411
- # or 'instanceView'.
334
+ # @param expand [String] The expand expression to apply on the operation.
412
335
  # @param [Hash{String => String}] The hash of custom headers need to be
413
336
  # applied to HTTP request.
414
337
  #
@@ -420,73 +343,44 @@ module Azure::ARM::Compute
420
343
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
421
344
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
422
345
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
423
- # Construct URL
424
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"
425
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
426
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
427
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
428
- url = URI.join(@client.base_url, path)
429
- properties = {}
430
- properties['$expand'] = ERB::Util.url_encode(expand.to_s) unless expand.nil?
431
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
432
- unless url.query.nil?
433
- url.query.split('&').each do |url_item|
434
- url_items_parts = url_item.split('=')
435
- properties[url_items_parts[0]] = url_items_parts[1]
436
- end
437
- end
438
- properties.reject!{ |key, value| value.nil? }
439
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
440
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
441
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
442
- url = URI.parse(corrected_url)
443
-
444
- connection = Faraday.new(:url => url) do |faraday|
445
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
446
- faraday.use :cookie_jar
447
- faraday.adapter Faraday.default_adapter
448
- end
449
- request_headers = Hash.new
346
+ request_headers = {}
450
347
 
451
348
  # Set Headers
452
349
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
453
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
454
-
455
- unless custom_headers.nil?
456
- custom_headers.each do |key, value|
457
- request_headers[key] = value
458
- end
459
- end
460
-
461
- # Send Request
462
- promise = Concurrent::Promise.new do
463
- connection.get do |request|
464
- request.headers = request_headers
465
- @client.credentials.sign_request(request) unless @client.credentials.nil?
466
- end
350
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
351
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}'
352
+ options = {
353
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
354
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
355
+ query_params: {'$expand' => expand,'api-version' => @client.api_version},
356
+ headers: request_headers.merge(custom_headers || {})
357
+ }
358
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
359
+ promise = request.run_promise do |req|
360
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
467
361
  end
468
362
 
469
363
  promise = promise.then do |http_response|
470
364
  status_code = http_response.status
471
365
  response_content = http_response.body
472
- unless (status_code == 200)
366
+ unless status_code == 200
473
367
  error_model = JSON.load(response_content)
474
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
368
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
475
369
  end
476
370
 
477
371
  # Create Result
478
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
372
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
479
373
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
480
374
  # Deserialize Response
481
375
  if status_code == 200
482
376
  begin
483
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
377
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
484
378
  unless parsed_response.nil?
485
379
  parsed_response = VirtualMachine.deserialize_object(parsed_response)
486
380
  end
487
381
  result.body = parsed_response
488
382
  rescue Exception => e
489
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
383
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
490
384
  end
491
385
  end
492
386
 
@@ -499,6 +393,7 @@ module Azure::ARM::Compute
499
393
  #
500
394
  # Shuts down the Virtual Machine and releases the compute resources. You are
501
395
  # not billed for the compute resources that this Virtual Machine uses.
396
+ #
502
397
  # @param resource_group_name [String] The name of the resource group.
503
398
  # @param vm_name [String] The name of the virtual machine.
504
399
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -514,7 +409,7 @@ module Azure::ARM::Compute
514
409
  end
515
410
 
516
411
  # Waiting for response.
517
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
412
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
518
413
  end
519
414
 
520
415
  promise
@@ -523,6 +418,7 @@ module Azure::ARM::Compute
523
418
  #
524
419
  # Shuts down the Virtual Machine and releases the compute resources. You are
525
420
  # not billed for the compute resources that this Virtual Machine uses.
421
+ #
526
422
  # @param resource_group_name [String] The name of the resource group.
527
423
  # @param vm_name [String] The name of the virtual machine.
528
424
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -536,60 +432,33 @@ module Azure::ARM::Compute
536
432
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
537
433
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
538
434
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
539
- # Construct URL
540
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate"
541
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
542
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
543
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
544
- url = URI.join(@client.base_url, path)
545
- properties = {}
546
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
547
- unless url.query.nil?
548
- url.query.split('&').each do |url_item|
549
- url_items_parts = url_item.split('=')
550
- properties[url_items_parts[0]] = url_items_parts[1]
551
- end
552
- end
553
- properties.reject!{ |key, value| value.nil? }
554
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
555
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
556
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
557
- url = URI.parse(corrected_url)
558
-
559
- connection = Faraday.new(:url => url) do |faraday|
560
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
561
- faraday.use :cookie_jar
562
- faraday.adapter Faraday.default_adapter
563
- end
564
- request_headers = Hash.new
435
+ request_headers = {}
565
436
 
566
437
  # Set Headers
567
438
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
568
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
569
-
570
- unless custom_headers.nil?
571
- custom_headers.each do |key, value|
572
- request_headers[key] = value
573
- end
574
- end
575
-
576
- # Send Request
577
- promise = Concurrent::Promise.new do
578
- connection.post do |request|
579
- request.headers = request_headers
580
- @client.credentials.sign_request(request) unless @client.credentials.nil?
581
- end
439
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
440
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate'
441
+ options = {
442
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
443
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
444
+ query_params: {'api-version' => @client.api_version},
445
+ headers: request_headers.merge(custom_headers || {})
446
+ }
447
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
448
+ promise = request.run_promise do |req|
449
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
582
450
  end
583
451
 
584
452
  promise = promise.then do |http_response|
585
453
  status_code = http_response.status
586
454
  response_content = http_response.body
587
- unless (status_code == 202)
588
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
455
+ unless status_code == 202
456
+ error_model = JSON.load(response_content)
457
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
589
458
  end
590
459
 
591
460
  # Create Result
592
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
461
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
593
462
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
594
463
 
595
464
  result
@@ -600,6 +469,7 @@ module Azure::ARM::Compute
600
469
 
601
470
  #
602
471
  # Sets the state of the VM as Generalized.
472
+ #
603
473
  # @param resource_group_name [String] The name of the resource group.
604
474
  # @param vm_name [String] The name of the virtual machine.
605
475
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -613,60 +483,33 @@ module Azure::ARM::Compute
613
483
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
614
484
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
615
485
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
616
- # Construct URL
617
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize"
618
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
619
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
620
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
621
- url = URI.join(@client.base_url, path)
622
- properties = {}
623
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
624
- unless url.query.nil?
625
- url.query.split('&').each do |url_item|
626
- url_items_parts = url_item.split('=')
627
- properties[url_items_parts[0]] = url_items_parts[1]
628
- end
629
- end
630
- properties.reject!{ |key, value| value.nil? }
631
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
632
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
633
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
634
- url = URI.parse(corrected_url)
635
-
636
- connection = Faraday.new(:url => url) do |faraday|
637
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
638
- faraday.use :cookie_jar
639
- faraday.adapter Faraday.default_adapter
640
- end
641
- request_headers = Hash.new
486
+ request_headers = {}
642
487
 
643
488
  # Set Headers
644
489
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
645
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
646
-
647
- unless custom_headers.nil?
648
- custom_headers.each do |key, value|
649
- request_headers[key] = value
650
- end
651
- end
652
-
653
- # Send Request
654
- promise = Concurrent::Promise.new do
655
- connection.post do |request|
656
- request.headers = request_headers
657
- @client.credentials.sign_request(request) unless @client.credentials.nil?
658
- end
490
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
491
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize'
492
+ options = {
493
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
494
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
495
+ query_params: {'api-version' => @client.api_version},
496
+ headers: request_headers.merge(custom_headers || {})
497
+ }
498
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
499
+ promise = request.run_promise do |req|
500
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
659
501
  end
660
502
 
661
503
  promise = promise.then do |http_response|
662
504
  status_code = http_response.status
663
505
  response_content = http_response.body
664
- unless (status_code == 200)
665
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
506
+ unless status_code == 200
507
+ error_model = JSON.load(response_content)
508
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
666
509
  end
667
510
 
668
511
  # Create Result
669
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
512
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
670
513
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
671
514
 
672
515
  result
@@ -677,6 +520,7 @@ module Azure::ARM::Compute
677
520
 
678
521
  #
679
522
  # The operation to list virtual machines under a resource group.
523
+ #
680
524
  # @param resource_group_name [String] The name of the resource group.
681
525
  # @param [Hash{String => String}] The hash of custom headers need to be
682
526
  # applied to HTTP request.
@@ -688,71 +532,44 @@ module Azure::ARM::Compute
688
532
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
689
533
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
690
534
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
691
- # Construct URL
692
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines"
693
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
694
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
695
- url = URI.join(@client.base_url, path)
696
- properties = {}
697
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
698
- unless url.query.nil?
699
- url.query.split('&').each do |url_item|
700
- url_items_parts = url_item.split('=')
701
- properties[url_items_parts[0]] = url_items_parts[1]
702
- end
703
- end
704
- properties.reject!{ |key, value| value.nil? }
705
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
706
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
707
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
708
- url = URI.parse(corrected_url)
709
-
710
- connection = Faraday.new(:url => url) do |faraday|
711
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
712
- faraday.use :cookie_jar
713
- faraday.adapter Faraday.default_adapter
714
- end
715
- request_headers = Hash.new
535
+ request_headers = {}
716
536
 
717
537
  # Set Headers
718
538
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
719
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
720
-
721
- unless custom_headers.nil?
722
- custom_headers.each do |key, value|
723
- request_headers[key] = value
724
- end
725
- end
726
-
727
- # Send Request
728
- promise = Concurrent::Promise.new do
729
- connection.get do |request|
730
- request.headers = request_headers
731
- @client.credentials.sign_request(request) unless @client.credentials.nil?
732
- end
539
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
540
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines'
541
+ options = {
542
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
543
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
544
+ query_params: {'api-version' => @client.api_version},
545
+ headers: request_headers.merge(custom_headers || {})
546
+ }
547
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
548
+ promise = request.run_promise do |req|
549
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
733
550
  end
734
551
 
735
552
  promise = promise.then do |http_response|
736
553
  status_code = http_response.status
737
554
  response_content = http_response.body
738
- unless (status_code == 200)
555
+ unless status_code == 200
739
556
  error_model = JSON.load(response_content)
740
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
557
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
741
558
  end
742
559
 
743
560
  # Create Result
744
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
561
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
745
562
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
746
563
  # Deserialize Response
747
564
  if status_code == 200
748
565
  begin
749
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
566
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
750
567
  unless parsed_response.nil?
751
568
  parsed_response = VirtualMachineListResult.deserialize_object(parsed_response)
752
569
  end
753
570
  result.body = parsed_response
754
571
  rescue Exception => e
755
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
572
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
756
573
  end
757
574
  end
758
575
 
@@ -766,6 +583,7 @@ module Azure::ARM::Compute
766
583
  # Gets the list of Virtual Machines in the subscription. Use nextLink property
767
584
  # in the response to get the next page of Virtual Machines. Do this till
768
585
  # nextLink is not null to fetch all the Virtual Machines.
586
+ #
769
587
  # @param [Hash{String => String}] The hash of custom headers need to be
770
588
  # applied to HTTP request.
771
589
  #
@@ -775,70 +593,44 @@ module Azure::ARM::Compute
775
593
  def list_all(custom_headers = nil)
776
594
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
777
595
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
778
- # Construct URL
779
- path = "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines"
780
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
781
- url = URI.join(@client.base_url, path)
782
- properties = {}
783
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
784
- unless url.query.nil?
785
- url.query.split('&').each do |url_item|
786
- url_items_parts = url_item.split('=')
787
- properties[url_items_parts[0]] = url_items_parts[1]
788
- end
789
- end
790
- properties.reject!{ |key, value| value.nil? }
791
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
792
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
793
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
794
- url = URI.parse(corrected_url)
795
-
796
- connection = Faraday.new(:url => url) do |faraday|
797
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
798
- faraday.use :cookie_jar
799
- faraday.adapter Faraday.default_adapter
800
- end
801
- request_headers = Hash.new
596
+ request_headers = {}
802
597
 
803
598
  # Set Headers
804
599
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
805
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
806
-
807
- unless custom_headers.nil?
808
- custom_headers.each do |key, value|
809
- request_headers[key] = value
810
- end
811
- end
812
-
813
- # Send Request
814
- promise = Concurrent::Promise.new do
815
- connection.get do |request|
816
- request.headers = request_headers
817
- @client.credentials.sign_request(request) unless @client.credentials.nil?
818
- end
600
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
601
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines'
602
+ options = {
603
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
604
+ path_params: {'subscriptionId' => @client.subscription_id},
605
+ query_params: {'api-version' => @client.api_version},
606
+ headers: request_headers.merge(custom_headers || {})
607
+ }
608
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
609
+ promise = request.run_promise do |req|
610
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
819
611
  end
820
612
 
821
613
  promise = promise.then do |http_response|
822
614
  status_code = http_response.status
823
615
  response_content = http_response.body
824
- unless (status_code == 200)
616
+ unless status_code == 200
825
617
  error_model = JSON.load(response_content)
826
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
618
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
827
619
  end
828
620
 
829
621
  # Create Result
830
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
622
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
831
623
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
832
624
  # Deserialize Response
833
625
  if status_code == 200
834
626
  begin
835
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
627
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
836
628
  unless parsed_response.nil?
837
629
  parsed_response = VirtualMachineListResult.deserialize_object(parsed_response)
838
630
  end
839
631
  result.body = parsed_response
840
632
  rescue Exception => e
841
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
633
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
842
634
  end
843
635
  end
844
636
 
@@ -850,6 +642,7 @@ module Azure::ARM::Compute
850
642
 
851
643
  #
852
644
  # Lists virtual-machine-sizes available to be used for a virtual machine.
645
+ #
853
646
  # @param resource_group_name [String] The name of the resource group.
854
647
  # @param vm_name [String] The name of the virtual machine.
855
648
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -863,72 +656,44 @@ module Azure::ARM::Compute
863
656
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
864
657
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
865
658
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
866
- # Construct URL
867
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes"
868
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
869
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
870
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
871
- url = URI.join(@client.base_url, path)
872
- properties = {}
873
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
874
- unless url.query.nil?
875
- url.query.split('&').each do |url_item|
876
- url_items_parts = url_item.split('=')
877
- properties[url_items_parts[0]] = url_items_parts[1]
878
- end
879
- end
880
- properties.reject!{ |key, value| value.nil? }
881
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
882
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
883
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
884
- url = URI.parse(corrected_url)
885
-
886
- connection = Faraday.new(:url => url) do |faraday|
887
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
888
- faraday.use :cookie_jar
889
- faraday.adapter Faraday.default_adapter
890
- end
891
- request_headers = Hash.new
659
+ request_headers = {}
892
660
 
893
661
  # Set Headers
894
662
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
895
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
896
-
897
- unless custom_headers.nil?
898
- custom_headers.each do |key, value|
899
- request_headers[key] = value
900
- end
901
- end
902
-
903
- # Send Request
904
- promise = Concurrent::Promise.new do
905
- connection.get do |request|
906
- request.headers = request_headers
907
- @client.credentials.sign_request(request) unless @client.credentials.nil?
908
- end
663
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
664
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes'
665
+ options = {
666
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
667
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
668
+ query_params: {'api-version' => @client.api_version},
669
+ headers: request_headers.merge(custom_headers || {})
670
+ }
671
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
672
+ promise = request.run_promise do |req|
673
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
909
674
  end
910
675
 
911
676
  promise = promise.then do |http_response|
912
677
  status_code = http_response.status
913
678
  response_content = http_response.body
914
- unless (status_code == 200)
679
+ unless status_code == 200
915
680
  error_model = JSON.load(response_content)
916
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
681
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
917
682
  end
918
683
 
919
684
  # Create Result
920
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
685
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
921
686
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
922
687
  # Deserialize Response
923
688
  if status_code == 200
924
689
  begin
925
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
690
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
926
691
  unless parsed_response.nil?
927
692
  parsed_response = VirtualMachineSizeListResult.deserialize_object(parsed_response)
928
693
  end
929
694
  result.body = parsed_response
930
695
  rescue Exception => e
931
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
696
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
932
697
  end
933
698
  end
934
699
 
@@ -940,6 +705,7 @@ module Azure::ARM::Compute
940
705
 
941
706
  #
942
707
  # The operation to power off (stop) a virtual machine.
708
+ #
943
709
  # @param resource_group_name [String] The name of the resource group.
944
710
  # @param vm_name [String] The name of the virtual machine.
945
711
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -955,7 +721,7 @@ module Azure::ARM::Compute
955
721
  end
956
722
 
957
723
  # Waiting for response.
958
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
724
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
959
725
  end
960
726
 
961
727
  promise
@@ -963,6 +729,7 @@ module Azure::ARM::Compute
963
729
 
964
730
  #
965
731
  # The operation to power off (stop) a virtual machine.
732
+ #
966
733
  # @param resource_group_name [String] The name of the resource group.
967
734
  # @param vm_name [String] The name of the virtual machine.
968
735
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -976,60 +743,33 @@ module Azure::ARM::Compute
976
743
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
977
744
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
978
745
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
979
- # Construct URL
980
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff"
981
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
982
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
983
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
984
- url = URI.join(@client.base_url, path)
985
- properties = {}
986
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
987
- unless url.query.nil?
988
- url.query.split('&').each do |url_item|
989
- url_items_parts = url_item.split('=')
990
- properties[url_items_parts[0]] = url_items_parts[1]
991
- end
992
- end
993
- properties.reject!{ |key, value| value.nil? }
994
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
995
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
996
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
997
- url = URI.parse(corrected_url)
998
-
999
- connection = Faraday.new(:url => url) do |faraday|
1000
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
1001
- faraday.use :cookie_jar
1002
- faraday.adapter Faraday.default_adapter
1003
- end
1004
- request_headers = Hash.new
746
+ request_headers = {}
1005
747
 
1006
748
  # Set Headers
1007
749
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1008
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
1009
-
1010
- unless custom_headers.nil?
1011
- custom_headers.each do |key, value|
1012
- request_headers[key] = value
1013
- end
1014
- end
1015
-
1016
- # Send Request
1017
- promise = Concurrent::Promise.new do
1018
- connection.post do |request|
1019
- request.headers = request_headers
1020
- @client.credentials.sign_request(request) unless @client.credentials.nil?
1021
- end
750
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
751
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff'
752
+ options = {
753
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
754
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
755
+ query_params: {'api-version' => @client.api_version},
756
+ headers: request_headers.merge(custom_headers || {})
757
+ }
758
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
759
+ promise = request.run_promise do |req|
760
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
1022
761
  end
1023
762
 
1024
763
  promise = promise.then do |http_response|
1025
764
  status_code = http_response.status
1026
765
  response_content = http_response.body
1027
- unless (status_code == 202)
1028
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
766
+ unless status_code == 202
767
+ error_model = JSON.load(response_content)
768
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1029
769
  end
1030
770
 
1031
771
  # Create Result
1032
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
772
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1033
773
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1034
774
 
1035
775
  result
@@ -1040,6 +780,7 @@ module Azure::ARM::Compute
1040
780
 
1041
781
  #
1042
782
  # The operation to restart a virtual machine.
783
+ #
1043
784
  # @param resource_group_name [String] The name of the resource group.
1044
785
  # @param vm_name [String] The name of the virtual machine.
1045
786
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -1055,7 +796,7 @@ module Azure::ARM::Compute
1055
796
  end
1056
797
 
1057
798
  # Waiting for response.
1058
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
799
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
1059
800
  end
1060
801
 
1061
802
  promise
@@ -1063,6 +804,7 @@ module Azure::ARM::Compute
1063
804
 
1064
805
  #
1065
806
  # The operation to restart a virtual machine.
807
+ #
1066
808
  # @param resource_group_name [String] The name of the resource group.
1067
809
  # @param vm_name [String] The name of the virtual machine.
1068
810
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -1076,60 +818,33 @@ module Azure::ARM::Compute
1076
818
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
1077
819
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1078
820
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1079
- # Construct URL
1080
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart"
1081
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
1082
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
1083
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
1084
- url = URI.join(@client.base_url, path)
1085
- properties = {}
1086
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
1087
- unless url.query.nil?
1088
- url.query.split('&').each do |url_item|
1089
- url_items_parts = url_item.split('=')
1090
- properties[url_items_parts[0]] = url_items_parts[1]
1091
- end
1092
- end
1093
- properties.reject!{ |key, value| value.nil? }
1094
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
1095
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
1096
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
1097
- url = URI.parse(corrected_url)
1098
-
1099
- connection = Faraday.new(:url => url) do |faraday|
1100
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
1101
- faraday.use :cookie_jar
1102
- faraday.adapter Faraday.default_adapter
1103
- end
1104
- request_headers = Hash.new
821
+ request_headers = {}
1105
822
 
1106
823
  # Set Headers
1107
824
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1108
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
1109
-
1110
- unless custom_headers.nil?
1111
- custom_headers.each do |key, value|
1112
- request_headers[key] = value
1113
- end
1114
- end
1115
-
1116
- # Send Request
1117
- promise = Concurrent::Promise.new do
1118
- connection.post do |request|
1119
- request.headers = request_headers
1120
- @client.credentials.sign_request(request) unless @client.credentials.nil?
1121
- end
825
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
826
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart'
827
+ options = {
828
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
829
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
830
+ query_params: {'api-version' => @client.api_version},
831
+ headers: request_headers.merge(custom_headers || {})
832
+ }
833
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
834
+ promise = request.run_promise do |req|
835
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
1122
836
  end
1123
837
 
1124
838
  promise = promise.then do |http_response|
1125
839
  status_code = http_response.status
1126
840
  response_content = http_response.body
1127
- unless (status_code == 202)
1128
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
841
+ unless status_code == 202
842
+ error_model = JSON.load(response_content)
843
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1129
844
  end
1130
845
 
1131
846
  # Create Result
1132
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
847
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1133
848
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1134
849
 
1135
850
  result
@@ -1140,6 +855,7 @@ module Azure::ARM::Compute
1140
855
 
1141
856
  #
1142
857
  # The operation to start a virtual machine.
858
+ #
1143
859
  # @param resource_group_name [String] The name of the resource group.
1144
860
  # @param vm_name [String] The name of the virtual machine.
1145
861
  # @return [Concurrent::Promise] promise which provides async access to http
@@ -1155,7 +871,7 @@ module Azure::ARM::Compute
1155
871
  end
1156
872
 
1157
873
  # Waiting for response.
1158
- @client.get_post_or_delete_operation_result(response, nil, deserialize_method)
874
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
1159
875
  end
1160
876
 
1161
877
  promise
@@ -1163,6 +879,7 @@ module Azure::ARM::Compute
1163
879
 
1164
880
  #
1165
881
  # The operation to start a virtual machine.
882
+ #
1166
883
  # @param resource_group_name [String] The name of the resource group.
1167
884
  # @param vm_name [String] The name of the virtual machine.
1168
885
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -1176,60 +893,108 @@ module Azure::ARM::Compute
1176
893
  fail ArgumentError, 'vm_name is nil' if vm_name.nil?
1177
894
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1178
895
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
1179
- # Construct URL
1180
- path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start"
1181
- path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
1182
- path['{vmName}'] = ERB::Util.url_encode(vm_name) if path.include?('{vmName}')
1183
- path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
1184
- url = URI.join(@client.base_url, path)
1185
- properties = {}
1186
- properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
1187
- unless url.query.nil?
1188
- url.query.split('&').each do |url_item|
1189
- url_items_parts = url_item.split('=')
1190
- properties[url_items_parts[0]] = url_items_parts[1]
1191
- end
1192
- end
1193
- properties.reject!{ |key, value| value.nil? }
1194
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
1195
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
1196
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
1197
- url = URI.parse(corrected_url)
1198
-
1199
- connection = Faraday.new(:url => url) do |faraday|
1200
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
1201
- faraday.use :cookie_jar
1202
- faraday.adapter Faraday.default_adapter
1203
- end
1204
- request_headers = Hash.new
896
+ request_headers = {}
1205
897
 
1206
898
  # Set Headers
1207
899
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1208
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
900
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
901
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start'
902
+ options = {
903
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
904
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
905
+ query_params: {'api-version' => @client.api_version},
906
+ headers: request_headers.merge(custom_headers || {})
907
+ }
908
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
909
+ promise = request.run_promise do |req|
910
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
911
+ end
1209
912
 
1210
- unless custom_headers.nil?
1211
- custom_headers.each do |key, value|
1212
- request_headers[key] = value
913
+ promise = promise.then do |http_response|
914
+ status_code = http_response.status
915
+ response_content = http_response.body
916
+ unless status_code == 202
917
+ error_model = JSON.load(response_content)
918
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1213
919
  end
920
+
921
+ # Create Result
922
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
923
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
924
+
925
+ result
1214
926
  end
1215
927
 
1216
- # Send Request
1217
- promise = Concurrent::Promise.new do
1218
- connection.post do |request|
1219
- request.headers = request_headers
1220
- @client.credentials.sign_request(request) unless @client.credentials.nil?
928
+ promise.execute
929
+ end
930
+
931
+ #
932
+ # The operation to redeploy a virtual machine.
933
+ #
934
+ # @param resource_group_name [String] The name of the resource group.
935
+ # @param vm_name [String] The name of the virtual machine.
936
+ # @return [Concurrent::Promise] promise which provides async access to http
937
+ # response.
938
+ #
939
+ def redeploy(resource_group_name, vm_name, custom_headers = nil)
940
+ # Send request
941
+ promise = begin_redeploy(resource_group_name, vm_name, custom_headers)
942
+
943
+ promise = promise.then do |response|
944
+ # Defining deserialization method.
945
+ deserialize_method = lambda do |parsed_response|
1221
946
  end
947
+
948
+ # Waiting for response.
949
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
950
+ end
951
+
952
+ promise
953
+ end
954
+
955
+ #
956
+ # The operation to redeploy a virtual machine.
957
+ #
958
+ # @param resource_group_name [String] The name of the resource group.
959
+ # @param vm_name [String] The name of the virtual machine.
960
+ # @param [Hash{String => String}] The hash of custom headers need to be
961
+ # applied to HTTP request.
962
+ #
963
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
964
+ # response.
965
+ #
966
+ def begin_redeploy(resource_group_name, vm_name, custom_headers = nil)
967
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
968
+ fail ArgumentError, 'vm_name is nil' if vm_name.nil?
969
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
970
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
971
+ request_headers = {}
972
+
973
+ # Set Headers
974
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
975
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
976
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy'
977
+ options = {
978
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
979
+ path_params: {'resourceGroupName' => resource_group_name,'vmName' => vm_name,'subscriptionId' => @client.subscription_id},
980
+ query_params: {'api-version' => @client.api_version},
981
+ headers: request_headers.merge(custom_headers || {})
982
+ }
983
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
984
+ promise = request.run_promise do |req|
985
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
1222
986
  end
1223
987
 
1224
988
  promise = promise.then do |http_response|
1225
989
  status_code = http_response.status
1226
990
  response_content = http_response.body
1227
- unless (status_code == 202)
1228
- fail MsRestAzure::AzureOperationError.new(connection, http_response)
991
+ unless status_code == 202
992
+ error_model = JSON.load(response_content)
993
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1229
994
  end
1230
995
 
1231
996
  # Create Result
1232
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
997
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1233
998
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1234
999
 
1235
1000
  result
@@ -1240,6 +1005,7 @@ module Azure::ARM::Compute
1240
1005
 
1241
1006
  #
1242
1007
  # The operation to list virtual machines under a resource group.
1008
+ #
1243
1009
  # @param next_page_link [String] The NextLink from the previous successful
1244
1010
  # call to List operation.
1245
1011
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -1250,69 +1016,43 @@ module Azure::ARM::Compute
1250
1016
  #
1251
1017
  def list_next(next_page_link, custom_headers = nil)
1252
1018
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1253
- # Construct URL
1254
- path = "{nextLink}"
1255
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
1256
- url = URI.parse(path)
1257
- properties = {}
1258
- unless url.query.nil?
1259
- url.query.split('&').each do |url_item|
1260
- url_items_parts = url_item.split('=')
1261
- properties[url_items_parts[0]] = url_items_parts[1]
1262
- end
1263
- end
1264
- properties.reject!{ |key, value| value.nil? }
1265
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
1266
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
1267
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
1268
- url = URI.parse(corrected_url)
1269
-
1270
- connection = Faraday.new(:url => url) do |faraday|
1271
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
1272
- faraday.use :cookie_jar
1273
- faraday.adapter Faraday.default_adapter
1274
- end
1275
- request_headers = Hash.new
1019
+ request_headers = {}
1276
1020
 
1277
1021
  # Set Headers
1278
1022
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1279
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
1280
-
1281
- unless custom_headers.nil?
1282
- custom_headers.each do |key, value|
1283
- request_headers[key] = value
1284
- end
1285
- end
1286
-
1287
- # Send Request
1288
- promise = Concurrent::Promise.new do
1289
- connection.get do |request|
1290
- request.headers = request_headers
1291
- @client.credentials.sign_request(request) unless @client.credentials.nil?
1292
- end
1023
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1024
+ path_template = '{nextLink}'
1025
+ options = {
1026
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1027
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1028
+ headers: request_headers.merge(custom_headers || {})
1029
+ }
1030
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
1031
+ promise = request.run_promise do |req|
1032
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
1293
1033
  end
1294
1034
 
1295
1035
  promise = promise.then do |http_response|
1296
1036
  status_code = http_response.status
1297
1037
  response_content = http_response.body
1298
- unless (status_code == 200)
1038
+ unless status_code == 200
1299
1039
  error_model = JSON.load(response_content)
1300
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
1040
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1301
1041
  end
1302
1042
 
1303
1043
  # Create Result
1304
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
1044
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1305
1045
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1306
1046
  # Deserialize Response
1307
1047
  if status_code == 200
1308
1048
  begin
1309
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
1049
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1310
1050
  unless parsed_response.nil?
1311
1051
  parsed_response = VirtualMachineListResult.deserialize_object(parsed_response)
1312
1052
  end
1313
1053
  result.body = parsed_response
1314
1054
  rescue Exception => e
1315
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
1055
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1316
1056
  end
1317
1057
  end
1318
1058
 
@@ -1326,6 +1066,7 @@ module Azure::ARM::Compute
1326
1066
  # Gets the list of Virtual Machines in the subscription. Use nextLink property
1327
1067
  # in the response to get the next page of Virtual Machines. Do this till
1328
1068
  # nextLink is not null to fetch all the Virtual Machines.
1069
+ #
1329
1070
  # @param next_page_link [String] The NextLink from the previous successful
1330
1071
  # call to List operation.
1331
1072
  # @param [Hash{String => String}] The hash of custom headers need to be
@@ -1336,69 +1077,102 @@ module Azure::ARM::Compute
1336
1077
  #
1337
1078
  def list_all_next(next_page_link, custom_headers = nil)
1338
1079
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1339
- # Construct URL
1340
- path = "{nextLink}"
1341
- path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
1342
- url = URI.parse(path)
1343
- properties = {}
1344
- unless url.query.nil?
1345
- url.query.split('&').each do |url_item|
1346
- url_items_parts = url_item.split('=')
1347
- properties[url_items_parts[0]] = url_items_parts[1]
1348
- end
1349
- end
1350
- properties.reject!{ |key, value| value.nil? }
1351
- url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
1352
- fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
1353
- corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
1354
- url = URI.parse(corrected_url)
1355
-
1356
- connection = Faraday.new(:url => url) do |faraday|
1357
- faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
1358
- faraday.use :cookie_jar
1359
- faraday.adapter Faraday.default_adapter
1360
- end
1361
- request_headers = Hash.new
1080
+ request_headers = {}
1362
1081
 
1363
1082
  # Set Headers
1364
1083
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1365
- request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
1084
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1085
+ path_template = '{nextLink}'
1086
+ options = {
1087
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1088
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1089
+ headers: request_headers.merge(custom_headers || {})
1090
+ }
1091
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
1092
+ promise = request.run_promise do |req|
1093
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
1094
+ end
1366
1095
 
1367
- unless custom_headers.nil?
1368
- custom_headers.each do |key, value|
1369
- request_headers[key] = value
1096
+ promise = promise.then do |http_response|
1097
+ status_code = http_response.status
1098
+ response_content = http_response.body
1099
+ unless status_code == 200
1100
+ error_model = JSON.load(response_content)
1101
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1370
1102
  end
1371
- end
1372
1103
 
1373
- # Send Request
1374
- promise = Concurrent::Promise.new do
1375
- connection.get do |request|
1376
- request.headers = request_headers
1377
- @client.credentials.sign_request(request) unless @client.credentials.nil?
1104
+ # Create Result
1105
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1106
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1107
+ # Deserialize Response
1108
+ if status_code == 200
1109
+ begin
1110
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1111
+ unless parsed_response.nil?
1112
+ parsed_response = VirtualMachineListResult.deserialize_object(parsed_response)
1113
+ end
1114
+ result.body = parsed_response
1115
+ rescue Exception => e
1116
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1117
+ end
1378
1118
  end
1119
+
1120
+ result
1121
+ end
1122
+
1123
+ promise.execute
1124
+ end
1125
+
1126
+ #
1127
+ # Lists virtual-machine-sizes available to be used for a virtual machine.
1128
+ #
1129
+ # @param next_page_link [String] The NextLink from the previous successful
1130
+ # call to List operation.
1131
+ # @param [Hash{String => String}] The hash of custom headers need to be
1132
+ # applied to HTTP request.
1133
+ #
1134
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
1135
+ # response.
1136
+ #
1137
+ def list_available_sizes_next(next_page_link, custom_headers = nil)
1138
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1139
+ request_headers = {}
1140
+
1141
+ # Set Headers
1142
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1143
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1144
+ path_template = '{nextLink}'
1145
+ options = {
1146
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1147
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1148
+ headers: request_headers.merge(custom_headers || {})
1149
+ }
1150
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
1151
+ promise = request.run_promise do |req|
1152
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
1379
1153
  end
1380
1154
 
1381
1155
  promise = promise.then do |http_response|
1382
1156
  status_code = http_response.status
1383
1157
  response_content = http_response.body
1384
- unless (status_code == 200)
1158
+ unless status_code == 200
1385
1159
  error_model = JSON.load(response_content)
1386
- fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
1160
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
1387
1161
  end
1388
1162
 
1389
1163
  # Create Result
1390
- result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
1164
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1391
1165
  result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1392
1166
  # Deserialize Response
1393
1167
  if status_code == 200
1394
1168
  begin
1395
- parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
1169
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1396
1170
  unless parsed_response.nil?
1397
- parsed_response = VirtualMachineListResult.deserialize_object(parsed_response)
1171
+ parsed_response = VirtualMachineSizeListResult.deserialize_object(parsed_response)
1398
1172
  end
1399
1173
  result.body = parsed_response
1400
1174
  rescue Exception => e
1401
- fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
1175
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1402
1176
  end
1403
1177
  end
1404
1178