/*
 * 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 labs in a subscription.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] Specify the $expand query. Example:
 * 'properties($select=defaultStorageAccount)'
 *
 * @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 LabList} 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 _listBySubscription(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 (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}/providers/Microsoft.DevTestLab/labs';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  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['LabList']().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);
  });
}

/**
 * List labs in a resource group.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] Specify the $expand query. Example:
 * 'properties($select=defaultStorageAccount)'
 *
 * @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 LabList} 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 _listByResourceGroup(resourceGroupName, 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 (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';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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['LabList']().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 lab.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] Specify the $expand query. Example:
 * 'properties($select=defaultStorageAccount)'
 *
 * @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 Lab} 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, 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 (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/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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['Lab']().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 lab. This operation can take a while to
 * complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} lab A lab.
 *
 * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
 * be either Premium or Standard. Default is Premium. Possible values include:
 * 'Standard', 'Premium'
 *
 * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
 * artifact resource IDs that should be applied on all Linux VM creations by
 * default, prior to the artifacts specified by the user.
 *
 * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
 * of artifact resource IDs that should be applied on all Windows VM creations
 * by default, prior to the artifacts specified by the user.
 *
 * @param {string} [lab.premiumDataDisks] The setting to enable usage of
 * premium data disks.
 * When its value is 'Enabled', creation of standard or premium data disks is
 * allowed.
 * When its value is 'Disabled', only creation of standard data disks is
 * allowed. Possible values include: 'Disabled', 'Enabled'
 *
 * @param {string} [lab.environmentPermission] The access rights to be granted
 * to the user when provisioning an environment. Possible values include:
 * 'Reader', 'Contributor'
 *
 * @param {object} [lab.announcement] The properties of any lab announcement
 * associated with this lab
 *
 * @param {string} [lab.announcement.title] The plain text title for the lab
 * announcement
 *
 * @param {string} [lab.announcement.markdown] The markdown text (if any) that
 * this lab displays in the UI. If left empty/null, nothing will be shown.
 *
 * @param {string} [lab.announcement.enabled] Is the lab announcement
 * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {date} [lab.announcement.expirationDate] The time at which the
 * announcement expires (null for never)
 *
 * @param {boolean} [lab.announcement.expired] Has this announcement expired?
 *
 * @param {object} [lab.support] The properties of any lab support message
 * associated with this lab
 *
 * @param {string} [lab.support.enabled] Is the lab support banner
 * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {string} [lab.support.markdown] The markdown text (if any) that this
 * lab displays in the UI. If left empty/null, nothing will be shown.
 *
 * @param {object} [lab.extendedProperties] Extended properties of the lab used
 * for experimental features
 *
 * @param {string} [lab.location] The location of the resource.
 *
 * @param {object} [lab.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 Lab} 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, name, lab, 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, name, lab, 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['Lab']().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 lab. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @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, 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, 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 labs.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} lab A lab.
 *
 * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
 * be either Premium or Standard. Default is Premium. Possible values include:
 * 'Standard', 'Premium'
 *
 * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
 * artifact resource IDs that should be applied on all Linux VM creations by
 * default, prior to the artifacts specified by the user.
 *
 * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
 * of artifact resource IDs that should be applied on all Windows VM creations
 * by default, prior to the artifacts specified by the user.
 *
 * @param {string} [lab.premiumDataDisks] The setting to enable usage of
 * premium data disks.
 * When its value is 'Enabled', creation of standard or premium data disks is
 * allowed.
 * When its value is 'Disabled', only creation of standard data disks is
 * allowed. Possible values include: 'Disabled', 'Enabled'
 *
 * @param {string} [lab.environmentPermission] The access rights to be granted
 * to the user when provisioning an environment. Possible values include:
 * 'Reader', 'Contributor'
 *
 * @param {object} [lab.announcement] The properties of any lab announcement
 * associated with this lab
 *
 * @param {string} [lab.announcement.title] The plain text title for the lab
 * announcement
 *
 * @param {string} [lab.announcement.markdown] The markdown text (if any) that
 * this lab displays in the UI. If left empty/null, nothing will be shown.
 *
 * @param {string} [lab.announcement.enabled] Is the lab announcement
 * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {date} [lab.announcement.expirationDate] The time at which the
 * announcement expires (null for never)
 *
 * @param {boolean} [lab.announcement.expired] Has this announcement expired?
 *
 * @param {object} [lab.support] The properties of any lab support message
 * associated with this lab
 *
 * @param {string} [lab.support.enabled] Is the lab support banner
 * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {string} [lab.support.markdown] The markdown text (if any) that this
 * lab displays in the UI. If left empty/null, nothing will be shown.
 *
 * @param {object} [lab.extendedProperties] Extended properties of the lab used
 * for experimental features
 *
 * @param {object} [lab.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 Lab} 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, name, lab, 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 (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 (lab === null || lab === undefined) {
      throw new Error('lab 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/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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 (lab !== null && lab !== undefined) {
      let requestModelMapper = new client.models['LabFragment']().mapper();
      requestModel = client.serialize(requestModelMapper, lab, 'lab');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(lab, 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['Lab']().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);
  });
}


/**
 * Claim a random claimable virtual machine in the lab. This operation can take
 * a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @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 _claimAnyVm(resourceGroupName, 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.beginClaimAnyVm(resourceGroupName, 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 virtual machines in a lab. This operation can take a while to
 * complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} labVirtualMachineCreationParameter Properties for creating a
 * virtual machine.
 *
 * @param {object} [labVirtualMachineCreationParameter.bulkCreationParameters]
 * The number of virtual machine instances to create.
 *
 * @param {number}
 * [labVirtualMachineCreationParameter.bulkCreationParameters.instanceCount]
 * The number of virtual machine instances to create.
 *
 * @param {string} [labVirtualMachineCreationParameter.notes] The notes of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.ownerObjectId] The
 * object identifier of the owner of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.ownerUserPrincipalName]
 * The user principal name of the virtual machine owner.
 *
 * @param {string} [labVirtualMachineCreationParameter.createdByUserId] The
 * object identifier of the creator of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.createdByUser] The email
 * address of creator of the virtual machine.
 *
 * @param {date} [labVirtualMachineCreationParameter.createdDate] The creation
 * date of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.computeId] The resource
 * identifier (Microsoft.Compute) of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.customImageId] The
 * custom image identifier of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.osType] The OS type of
 * the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.size] The size of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.userName] The user name
 * of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.password] The password
 * of the virtual machine administrator.
 *
 * @param {string} [labVirtualMachineCreationParameter.sshKey] The SSH key of
 * the virtual machine administrator.
 *
 * @param {boolean}
 * [labVirtualMachineCreationParameter.isAuthenticationWithSshKey] Indicates
 * whether this virtual machine uses an SSH key for authentication.
 *
 * @param {string} [labVirtualMachineCreationParameter.fqdn] The
 * fully-qualified domain name of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.labSubnetName] The lab
 * subnet name of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.labVirtualNetworkId] The
 * lab virtual network identifier of the virtual machine.
 *
 * @param {boolean}
 * [labVirtualMachineCreationParameter.disallowPublicIpAddress] Indicates
 * whether the virtual machine is to be created without a public IP address.
 *
 * @param {array} [labVirtualMachineCreationParameter.artifacts] The artifacts
 * to be installed on the virtual machine.
 *
 * @param {object}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus] The artifact
 * deployment status for the virtual machine.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus.deploymentStatus]
 * The deployment status of the artifact.
 *
 * @param {number}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus.artifactsApplied]
 * The total count of the artifacts that were successfully applied.
 *
 * @param {number}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus.totalArtifacts]
 * The total count of the artifacts that were tentatively applied.
 *
 * @param {object} [labVirtualMachineCreationParameter.galleryImageReference]
 * The Microsoft Azure Marketplace image reference of the virtual machine.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.offer] The offer
 * of the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.publisher] The
 * publisher of the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.sku] The SKU of
 * the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.osType] The OS
 * type of the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.version] The
 * version of the gallery image.
 *
 * @param {string} [labVirtualMachineCreationParameter.planId] The id of the
 * plan associated with the virtual machine image
 *
 * @param {object} [labVirtualMachineCreationParameter.networkInterface] The
 * network interface properties.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.virtualNetworkId] The
 * resource ID of the virtual network.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.subnetId] The resource
 * ID of the sub net.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.publicIpAddressId] The
 * resource ID of the public IP address.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.publicIpAddress] The
 * public IP address.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.privateIpAddress] The
 * private IP address.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.dnsName] The DNS name.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.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}
 * [labVirtualMachineCreationParameter.networkInterface.sshAuthority] The
 * SshAuthority property is a server DNS host name or IP address followed by
 * the service port number for SSH.
 *
 * @param {object}
 * [labVirtualMachineCreationParameter.networkInterface.sharedPublicIpAddressConfiguration]
 * The configuration for sharing a public IP address across multiple virtual
 * machines.
 *
 * @param {array}
 * [labVirtualMachineCreationParameter.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
 * The incoming NAT rules
 *
 * @param {date} [labVirtualMachineCreationParameter.expirationDate] The
 * expiration date for VM.
 *
 * @param {boolean} [labVirtualMachineCreationParameter.allowClaim] Indicates
 * whether another user can take ownership of the virtual machine
 *
 * @param {string} [labVirtualMachineCreationParameter.storageType] Storage
 * type to use for virtual machine (i.e. Standard, Premium).
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.virtualMachineCreationSource] Tells
 * source of creation of lab virtual machine. Output property only. Possible
 * values include: 'FromCustomImage', 'FromGalleryImage'
 *
 * @param {string} [labVirtualMachineCreationParameter.environmentId] The
 * resource ID of the environment that contains this virtual machine, if any.
 *
 * @param {array} [labVirtualMachineCreationParameter.dataDiskParameters] New
 * or existing data disks to attach to the virtual machine after creation
 *
 * @param {array} [labVirtualMachineCreationParameter.scheduleParameters]
 * Virtual Machine schedules to be created
 *
 * @param {string} [labVirtualMachineCreationParameter.lastKnownPowerState]
 * Last known compute power state captured in DTL
 *
 * @param {string} [labVirtualMachineCreationParameter.name] The name of the
 * virtual machine or environment
 *
 * @param {string} [labVirtualMachineCreationParameter.location] The location
 * of the new virtual machine or environment
 *
 * @param {object} [labVirtualMachineCreationParameter.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.
 *
 *                      {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 _createEnvironment(resourceGroupName, name, labVirtualMachineCreationParameter, 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.beginCreateEnvironment(resourceGroupName, name, labVirtualMachineCreationParameter, 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);
    });
  });
}


/**
 * Exports the lab resource usage into a storage account This operation can
 * take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} exportResourceUsageParameters The parameters of the export
 * operation.
 *
 * @param {string} [exportResourceUsageParameters.blobStorageAbsoluteSasUri]
 * The blob storage absolute sas uri with write permission to the container
 * which the usage data needs to be uploaded to.
 *
 * @param {date} [exportResourceUsageParameters.usageStartDate] The start time
 * of the usage. If not provided, usage will be reported since the beginning of
 * data collection.
 *
 * @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 _exportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, 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.beginExportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, 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);
    });
  });
}

/**
 * Generate a URI for uploading custom disk images to a Lab.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} generateUploadUriParameter Properties for generating an
 * upload URI.
 *
 * @param {string} [generateUploadUriParameter.blobName] The blob name of the
 * upload URI.
 *
 * @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 GenerateUploadUriResponse} 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 _generateUploadUri(resourceGroupName, name, generateUploadUriParameter, 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 (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 (generateUploadUriParameter === null || generateUploadUriParameter === undefined) {
      throw new Error('generateUploadUriParameter 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/{name}/generateUploadUri';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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 (generateUploadUriParameter !== null && generateUploadUriParameter !== undefined) {
      let requestModelMapper = new client.models['GenerateUploadUriParameter']().mapper();
      requestModel = client.serialize(requestModelMapper, generateUploadUriParameter, 'generateUploadUriParameter');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(generateUploadUriParameter, 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['GenerateUploadUriResponse']().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);
  });
}


/**
 * Import a virtual machine into a different lab. This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} importLabVirtualMachineRequest This represents the payload
 * required to import a virtual machine from a different lab into the current
 * one
 *
 * @param {string}
 * [importLabVirtualMachineRequest.sourceVirtualMachineResourceId] The full
 * resource ID of the virtual machine to be imported.
 *
 * @param {string}
 * [importLabVirtualMachineRequest.destinationVirtualMachineName] The name of
 * the virtual machine in the destination lab
 *
 * @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 _importVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, 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.beginImportVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, 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);
    });
  });
}

/**
 * List disk images available for custom image creation.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @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 LabVhdList} 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 _listVhds(resourceGroupName, 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 (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/{name}/listVhds';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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['LabVhdList']().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 lab. This operation can take a while to
 * complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} lab A lab.
 *
 * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
 * be either Premium or Standard. Default is Premium. Possible values include:
 * 'Standard', 'Premium'
 *
 * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
 * artifact resource IDs that should be applied on all Linux VM creations by
 * default, prior to the artifacts specified by the user.
 *
 * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
 * of artifact resource IDs that should be applied on all Windows VM creations
 * by default, prior to the artifacts specified by the user.
 *
 * @param {string} [lab.premiumDataDisks] The setting to enable usage of
 * premium data disks.
 * When its value is 'Enabled', creation of standard or premium data disks is
 * allowed.
 * When its value is 'Disabled', only creation of standard data disks is
 * allowed. Possible values include: 'Disabled', 'Enabled'
 *
 * @param {string} [lab.environmentPermission] The access rights to be granted
 * to the user when provisioning an environment. Possible values include:
 * 'Reader', 'Contributor'
 *
 * @param {object} [lab.announcement] The properties of any lab announcement
 * associated with this lab
 *
 * @param {string} [lab.announcement.title] The plain text title for the lab
 * announcement
 *
 * @param {string} [lab.announcement.markdown] The markdown text (if any) that
 * this lab displays in the UI. If left empty/null, nothing will be shown.
 *
 * @param {string} [lab.announcement.enabled] Is the lab announcement
 * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {date} [lab.announcement.expirationDate] The time at which the
 * announcement expires (null for never)
 *
 * @param {boolean} [lab.announcement.expired] Has this announcement expired?
 *
 * @param {object} [lab.support] The properties of any lab support message
 * associated with this lab
 *
 * @param {string} [lab.support.enabled] Is the lab support banner
 * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {string} [lab.support.markdown] The markdown text (if any) that this
 * lab displays in the UI. If left empty/null, nothing will be shown.
 *
 * @param {object} [lab.extendedProperties] Extended properties of the lab used
 * for experimental features
 *
 * @param {string} [lab.location] The location of the resource.
 *
 * @param {object} [lab.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 Lab} 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, name, lab, 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 (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 (lab === null || lab === undefined) {
      throw new Error('lab 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/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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 (lab !== null && lab !== undefined) {
      let requestModelMapper = new client.models['Lab']().mapper();
      requestModel = client.serialize(requestModelMapper, lab, 'lab');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(lab, 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['Lab']().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['Lab']().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 lab. This operation can take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @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, 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 (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/{name}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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);
  });
}

/**
 * Claim a random claimable virtual machine in the lab. This operation can take
 * a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @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 _beginClaimAnyVm(resourceGroupName, 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 (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/{name}/claimAnyVm';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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);
  });
}

/**
 * Create virtual machines in a lab. This operation can take a while to
 * complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} labVirtualMachineCreationParameter Properties for creating a
 * virtual machine.
 *
 * @param {object} [labVirtualMachineCreationParameter.bulkCreationParameters]
 * The number of virtual machine instances to create.
 *
 * @param {number}
 * [labVirtualMachineCreationParameter.bulkCreationParameters.instanceCount]
 * The number of virtual machine instances to create.
 *
 * @param {string} [labVirtualMachineCreationParameter.notes] The notes of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.ownerObjectId] The
 * object identifier of the owner of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.ownerUserPrincipalName]
 * The user principal name of the virtual machine owner.
 *
 * @param {string} [labVirtualMachineCreationParameter.createdByUserId] The
 * object identifier of the creator of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.createdByUser] The email
 * address of creator of the virtual machine.
 *
 * @param {date} [labVirtualMachineCreationParameter.createdDate] The creation
 * date of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.computeId] The resource
 * identifier (Microsoft.Compute) of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.customImageId] The
 * custom image identifier of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.osType] The OS type of
 * the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.size] The size of the
 * virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.userName] The user name
 * of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.password] The password
 * of the virtual machine administrator.
 *
 * @param {string} [labVirtualMachineCreationParameter.sshKey] The SSH key of
 * the virtual machine administrator.
 *
 * @param {boolean}
 * [labVirtualMachineCreationParameter.isAuthenticationWithSshKey] Indicates
 * whether this virtual machine uses an SSH key for authentication.
 *
 * @param {string} [labVirtualMachineCreationParameter.fqdn] The
 * fully-qualified domain name of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.labSubnetName] The lab
 * subnet name of the virtual machine.
 *
 * @param {string} [labVirtualMachineCreationParameter.labVirtualNetworkId] The
 * lab virtual network identifier of the virtual machine.
 *
 * @param {boolean}
 * [labVirtualMachineCreationParameter.disallowPublicIpAddress] Indicates
 * whether the virtual machine is to be created without a public IP address.
 *
 * @param {array} [labVirtualMachineCreationParameter.artifacts] The artifacts
 * to be installed on the virtual machine.
 *
 * @param {object}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus] The artifact
 * deployment status for the virtual machine.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus.deploymentStatus]
 * The deployment status of the artifact.
 *
 * @param {number}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus.artifactsApplied]
 * The total count of the artifacts that were successfully applied.
 *
 * @param {number}
 * [labVirtualMachineCreationParameter.artifactDeploymentStatus.totalArtifacts]
 * The total count of the artifacts that were tentatively applied.
 *
 * @param {object} [labVirtualMachineCreationParameter.galleryImageReference]
 * The Microsoft Azure Marketplace image reference of the virtual machine.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.offer] The offer
 * of the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.publisher] The
 * publisher of the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.sku] The SKU of
 * the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.osType] The OS
 * type of the gallery image.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.galleryImageReference.version] The
 * version of the gallery image.
 *
 * @param {string} [labVirtualMachineCreationParameter.planId] The id of the
 * plan associated with the virtual machine image
 *
 * @param {object} [labVirtualMachineCreationParameter.networkInterface] The
 * network interface properties.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.virtualNetworkId] The
 * resource ID of the virtual network.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.subnetId] The resource
 * ID of the sub net.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.publicIpAddressId] The
 * resource ID of the public IP address.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.publicIpAddress] The
 * public IP address.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.privateIpAddress] The
 * private IP address.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.networkInterface.dnsName] The DNS name.
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.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}
 * [labVirtualMachineCreationParameter.networkInterface.sshAuthority] The
 * SshAuthority property is a server DNS host name or IP address followed by
 * the service port number for SSH.
 *
 * @param {object}
 * [labVirtualMachineCreationParameter.networkInterface.sharedPublicIpAddressConfiguration]
 * The configuration for sharing a public IP address across multiple virtual
 * machines.
 *
 * @param {array}
 * [labVirtualMachineCreationParameter.networkInterface.sharedPublicIpAddressConfiguration.inboundNatRules]
 * The incoming NAT rules
 *
 * @param {date} [labVirtualMachineCreationParameter.expirationDate] The
 * expiration date for VM.
 *
 * @param {boolean} [labVirtualMachineCreationParameter.allowClaim] Indicates
 * whether another user can take ownership of the virtual machine
 *
 * @param {string} [labVirtualMachineCreationParameter.storageType] Storage
 * type to use for virtual machine (i.e. Standard, Premium).
 *
 * @param {string}
 * [labVirtualMachineCreationParameter.virtualMachineCreationSource] Tells
 * source of creation of lab virtual machine. Output property only. Possible
 * values include: 'FromCustomImage', 'FromGalleryImage'
 *
 * @param {string} [labVirtualMachineCreationParameter.environmentId] The
 * resource ID of the environment that contains this virtual machine, if any.
 *
 * @param {array} [labVirtualMachineCreationParameter.dataDiskParameters] New
 * or existing data disks to attach to the virtual machine after creation
 *
 * @param {array} [labVirtualMachineCreationParameter.scheduleParameters]
 * Virtual Machine schedules to be created
 *
 * @param {string} [labVirtualMachineCreationParameter.lastKnownPowerState]
 * Last known compute power state captured in DTL
 *
 * @param {string} [labVirtualMachineCreationParameter.name] The name of the
 * virtual machine or environment
 *
 * @param {string} [labVirtualMachineCreationParameter.location] The location
 * of the new virtual machine or environment
 *
 * @param {object} [labVirtualMachineCreationParameter.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.
 *
 *                      {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 _beginCreateEnvironment(resourceGroupName, name, labVirtualMachineCreationParameter, 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 (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 (labVirtualMachineCreationParameter === null || labVirtualMachineCreationParameter === undefined) {
      throw new Error('labVirtualMachineCreationParameter 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/{name}/createEnvironment';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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 (labVirtualMachineCreationParameter !== null && labVirtualMachineCreationParameter !== undefined) {
      let requestModelMapper = new client.models['LabVirtualMachineCreationParameter']().mapper();
      requestModel = client.serialize(requestModelMapper, labVirtualMachineCreationParameter, 'labVirtualMachineCreationParameter');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(labVirtualMachineCreationParameter, 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);
  });
}

/**
 * Exports the lab resource usage into a storage account This operation can
 * take a while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} exportResourceUsageParameters The parameters of the export
 * operation.
 *
 * @param {string} [exportResourceUsageParameters.blobStorageAbsoluteSasUri]
 * The blob storage absolute sas uri with write permission to the container
 * which the usage data needs to be uploaded to.
 *
 * @param {date} [exportResourceUsageParameters.usageStartDate] The start time
 * of the usage. If not provided, usage will be reported since the beginning of
 * data collection.
 *
 * @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 _beginExportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, 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 (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 (exportResourceUsageParameters === null || exportResourceUsageParameters === undefined) {
      throw new Error('exportResourceUsageParameters 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/{name}/exportResourceUsage';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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 (exportResourceUsageParameters !== null && exportResourceUsageParameters !== undefined) {
      let requestModelMapper = new client.models['ExportResourceUsageParameters']().mapper();
      requestModel = client.serialize(requestModelMapper, exportResourceUsageParameters, 'exportResourceUsageParameters');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(exportResourceUsageParameters, 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);
  });
}

/**
 * Import a virtual machine into a different lab. This operation can take a
 * while to complete.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} name The name of the lab.
 *
 * @param {object} importLabVirtualMachineRequest This represents the payload
 * required to import a virtual machine from a different lab into the current
 * one
 *
 * @param {string}
 * [importLabVirtualMachineRequest.sourceVirtualMachineResourceId] The full
 * resource ID of the virtual machine to be imported.
 *
 * @param {string}
 * [importLabVirtualMachineRequest.destinationVirtualMachineName] The name of
 * the virtual machine in the destination lab
 *
 * @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 _beginImportVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, 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 (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 (importLabVirtualMachineRequest === null || importLabVirtualMachineRequest === undefined) {
      throw new Error('importLabVirtualMachineRequest 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/{name}/importVirtualMachine';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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 (importLabVirtualMachineRequest !== null && importLabVirtualMachineRequest !== undefined) {
      let requestModelMapper = new client.models['ImportLabVirtualMachineRequest']().mapper();
      requestModel = client.serialize(requestModelMapper, importLabVirtualMachineRequest, 'importLabVirtualMachineRequest');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(importLabVirtualMachineRequest, 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);
  });
}

/**
 * List labs in a subscription.
 *
 * @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 LabList} 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 _listBySubscriptionNext(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['LabList']().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);
  });
}

/**
 * List labs in a resource group.
 *
 * @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 LabList} 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 _listByResourceGroupNext(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['LabList']().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);
  });
}

/**
 * List disk images available for custom image creation.
 *
 * @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 LabVhdList} 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 _listVhdsNext(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 = '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['LabVhdList']().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 Labs. */
