# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0 # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure::ARM::Compute # # The Compute Management Client. # class VirtualMachineScaleSetVMs include Azure::ARM::Compute::Models include MsRestAzure # # Creates and initializes a new instance of the VirtualMachineScaleSetVMs class. # @param client service class for accessing basic functionality. # def initialize(client) @client = client end # @return reference to the ComputeManagementClient attr_reader :client # # The operation to re-image a virtual machine scale set instance. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @return [Concurrent::Promise] promise which provides async access to http # response. # def reimage(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) # Send request promise = begin_reimage(resource_group_name, vm_scale_set_name, instance_id, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_post_or_delete_operation_result(response, deserialize_method) end promise end # # The operation to re-image a virtual machine scale set instance. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def begin_reimage(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end # # The operation to deallocate a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @return [Concurrent::Promise] promise which provides async access to http # response. # def deallocate(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) # Send request promise = begin_deallocate(resource_group_name, vm_scale_set_name, instance_id, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_post_or_delete_operation_result(response, deserialize_method) end promise end # # The operation to deallocate a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def begin_deallocate(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end # # The operation to delete a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @return [Concurrent::Promise] promise which provides async access to http # response. # def delete(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) # Send request promise = begin_delete(resource_group_name, vm_scale_set_name, instance_id, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_post_or_delete_operation_result(response, deserialize_method) end promise end # # The operation to delete a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def begin_delete(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 200 || status_code == 202 || status_code == 204 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end # # The operation to get a virtual machine scale set virtual machine. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def get(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) unless parsed_response.nil? parsed_response = VirtualMachineScaleSetVM.deserialize_object(parsed_response) end result.body = parsed_response rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # The operation to get a virtual machine scale set virtual machine. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def get_instance_view(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) unless parsed_response.nil? parsed_response = VirtualMachineScaleSetVMInstanceView.deserialize_object(parsed_response) end result.body = parsed_response rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # The operation to list virtual machine scale sets VMs. # # @param resource_group_name [String] The name of the resource group. # @param virtual_machine_scale_set_name [String] The name of the virtual # machine scale set. # @param filter [String] The filter to apply on the operation. # @param select [String] The list parameters. # @param expand [String] The expand expression to apply on the operation. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def list(resource_group_name, virtual_machine_scale_set_name, filter = nil, select = nil, expand = nil, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'virtual_machine_scale_set_name is nil' if virtual_machine_scale_set_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'virtualMachineScaleSetName' => virtual_machine_scale_set_name,'subscriptionId' => @client.subscription_id}, query_params: {'$filter' => filter,'$select' => select,'$expand' => expand,'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) unless parsed_response.nil? parsed_response = VirtualMachineScaleSetVMListResult.deserialize_object(parsed_response) end result.body = parsed_response rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # The operation to power off (stop) a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @return [Concurrent::Promise] promise which provides async access to http # response. # def power_off(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) # Send request promise = begin_power_off(resource_group_name, vm_scale_set_name, instance_id, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_post_or_delete_operation_result(response, deserialize_method) end promise end # # The operation to power off (stop) a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def begin_power_off(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end # # The operation to restart a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @return [Concurrent::Promise] promise which provides async access to http # response. # def restart(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) # Send request promise = begin_restart(resource_group_name, vm_scale_set_name, instance_id, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_post_or_delete_operation_result(response, deserialize_method) end promise end # # The operation to restart a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def begin_restart(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end # # The operation to start a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @return [Concurrent::Promise] promise which provides async access to http # response. # def start(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) # Send request promise = begin_start(resource_group_name, vm_scale_set_name, instance_id, custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| end # Waiting for response. @client.get_post_or_delete_operation_result(response, deserialize_method) end promise end # # The operation to start a virtual machine scale set. # # @param resource_group_name [String] The name of the resource group. # @param vm_scale_set_name [String] The name of the virtual machine scale set. # @param instance_id [String] The instance id of the virtual machine. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def begin_start(resource_group_name, vm_scale_set_name, instance_id, custom_headers = nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, 'vm_scale_set_name is nil' if vm_scale_set_name.nil? fail ArgumentError, 'instance_id is nil' if instance_id.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'vmScaleSetName' => vm_scale_set_name,'instanceId' => instance_id,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 202 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result end promise.execute end # # The operation to list virtual machine scale sets VMs. # # @param next_page_link [String] The NextLink from the previous successful # call to List operation. # @param [Hash{String => String}] The hash of custom headers need to be # applied to HTTP request. # # @return [Concurrent::Promise] Promise object which allows to get HTTP # response. # def list_next(next_page_link, custom_headers = nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.nil? request_headers = {} # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '{nextLink}' options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}) } request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options) promise = request.run_promise do |req| @client.credentials.sign_request(req) unless @client.credentials.nil? end promise = promise.then do |http_response| status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(request, http_response, error_model) end # Create Result result = MsRestAzure::AzureOperationResponse.new(request, http_response) result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) unless parsed_response.nil? parsed_response = VirtualMachineScaleSetVMListResult.deserialize_object(parsed_response) end result.body = parsed_response rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end end end