text: # coding=utf-8
  # --------------------------------------------------------------------------
  # Copyright (c) Microsoft Corporation. All rights reserved.
  # Licensed under the MIT License. See License.txt in the project root for
  # license information.
  #
  # Code generated by Microsoft (R) AutoRest Code Generator.
  # Changes may cause incorrect behavior and will be lost if the code is
  # regenerated.
  # --------------------------------------------------------------------------
  
  import uuid
  from msrest.pipeline import ClientRawResponse
  from msrestazure.azure_exceptions import CloudError
  from msrest.polling import LROPoller, NoPolling
  from msrestazure.polling.arm_polling import ARMPolling
  
  from .. import models
  
  
  class VirtualMachineScaleSetVMsOperations(object):
      """VirtualMachineScaleSetVMsOperations operations.
  
      You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.
  
      :param client: Client for service requests.
      :param config: Configuration of service client.
      :param serializer: An object model serializer.
      :param deserializer: An object model deserializer.
      :ivar api_version: Client Api Version. Constant value: "2019-12-01".
      """
  
      models = models
  
      def __init__(self, client, config, serializer, deserializer):
  
          self._client = client
          self._serialize = serializer
          self._deserialize = deserializer
          self.api_version = "2019-12-01"
  
          self.config = config
  
  
      def _reimage_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, temp_disk=None, custom_headers=None, raw=False, **operation_config):
          vm_scale_set_vm_reimage_input = None
          if temp_disk is not None:
              vm_scale_set_vm_reimage_input = models.VirtualMachineScaleSetVMReimageParameters(temp_disk=temp_disk)
  
          # Construct URL
          url = self.reimage.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          header_parameters['Content-Type'] = 'application/json; charset=utf-8'
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct body
          if vm_scale_set_vm_reimage_input is not None:
              body_content = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters')
          else:
              body_content = None
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def reimage(
              self, resource_group_name, vm_scale_set_name, instance_id, temp_disk=None, custom_headers=None, raw=False, polling=True, **operation_config):
          """Reimages (upgrade the operating system) a specific virtual machine in a
          VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param temp_disk: Specifies whether to reimage temp disk. Default
           value: false. Note: This temp disk reimage parameter is only supported
           for VM/VMSS with Ephemeral OS disk.
          :type temp_disk: bool
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._reimage_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              temp_disk=temp_disk,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      reimage.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage'}
  
  
      def _reimage_all_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.reimage_all.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def reimage_all(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Allows you to re-image all the disks ( including data disks ) in the a
          VM scale set instance. This operation is only supported for managed
          disks.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._reimage_all_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      reimage_all.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall'}
  
  
      def _deallocate_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.deallocate.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def deallocate(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Deallocates a specific virtual machine in a VM scale set. Shuts down
          the virtual machine and releases the compute resources it uses. You are
          not billed for the compute resources of this virtual machine once it is
          deallocated.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._deallocate_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      deallocate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate'}
  
  
      def _update_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, parameters, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.update.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          header_parameters['Accept'] = 'application/json'
          header_parameters['Content-Type'] = 'application/json; charset=utf-8'
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct body
          body_content = self._serialize.body(parameters, 'VirtualMachineScaleSetVM')
  
          # Construct and send request
          request = self._client.put(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize('VirtualMachineScaleSetVM', response)
          if response.status_code == 202:
              deserialized = self._deserialize('VirtualMachineScaleSetVM', response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      def update(
              self, resource_group_name, vm_scale_set_name, instance_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
          """Updates a virtual machine of a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set where the
           extension should be create or updated.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param parameters: Parameters supplied to the Update Virtual Machine
           Scale Sets VM operation.
          :type parameters:
           ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns
           VirtualMachineScaleSetVM or
           ClientRawResponse<VirtualMachineScaleSetVM> if raw==True
          :rtype:
           ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM]
           or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._update_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              parameters=parameters,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              deserialized = self._deserialize('VirtualMachineScaleSetVM', response)
  
              if raw:
                  client_raw_response = ClientRawResponse(deserialized, response)
                  return client_raw_response
  
              return deserialized
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'}
  
  
      def _delete_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.delete.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.delete(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202, 204]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def delete(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Deletes a virtual machine from a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._delete_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'}
  
      def get(
              self, resource_group_name, vm_scale_set_name, instance_id, expand=None, custom_headers=None, raw=False, **operation_config):
          """Gets a virtual machine from a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param expand: The expand expression to apply on the operation.
           Possible values include: 'instanceView'
          :type expand: str or
           ~azure.mgmt.compute.v2019_12_01.models.InstanceViewTypes
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: returns the direct response alongside the
           deserialized response
          :param operation_config: :ref:`Operation configuration
           overrides<msrest:optionsforoperations>`.
          :return: VirtualMachineScaleSetVM or ClientRawResponse if raw=true
          :rtype:
           ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM or
           ~msrest.pipeline.ClientRawResponse
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          # Construct URL
          url = self.get.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          if expand is not None:
              query_parameters['$expand'] = self._serialize.query("expand", expand, 'InstanceViewTypes')
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          header_parameters['Accept'] = 'application/json'
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.get(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          deserialized = None
          if response.status_code == 200:
              deserialized = self._deserialize('VirtualMachineScaleSetVM', response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
      get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}'}
  
      def get_instance_view(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          """Gets the status of a virtual machine from a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: returns the direct response alongside the
           deserialized response
          :param operation_config: :ref:`Operation configuration
           overrides<msrest:optionsforoperations>`.
          :return: VirtualMachineScaleSetVMInstanceView or ClientRawResponse if
           raw=true
          :rtype:
           ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceView
           or ~msrest.pipeline.ClientRawResponse
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          # Construct URL
          url = self.get_instance_view.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          header_parameters['Accept'] = 'application/json'
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.get(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          deserialized = None
          if response.status_code == 200:
              deserialized = self._deserialize('VirtualMachineScaleSetVMInstanceView', response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
      get_instance_view.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView'}
  
      def list(
              self, resource_group_name, virtual_machine_scale_set_name, filter=None, select=None, expand=None, custom_headers=None, raw=False, **operation_config):
          """Gets a list of all virtual machines in a VM scale sets.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param virtual_machine_scale_set_name: The name of the VM scale set.
          :type virtual_machine_scale_set_name: str
          :param filter: The filter to apply to the operation.
          :type filter: str
          :param select: The list parameters.
          :type select: str
          :param expand: The expand expression to apply to the operation.
          :type expand: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: returns the direct response alongside the
           deserialized response
          :param operation_config: :ref:`Operation configuration
           overrides<msrest:optionsforoperations>`.
          :return: An iterator like instance of VirtualMachineScaleSetVM
          :rtype:
           ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          def prepare_request(next_link=None):
              if not next_link:
                  # Construct URL
                  url = self.list.metadata['url']
                  path_format_arguments = {
                      'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
                      'virtualMachineScaleSetName': self._serialize.url("virtual_machine_scale_set_name", virtual_machine_scale_set_name, 'str'),
                      'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
                  }
                  url = self._client.format_url(url, **path_format_arguments)
  
                  # Construct parameters
                  query_parameters = {}
                  if filter is not None:
                      query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
                  if select is not None:
                      query_parameters['$select'] = self._serialize.query("select", select, 'str')
                  if expand is not None:
                      query_parameters['$expand'] = self._serialize.query("expand", expand, 'str')
                  query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
              else:
                  url = next_link
                  query_parameters = {}
  
              # Construct headers
              header_parameters = {}
              header_parameters['Accept'] = 'application/json'
              if self.config.generate_client_request_id:
                  header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
              if custom_headers:
                  header_parameters.update(custom_headers)
              if self.config.accept_language is not None:
                  header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
              # Construct and send request
              request = self._client.get(url, query_parameters, header_parameters)
              return request
  
          def internal_paging(next_link=None):
              request = prepare_request(next_link)
  
              response = self._client.send(request, stream=False, **operation_config)
  
              if response.status_code not in [200]:
                  exp = CloudError(response)
                  exp.request_id = response.headers.get('x-ms-request-id')
                  raise exp
  
              return response
  
          # Deserialize response
          header_dict = None
          if raw:
              header_dict = {}
          deserialized = models.VirtualMachineScaleSetVMPaged(internal_paging, self._deserialize.dependencies, header_dict)
  
          return deserialized
      list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines'}
  
  
      def _power_off_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, skip_shutdown=False, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.power_off.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          if skip_shutdown is not None:
              query_parameters['skipShutdown'] = self._serialize.query("skip_shutdown", skip_shutdown, 'bool')
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def power_off(
              self, resource_group_name, vm_scale_set_name, instance_id, skip_shutdown=False, custom_headers=None, raw=False, polling=True, **operation_config):
          """Power off (stop) a virtual machine in a VM scale set. Note that
          resources are still attached and you are getting charged for the
          resources. Instead, use deallocate to release resources and avoid
          charges.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param skip_shutdown: The parameter to request non-graceful VM
           shutdown. True value for this flag indicates non-graceful shutdown
           whereas false indicates otherwise. Default value for this flag is
           false if not specified
          :type skip_shutdown: bool
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._power_off_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              skip_shutdown=skip_shutdown,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      power_off.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff'}
  
  
      def _restart_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.restart.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def restart(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Restarts a virtual machine in a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._restart_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart'}
  
  
      def _start_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.start.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def start(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Starts a virtual machine in a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._start_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start'}
  
  
      def _redeploy_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.redeploy.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def redeploy(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Shuts down the virtual machine in the virtual machine scale set, moves
          it to a new node, and powers it back on.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._redeploy_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy'}
  
  
      def _perform_maintenance_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.perform_maintenance.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          if raw:
              client_raw_response = ClientRawResponse(None, response)
              return client_raw_response
  
      def perform_maintenance(
              self, resource_group_name, vm_scale_set_name, instance_id, custom_headers=None, raw=False, polling=True, **operation_config):
          """Performs maintenance on a virtual machine in a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns None or
           ClientRawResponse<None> if raw==True
          :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._perform_maintenance_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              if raw:
                  client_raw_response = ClientRawResponse(None, response)
                  return client_raw_response
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      perform_maintenance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance'}
  
  
      def _run_command_initial(
              self, resource_group_name, vm_scale_set_name, instance_id, parameters, custom_headers=None, raw=False, **operation_config):
          # Construct URL
          url = self.run_command.metadata['url']
          path_format_arguments = {
              'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
              'vmScaleSetName': self._serialize.url("vm_scale_set_name", vm_scale_set_name, 'str'),
              'instanceId': self._serialize.url("instance_id", instance_id, 'str'),
              'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
          }
          url = self._client.format_url(url, **path_format_arguments)
  
          # Construct parameters
          query_parameters = {}
          query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
  
          # Construct headers
          header_parameters = {}
          header_parameters['Accept'] = 'application/json'
          header_parameters['Content-Type'] = 'application/json; charset=utf-8'
          if self.config.generate_client_request_id:
              header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
          if custom_headers:
              header_parameters.update(custom_headers)
          if self.config.accept_language is not None:
              header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
  
          # Construct body
          body_content = self._serialize.body(parameters, 'RunCommandInput')
  
          # Construct and send request
          request = self._client.post(url, query_parameters, header_parameters, body_content)
          response = self._client.send(request, stream=False, **operation_config)
  
          if response.status_code not in [200, 202]:
              exp = CloudError(response)
              exp.request_id = response.headers.get('x-ms-request-id')
              raise exp
  
          deserialized = None
  
          if response.status_code == 200:
              deserialized = self._deserialize('RunCommandResult', response)
  
          if raw:
              client_raw_response = ClientRawResponse(deserialized, response)
              return client_raw_response
  
          return deserialized
  
      def run_command(
              self, resource_group_name, vm_scale_set_name, instance_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
          """Run command on a virtual machine in a VM scale set.
  
          :param resource_group_name: The name of the resource group.
          :type resource_group_name: str
          :param vm_scale_set_name: The name of the VM scale set.
          :type vm_scale_set_name: str
          :param instance_id: The instance ID of the virtual machine.
          :type instance_id: str
          :param parameters: Parameters supplied to the Run command operation.
          :type parameters:
           ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput
          :param dict custom_headers: headers that will be added to the request
          :param bool raw: The poller return type is ClientRawResponse, the
           direct response alongside the deserialized response
          :param polling: True for ARMPolling, False for no polling, or a
           polling object for personal polling strategy
          :return: An instance of LROPoller that returns RunCommandResult or
           ClientRawResponse<RunCommandResult> if raw==True
          :rtype:
           ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult]
           or
           ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult]]
          :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
          """
          raw_result = self._run_command_initial(
              resource_group_name=resource_group_name,
              vm_scale_set_name=vm_scale_set_name,
              instance_id=instance_id,
              parameters=parameters,
              custom_headers=custom_headers,
              raw=True,
              **operation_config
          )
  
          def get_long_running_output(response):
              deserialized = self._deserialize('RunCommandResult', response)
  
              if raw:
                  client_raw_response = ClientRawResponse(deserialized, response)
                  return client_raw_response
  
              return deserialized
  
          lro_delay = operation_config.get(
              'long_running_operation_timeout',
              self.config.long_running_operation_timeout)
          if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config)
          elif polling is False: polling_method = NoPolling()
          else: polling_method = polling
          return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
      run_command.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand'}
  