class Labs {
  /**
   * Create a Labs.
   * @param {DevTestLabsClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listBySubscription = _listBySubscription;
    this._listByResourceGroup = _listByResourceGroup;
    this._get = _get;
    this._createOrUpdate = _createOrUpdate;
    this._deleteMethod = _deleteMethod;
    this._update = _update;
    this._claimAnyVm = _claimAnyVm;
    this._createEnvironment = _createEnvironment;
    this._exportResourceUsage = _exportResourceUsage;
    this._generateUploadUri = _generateUploadUri;
    this._importVirtualMachine = _importVirtualMachine;
    this._listVhds = _listVhds;
    this._beginCreateOrUpdate = _beginCreateOrUpdate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginClaimAnyVm = _beginClaimAnyVm;
    this._beginCreateEnvironment = _beginCreateEnvironment;
    this._beginExportResourceUsage = _beginExportResourceUsage;
    this._beginImportVirtualMachine = _beginImportVirtualMachine;
    this._listBySubscriptionNext = _listBySubscriptionNext;
    this._listByResourceGroupNext = _listByResourceGroupNext;
    this._listVhdsNext = _listVhdsNext;
  }

  /**
   * List labs in a subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=defaultStorageAccount)'
   *
   * @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<LabList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listBySubscriptionWithHttpOperationResponse(options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listBySubscription(options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List labs in a subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=defaultStorageAccount)'
   *
   * @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 {LabList} - 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 LabList} 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.
   */
  listBySubscription(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._listBySubscription(options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listBySubscription(options, optionalCallback);
    }
  }

