/*
 * 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.
 */

'use strict';

const msRest = require('ms-rest');
const msRestAzure = require('ms-rest-azure');
const WebResource = msRest.WebResource;

/**
 * List virtual machines in a given lab.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] Specify the $expand query. Example:
 * 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
 *
 * @param {string} [options.filter] The filter to apply to the operation.
 * Example: '$filter=contains(name,'myName')
 *
 * @param {number} [options.top] The maximum number of resources to return from
 * the operation. Example: '$top=10'
 *
 * @param {string} [options.orderby] The ordering expression for the results,
 * using OData notation. Example: '$orderby=name desc'
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link LabVirtualMachineList} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _list(resourceGroupName, labName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let expand = (options && options.expand !== undefined) ? options.expand : undefined;
  let filter = (options && options.filter !== undefined) ? options.filter : undefined;
  let top = (options && options.top !== undefined) ? options.top : undefined;
  let orderby = (options && options.orderby !== undefined) ? options.orderby : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
      throw new Error('filter must be of type string.');
    }
    if (top !== null && top !== undefined && typeof top !== 'number') {
      throw new Error('top must be of type number.');
    }
    if (orderby !== null && orderby !== undefined && typeof orderby.valueOf() !== 'string') {
      throw new Error('orderby must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  let queryParameters = [];
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  if (filter !== null && filter !== undefined) {
    queryParameters.push('$filter=' + encodeURIComponent(filter));
  }
  if (top !== null && top !== undefined) {
    queryParameters.push('$top=' + encodeURIComponent(top.toString()));
  }
  if (orderby !== null && orderby !== undefined) {
    queryParameters.push('$orderby=' + encodeURIComponent(orderby));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachineList']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Get virtual machine.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] Specify the $expand query. Example:
 * 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link LabVirtualMachine} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _get(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let expand = (options && options.expand !== undefined) ? options.expand : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachine']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}


/**
 * Create or replace an existing Virtual machine. This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} labVirtualMachine A virtual machine.
 *
 * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
 *
 * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
 * the owner of the virtual machine.
 *
 * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
 * principal name of the virtual machine owner.
 *
 * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
 * the creator of the virtual machine.
 *
 * @param {string} [labVirtualMachine.createdByUser] The email address of
 * creator of the virtual machine.
 *
 * @param {date} [labVirtualMachine.createdDate] The creation date of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachine.computeId] The resource identifier
 * (Microsoft.Compute) of the virtual machine.
 *
 * @param {string} [labVirtualMachine.customImageId] The custom image
 * identifier of the virtual machine.
 *
 * @param {string} [labVirtualMachine.osType] The OS type of the virtual
 * machine.
 *
 * @param {string} [labVirtualMachine.size] The size of the virtual machine.
 *
 * @param {string} [labVirtualMachine.userName] The user name of the virtual
 * machine.
 *
 * @param {string} [labVirtualMachine.password] The password of the virtual
 * machine administrator.
 *
 * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
 * machine administrator.
 *
 * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
 * whether this virtual machine uses an SSH key for authentication.
 *
 * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
 * the virtual machine.
 *
 * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
 * network identifier of the virtual machine.
 *
 * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
 * whether the virtual machine is to be created without a public IP address.
 *
 * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
 * on the virtual machine.
 *
 * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
 * deployment status for the virtual machine.
 *
 * @param {string}
 * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
 * status of the artifact.
 *
 * @param {number}
 * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
 * count of the artifacts that were successfully applied.
 *
 * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
 * The total count of the artifacts that were tentatively applied.
 *
 * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
 * Azure Marketplace image reference of the virtual machine.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
 * the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
 * publisher of the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
 * gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
 * of the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.version] The
 * version of the gallery image.
 *
 * @param {string} [labVirtualMachine.planId] The id of the plan associated
 * with the virtual machine image
 *
 * @param {object} [labVirtualMachine.networkInterface] The network interface
 * properties.
 *
 * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
 * resource ID of the virtual network.
 *
 * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
 * ID of the sub net.
 *
 * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
 * resource ID of the public IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
 * public IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
 * private IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
 *
 * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
 * RdpAuthority property is a server DNS host name or IP address followed by
 * the service port number for RDP (Remote Desktop Protocol).
 *
 * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
 * SshAuthority property is a server DNS host name or IP address followed by
 * the service port number for SSH.
 *
 * @param {object}
 * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
 * configuration for sharing a public IP address across multiple virtual
 * machines.
 *
 * @param {array}
 * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
 * The incoming NAT rules
 *
 * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
 *
 * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
 * user can take ownership of the virtual machine
 *
 * @param {string} [labVirtualMachine.storageType] Storage type to use for
 * virtual machine (i.e. Standard, Premium).
 *
 * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
 * source of creation of lab virtual machine. Output property only. Possible
 * values include: 'FromCustomImage', 'FromGalleryImage'
 *
 * @param {string} [labVirtualMachine.environmentId] The resource ID of the
 * environment that contains this virtual machine, if any.
 *
 * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
 * disks to attach to the virtual machine after creation
 *
 * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
 * schedules to be created
 *
 * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
 * power state captured in DTL
 *
 * @param {string} [labVirtualMachine.location] The location of the resource.
 *
 * @param {object} [labVirtualMachine.tags] The tags of the resource.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link LabVirtualMachine} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _createOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginCreateOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachine']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Delete virtual machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _deleteMethod(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginDeleteMethod(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}

/**
 * Modify properties of virtual machines.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} labVirtualMachine A virtual machine.
 *
 * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
 *
 * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
 * the owner of the virtual machine.
 *
 * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
 * principal name of the virtual machine owner.
 *
 * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
 * the creator of the virtual machine.
 *
 * @param {string} [labVirtualMachine.createdByUser] The email address of
 * creator of the virtual machine.
 *
 * @param {date} [labVirtualMachine.createdDate] The creation date of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachine.computeId] The resource identifier
 * (Microsoft.Compute) of the virtual machine.
 *
 * @param {string} [labVirtualMachine.customImageId] The custom image
 * identifier of the virtual machine.
 *
 * @param {string} [labVirtualMachine.osType] The OS type of the virtual
 * machine.
 *
 * @param {string} [labVirtualMachine.size] The size of the virtual machine.
 *
 * @param {string} [labVirtualMachine.userName] The user name of the virtual
 * machine.
 *
 * @param {string} [labVirtualMachine.password] The password of the virtual
 * machine administrator.
 *
 * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
 * machine administrator.
 *
 * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
 * whether this virtual machine uses an SSH key for authentication.
 *
 * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
 * the virtual machine.
 *
 * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
 * network identifier of the virtual machine.
 *
 * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
 * whether the virtual machine is to be created without a public IP address.
 *
 * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
 * on the virtual machine.
 *
 * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
 * deployment status for the virtual machine.
 *
 * @param {string}
 * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
 * status of the artifact.
 *
 * @param {number}
 * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
 * count of the artifacts that were successfully applied.
 *
 * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
 * The total count of the artifacts that were tentatively applied.
 *
 * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
 * Azure Marketplace image reference of the virtual machine.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
 * the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
 * publisher of the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
 * gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
 * of the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.version] The
 * version of the gallery image.
 *
 * @param {string} [labVirtualMachine.planId] The id of the plan associated
 * with the virtual machine image
 *
 * @param {object} [labVirtualMachine.networkInterface] The network interface
 * properties.
 *
 * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
 * resource ID of the virtual network.
 *
 * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
 * ID of the sub net.
 *
 * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
 * resource ID of the public IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
 * public IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
 * private IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
 *
 * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
 * RdpAuthority property is a server DNS host name or IP address followed by
 * the service port number for RDP (Remote Desktop Protocol).
 *
 * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
 * SshAuthority property is a server DNS host name or IP address followed by
 * the service port number for SSH.
 *
 * @param {object}
 * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
 * configuration for sharing a public IP address across multiple virtual
 * machines.
 *
 * @param {array}
 * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
 * The incoming NAT rules
 *
 * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
 *
 * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
 * user can take ownership of the virtual machine
 *
 * @param {string} [labVirtualMachine.storageType] Storage type to use for
 * virtual machine (i.e. Standard, Premium).
 *
 * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
 * source of creation of lab virtual machine. Output property only. Possible
 * values include: 'FromCustomImage', 'FromGalleryImage'
 *
 * @param {string} [labVirtualMachine.environmentId] The resource ID of the
 * environment that contains this virtual machine, if any.
 *
 * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
 * disks to attach to the virtual machine after creation
 *
 * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
 * schedules to be created
 *
 * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
 * power state captured in DTL
 *
 * @param {object} [labVirtualMachine.tags] The tags of the resource.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link LabVirtualMachine} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _update(resourceGroupName, labName, name, labVirtualMachine, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (labVirtualMachine === null || labVirtualMachine === undefined) {
      throw new Error('labVirtualMachine cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'PATCH';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (labVirtualMachine !== null && labVirtualMachine !== undefined) {
      let requestModelMapper = new client.models['LabVirtualMachineFragment']().mapper();
      requestModel = client.serialize(requestModelMapper, labVirtualMachine, 'labVirtualMachine');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(labVirtualMachine, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachine']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}


/**
 * Attach a new or existing data disk to virtual machine. This operation can
 * take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} dataDiskProperties Request body for adding a new or existing
 * data disk to a virtual machine.
 *
 * @param {object} [dataDiskProperties.attachNewDataDiskOptions] Specifies
 * options to attach a new disk to the virtual machine.
 *
 * @param {number} [dataDiskProperties.attachNewDataDiskOptions.diskSizeGiB]
 * Size of the disk to be attached in Gibibytes.
 *
 * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskName] The
 * name of the disk to be attached.
 *
 * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskType] The
 * storage type for the disk (i.e. Standard, Premium). Possible values include:
 * 'Standard', 'Premium'
 *
 * @param {string} [dataDiskProperties.existingLabDiskId] Specifies the
 * existing lab disk id to attach to virtual machine.
 *
 * @param {string} [dataDiskProperties.hostCaching] Caching option for a data
 * disk (i.e. None, ReadOnly, ReadWrite). Possible values include: 'None',
 * 'ReadOnly', 'ReadWrite'
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _addDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginAddDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Apply artifacts to virtual machine. This operation can take a while to
 * complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} applyArtifactsRequest Request body for applying artifacts to
 * a virtual machine.
 *
 * @param {array} [applyArtifactsRequest.artifacts] The list of artifacts to
 * apply.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _applyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginApplyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Take ownership of an existing virtual machine This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _claim(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginClaim(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Detach the specified disk from the virtual machine. This operation can take
 * a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} detachDataDiskProperties Request body for detaching data
 * disk from a virtual machine.
 *
 * @param {string} [detachDataDiskProperties.existingLabDiskId] Specifies the
 * disk resource ID to detach from virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _detachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginDetachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}

/**
 * Gets a string that represents the contents of the RDP file for the virtual
 * machine
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link RdpConnection} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _getRdpFileContents(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/getRdpFileContents';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['RdpConnection']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Lists the applicable start/stop schedules, if any.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link ApplicableSchedule} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listApplicableSchedules(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ApplicableSchedule']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}


/**
 * Redeploy a virtual machine This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _redeploy(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginRedeploy(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Resize Virtual Machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} resizeLabVirtualMachineProperties Request body for resizing
 * a virtual machine.
 *
 * @param {string} [resizeLabVirtualMachineProperties.size] Specifies the size
 * of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _resize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginResize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Restart a virtual machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _restart(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginRestart(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Start a virtual machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _start(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginStart(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Stop a virtual machine This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _stop(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginStop(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Transfers all data disks attached to the virtual machine to be owned by the
 * current user. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _transferDisks(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginTransferDisks(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Release ownership of an existing virtual machine This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _unClaim(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginUnClaim(resourceGroupName, labName, name, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response

      return callback(null, result, httpRequest, response);
    });
  });
}

/**
 * Create or replace an existing Virtual machine. This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} labVirtualMachine A virtual machine.
 *
 * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
 *
 * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
 * the owner of the virtual machine.
 *
 * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
 * principal name of the virtual machine owner.
 *
 * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
 * the creator of the virtual machine.
 *
 * @param {string} [labVirtualMachine.createdByUser] The email address of
 * creator of the virtual machine.
 *
 * @param {date} [labVirtualMachine.createdDate] The creation date of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachine.computeId] The resource identifier
 * (Microsoft.Compute) of the virtual machine.
 *
 * @param {string} [labVirtualMachine.customImageId] The custom image
 * identifier of the virtual machine.
 *
 * @param {string} [labVirtualMachine.osType] The OS type of the virtual
 * machine.
 *
 * @param {string} [labVirtualMachine.size] The size of the virtual machine.
 *
 * @param {string} [labVirtualMachine.userName] The user name of the virtual
 * machine.
 *
 * @param {string} [labVirtualMachine.password] The password of the virtual
 * machine administrator.
 *
 * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
 * machine administrator.
 *
 * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
 * whether this virtual machine uses an SSH key for authentication.
 *
 * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
 * the virtual machine.
 *
 * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
 * network identifier of the virtual machine.
 *
 * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
 * whether the virtual machine is to be created without a public IP address.
 *
 * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
 * on the virtual machine.
 *
 * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
 * deployment status for the virtual machine.
 *
 * @param {string}
 * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
 * status of the artifact.
 *
 * @param {number}
 * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
 * count of the artifacts that were successfully applied.
 *
 * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
 * The total count of the artifacts that were tentatively applied.
 *
 * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
 * Azure Marketplace image reference of the virtual machine.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
 * the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
 * publisher of the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
 * gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
 * of the gallery image.
 *
 * @param {string} [labVirtualMachine.galleryImageReference.version] The
 * version of the gallery image.
 *
 * @param {string} [labVirtualMachine.planId] The id of the plan associated
 * with the virtual machine image
 *
 * @param {object} [labVirtualMachine.networkInterface] The network interface
 * properties.
 *
 * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
 * resource ID of the virtual network.
 *
 * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
 * ID of the sub net.
 *
 * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
 * resource ID of the public IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
 * public IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
 * private IP address.
 *
 * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
 *
 * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
 * RdpAuthority property is a server DNS host name or IP address followed by
 * the service port number for RDP (Remote Desktop Protocol).
 *
 * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
 * SshAuthority property is a server DNS host name or IP address followed by
 * the service port number for SSH.
 *
 * @param {object}
 * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
 * configuration for sharing a public IP address across multiple virtual
 * machines.
 *
 * @param {array}
 * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
 * The incoming NAT rules
 *
 * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
 *
 * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
 * user can take ownership of the virtual machine
 *
 * @param {string} [labVirtualMachine.storageType] Storage type to use for
 * virtual machine (i.e. Standard, Premium).
 *
 * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
 * source of creation of lab virtual machine. Output property only. Possible
 * values include: 'FromCustomImage', 'FromGalleryImage'
 *
 * @param {string} [labVirtualMachine.environmentId] The resource ID of the
 * environment that contains this virtual machine, if any.
 *
 * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
 * disks to attach to the virtual machine after creation
 *
 * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
 * schedules to be created
 *
 * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
 * power state captured in DTL
 *
 * @param {string} [labVirtualMachine.location] The location of the resource.
 *
 * @param {object} [labVirtualMachine.tags] The tags of the resource.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link LabVirtualMachine} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginCreateOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (labVirtualMachine === null || labVirtualMachine === undefined) {
      throw new Error('labVirtualMachine cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'PUT';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (labVirtualMachine !== null && labVirtualMachine !== undefined) {
      let requestModelMapper = new client.models['LabVirtualMachine']().mapper();
      requestModel = client.serialize(requestModelMapper, labVirtualMachine, 'labVirtualMachine');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(labVirtualMachine, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 201) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachine']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }
    // Deserialize Response
    if (statusCode === 201) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachine']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError1.request = msRest.stripRequest(httpRequest);
        deserializationError1.response = msRest.stripResponse(response);
        return callback(deserializationError1);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Delete virtual machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDeleteMethod(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'DELETE';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202 && statusCode !== 204) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Attach a new or existing data disk to virtual machine. This operation can
 * take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} dataDiskProperties Request body for adding a new or existing
 * data disk to a virtual machine.
 *
 * @param {object} [dataDiskProperties.attachNewDataDiskOptions] Specifies
 * options to attach a new disk to the virtual machine.
 *
 * @param {number} [dataDiskProperties.attachNewDataDiskOptions.diskSizeGiB]
 * Size of the disk to be attached in Gibibytes.
 *
 * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskName] The
 * name of the disk to be attached.
 *
 * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskType] The
 * storage type for the disk (i.e. Standard, Premium). Possible values include:
 * 'Standard', 'Premium'
 *
 * @param {string} [dataDiskProperties.existingLabDiskId] Specifies the
 * existing lab disk id to attach to virtual machine.
 *
 * @param {string} [dataDiskProperties.hostCaching] Caching option for a data
 * disk (i.e. None, ReadOnly, ReadWrite). Possible values include: 'None',
 * 'ReadOnly', 'ReadWrite'
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginAddDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (dataDiskProperties === null || dataDiskProperties === undefined) {
      throw new Error('dataDiskProperties cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (dataDiskProperties !== null && dataDiskProperties !== undefined) {
      let requestModelMapper = new client.models['DataDiskProperties']().mapper();
      requestModel = client.serialize(requestModelMapper, dataDiskProperties, 'dataDiskProperties');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(dataDiskProperties, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Apply artifacts to virtual machine. This operation can take a while to
 * complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} applyArtifactsRequest Request body for applying artifacts to
 * a virtual machine.
 *
 * @param {array} [applyArtifactsRequest.artifacts] The list of artifacts to
 * apply.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginApplyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (applyArtifactsRequest === null || applyArtifactsRequest === undefined) {
      throw new Error('applyArtifactsRequest cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (applyArtifactsRequest !== null && applyArtifactsRequest !== undefined) {
      let requestModelMapper = new client.models['ApplyArtifactsRequest']().mapper();
      requestModel = client.serialize(requestModelMapper, applyArtifactsRequest, 'applyArtifactsRequest');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(applyArtifactsRequest, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Take ownership of an existing virtual machine This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginClaim(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Detach the specified disk from the virtual machine. This operation can take
 * a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} detachDataDiskProperties Request body for detaching data
 * disk from a virtual machine.
 *
 * @param {string} [detachDataDiskProperties.existingLabDiskId] Specifies the
 * disk resource ID to detach from virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDetachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (detachDataDiskProperties === null || detachDataDiskProperties === undefined) {
      throw new Error('detachDataDiskProperties cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (detachDataDiskProperties !== null && detachDataDiskProperties !== undefined) {
      let requestModelMapper = new client.models['DetachDataDiskProperties']().mapper();
      requestModel = client.serialize(requestModelMapper, detachDataDiskProperties, 'detachDataDiskProperties');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(detachDataDiskProperties, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Redeploy a virtual machine This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginRedeploy(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Resize Virtual Machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} resizeLabVirtualMachineProperties Request body for resizing
 * a virtual machine.
 *
 * @param {string} [resizeLabVirtualMachineProperties.size] Specifies the size
 * of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginResize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (resizeLabVirtualMachineProperties === null || resizeLabVirtualMachineProperties === undefined) {
      throw new Error('resizeLabVirtualMachineProperties cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (resizeLabVirtualMachineProperties !== null && resizeLabVirtualMachineProperties !== undefined) {
      let requestModelMapper = new client.models['ResizeLabVirtualMachineProperties']().mapper();
      requestModel = client.serialize(requestModelMapper, resizeLabVirtualMachineProperties, 'resizeLabVirtualMachineProperties');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(resizeLabVirtualMachineProperties, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Restart a virtual machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginRestart(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Start a virtual machine. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginStart(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Stop a virtual machine This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginStop(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Transfers all data disks attached to the virtual machine to be owned by the
 * current user. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginTransferDisks(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Release ownership of an existing virtual machine This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} labName The name of the lab.
 *
 * @param {string} name The name of the virtual machine.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginUnClaim(resourceGroupName, labName, name, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
      throw new Error('labName cannot be null or undefined and it must be of type string.');
    }
    if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
      throw new Error('name cannot be null or undefined and it must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
  requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * List virtual machines in a given lab.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link LabVirtualMachineList} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let requestUrl = '{nextLink}';
  requestUrl = requestUrl.replace('{nextLink}', nextPageLink);

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['LabVirtualMachineList']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}

/** Class representing a VirtualMachines. */
class VirtualMachines {
  /**
   * Create a VirtualMachines.
   * @param {DevTestLabsClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._list = _list;
    this._get = _get;
    this._createOrUpdate = _createOrUpdate;
    this._deleteMethod = _deleteMethod;
    this._update = _update;
    this._addDataDisk = _addDataDisk;
    this._applyArtifacts = _applyArtifacts;
    this._claim = _claim;
    this._detachDataDisk = _detachDataDisk;
    this._getRdpFileContents = _getRdpFileContents;
    this._listApplicableSchedules = _listApplicableSchedules;
    this._redeploy = _redeploy;
    this._resize = _resize;
    this._restart = _restart;
    this._start = _start;
    this._stop = _stop;
    this._transferDisks = _transferDisks;
    this._unClaim = _unClaim;
    this._beginCreateOrUpdate = _beginCreateOrUpdate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginAddDataDisk = _beginAddDataDisk;
    this._beginApplyArtifacts = _beginApplyArtifacts;
    this._beginClaim = _beginClaim;
    this._beginDetachDataDisk = _beginDetachDataDisk;
    this._beginRedeploy = _beginRedeploy;
    this._beginResize = _beginResize;
    this._beginRestart = _beginRestart;
    this._beginStart = _beginStart;
    this._beginStop = _beginStop;
    this._beginTransferDisks = _beginTransferDisks;
    this._beginUnClaim = _beginUnClaim;
    this._listNext = _listNext;
  }

  /**
   * List virtual machines in a given lab.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
   *
   * @param {string} [options.filter] The filter to apply to the operation.
   * Example: '$filter=contains(name,'myName')
   *
   * @param {number} [options.top] The maximum number of resources to return from
   * the operation. Example: '$top=10'
   *
   * @param {string} [options.orderby] The ordering expression for the results,
   * using OData notation. Example: '$orderby=name desc'
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<LabVirtualMachineList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listWithHttpOperationResponse(resourceGroupName, labName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._list(resourceGroupName, labName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List virtual machines in a given lab.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
   *
   * @param {string} [options.filter] The filter to apply to the operation.
   * Example: '$filter=contains(name,'myName')
   *
   * @param {number} [options.top] The maximum number of resources to return from
   * the operation. Example: '$top=10'
   *
   * @param {string} [options.orderby] The ordering expression for the results,
   * using OData notation. Example: '$orderby=name desc'
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {LabVirtualMachineList} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link LabVirtualMachineList} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  list(resourceGroupName, labName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._list(resourceGroupName, labName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._list(resourceGroupName, labName, options, optionalCallback);
    }
  }

  /**
   * Get virtual machine.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<LabVirtualMachine>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get virtual machine.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {LabVirtualMachine} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link LabVirtualMachine} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  get(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Create or replace an existing Virtual machine. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} labVirtualMachine A virtual machine.
   *
   * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
   * the owner of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
   * principal name of the virtual machine owner.
   *
   * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
   * the creator of the virtual machine.
   *
   * @param {string} [labVirtualMachine.createdByUser] The email address of
   * creator of the virtual machine.
   *
   * @param {date} [labVirtualMachine.createdDate] The creation date of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.computeId] The resource identifier
   * (Microsoft.Compute) of the virtual machine.
   *
   * @param {string} [labVirtualMachine.customImageId] The custom image
   * identifier of the virtual machine.
   *
   * @param {string} [labVirtualMachine.osType] The OS type of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.size] The size of the virtual machine.
   *
   * @param {string} [labVirtualMachine.userName] The user name of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.password] The password of the virtual
   * machine administrator.
   *
   * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
   * machine administrator.
   *
   * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
   * whether this virtual machine uses an SSH key for authentication.
   *
   * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
   * the virtual machine.
   *
   * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
   * network identifier of the virtual machine.
   *
   * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
   * whether the virtual machine is to be created without a public IP address.
   *
   * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
   * on the virtual machine.
   *
   * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
   * deployment status for the virtual machine.
   *
   * @param {string}
   * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
   * status of the artifact.
   *
   * @param {number}
   * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
   * count of the artifacts that were successfully applied.
   *
   * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
   * The total count of the artifacts that were tentatively applied.
   *
   * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
   * Azure Marketplace image reference of the virtual machine.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
   * the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
   * publisher of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
   * gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
   * of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.version] The
   * version of the gallery image.
   *
   * @param {string} [labVirtualMachine.planId] The id of the plan associated
   * with the virtual machine image
   *
   * @param {object} [labVirtualMachine.networkInterface] The network interface
   * properties.
   *
   * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
   * resource ID of the virtual network.
   *
   * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
   * ID of the sub net.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
   * resource ID of the public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
   * public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
   * private IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
   *
   * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
   * RdpAuthority property is a server DNS host name or IP address followed by
   * the service port number for RDP (Remote Desktop Protocol).
   *
   * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
   * SshAuthority property is a server DNS host name or IP address followed by
   * the service port number for SSH.
   *
   * @param {object}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
   * configuration for sharing a public IP address across multiple virtual
   * machines.
   *
   * @param {array}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
   * The incoming NAT rules
   *
   * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
   *
   * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
   * user can take ownership of the virtual machine
   *
   * @param {string} [labVirtualMachine.storageType] Storage type to use for
   * virtual machine (i.e. Standard, Premium).
   *
   * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
   * source of creation of lab virtual machine. Output property only. Possible
   * values include: 'FromCustomImage', 'FromGalleryImage'
   *
   * @param {string} [labVirtualMachine.environmentId] The resource ID of the
   * environment that contains this virtual machine, if any.
   *
   * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
   * disks to attach to the virtual machine after creation
   *
   * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
   * schedules to be created
   *
   * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
   * power state captured in DTL
   *
   * @param {string} [labVirtualMachine.location] The location of the resource.
   *
   * @param {object} [labVirtualMachine.tags] The tags of the resource.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<LabVirtualMachine>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, labName, name, labVirtualMachine, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Create or replace an existing Virtual machine. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} labVirtualMachine A virtual machine.
   *
   * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
   * the owner of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
   * principal name of the virtual machine owner.
   *
   * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
   * the creator of the virtual machine.
   *
   * @param {string} [labVirtualMachine.createdByUser] The email address of
   * creator of the virtual machine.
   *
   * @param {date} [labVirtualMachine.createdDate] The creation date of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.computeId] The resource identifier
   * (Microsoft.Compute) of the virtual machine.
   *
   * @param {string} [labVirtualMachine.customImageId] The custom image
   * identifier of the virtual machine.
   *
   * @param {string} [labVirtualMachine.osType] The OS type of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.size] The size of the virtual machine.
   *
   * @param {string} [labVirtualMachine.userName] The user name of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.password] The password of the virtual
   * machine administrator.
   *
   * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
   * machine administrator.
   *
   * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
   * whether this virtual machine uses an SSH key for authentication.
   *
   * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
   * the virtual machine.
   *
   * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
   * network identifier of the virtual machine.
   *
   * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
   * whether the virtual machine is to be created without a public IP address.
   *
   * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
   * on the virtual machine.
   *
   * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
   * deployment status for the virtual machine.
   *
   * @param {string}
   * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
   * status of the artifact.
   *
   * @param {number}
   * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
   * count of the artifacts that were successfully applied.
   *
   * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
   * The total count of the artifacts that were tentatively applied.
   *
   * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
   * Azure Marketplace image reference of the virtual machine.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
   * the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
   * publisher of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
   * gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
   * of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.version] The
   * version of the gallery image.
   *
   * @param {string} [labVirtualMachine.planId] The id of the plan associated
   * with the virtual machine image
   *
   * @param {object} [labVirtualMachine.networkInterface] The network interface
   * properties.
   *
   * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
   * resource ID of the virtual network.
   *
   * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
   * ID of the sub net.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
   * resource ID of the public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
   * public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
   * private IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
   *
   * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
   * RdpAuthority property is a server DNS host name or IP address followed by
   * the service port number for RDP (Remote Desktop Protocol).
   *
   * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
   * SshAuthority property is a server DNS host name or IP address followed by
   * the service port number for SSH.
   *
   * @param {object}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
   * configuration for sharing a public IP address across multiple virtual
   * machines.
   *
   * @param {array}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
   * The incoming NAT rules
   *
   * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
   *
   * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
   * user can take ownership of the virtual machine
   *
   * @param {string} [labVirtualMachine.storageType] Storage type to use for
   * virtual machine (i.e. Standard, Premium).
   *
   * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
   * source of creation of lab virtual machine. Output property only. Possible
   * values include: 'FromCustomImage', 'FromGalleryImage'
   *
   * @param {string} [labVirtualMachine.environmentId] The resource ID of the
   * environment that contains this virtual machine, if any.
   *
   * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
   * disks to attach to the virtual machine after creation
   *
   * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
   * schedules to be created
   *
   * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
   * power state captured in DTL
   *
   * @param {string} [labVirtualMachine.location] The location of the resource.
   *
   * @param {object} [labVirtualMachine.tags] The tags of the resource.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {LabVirtualMachine} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link LabVirtualMachine} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  createOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._createOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, optionalCallback);
    }
  }

  /**
   * Delete virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteMethodWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Delete virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteMethod(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Modify properties of virtual machines.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} labVirtualMachine A virtual machine.
   *
   * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
   * the owner of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
   * principal name of the virtual machine owner.
   *
   * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
   * the creator of the virtual machine.
   *
   * @param {string} [labVirtualMachine.createdByUser] The email address of
   * creator of the virtual machine.
   *
   * @param {date} [labVirtualMachine.createdDate] The creation date of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.computeId] The resource identifier
   * (Microsoft.Compute) of the virtual machine.
   *
   * @param {string} [labVirtualMachine.customImageId] The custom image
   * identifier of the virtual machine.
   *
   * @param {string} [labVirtualMachine.osType] The OS type of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.size] The size of the virtual machine.
   *
   * @param {string} [labVirtualMachine.userName] The user name of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.password] The password of the virtual
   * machine administrator.
   *
   * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
   * machine administrator.
   *
   * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
   * whether this virtual machine uses an SSH key for authentication.
   *
   * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
   * the virtual machine.
   *
   * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
   * network identifier of the virtual machine.
   *
   * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
   * whether the virtual machine is to be created without a public IP address.
   *
   * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
   * on the virtual machine.
   *
   * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
   * deployment status for the virtual machine.
   *
   * @param {string}
   * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
   * status of the artifact.
   *
   * @param {number}
   * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
   * count of the artifacts that were successfully applied.
   *
   * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
   * The total count of the artifacts that were tentatively applied.
   *
   * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
   * Azure Marketplace image reference of the virtual machine.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
   * the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
   * publisher of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
   * gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
   * of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.version] The
   * version of the gallery image.
   *
   * @param {string} [labVirtualMachine.planId] The id of the plan associated
   * with the virtual machine image
   *
   * @param {object} [labVirtualMachine.networkInterface] The network interface
   * properties.
   *
   * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
   * resource ID of the virtual network.
   *
   * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
   * ID of the sub net.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
   * resource ID of the public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
   * public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
   * private IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
   *
   * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
   * RdpAuthority property is a server DNS host name or IP address followed by
   * the service port number for RDP (Remote Desktop Protocol).
   *
   * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
   * SshAuthority property is a server DNS host name or IP address followed by
   * the service port number for SSH.
   *
   * @param {object}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
   * configuration for sharing a public IP address across multiple virtual
   * machines.
   *
   * @param {array}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
   * The incoming NAT rules
   *
   * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
   *
   * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
   * user can take ownership of the virtual machine
   *
   * @param {string} [labVirtualMachine.storageType] Storage type to use for
   * virtual machine (i.e. Standard, Premium).
   *
   * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
   * source of creation of lab virtual machine. Output property only. Possible
   * values include: 'FromCustomImage', 'FromGalleryImage'
   *
   * @param {string} [labVirtualMachine.environmentId] The resource ID of the
   * environment that contains this virtual machine, if any.
   *
   * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
   * disks to attach to the virtual machine after creation
   *
   * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
   * schedules to be created
   *
   * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
   * power state captured in DTL
   *
   * @param {object} [labVirtualMachine.tags] The tags of the resource.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<LabVirtualMachine>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, labName, name, labVirtualMachine, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, labName, name, labVirtualMachine, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Modify properties of virtual machines.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} labVirtualMachine A virtual machine.
   *
   * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
   * the owner of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
   * principal name of the virtual machine owner.
   *
   * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
   * the creator of the virtual machine.
   *
   * @param {string} [labVirtualMachine.createdByUser] The email address of
   * creator of the virtual machine.
   *
   * @param {date} [labVirtualMachine.createdDate] The creation date of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.computeId] The resource identifier
   * (Microsoft.Compute) of the virtual machine.
   *
   * @param {string} [labVirtualMachine.customImageId] The custom image
   * identifier of the virtual machine.
   *
   * @param {string} [labVirtualMachine.osType] The OS type of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.size] The size of the virtual machine.
   *
   * @param {string} [labVirtualMachine.userName] The user name of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.password] The password of the virtual
   * machine administrator.
   *
   * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
   * machine administrator.
   *
   * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
   * whether this virtual machine uses an SSH key for authentication.
   *
   * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
   * the virtual machine.
   *
   * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
   * network identifier of the virtual machine.
   *
   * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
   * whether the virtual machine is to be created without a public IP address.
   *
   * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
   * on the virtual machine.
   *
   * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
   * deployment status for the virtual machine.
   *
   * @param {string}
   * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
   * status of the artifact.
   *
   * @param {number}
   * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
   * count of the artifacts that were successfully applied.
   *
   * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
   * The total count of the artifacts that were tentatively applied.
   *
   * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
   * Azure Marketplace image reference of the virtual machine.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
   * the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
   * publisher of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
   * gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
   * of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.version] The
   * version of the gallery image.
   *
   * @param {string} [labVirtualMachine.planId] The id of the plan associated
   * with the virtual machine image
   *
   * @param {object} [labVirtualMachine.networkInterface] The network interface
   * properties.
   *
   * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
   * resource ID of the virtual network.
   *
   * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
   * ID of the sub net.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
   * resource ID of the public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
   * public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
   * private IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
   *
   * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
   * RdpAuthority property is a server DNS host name or IP address followed by
   * the service port number for RDP (Remote Desktop Protocol).
   *
   * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
   * SshAuthority property is a server DNS host name or IP address followed by
   * the service port number for SSH.
   *
   * @param {object}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
   * configuration for sharing a public IP address across multiple virtual
   * machines.
   *
   * @param {array}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
   * The incoming NAT rules
   *
   * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
   *
   * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
   * user can take ownership of the virtual machine
   *
   * @param {string} [labVirtualMachine.storageType] Storage type to use for
   * virtual machine (i.e. Standard, Premium).
   *
   * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
   * source of creation of lab virtual machine. Output property only. Possible
   * values include: 'FromCustomImage', 'FromGalleryImage'
   *
   * @param {string} [labVirtualMachine.environmentId] The resource ID of the
   * environment that contains this virtual machine, if any.
   *
   * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
   * disks to attach to the virtual machine after creation
   *
   * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
   * schedules to be created
   *
   * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
   * power state captured in DTL
   *
   * @param {object} [labVirtualMachine.tags] The tags of the resource.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {LabVirtualMachine} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link LabVirtualMachine} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  update(resourceGroupName, labName, name, labVirtualMachine, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._update(resourceGroupName, labName, name, labVirtualMachine, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, labName, name, labVirtualMachine, options, optionalCallback);
    }
  }

  /**
   * Attach a new or existing data disk to virtual machine. This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} dataDiskProperties Request body for adding a new or existing
   * data disk to a virtual machine.
   *
   * @param {object} [dataDiskProperties.attachNewDataDiskOptions] Specifies
   * options to attach a new disk to the virtual machine.
   *
   * @param {number} [dataDiskProperties.attachNewDataDiskOptions.diskSizeGiB]
   * Size of the disk to be attached in Gibibytes.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskName] The
   * name of the disk to be attached.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskType] The
   * storage type for the disk (i.e. Standard, Premium). Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {string} [dataDiskProperties.existingLabDiskId] Specifies the
   * existing lab disk id to attach to virtual machine.
   *
   * @param {string} [dataDiskProperties.hostCaching] Caching option for a data
   * disk (i.e. None, ReadOnly, ReadWrite). Possible values include: 'None',
   * 'ReadOnly', 'ReadWrite'
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  addDataDiskWithHttpOperationResponse(resourceGroupName, labName, name, dataDiskProperties, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._addDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Attach a new or existing data disk to virtual machine. This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} dataDiskProperties Request body for adding a new or existing
   * data disk to a virtual machine.
   *
   * @param {object} [dataDiskProperties.attachNewDataDiskOptions] Specifies
   * options to attach a new disk to the virtual machine.
   *
   * @param {number} [dataDiskProperties.attachNewDataDiskOptions.diskSizeGiB]
   * Size of the disk to be attached in Gibibytes.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskName] The
   * name of the disk to be attached.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskType] The
   * storage type for the disk (i.e. Standard, Premium). Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {string} [dataDiskProperties.existingLabDiskId] Specifies the
   * existing lab disk id to attach to virtual machine.
   *
   * @param {string} [dataDiskProperties.hostCaching] Caching option for a data
   * disk (i.e. None, ReadOnly, ReadWrite). Possible values include: 'None',
   * 'ReadOnly', 'ReadWrite'
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  addDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._addDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._addDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, optionalCallback);
    }
  }

  /**
   * Apply artifacts to virtual machine. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} applyArtifactsRequest Request body for applying artifacts to
   * a virtual machine.
   *
   * @param {array} [applyArtifactsRequest.artifacts] The list of artifacts to
   * apply.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  applyArtifactsWithHttpOperationResponse(resourceGroupName, labName, name, applyArtifactsRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._applyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Apply artifacts to virtual machine. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} applyArtifactsRequest Request body for applying artifacts to
   * a virtual machine.
   *
   * @param {array} [applyArtifactsRequest.artifacts] The list of artifacts to
   * apply.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  applyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._applyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._applyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, optionalCallback);
    }
  }

  /**
   * Take ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  claimWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._claim(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Take ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  claim(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._claim(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._claim(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Detach the specified disk from the virtual machine. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} detachDataDiskProperties Request body for detaching data
   * disk from a virtual machine.
   *
   * @param {string} [detachDataDiskProperties.existingLabDiskId] Specifies the
   * disk resource ID to detach from virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  detachDataDiskWithHttpOperationResponse(resourceGroupName, labName, name, detachDataDiskProperties, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._detachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Detach the specified disk from the virtual machine. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} detachDataDiskProperties Request body for detaching data
   * disk from a virtual machine.
   *
   * @param {string} [detachDataDiskProperties.existingLabDiskId] Specifies the
   * disk resource ID to detach from virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  detachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._detachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._detachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, optionalCallback);
    }
  }

  /**
   * Gets a string that represents the contents of the RDP file for the virtual
   * machine
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<RdpConnection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getRdpFileContentsWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getRdpFileContents(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a string that represents the contents of the RDP file for the virtual
   * machine
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {RdpConnection} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link RdpConnection} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  getRdpFileContents(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._getRdpFileContents(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getRdpFileContents(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Lists the applicable start/stop schedules, if any.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ApplicableSchedule>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listApplicableSchedulesWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listApplicableSchedules(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists the applicable start/stop schedules, if any.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {ApplicableSchedule} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link ApplicableSchedule} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listApplicableSchedules(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listApplicableSchedules(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listApplicableSchedules(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Redeploy a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  redeployWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._redeploy(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Redeploy a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  redeploy(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._redeploy(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._redeploy(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Resize Virtual Machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} resizeLabVirtualMachineProperties Request body for resizing
   * a virtual machine.
   *
   * @param {string} [resizeLabVirtualMachineProperties.size] Specifies the size
   * of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  resizeWithHttpOperationResponse(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._resize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Resize Virtual Machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} resizeLabVirtualMachineProperties Request body for resizing
   * a virtual machine.
   *
   * @param {string} [resizeLabVirtualMachineProperties.size] Specifies the size
   * of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  resize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._resize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._resize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, optionalCallback);
    }
  }

  /**
   * Restart a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  restartWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._restart(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Restart a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  restart(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._restart(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._restart(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Start a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  startWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._start(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Start a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  start(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._start(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._start(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Stop a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  stopWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._stop(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Stop a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  stop(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._stop(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._stop(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Transfers all data disks attached to the virtual machine to be owned by the
   * current user. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  transferDisksWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._transferDisks(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Transfers all data disks attached to the virtual machine to be owned by the
   * current user. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  transferDisks(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._transferDisks(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._transferDisks(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Release ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  unClaimWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._unClaim(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Release ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  unClaim(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._unClaim(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._unClaim(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Create or replace an existing Virtual machine. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} labVirtualMachine A virtual machine.
   *
   * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
   * the owner of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
   * principal name of the virtual machine owner.
   *
   * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
   * the creator of the virtual machine.
   *
   * @param {string} [labVirtualMachine.createdByUser] The email address of
   * creator of the virtual machine.
   *
   * @param {date} [labVirtualMachine.createdDate] The creation date of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.computeId] The resource identifier
   * (Microsoft.Compute) of the virtual machine.
   *
   * @param {string} [labVirtualMachine.customImageId] The custom image
   * identifier of the virtual machine.
   *
   * @param {string} [labVirtualMachine.osType] The OS type of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.size] The size of the virtual machine.
   *
   * @param {string} [labVirtualMachine.userName] The user name of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.password] The password of the virtual
   * machine administrator.
   *
   * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
   * machine administrator.
   *
   * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
   * whether this virtual machine uses an SSH key for authentication.
   *
   * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
   * the virtual machine.
   *
   * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
   * network identifier of the virtual machine.
   *
   * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
   * whether the virtual machine is to be created without a public IP address.
   *
   * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
   * on the virtual machine.
   *
   * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
   * deployment status for the virtual machine.
   *
   * @param {string}
   * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
   * status of the artifact.
   *
   * @param {number}
   * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
   * count of the artifacts that were successfully applied.
   *
   * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
   * The total count of the artifacts that were tentatively applied.
   *
   * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
   * Azure Marketplace image reference of the virtual machine.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
   * the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
   * publisher of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
   * gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
   * of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.version] The
   * version of the gallery image.
   *
   * @param {string} [labVirtualMachine.planId] The id of the plan associated
   * with the virtual machine image
   *
   * @param {object} [labVirtualMachine.networkInterface] The network interface
   * properties.
   *
   * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
   * resource ID of the virtual network.
   *
   * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
   * ID of the sub net.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
   * resource ID of the public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
   * public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
   * private IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
   *
   * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
   * RdpAuthority property is a server DNS host name or IP address followed by
   * the service port number for RDP (Remote Desktop Protocol).
   *
   * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
   * SshAuthority property is a server DNS host name or IP address followed by
   * the service port number for SSH.
   *
   * @param {object}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
   * configuration for sharing a public IP address across multiple virtual
   * machines.
   *
   * @param {array}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
   * The incoming NAT rules
   *
   * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
   *
   * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
   * user can take ownership of the virtual machine
   *
   * @param {string} [labVirtualMachine.storageType] Storage type to use for
   * virtual machine (i.e. Standard, Premium).
   *
   * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
   * source of creation of lab virtual machine. Output property only. Possible
   * values include: 'FromCustomImage', 'FromGalleryImage'
   *
   * @param {string} [labVirtualMachine.environmentId] The resource ID of the
   * environment that contains this virtual machine, if any.
   *
   * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
   * disks to attach to the virtual machine after creation
   *
   * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
   * schedules to be created
   *
   * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
   * power state captured in DTL
   *
   * @param {string} [labVirtualMachine.location] The location of the resource.
   *
   * @param {object} [labVirtualMachine.tags] The tags of the resource.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<LabVirtualMachine>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, labName, name, labVirtualMachine, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Create or replace an existing Virtual machine. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} labVirtualMachine A virtual machine.
   *
   * @param {string} [labVirtualMachine.notes] The notes of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerObjectId] The object identifier of
   * the owner of the virtual machine.
   *
   * @param {string} [labVirtualMachine.ownerUserPrincipalName] The user
   * principal name of the virtual machine owner.
   *
   * @param {string} [labVirtualMachine.createdByUserId] The object identifier of
   * the creator of the virtual machine.
   *
   * @param {string} [labVirtualMachine.createdByUser] The email address of
   * creator of the virtual machine.
   *
   * @param {date} [labVirtualMachine.createdDate] The creation date of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.computeId] The resource identifier
   * (Microsoft.Compute) of the virtual machine.
   *
   * @param {string} [labVirtualMachine.customImageId] The custom image
   * identifier of the virtual machine.
   *
   * @param {string} [labVirtualMachine.osType] The OS type of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.size] The size of the virtual machine.
   *
   * @param {string} [labVirtualMachine.userName] The user name of the virtual
   * machine.
   *
   * @param {string} [labVirtualMachine.password] The password of the virtual
   * machine administrator.
   *
   * @param {string} [labVirtualMachine.sshKey] The SSH key of the virtual
   * machine administrator.
   *
   * @param {boolean} [labVirtualMachine.isAuthenticationWithSshKey] Indicates
   * whether this virtual machine uses an SSH key for authentication.
   *
   * @param {string} [labVirtualMachine.fqdn] The fully-qualified domain name of
   * the virtual machine.
   *
   * @param {string} [labVirtualMachine.labSubnetName] The lab subnet name of the
   * virtual machine.
   *
   * @param {string} [labVirtualMachine.labVirtualNetworkId] The lab virtual
   * network identifier of the virtual machine.
   *
   * @param {boolean} [labVirtualMachine.disallowPublicIpAddress] Indicates
   * whether the virtual machine is to be created without a public IP address.
   *
   * @param {array} [labVirtualMachine.artifacts] The artifacts to be installed
   * on the virtual machine.
   *
   * @param {object} [labVirtualMachine.artifactDeploymentStatus] The artifact
   * deployment status for the virtual machine.
   *
   * @param {string}
   * [labVirtualMachine.artifactDeploymentStatus.deploymentStatus] The deployment
   * status of the artifact.
   *
   * @param {number}
   * [labVirtualMachine.artifactDeploymentStatus.artifactsApplied] The total
   * count of the artifacts that were successfully applied.
   *
   * @param {number} [labVirtualMachine.artifactDeploymentStatus.totalArtifacts]
   * The total count of the artifacts that were tentatively applied.
   *
   * @param {object} [labVirtualMachine.galleryImageReference] The Microsoft
   * Azure Marketplace image reference of the virtual machine.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.offer] The offer of
   * the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.publisher] The
   * publisher of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.sku] The SKU of the
   * gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.osType] The OS type
   * of the gallery image.
   *
   * @param {string} [labVirtualMachine.galleryImageReference.version] The
   * version of the gallery image.
   *
   * @param {string} [labVirtualMachine.planId] The id of the plan associated
   * with the virtual machine image
   *
   * @param {object} [labVirtualMachine.networkInterface] The network interface
   * properties.
   *
   * @param {string} [labVirtualMachine.networkInterface.virtualNetworkId] The
   * resource ID of the virtual network.
   *
   * @param {string} [labVirtualMachine.networkInterface.subnetId] The resource
   * ID of the sub net.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddressId] The
   * resource ID of the public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.publicIpAddress] The
   * public IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.privateIpAddress] The
   * private IP address.
   *
   * @param {string} [labVirtualMachine.networkInterface.dnsName] The DNS name.
   *
   * @param {string} [labVirtualMachine.networkInterface.rdpAuthority] The
   * RdpAuthority property is a server DNS host name or IP address followed by
   * the service port number for RDP (Remote Desktop Protocol).
   *
   * @param {string} [labVirtualMachine.networkInterface.sshAuthority] The
   * SshAuthority property is a server DNS host name or IP address followed by
   * the service port number for SSH.
   *
   * @param {object}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration] The
   * configuration for sharing a public IP address across multiple virtual
   * machines.
   *
   * @param {array}
   * [labVirtualMachine.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
   * The incoming NAT rules
   *
   * @param {date} [labVirtualMachine.expirationDate] The expiration date for VM.
   *
   * @param {boolean} [labVirtualMachine.allowClaim] Indicates whether another
   * user can take ownership of the virtual machine
   *
   * @param {string} [labVirtualMachine.storageType] Storage type to use for
   * virtual machine (i.e. Standard, Premium).
   *
   * @param {string} [labVirtualMachine.virtualMachineCreationSource] Tells
   * source of creation of lab virtual machine. Output property only. Possible
   * values include: 'FromCustomImage', 'FromGalleryImage'
   *
   * @param {string} [labVirtualMachine.environmentId] The resource ID of the
   * environment that contains this virtual machine, if any.
   *
   * @param {array} [labVirtualMachine.dataDiskParameters] New or existing data
   * disks to attach to the virtual machine after creation
   *
   * @param {array} [labVirtualMachine.scheduleParameters] Virtual Machine
   * schedules to be created
   *
   * @param {string} [labVirtualMachine.lastKnownPowerState] Last known compute
   * power state captured in DTL
   *
   * @param {string} [labVirtualMachine.location] The location of the resource.
   *
   * @param {object} [labVirtualMachine.tags] The tags of the resource.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {LabVirtualMachine} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link LabVirtualMachine} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginCreateOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginCreateOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdate(resourceGroupName, labName, name, labVirtualMachine, options, optionalCallback);
    }
  }

  /**
   * Delete virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Delete virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Attach a new or existing data disk to virtual machine. This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} dataDiskProperties Request body for adding a new or existing
   * data disk to a virtual machine.
   *
   * @param {object} [dataDiskProperties.attachNewDataDiskOptions] Specifies
   * options to attach a new disk to the virtual machine.
   *
   * @param {number} [dataDiskProperties.attachNewDataDiskOptions.diskSizeGiB]
   * Size of the disk to be attached in Gibibytes.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskName] The
   * name of the disk to be attached.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskType] The
   * storage type for the disk (i.e. Standard, Premium). Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {string} [dataDiskProperties.existingLabDiskId] Specifies the
   * existing lab disk id to attach to virtual machine.
   *
   * @param {string} [dataDiskProperties.hostCaching] Caching option for a data
   * disk (i.e. None, ReadOnly, ReadWrite). Possible values include: 'None',
   * 'ReadOnly', 'ReadWrite'
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginAddDataDiskWithHttpOperationResponse(resourceGroupName, labName, name, dataDiskProperties, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginAddDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Attach a new or existing data disk to virtual machine. This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} dataDiskProperties Request body for adding a new or existing
   * data disk to a virtual machine.
   *
   * @param {object} [dataDiskProperties.attachNewDataDiskOptions] Specifies
   * options to attach a new disk to the virtual machine.
   *
   * @param {number} [dataDiskProperties.attachNewDataDiskOptions.diskSizeGiB]
   * Size of the disk to be attached in Gibibytes.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskName] The
   * name of the disk to be attached.
   *
   * @param {string} [dataDiskProperties.attachNewDataDiskOptions.diskType] The
   * storage type for the disk (i.e. Standard, Premium). Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {string} [dataDiskProperties.existingLabDiskId] Specifies the
   * existing lab disk id to attach to virtual machine.
   *
   * @param {string} [dataDiskProperties.hostCaching] Caching option for a data
   * disk (i.e. None, ReadOnly, ReadWrite). Possible values include: 'None',
   * 'ReadOnly', 'ReadWrite'
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginAddDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginAddDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginAddDataDisk(resourceGroupName, labName, name, dataDiskProperties, options, optionalCallback);
    }
  }

  /**
   * Apply artifacts to virtual machine. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} applyArtifactsRequest Request body for applying artifacts to
   * a virtual machine.
   *
   * @param {array} [applyArtifactsRequest.artifacts] The list of artifacts to
   * apply.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginApplyArtifactsWithHttpOperationResponse(resourceGroupName, labName, name, applyArtifactsRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginApplyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Apply artifacts to virtual machine. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} applyArtifactsRequest Request body for applying artifacts to
   * a virtual machine.
   *
   * @param {array} [applyArtifactsRequest.artifacts] The list of artifacts to
   * apply.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginApplyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginApplyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginApplyArtifacts(resourceGroupName, labName, name, applyArtifactsRequest, options, optionalCallback);
    }
  }

  /**
   * Take ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginClaimWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginClaim(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Take ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginClaim(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginClaim(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginClaim(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Detach the specified disk from the virtual machine. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} detachDataDiskProperties Request body for detaching data
   * disk from a virtual machine.
   *
   * @param {string} [detachDataDiskProperties.existingLabDiskId] Specifies the
   * disk resource ID to detach from virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDetachDataDiskWithHttpOperationResponse(resourceGroupName, labName, name, detachDataDiskProperties, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDetachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Detach the specified disk from the virtual machine. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} detachDataDiskProperties Request body for detaching data
   * disk from a virtual machine.
   *
   * @param {string} [detachDataDiskProperties.existingLabDiskId] Specifies the
   * disk resource ID to detach from virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDetachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginDetachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDetachDataDisk(resourceGroupName, labName, name, detachDataDiskProperties, options, optionalCallback);
    }
  }

  /**
   * Redeploy a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginRedeployWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginRedeploy(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Redeploy a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginRedeploy(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginRedeploy(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginRedeploy(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Resize Virtual Machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} resizeLabVirtualMachineProperties Request body for resizing
   * a virtual machine.
   *
   * @param {string} [resizeLabVirtualMachineProperties.size] Specifies the size
   * of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginResizeWithHttpOperationResponse(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginResize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Resize Virtual Machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} resizeLabVirtualMachineProperties Request body for resizing
   * a virtual machine.
   *
   * @param {string} [resizeLabVirtualMachineProperties.size] Specifies the size
   * of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginResize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginResize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginResize(resourceGroupName, labName, name, resizeLabVirtualMachineProperties, options, optionalCallback);
    }
  }

  /**
   * Restart a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginRestartWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginRestart(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Restart a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginRestart(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginRestart(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginRestart(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Start a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginStartWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginStart(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Start a virtual machine. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginStart(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginStart(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginStart(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Stop a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginStopWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginStop(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Stop a virtual machine This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginStop(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginStop(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginStop(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Transfers all data disks attached to the virtual machine to be owned by the
   * current user. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginTransferDisksWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginTransferDisks(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Transfers all data disks attached to the virtual machine to be owned by the
   * current user. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginTransferDisks(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginTransferDisks(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginTransferDisks(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * Release ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUnClaimWithHttpOperationResponse(resourceGroupName, labName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUnClaim(resourceGroupName, labName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Release ownership of an existing virtual machine This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} name The name of the virtual machine.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginUnClaim(resourceGroupName, labName, name, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginUnClaim(resourceGroupName, labName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUnClaim(resourceGroupName, labName, name, options, optionalCallback);
    }
  }

  /**
   * List virtual machines in a given lab.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<LabVirtualMachineList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List virtual machines in a given lab.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {LabVirtualMachineList} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link LabVirtualMachineList} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = VirtualMachines;