  /**
   * List labs in a resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=defaultStorageAccount)'
   *
   * @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<LabList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List labs in a resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=defaultStorageAccount)'
   *
   * @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 {LabList} - 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 LabList} 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.
   */
  listByResourceGroup(resourceGroupName, 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._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByResourceGroup(resourceGroupName, options, optionalCallback);
    }
  }

  /**
   * Get lab.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=defaultStorageAccount)'
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Lab>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, 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 lab.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=defaultStorageAccount)'
   *
   * @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 {Lab} - 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 Lab} 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, 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, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, name, options, optionalCallback);
    }
  }

  /**
   * Create or replace an existing lab. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} lab A lab.
   *
   * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
   * be either Premium or Standard. Default is Premium. Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
   * artifact resource IDs that should be applied on all Linux VM creations by
   * default, prior to the artifacts specified by the user.
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
   * of artifact resource IDs that should be applied on all Windows VM creations
   * by default, prior to the artifacts specified by the user.
   *
   * @param {string} [lab.premiumDataDisks] The setting to enable usage of
   * premium data disks.
   * When its value is 'Enabled', creation of standard or premium data disks is
   * allowed.
   * When its value is 'Disabled', only creation of standard data disks is
   * allowed. Possible values include: 'Disabled', 'Enabled'
   *
   * @param {string} [lab.environmentPermission] The access rights to be granted
   * to the user when provisioning an environment. Possible values include:
   * 'Reader', 'Contributor'
   *
   * @param {object} [lab.announcement] The properties of any lab announcement
   * associated with this lab
   *
   * @param {string} [lab.announcement.title] The plain text title for the lab
   * announcement
   *
   * @param {string} [lab.announcement.markdown] The markdown text (if any) that
   * this lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {string} [lab.announcement.enabled] Is the lab announcement
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {date} [lab.announcement.expirationDate] The time at which the
   * announcement expires (null for never)
   *
   * @param {boolean} [lab.announcement.expired] Has this announcement expired?
   *
   * @param {object} [lab.support] The properties of any lab support message
   * associated with this lab
   *
   * @param {string} [lab.support.enabled] Is the lab support banner
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [lab.support.markdown] The markdown text (if any) that this
   * lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {object} [lab.extendedProperties] Extended properties of the lab used
   * for experimental features
   *
   * @param {string} [lab.location] The location of the resource.
   *
   * @param {object} [lab.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<Lab>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, name, lab, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(resourceGroupName, name, lab, 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 lab. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} lab A lab.
   *
   * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
   * be either Premium or Standard. Default is Premium. Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
   * artifact resource IDs that should be applied on all Linux VM creations by
   * default, prior to the artifacts specified by the user.
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
   * of artifact resource IDs that should be applied on all Windows VM creations
   * by default, prior to the artifacts specified by the user.
   *
   * @param {string} [lab.premiumDataDisks] The setting to enable usage of
   * premium data disks.
   * When its value is 'Enabled', creation of standard or premium data disks is
   * allowed.
   * When its value is 'Disabled', only creation of standard data disks is
   * allowed. Possible values include: 'Disabled', 'Enabled'
   *
   * @param {string} [lab.environmentPermission] The access rights to be granted
   * to the user when provisioning an environment. Possible values include:
   * 'Reader', 'Contributor'
   *
   * @param {object} [lab.announcement] The properties of any lab announcement
   * associated with this lab
   *
   * @param {string} [lab.announcement.title] The plain text title for the lab
   * announcement
   *
   * @param {string} [lab.announcement.markdown] The markdown text (if any) that
   * this lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {string} [lab.announcement.enabled] Is the lab announcement
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {date} [lab.announcement.expirationDate] The time at which the
   * announcement expires (null for never)
   *
   * @param {boolean} [lab.announcement.expired] Has this announcement expired?
   *
   * @param {object} [lab.support] The properties of any lab support message
   * associated with this lab
   *
   * @param {string} [lab.support.enabled] Is the lab support banner
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [lab.support.markdown] The markdown text (if any) that this
   * lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {object} [lab.extendedProperties] Extended properties of the lab used
   * for experimental features
   *
   * @param {string} [lab.location] The location of the resource.
   *
   * @param {object} [lab.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 {Lab} - 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 Lab} 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, name, lab, 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, name, lab, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, name, lab, options, optionalCallback);
    }
  }

  /**
   * Delete lab. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, 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 lab. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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, 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, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, name, options, optionalCallback);
    }
  }

  /**
   * Modify properties of labs.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} lab A lab.
   *
   * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
   * be either Premium or Standard. Default is Premium. Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
   * artifact resource IDs that should be applied on all Linux VM creations by
   * default, prior to the artifacts specified by the user.
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
   * of artifact resource IDs that should be applied on all Windows VM creations
   * by default, prior to the artifacts specified by the user.
   *
   * @param {string} [lab.premiumDataDisks] The setting to enable usage of
   * premium data disks.
   * When its value is 'Enabled', creation of standard or premium data disks is
   * allowed.
   * When its value is 'Disabled', only creation of standard data disks is
   * allowed. Possible values include: 'Disabled', 'Enabled'
   *
   * @param {string} [lab.environmentPermission] The access rights to be granted
   * to the user when provisioning an environment. Possible values include:
   * 'Reader', 'Contributor'
   *
   * @param {object} [lab.announcement] The properties of any lab announcement
   * associated with this lab
   *
   * @param {string} [lab.announcement.title] The plain text title for the lab
   * announcement
   *
   * @param {string} [lab.announcement.markdown] The markdown text (if any) that
   * this lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {string} [lab.announcement.enabled] Is the lab announcement
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {date} [lab.announcement.expirationDate] The time at which the
   * announcement expires (null for never)
   *
   * @param {boolean} [lab.announcement.expired] Has this announcement expired?
   *
   * @param {object} [lab.support] The properties of any lab support message
   * associated with this lab
   *
   * @param {string} [lab.support.enabled] Is the lab support banner
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [lab.support.markdown] The markdown text (if any) that this
   * lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {object} [lab.extendedProperties] Extended properties of the lab used
   * for experimental features
   *
   * @param {object} [lab.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<Lab>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, name, lab, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, name, lab, 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 labs.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} lab A lab.
   *
   * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
   * be either Premium or Standard. Default is Premium. Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
   * artifact resource IDs that should be applied on all Linux VM creations by
   * default, prior to the artifacts specified by the user.
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
   * of artifact resource IDs that should be applied on all Windows VM creations
   * by default, prior to the artifacts specified by the user.
   *
   * @param {string} [lab.premiumDataDisks] The setting to enable usage of
   * premium data disks.
   * When its value is 'Enabled', creation of standard or premium data disks is
   * allowed.
   * When its value is 'Disabled', only creation of standard data disks is
   * allowed. Possible values include: 'Disabled', 'Enabled'
   *
   * @param {string} [lab.environmentPermission] The access rights to be granted
   * to the user when provisioning an environment. Possible values include:
   * 'Reader', 'Contributor'
   *
   * @param {object} [lab.announcement] The properties of any lab announcement
   * associated with this lab
   *
   * @param {string} [lab.announcement.title] The plain text title for the lab
   * announcement
   *
   * @param {string} [lab.announcement.markdown] The markdown text (if any) that
   * this lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {string} [lab.announcement.enabled] Is the lab announcement
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {date} [lab.announcement.expirationDate] The time at which the
   * announcement expires (null for never)
   *
   * @param {boolean} [lab.announcement.expired] Has this announcement expired?
   *
   * @param {object} [lab.support] The properties of any lab support message
   * associated with this lab
   *
   * @param {string} [lab.support.enabled] Is the lab support banner
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [lab.support.markdown] The markdown text (if any) that this
   * lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {object} [lab.extendedProperties] Extended properties of the lab used
   * for experimental features
   *
   * @param {object} [lab.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 {Lab} - 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 Lab} 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, name, lab, 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, name, lab, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, name, lab, options, optionalCallback);
    }
  }

  /**
   * Claim a random claimable virtual machine in the lab. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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.
   */
  claimAnyVmWithHttpOperationResponse(resourceGroupName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._claimAnyVm(resourceGroupName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Claim a random claimable virtual machine in the lab. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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.
   */
  claimAnyVm(resourceGroupName, 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._claimAnyVm(resourceGroupName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._claimAnyVm(resourceGroupName, name, options, optionalCallback);
    }
  }

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

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

  /**
   * Exports the lab resource usage into a storage account This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} exportResourceUsageParameters The parameters of the export
   * operation.
   *
   * @param {string} [exportResourceUsageParameters.blobStorageAbsoluteSasUri]
   * The blob storage absolute sas uri with write permission to the container
   * which the usage data needs to be uploaded to.
   *
   * @param {date} [exportResourceUsageParameters.usageStartDate] The start time
   * of the usage. If not provided, usage will be reported since the beginning of
   * data collection.
   *
   * @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.
   */
  exportResourceUsageWithHttpOperationResponse(resourceGroupName, name, exportResourceUsageParameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._exportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Exports the lab resource usage into a storage account This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} exportResourceUsageParameters The parameters of the export
   * operation.
   *
   * @param {string} [exportResourceUsageParameters.blobStorageAbsoluteSasUri]
   * The blob storage absolute sas uri with write permission to the container
   * which the usage data needs to be uploaded to.
   *
   * @param {date} [exportResourceUsageParameters.usageStartDate] The start time
   * of the usage. If not provided, usage will be reported since the beginning of
   * data collection.
   *
   * @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.
   */
  exportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, 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._exportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._exportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, options, optionalCallback);
    }
  }

  /**
   * Generate a URI for uploading custom disk images to a Lab.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} generateUploadUriParameter Properties for generating an
   * upload URI.
   *
   * @param {string} [generateUploadUriParameter.blobName] The blob name of the
   * upload URI.
   *
   * @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<GenerateUploadUriResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  generateUploadUriWithHttpOperationResponse(resourceGroupName, name, generateUploadUriParameter, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._generateUploadUri(resourceGroupName, name, generateUploadUriParameter, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Generate a URI for uploading custom disk images to a Lab.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} generateUploadUriParameter Properties for generating an
   * upload URI.
   *
   * @param {string} [generateUploadUriParameter.blobName] The blob name of the
   * upload URI.
   *
   * @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 {GenerateUploadUriResponse} - 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 GenerateUploadUriResponse} 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.
   */
  generateUploadUri(resourceGroupName, name, generateUploadUriParameter, 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._generateUploadUri(resourceGroupName, name, generateUploadUriParameter, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._generateUploadUri(resourceGroupName, name, generateUploadUriParameter, options, optionalCallback);
    }
  }

  /**
   * Import a virtual machine into a different lab. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} importLabVirtualMachineRequest This represents the payload
   * required to import a virtual machine from a different lab into the current
   * one
   *
   * @param {string}
   * [importLabVirtualMachineRequest.sourceVirtualMachineResourceId] The full
   * resource ID of the virtual machine to be imported.
   *
   * @param {string}
   * [importLabVirtualMachineRequest.destinationVirtualMachineName] The name of
   * the virtual machine in the destination lab
   *
   * @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.
   */
  importVirtualMachineWithHttpOperationResponse(resourceGroupName, name, importLabVirtualMachineRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._importVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Import a virtual machine into a different lab. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} importLabVirtualMachineRequest This represents the payload
   * required to import a virtual machine from a different lab into the current
   * one
   *
   * @param {string}
   * [importLabVirtualMachineRequest.sourceVirtualMachineResourceId] The full
   * resource ID of the virtual machine to be imported.
   *
   * @param {string}
   * [importLabVirtualMachineRequest.destinationVirtualMachineName] The name of
   * the virtual machine in the destination lab
   *
   * @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.
   */
  importVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, 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._importVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._importVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, options, optionalCallback);
    }
  }

  /**
   * List disk images available for custom image creation.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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<LabVhdList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listVhdsWithHttpOperationResponse(resourceGroupName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listVhds(resourceGroupName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List disk images available for custom image creation.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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 {LabVhdList} - 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 LabVhdList} 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.
   */
  listVhds(resourceGroupName, 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._listVhds(resourceGroupName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listVhds(resourceGroupName, name, options, optionalCallback);
    }
  }

  /**
   * Create or replace an existing lab. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} lab A lab.
   *
   * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
   * be either Premium or Standard. Default is Premium. Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
   * artifact resource IDs that should be applied on all Linux VM creations by
   * default, prior to the artifacts specified by the user.
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
   * of artifact resource IDs that should be applied on all Windows VM creations
   * by default, prior to the artifacts specified by the user.
   *
   * @param {string} [lab.premiumDataDisks] The setting to enable usage of
   * premium data disks.
   * When its value is 'Enabled', creation of standard or premium data disks is
   * allowed.
   * When its value is 'Disabled', only creation of standard data disks is
   * allowed. Possible values include: 'Disabled', 'Enabled'
   *
   * @param {string} [lab.environmentPermission] The access rights to be granted
   * to the user when provisioning an environment. Possible values include:
   * 'Reader', 'Contributor'
   *
   * @param {object} [lab.announcement] The properties of any lab announcement
   * associated with this lab
   *
   * @param {string} [lab.announcement.title] The plain text title for the lab
   * announcement
   *
   * @param {string} [lab.announcement.markdown] The markdown text (if any) that
   * this lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {string} [lab.announcement.enabled] Is the lab announcement
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {date} [lab.announcement.expirationDate] The time at which the
   * announcement expires (null for never)
   *
   * @param {boolean} [lab.announcement.expired] Has this announcement expired?
   *
   * @param {object} [lab.support] The properties of any lab support message
   * associated with this lab
   *
   * @param {string} [lab.support.enabled] Is the lab support banner
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [lab.support.markdown] The markdown text (if any) that this
   * lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {object} [lab.extendedProperties] Extended properties of the lab used
   * for experimental features
   *
   * @param {string} [lab.location] The location of the resource.
   *
   * @param {object} [lab.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<Lab>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, name, lab, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdate(resourceGroupName, name, lab, 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 lab. This operation can take a while to
   * complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} lab A lab.
   *
   * @param {string} [lab.labStorageType] Type of storage used by the lab. It can
   * be either Premium or Standard. Default is Premium. Possible values include:
   * 'Standard', 'Premium'
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsLinux] The ordered list of
   * artifact resource IDs that should be applied on all Linux VM creations by
   * default, prior to the artifacts specified by the user.
   *
   * @param {array} [lab.mandatoryArtifactsResourceIdsWindows] The ordered list
   * of artifact resource IDs that should be applied on all Windows VM creations
   * by default, prior to the artifacts specified by the user.
   *
   * @param {string} [lab.premiumDataDisks] The setting to enable usage of
   * premium data disks.
   * When its value is 'Enabled', creation of standard or premium data disks is
   * allowed.
   * When its value is 'Disabled', only creation of standard data disks is
   * allowed. Possible values include: 'Disabled', 'Enabled'
   *
   * @param {string} [lab.environmentPermission] The access rights to be granted
   * to the user when provisioning an environment. Possible values include:
   * 'Reader', 'Contributor'
   *
   * @param {object} [lab.announcement] The properties of any lab announcement
   * associated with this lab
   *
   * @param {string} [lab.announcement.title] The plain text title for the lab
   * announcement
   *
   * @param {string} [lab.announcement.markdown] The markdown text (if any) that
   * this lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {string} [lab.announcement.enabled] Is the lab announcement
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {date} [lab.announcement.expirationDate] The time at which the
   * announcement expires (null for never)
   *
   * @param {boolean} [lab.announcement.expired] Has this announcement expired?
   *
   * @param {object} [lab.support] The properties of any lab support message
   * associated with this lab
   *
   * @param {string} [lab.support.enabled] Is the lab support banner
   * active/enabled at this time?. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [lab.support.markdown] The markdown text (if any) that this
   * lab displays in the UI. If left empty/null, nothing will be shown.
   *
   * @param {object} [lab.extendedProperties] Extended properties of the lab used
   * for experimental features
   *
   * @param {string} [lab.location] The location of the resource.
   *
   * @param {object} [lab.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 {Lab} - 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 Lab} 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, name, lab, 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, name, lab, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdate(resourceGroupName, name, lab, options, optionalCallback);
    }
  }

  /**
   * Delete lab. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, 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 lab. This operation can take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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, 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, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, name, options, optionalCallback);
    }
  }

  /**
   * Claim a random claimable virtual machine in the lab. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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.
   */
  beginClaimAnyVmWithHttpOperationResponse(resourceGroupName, name, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginClaimAnyVm(resourceGroupName, name, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Claim a random claimable virtual machine in the lab. This operation can take
   * a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @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.
   */
  beginClaimAnyVm(resourceGroupName, 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._beginClaimAnyVm(resourceGroupName, name, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginClaimAnyVm(resourceGroupName, name, options, optionalCallback);
    }
  }

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

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

  /**
   * Exports the lab resource usage into a storage account This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} exportResourceUsageParameters The parameters of the export
   * operation.
   *
   * @param {string} [exportResourceUsageParameters.blobStorageAbsoluteSasUri]
   * The blob storage absolute sas uri with write permission to the container
   * which the usage data needs to be uploaded to.
   *
   * @param {date} [exportResourceUsageParameters.usageStartDate] The start time
   * of the usage. If not provided, usage will be reported since the beginning of
   * data collection.
   *
   * @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.
   */
  beginExportResourceUsageWithHttpOperationResponse(resourceGroupName, name, exportResourceUsageParameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginExportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Exports the lab resource usage into a storage account This operation can
   * take a while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} exportResourceUsageParameters The parameters of the export
   * operation.
   *
   * @param {string} [exportResourceUsageParameters.blobStorageAbsoluteSasUri]
   * The blob storage absolute sas uri with write permission to the container
   * which the usage data needs to be uploaded to.
   *
   * @param {date} [exportResourceUsageParameters.usageStartDate] The start time
   * of the usage. If not provided, usage will be reported since the beginning of
   * data collection.
   *
   * @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.
   */
  beginExportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, 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._beginExportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginExportResourceUsage(resourceGroupName, name, exportResourceUsageParameters, options, optionalCallback);
    }
  }

  /**
   * Import a virtual machine into a different lab. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} importLabVirtualMachineRequest This represents the payload
   * required to import a virtual machine from a different lab into the current
   * one
   *
   * @param {string}
   * [importLabVirtualMachineRequest.sourceVirtualMachineResourceId] The full
   * resource ID of the virtual machine to be imported.
   *
   * @param {string}
   * [importLabVirtualMachineRequest.destinationVirtualMachineName] The name of
   * the virtual machine in the destination lab
   *
   * @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.
   */
  beginImportVirtualMachineWithHttpOperationResponse(resourceGroupName, name, importLabVirtualMachineRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginImportVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Import a virtual machine into a different lab. This operation can take a
   * while to complete.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} name The name of the lab.
   *
   * @param {object} importLabVirtualMachineRequest This represents the payload
   * required to import a virtual machine from a different lab into the current
   * one
   *
   * @param {string}
   * [importLabVirtualMachineRequest.sourceVirtualMachineResourceId] The full
   * resource ID of the virtual machine to be imported.
   *
   * @param {string}
   * [importLabVirtualMachineRequest.destinationVirtualMachineName] The name of
   * the virtual machine in the destination lab
   *
   * @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.
   */
  beginImportVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, 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._beginImportVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginImportVirtualMachine(resourceGroupName, name, importLabVirtualMachineRequest, options, optionalCallback);
    }
  }

  /**
   * List labs in a subscription.
   *
   * @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<LabList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listBySubscriptionNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listBySubscriptionNext(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 labs in a subscription.
   *
   * @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 {LabList} - 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 LabList} 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.
   */
  listBySubscriptionNext(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._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listBySubscriptionNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * List labs in a resource group.
   *
   * @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<LabList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByResourceGroupNext(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 labs in a resource group.
   *
   * @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 {LabList} - 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 LabList} 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.
   */
  listByResourceGroupNext(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._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByResourceGroupNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * List disk images available for custom image creation.
   *
   * @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<LabVhdList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listVhdsNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listVhdsNext(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 disk images available for custom image creation.
   *
   * @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 {LabVhdList} - 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 LabVhdList} 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.
   */
  listVhdsNext(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._listVhdsNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listVhdsNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = Labs;
