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


/**
 * Creates a Cluster in the given Workspace.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @param {object} parameters The parameters to provide for the Cluster
 * creation.
 *
 * @param {string} parameters.vmSize VM size. The size of the virtual machines
 * in the cluster. All nodes in a cluster have the same VM size. For
 * information about available VM sizes for clusters using images from the
 * Virtual Machines Marketplace see Sizes for Virtual Machines (Linux). Batch
 * AI service supports all Azure VM sizes except STANDARD_A0 and those with
 * premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
 *
 * @param {string} [parameters.vmPriority] VM priority. VM priority. Allowed
 * values are: dedicated (default) and lowpriority. Possible values include:
 * 'dedicated', 'lowpriority'
 *
 * @param {object} [parameters.scaleSettings] Scale settings. Scale settings
 * for the cluster. Batch AI service supports manual and auto scale clusters.
 *
 * @param {object} [parameters.scaleSettings.manual] Manual scale settings.
 * Manual scale settings for the cluster.
 *
 * @param {number} parameters.scaleSettings.manual.targetNodeCount Target node
 * count. The desired number of compute nodes in the Cluster. Default is 0.
 *
 * @param {string} [parameters.scaleSettings.manual.nodeDeallocationOption]
 * Node deallocation options. An action to be performed when the cluster size
 * is decreasing. The default value is requeue. Possible values include:
 * 'requeue', 'terminate', 'waitforjobcompletion'
 *
 * @param {object} [parameters.scaleSettings.autoScale] Auto-scale settings.
 * Auto-scale settings for the cluster.
 *
 * @param {number} parameters.scaleSettings.autoScale.minimumNodeCount Minimum
 * node count. The minimum number of compute nodes the Batch AI service will
 * try to allocate for the cluster. Note, the actual number of nodes can be
 * less than the specified value if the subscription has not enough quota to
 * fulfill the request.
 *
 * @param {number} parameters.scaleSettings.autoScale.maximumNodeCount Maximum
 * node count. The maximum number of compute nodes the cluster can have.
 *
 * @param {number} [parameters.scaleSettings.autoScale.initialNodeCount]
 * Initial node count. The number of compute nodes to allocate on cluster
 * creation. Note that this value is used only during cluster creation.
 * Default: 0.
 *
 * @param {object} [parameters.virtualMachineConfiguration] VM configuration.
 * OS image configuration for cluster nodes. All nodes in a cluster have the
 * same OS image.
 *
 * @param {object} [parameters.virtualMachineConfiguration.imageReference]
 * Image reference. OS image reference for cluster nodes.
 *
 * @param {string}
 * parameters.virtualMachineConfiguration.imageReference.publisher Publisher.
 * Publisher of the image.
 *
 * @param {string} parameters.virtualMachineConfiguration.imageReference.offer
 * Offer. Offer of the image.
 *
 * @param {string} parameters.virtualMachineConfiguration.imageReference.sku
 * SKU. SKU of the image.
 *
 * @param {string}
 * [parameters.virtualMachineConfiguration.imageReference.version] Version.
 * Version of the image.
 *
 * @param {string}
 * [parameters.virtualMachineConfiguration.imageReference.virtualMachineImageId]
 * Custom VM image resource ID. The ARM resource identifier of the virtual
 * machine image for the compute nodes. This is of the form
 * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
 * The virtual machine image must be in the same region and subscription as the
 * cluster. For information about the firewall settings for the Batch node
 * agent to communicate with the Batch service see
 * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
 * Note, you need to provide publisher, offer and sku of the base OS image of
 * which the custom image has been derived from.
 *
 * @param {object} [parameters.nodeSetup] Node setup. Setup to be performed on
 * each compute node in the cluster.
 *
 * @param {object} [parameters.nodeSetup.setupTask] Setup task. Setup task to
 * run on cluster nodes when nodes got created or rebooted. The setup task code
 * needs to be idempotent. Generally the setup task is used to download static
 * data that is required for all jobs that run on the cluster VMs and/or to
 * download/install software.
 *
 * @param {string} parameters.nodeSetup.setupTask.commandLine Command line. The
 * command line to be executed on each cluster's node after it being allocated
 * or rebooted. The command is executed in a bash subshell as a root.
 *
 * @param {array} [parameters.nodeSetup.setupTask.environmentVariables]
 * Environment variables. A collection of user defined environment variables to
 * be set for setup task.
 *
 * @param {array} [parameters.nodeSetup.setupTask.secrets] Secrets. A
 * collection of user defined environment variables with secret values to be
 * set for the setup task. Server will never report values of these variables
 * back.
 *
 * @param {string} parameters.nodeSetup.setupTask.stdOutErrPathPrefix Output
 * path prefix. The prefix of a path where the Batch AI service will upload the
 * stdout, stderr and execution log of the setup task.
 *
 * @param {object} [parameters.nodeSetup.mountVolumes] Mount volumes. Mount
 * volumes to be available to setup task and all jobs executing on the cluster.
 * The volumes will be mounted at location specified by $AZ_BATCHAI_MOUNT_ROOT
 * environment variable.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.azureFileShares] Azure
 * File Shares. A collection of Azure File Shares that are to be mounted to the
 * cluster nodes.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.azureBlobFileSystems]
 * Azure Blob file systems. A collection of Azure Blob Containers that are to
 * be mounted to the cluster nodes.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.fileServers] File Servers.
 * A collection of Batch AI File Servers that are to be mounted to the cluster
 * nodes.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.unmanagedFileSystems]
 * Unmanaged file systems. A collection of unmanaged file systems that are to
 * be mounted to the cluster nodes.
 *
 * @param {object} [parameters.nodeSetup.performanceCountersSettings]
 * Performance counters settings. Settings for performance counters collecting
 * and uploading.
 *
 * @param {object}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference Azure
 * Application Insights reference. Azure Application Insights information for
 * performance counters reporting. If provided, Batch AI will upload node
 * performance counters to the corresponding Azure Application Insights
 * account.
 *
 * @param {object}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.component
 * Component ID. Azure Application Insights component resource ID.
 *
 * @param {string}
 * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKey]
 * Instrumentation Key. Value of the Azure Application Insights instrumentation
 * key.
 *
 * @param {object}
 * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference]
 * Instrumentation key KeyVault Secret reference. KeyVault Store and Secret
 * which contains Azure Application Insights instrumentation key. One of
 * instrumentationKey or instrumentationKeySecretReference must be specified.
 *
 * @param {object}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.sourceVault
 * Key Vault resource identifier. Fully qualified resource indentifier of the
 * Key Vault.
 *
 * @param {string}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.secretUrl
 * Secret URL. The URL referencing a secret in the Key Vault.
 *
 * @param {object} parameters.userAccountSettings User account settings.
 * Settings for an administrator user account that will be created on each
 * compute node in the cluster.
 *
 * @param {string} parameters.userAccountSettings.adminUserName User name. Name
 * of the administrator user account which can be used to SSH to nodes.
 *
 * @param {string} [parameters.userAccountSettings.adminUserSshPublicKey] SSH
 * public key. SSH public key of the administrator user account.
 *
 * @param {string} [parameters.userAccountSettings.adminUserPassword] Password.
 * Password of the administrator user account.
 *
 * @param {object} [parameters.subnet] Subnet. Existing virtual network subnet
 * to put the cluster nodes in. Note, if a File Server mount configured in node
 * setup, the File Server's subnet will be used automatically.
 *
 * @param {string} parameters.subnet.id The ID 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 Cluster} 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 _create(resourceGroupName, workspaceName, clusterName, parameters, 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.beginCreate(resourceGroupName, workspaceName, clusterName, parameters, 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['Cluster']().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);
    });
  });
}

/**
 * Updates properties of a Cluster.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.scaleSettings] Scale settings. Desired scale
 * settings for the cluster. Batch AI service supports manual and auto scale
 * clusters.
 *
 * @param {object} [options.scaleSettings.manual] Manual scale settings. Manual
 * scale settings for the cluster.
 *
 * @param {number} options.scaleSettings.manual.targetNodeCount Target node
 * count. The desired number of compute nodes in the Cluster. Default is 0.
 *
 * @param {string} [options.scaleSettings.manual.nodeDeallocationOption] Node
 * deallocation options. An action to be performed when the cluster size is
 * decreasing. The default value is requeue. Possible values include:
 * 'requeue', 'terminate', 'waitforjobcompletion'
 *
 * @param {object} [options.scaleSettings.autoScale] Auto-scale settings.
 * Auto-scale settings for the cluster.
 *
 * @param {number} options.scaleSettings.autoScale.minimumNodeCount Minimum
 * node count. The minimum number of compute nodes the Batch AI service will
 * try to allocate for the cluster. Note, the actual number of nodes can be
 * less than the specified value if the subscription has not enough quota to
 * fulfill the request.
 *
 * @param {number} options.scaleSettings.autoScale.maximumNodeCount Maximum
 * node count. The maximum number of compute nodes the cluster can have.
 *
 * @param {number} [options.scaleSettings.autoScale.initialNodeCount] Initial
 * node count. The number of compute nodes to allocate on cluster creation.
 * Note that this value is used only during cluster creation. Default: 0.
 *
 * @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 Cluster} 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, workspaceName, clusterName, 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 scaleSettings = (options && options.scaleSettings !== undefined) ? options.scaleSettings : undefined;
  // Validate
  try {
    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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') {
      throw new Error('clusterName cannot be null or undefined and it must be of type string.');
    }
    if (clusterName !== null && clusterName !== undefined) {
      if (clusterName.length > 64)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MaxLength": 64');
      }
      if (clusterName.length < 1)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MinLength": 1');
      }
      if (clusterName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"clusterName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    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.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 (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);
  }
  let parameters;
  if (scaleSettings !== null && scaleSettings !== undefined) {
    parameters = new client.models['ClusterUpdateParameters']();
    parameters.scaleSettings = scaleSettings;
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/clusters/{clusterName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  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 (parameters !== null && parameters !== undefined) {
      let requestModelMapper = new client.models['ClusterUpdateParameters']().mapper();
      requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(parameters, 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['Cluster']().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);
  });
}


/**
 * Deletes a Cluster.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @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, workspaceName, clusterName, 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, workspaceName, clusterName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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

/**
 * Gets information about a Cluster.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @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 Cluster} 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, workspaceName, clusterName, 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 (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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') {
      throw new Error('clusterName cannot be null or undefined and it must be of type string.');
    }
    if (clusterName !== null && clusterName !== undefined) {
      if (clusterName.length > 64)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MaxLength": 64');
      }
      if (clusterName.length < 1)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MinLength": 1');
      }
      if (clusterName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"clusterName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    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.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 (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.BatchAI/workspaces/{workspaceName}/clusters/{clusterName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  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 = '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['Cluster']().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 the IP address, port of all the compute nodes in the Cluster.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @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 RemoteLoginInformationListResult} 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 _listRemoteLoginInformation(resourceGroupName, workspaceName, clusterName, 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 (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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') {
      throw new Error('clusterName cannot be null or undefined and it must be of type string.');
    }
    if (clusterName !== null && clusterName !== undefined) {
      if (clusterName.length > 64)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MaxLength": 64');
      }
      if (clusterName.length < 1)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MinLength": 1');
      }
      if (clusterName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"clusterName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    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.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 (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.BatchAI/workspaces/{workspaceName}/clusters/{clusterName}/listRemoteLoginInformation';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  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['RemoteLoginInformationListResult']().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);
  });
}

/**
 * Gets information about Clusters associated with the given Workspace.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.clustersListByWorkspaceOptions] Additional
 * parameters for the operation
 *
 * @param {number} [options.clustersListByWorkspaceOptions.maxResults] The
 * maximum number of items to return in the response. A maximum of 1000 files
 * can be returned.
 *
 * @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 ClusterListResult} 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 _listByWorkspace(resourceGroupName, workspaceName, 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 clustersListByWorkspaceOptions = (options && options.clustersListByWorkspaceOptions !== undefined) ? options.clustersListByWorkspaceOptions : undefined;
  // Validate
  try {
    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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    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.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 (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);
  }
  let maxResults;
  try {
    if (clustersListByWorkspaceOptions !== null && clustersListByWorkspaceOptions !== undefined)
    {
      maxResults = clustersListByWorkspaceOptions.maxResults;
      if (maxResults !== null && maxResults !== undefined && typeof maxResults !== 'number') {
        throw new Error('maxResults must be of type number.');
      }
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/clusters';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (maxResults !== null && maxResults !== undefined) {
    queryParameters.push('maxresults=' + encodeURIComponent(maxResults.toString()));
  }
  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['ClusterListResult']().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);
  });
}

/**
 * Creates a Cluster in the given Workspace.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @param {object} parameters The parameters to provide for the Cluster
 * creation.
 *
 * @param {string} parameters.vmSize VM size. The size of the virtual machines
 * in the cluster. All nodes in a cluster have the same VM size. For
 * information about available VM sizes for clusters using images from the
 * Virtual Machines Marketplace see Sizes for Virtual Machines (Linux). Batch
 * AI service supports all Azure VM sizes except STANDARD_A0 and those with
 * premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
 *
 * @param {string} [parameters.vmPriority] VM priority. VM priority. Allowed
 * values are: dedicated (default) and lowpriority. Possible values include:
 * 'dedicated', 'lowpriority'
 *
 * @param {object} [parameters.scaleSettings] Scale settings. Scale settings
 * for the cluster. Batch AI service supports manual and auto scale clusters.
 *
 * @param {object} [parameters.scaleSettings.manual] Manual scale settings.
 * Manual scale settings for the cluster.
 *
 * @param {number} parameters.scaleSettings.manual.targetNodeCount Target node
 * count. The desired number of compute nodes in the Cluster. Default is 0.
 *
 * @param {string} [parameters.scaleSettings.manual.nodeDeallocationOption]
 * Node deallocation options. An action to be performed when the cluster size
 * is decreasing. The default value is requeue. Possible values include:
 * 'requeue', 'terminate', 'waitforjobcompletion'
 *
 * @param {object} [parameters.scaleSettings.autoScale] Auto-scale settings.
 * Auto-scale settings for the cluster.
 *
 * @param {number} parameters.scaleSettings.autoScale.minimumNodeCount Minimum
 * node count. The minimum number of compute nodes the Batch AI service will
 * try to allocate for the cluster. Note, the actual number of nodes can be
 * less than the specified value if the subscription has not enough quota to
 * fulfill the request.
 *
 * @param {number} parameters.scaleSettings.autoScale.maximumNodeCount Maximum
 * node count. The maximum number of compute nodes the cluster can have.
 *
 * @param {number} [parameters.scaleSettings.autoScale.initialNodeCount]
 * Initial node count. The number of compute nodes to allocate on cluster
 * creation. Note that this value is used only during cluster creation.
 * Default: 0.
 *
 * @param {object} [parameters.virtualMachineConfiguration] VM configuration.
 * OS image configuration for cluster nodes. All nodes in a cluster have the
 * same OS image.
 *
 * @param {object} [parameters.virtualMachineConfiguration.imageReference]
 * Image reference. OS image reference for cluster nodes.
 *
 * @param {string}
 * parameters.virtualMachineConfiguration.imageReference.publisher Publisher.
 * Publisher of the image.
 *
 * @param {string} parameters.virtualMachineConfiguration.imageReference.offer
 * Offer. Offer of the image.
 *
 * @param {string} parameters.virtualMachineConfiguration.imageReference.sku
 * SKU. SKU of the image.
 *
 * @param {string}
 * [parameters.virtualMachineConfiguration.imageReference.version] Version.
 * Version of the image.
 *
 * @param {string}
 * [parameters.virtualMachineConfiguration.imageReference.virtualMachineImageId]
 * Custom VM image resource ID. The ARM resource identifier of the virtual
 * machine image for the compute nodes. This is of the form
 * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
 * The virtual machine image must be in the same region and subscription as the
 * cluster. For information about the firewall settings for the Batch node
 * agent to communicate with the Batch service see
 * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
 * Note, you need to provide publisher, offer and sku of the base OS image of
 * which the custom image has been derived from.
 *
 * @param {object} [parameters.nodeSetup] Node setup. Setup to be performed on
 * each compute node in the cluster.
 *
 * @param {object} [parameters.nodeSetup.setupTask] Setup task. Setup task to
 * run on cluster nodes when nodes got created or rebooted. The setup task code
 * needs to be idempotent. Generally the setup task is used to download static
 * data that is required for all jobs that run on the cluster VMs and/or to
 * download/install software.
 *
 * @param {string} parameters.nodeSetup.setupTask.commandLine Command line. The
 * command line to be executed on each cluster's node after it being allocated
 * or rebooted. The command is executed in a bash subshell as a root.
 *
 * @param {array} [parameters.nodeSetup.setupTask.environmentVariables]
 * Environment variables. A collection of user defined environment variables to
 * be set for setup task.
 *
 * @param {array} [parameters.nodeSetup.setupTask.secrets] Secrets. A
 * collection of user defined environment variables with secret values to be
 * set for the setup task. Server will never report values of these variables
 * back.
 *
 * @param {string} parameters.nodeSetup.setupTask.stdOutErrPathPrefix Output
 * path prefix. The prefix of a path where the Batch AI service will upload the
 * stdout, stderr and execution log of the setup task.
 *
 * @param {object} [parameters.nodeSetup.mountVolumes] Mount volumes. Mount
 * volumes to be available to setup task and all jobs executing on the cluster.
 * The volumes will be mounted at location specified by $AZ_BATCHAI_MOUNT_ROOT
 * environment variable.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.azureFileShares] Azure
 * File Shares. A collection of Azure File Shares that are to be mounted to the
 * cluster nodes.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.azureBlobFileSystems]
 * Azure Blob file systems. A collection of Azure Blob Containers that are to
 * be mounted to the cluster nodes.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.fileServers] File Servers.
 * A collection of Batch AI File Servers that are to be mounted to the cluster
 * nodes.
 *
 * @param {array} [parameters.nodeSetup.mountVolumes.unmanagedFileSystems]
 * Unmanaged file systems. A collection of unmanaged file systems that are to
 * be mounted to the cluster nodes.
 *
 * @param {object} [parameters.nodeSetup.performanceCountersSettings]
 * Performance counters settings. Settings for performance counters collecting
 * and uploading.
 *
 * @param {object}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference Azure
 * Application Insights reference. Azure Application Insights information for
 * performance counters reporting. If provided, Batch AI will upload node
 * performance counters to the corresponding Azure Application Insights
 * account.
 *
 * @param {object}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.component
 * Component ID. Azure Application Insights component resource ID.
 *
 * @param {string}
 * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKey]
 * Instrumentation Key. Value of the Azure Application Insights instrumentation
 * key.
 *
 * @param {object}
 * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference]
 * Instrumentation key KeyVault Secret reference. KeyVault Store and Secret
 * which contains Azure Application Insights instrumentation key. One of
 * instrumentationKey or instrumentationKeySecretReference must be specified.
 *
 * @param {object}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.sourceVault
 * Key Vault resource identifier. Fully qualified resource indentifier of the
 * Key Vault.
 *
 * @param {string}
 * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.secretUrl
 * Secret URL. The URL referencing a secret in the Key Vault.
 *
 * @param {object} parameters.userAccountSettings User account settings.
 * Settings for an administrator user account that will be created on each
 * compute node in the cluster.
 *
 * @param {string} parameters.userAccountSettings.adminUserName User name. Name
 * of the administrator user account which can be used to SSH to nodes.
 *
 * @param {string} [parameters.userAccountSettings.adminUserSshPublicKey] SSH
 * public key. SSH public key of the administrator user account.
 *
 * @param {string} [parameters.userAccountSettings.adminUserPassword] Password.
 * Password of the administrator user account.
 *
 * @param {object} [parameters.subnet] Subnet. Existing virtual network subnet
 * to put the cluster nodes in. Note, if a File Server mount configured in node
 * setup, the File Server's subnet will be used automatically.
 *
 * @param {string} parameters.subnet.id The ID 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 Cluster} 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 _beginCreate(resourceGroupName, workspaceName, clusterName, parameters, 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 (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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') {
      throw new Error('clusterName cannot be null or undefined and it must be of type string.');
    }
    if (clusterName !== null && clusterName !== undefined) {
      if (clusterName.length > 64)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MaxLength": 64');
      }
      if (clusterName.length < 1)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MinLength": 1');
      }
      if (clusterName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"clusterName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters 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.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 (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.BatchAI/workspaces/{workspaceName}/clusters/{clusterName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  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 (parameters !== null && parameters !== undefined) {
      let requestModelMapper = new client.models['ClusterCreateParameters']().mapper();
      requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(parameters, 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;
    // 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['Cluster']().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);
  });
}

/**
 * Deletes a Cluster.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} clusterName The name of the cluster within the specified
 * resource group. Cluster names can only contain a combination of alphanumeric
 * characters along with dash (-) and underscore (_). The name must be from 1
 * through 64 characters long.
 *
 * @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, workspaceName, clusterName, 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 (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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (clusterName === null || clusterName === undefined || typeof clusterName.valueOf() !== 'string') {
      throw new Error('clusterName cannot be null or undefined and it must be of type string.');
    }
    if (clusterName !== null && clusterName !== undefined) {
      if (clusterName.length > 64)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MaxLength": 64');
      }
      if (clusterName.length < 1)
      {
        throw new Error('"clusterName" should satisfy the constraint - "MinLength": 1');
      }
      if (clusterName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"clusterName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    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.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 (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.BatchAI/workspaces/{workspaceName}/clusters/{clusterName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{clusterName}', encodeURIComponent(clusterName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  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);
  });
}

/**
 * Get the IP address, port of all the compute nodes in the Cluster.
 *
 * @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 RemoteLoginInformationListResult} 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 _listRemoteLoginInformationNext(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['RemoteLoginInformationListResult']().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);
  });
}

/**
 * Gets information about Clusters associated with the given Workspace.
 *
 * @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 ClusterListResult} 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 _listByWorkspaceNext(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['ClusterListResult']().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 Clusters. */
class Clusters {
  /**
   * Create a Clusters.
   * @param {BatchAIManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._create = _create;
    this._update = _update;
    this._deleteMethod = _deleteMethod;
    this._get = _get;
    this._listRemoteLoginInformation = _listRemoteLoginInformation;
    this._listByWorkspace = _listByWorkspace;
    this._beginCreate = _beginCreate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._listRemoteLoginInformationNext = _listRemoteLoginInformationNext;
    this._listByWorkspaceNext = _listByWorkspaceNext;
  }

  /**
   * Creates a Cluster in the given Workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for the Cluster
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machines
   * in the cluster. All nodes in a cluster have the same VM size. For
   * information about available VM sizes for clusters using images from the
   * Virtual Machines Marketplace see Sizes for Virtual Machines (Linux). Batch
   * AI service supports all Azure VM sizes except STANDARD_A0 and those with
   * premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {string} [parameters.vmPriority] VM priority. VM priority. Allowed
   * values are: dedicated (default) and lowpriority. Possible values include:
   * 'dedicated', 'lowpriority'
   *
   * @param {object} [parameters.scaleSettings] Scale settings. Scale settings
   * for the cluster. Batch AI service supports manual and auto scale clusters.
   *
   * @param {object} [parameters.scaleSettings.manual] Manual scale settings.
   * Manual scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.manual.targetNodeCount Target node
   * count. The desired number of compute nodes in the Cluster. Default is 0.
   *
   * @param {string} [parameters.scaleSettings.manual.nodeDeallocationOption]
   * Node deallocation options. An action to be performed when the cluster size
   * is decreasing. The default value is requeue. Possible values include:
   * 'requeue', 'terminate', 'waitforjobcompletion'
   *
   * @param {object} [parameters.scaleSettings.autoScale] Auto-scale settings.
   * Auto-scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.autoScale.minimumNodeCount Minimum
   * node count. The minimum number of compute nodes the Batch AI service will
   * try to allocate for the cluster. Note, the actual number of nodes can be
   * less than the specified value if the subscription has not enough quota to
   * fulfill the request.
   *
   * @param {number} parameters.scaleSettings.autoScale.maximumNodeCount Maximum
   * node count. The maximum number of compute nodes the cluster can have.
   *
   * @param {number} [parameters.scaleSettings.autoScale.initialNodeCount]
   * Initial node count. The number of compute nodes to allocate on cluster
   * creation. Note that this value is used only during cluster creation.
   * Default: 0.
   *
   * @param {object} [parameters.virtualMachineConfiguration] VM configuration.
   * OS image configuration for cluster nodes. All nodes in a cluster have the
   * same OS image.
   *
   * @param {object} [parameters.virtualMachineConfiguration.imageReference]
   * Image reference. OS image reference for cluster nodes.
   *
   * @param {string}
   * parameters.virtualMachineConfiguration.imageReference.publisher Publisher.
   * Publisher of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.offer
   * Offer. Offer of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.sku
   * SKU. SKU of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.version] Version.
   * Version of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.virtualMachineImageId]
   * Custom VM image resource ID. The ARM resource identifier of the virtual
   * machine image for the compute nodes. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
   * The virtual machine image must be in the same region and subscription as the
   * cluster. For information about the firewall settings for the Batch node
   * agent to communicate with the Batch service see
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
   * Note, you need to provide publisher, offer and sku of the base OS image of
   * which the custom image has been derived from.
   *
   * @param {object} [parameters.nodeSetup] Node setup. Setup to be performed on
   * each compute node in the cluster.
   *
   * @param {object} [parameters.nodeSetup.setupTask] Setup task. Setup task to
   * run on cluster nodes when nodes got created or rebooted. The setup task code
   * needs to be idempotent. Generally the setup task is used to download static
   * data that is required for all jobs that run on the cluster VMs and/or to
   * download/install software.
   *
   * @param {string} parameters.nodeSetup.setupTask.commandLine Command line. The
   * command line to be executed on each cluster's node after it being allocated
   * or rebooted. The command is executed in a bash subshell as a root.
   *
   * @param {array} [parameters.nodeSetup.setupTask.environmentVariables]
   * Environment variables. A collection of user defined environment variables to
   * be set for setup task.
   *
   * @param {array} [parameters.nodeSetup.setupTask.secrets] Secrets. A
   * collection of user defined environment variables with secret values to be
   * set for the setup task. Server will never report values of these variables
   * back.
   *
   * @param {string} parameters.nodeSetup.setupTask.stdOutErrPathPrefix Output
   * path prefix. The prefix of a path where the Batch AI service will upload the
   * stdout, stderr and execution log of the setup task.
   *
   * @param {object} [parameters.nodeSetup.mountVolumes] Mount volumes. Mount
   * volumes to be available to setup task and all jobs executing on the cluster.
   * The volumes will be mounted at location specified by $AZ_BATCHAI_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureFileShares] Azure
   * File Shares. A collection of Azure File Shares that are to be mounted to the
   * cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureBlobFileSystems]
   * Azure Blob file systems. A collection of Azure Blob Containers that are to
   * be mounted to the cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.fileServers] File Servers.
   * A collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.unmanagedFileSystems]
   * Unmanaged file systems. A collection of unmanaged file systems that are to
   * be mounted to the cluster nodes.
   *
   * @param {object} [parameters.nodeSetup.performanceCountersSettings]
   * Performance counters settings. Settings for performance counters collecting
   * and uploading.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference Azure
   * Application Insights reference. Azure Application Insights information for
   * performance counters reporting. If provided, Batch AI will upload node
   * performance counters to the corresponding Azure Application Insights
   * account.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.component
   * Component ID. Azure Application Insights component resource ID.
   *
   * @param {string}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKey]
   * Instrumentation Key. Value of the Azure Application Insights instrumentation
   * key.
   *
   * @param {object}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference]
   * Instrumentation key KeyVault Secret reference. KeyVault Store and Secret
   * which contains Azure Application Insights instrumentation key. One of
   * instrumentationKey or instrumentationKeySecretReference must be specified.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {object} parameters.userAccountSettings User account settings.
   * Settings for an administrator user account that will be created on each
   * compute node in the cluster.
   *
   * @param {string} parameters.userAccountSettings.adminUserName User name. Name
   * of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string} [parameters.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string} [parameters.userAccountSettings.adminUserPassword] Password.
   * Password of the administrator user account.
   *
   * @param {object} [parameters.subnet] Subnet. Existing virtual network subnet
   * to put the cluster nodes in. Note, if a File Server mount configured in node
   * setup, the File Server's subnet will be used automatically.
   *
   * @param {string} parameters.subnet.id The ID 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<Cluster>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(resourceGroupName, workspaceName, clusterName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(resourceGroupName, workspaceName, clusterName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a Cluster in the given Workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for the Cluster
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machines
   * in the cluster. All nodes in a cluster have the same VM size. For
   * information about available VM sizes for clusters using images from the
   * Virtual Machines Marketplace see Sizes for Virtual Machines (Linux). Batch
   * AI service supports all Azure VM sizes except STANDARD_A0 and those with
   * premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {string} [parameters.vmPriority] VM priority. VM priority. Allowed
   * values are: dedicated (default) and lowpriority. Possible values include:
   * 'dedicated', 'lowpriority'
   *
   * @param {object} [parameters.scaleSettings] Scale settings. Scale settings
   * for the cluster. Batch AI service supports manual and auto scale clusters.
   *
   * @param {object} [parameters.scaleSettings.manual] Manual scale settings.
   * Manual scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.manual.targetNodeCount Target node
   * count. The desired number of compute nodes in the Cluster. Default is 0.
   *
   * @param {string} [parameters.scaleSettings.manual.nodeDeallocationOption]
   * Node deallocation options. An action to be performed when the cluster size
   * is decreasing. The default value is requeue. Possible values include:
   * 'requeue', 'terminate', 'waitforjobcompletion'
   *
   * @param {object} [parameters.scaleSettings.autoScale] Auto-scale settings.
   * Auto-scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.autoScale.minimumNodeCount Minimum
   * node count. The minimum number of compute nodes the Batch AI service will
   * try to allocate for the cluster. Note, the actual number of nodes can be
   * less than the specified value if the subscription has not enough quota to
   * fulfill the request.
   *
   * @param {number} parameters.scaleSettings.autoScale.maximumNodeCount Maximum
   * node count. The maximum number of compute nodes the cluster can have.
   *
   * @param {number} [parameters.scaleSettings.autoScale.initialNodeCount]
   * Initial node count. The number of compute nodes to allocate on cluster
   * creation. Note that this value is used only during cluster creation.
   * Default: 0.
   *
   * @param {object} [parameters.virtualMachineConfiguration] VM configuration.
   * OS image configuration for cluster nodes. All nodes in a cluster have the
   * same OS image.
   *
   * @param {object} [parameters.virtualMachineConfiguration.imageReference]
   * Image reference. OS image reference for cluster nodes.
   *
   * @param {string}
   * parameters.virtualMachineConfiguration.imageReference.publisher Publisher.
   * Publisher of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.offer
   * Offer. Offer of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.sku
   * SKU. SKU of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.version] Version.
   * Version of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.virtualMachineImageId]
   * Custom VM image resource ID. The ARM resource identifier of the virtual
   * machine image for the compute nodes. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
   * The virtual machine image must be in the same region and subscription as the
   * cluster. For information about the firewall settings for the Batch node
   * agent to communicate with the Batch service see
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
   * Note, you need to provide publisher, offer and sku of the base OS image of
   * which the custom image has been derived from.
   *
   * @param {object} [parameters.nodeSetup] Node setup. Setup to be performed on
   * each compute node in the cluster.
   *
   * @param {object} [parameters.nodeSetup.setupTask] Setup task. Setup task to
   * run on cluster nodes when nodes got created or rebooted. The setup task code
   * needs to be idempotent. Generally the setup task is used to download static
   * data that is required for all jobs that run on the cluster VMs and/or to
   * download/install software.
   *
   * @param {string} parameters.nodeSetup.setupTask.commandLine Command line. The
   * command line to be executed on each cluster's node after it being allocated
   * or rebooted. The command is executed in a bash subshell as a root.
   *
   * @param {array} [parameters.nodeSetup.setupTask.environmentVariables]
   * Environment variables. A collection of user defined environment variables to
   * be set for setup task.
   *
   * @param {array} [parameters.nodeSetup.setupTask.secrets] Secrets. A
   * collection of user defined environment variables with secret values to be
   * set for the setup task. Server will never report values of these variables
   * back.
   *
   * @param {string} parameters.nodeSetup.setupTask.stdOutErrPathPrefix Output
   * path prefix. The prefix of a path where the Batch AI service will upload the
   * stdout, stderr and execution log of the setup task.
   *
   * @param {object} [parameters.nodeSetup.mountVolumes] Mount volumes. Mount
   * volumes to be available to setup task and all jobs executing on the cluster.
   * The volumes will be mounted at location specified by $AZ_BATCHAI_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureFileShares] Azure
   * File Shares. A collection of Azure File Shares that are to be mounted to the
   * cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureBlobFileSystems]
   * Azure Blob file systems. A collection of Azure Blob Containers that are to
   * be mounted to the cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.fileServers] File Servers.
   * A collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.unmanagedFileSystems]
   * Unmanaged file systems. A collection of unmanaged file systems that are to
   * be mounted to the cluster nodes.
   *
   * @param {object} [parameters.nodeSetup.performanceCountersSettings]
   * Performance counters settings. Settings for performance counters collecting
   * and uploading.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference Azure
   * Application Insights reference. Azure Application Insights information for
   * performance counters reporting. If provided, Batch AI will upload node
   * performance counters to the corresponding Azure Application Insights
   * account.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.component
   * Component ID. Azure Application Insights component resource ID.
   *
   * @param {string}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKey]
   * Instrumentation Key. Value of the Azure Application Insights instrumentation
   * key.
   *
   * @param {object}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference]
   * Instrumentation key KeyVault Secret reference. KeyVault Store and Secret
   * which contains Azure Application Insights instrumentation key. One of
   * instrumentationKey or instrumentationKeySecretReference must be specified.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {object} parameters.userAccountSettings User account settings.
   * Settings for an administrator user account that will be created on each
   * compute node in the cluster.
   *
   * @param {string} parameters.userAccountSettings.adminUserName User name. Name
   * of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string} [parameters.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string} [parameters.userAccountSettings.adminUserPassword] Password.
   * Password of the administrator user account.
   *
   * @param {object} [parameters.subnet] Subnet. Existing virtual network subnet
   * to put the cluster nodes in. Note, if a File Server mount configured in node
   * setup, the File Server's subnet will be used automatically.
   *
   * @param {string} parameters.subnet.id The ID 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 {Cluster} - 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 Cluster} 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.
   */
  create(resourceGroupName, workspaceName, clusterName, parameters, 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._create(resourceGroupName, workspaceName, clusterName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(resourceGroupName, workspaceName, clusterName, parameters, options, optionalCallback);
    }
  }

  /**
   * Updates properties of a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.scaleSettings] Scale settings. Desired scale
   * settings for the cluster. Batch AI service supports manual and auto scale
   * clusters.
   *
   * @param {object} [options.scaleSettings.manual] Manual scale settings. Manual
   * scale settings for the cluster.
   *
   * @param {number} options.scaleSettings.manual.targetNodeCount Target node
   * count. The desired number of compute nodes in the Cluster. Default is 0.
   *
   * @param {string} [options.scaleSettings.manual.nodeDeallocationOption] Node
   * deallocation options. An action to be performed when the cluster size is
   * decreasing. The default value is requeue. Possible values include:
   * 'requeue', 'terminate', 'waitforjobcompletion'
   *
   * @param {object} [options.scaleSettings.autoScale] Auto-scale settings.
   * Auto-scale settings for the cluster.
   *
   * @param {number} options.scaleSettings.autoScale.minimumNodeCount Minimum
   * node count. The minimum number of compute nodes the Batch AI service will
   * try to allocate for the cluster. Note, the actual number of nodes can be
   * less than the specified value if the subscription has not enough quota to
   * fulfill the request.
   *
   * @param {number} options.scaleSettings.autoScale.maximumNodeCount Maximum
   * node count. The maximum number of compute nodes the cluster can have.
   *
   * @param {number} [options.scaleSettings.autoScale.initialNodeCount] Initial
   * node count. The number of compute nodes to allocate on cluster creation.
   * Note that this value is used only during cluster creation. Default: 0.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Cluster>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, workspaceName, clusterName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, workspaceName, clusterName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates properties of a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.scaleSettings] Scale settings. Desired scale
   * settings for the cluster. Batch AI service supports manual and auto scale
   * clusters.
   *
   * @param {object} [options.scaleSettings.manual] Manual scale settings. Manual
   * scale settings for the cluster.
   *
   * @param {number} options.scaleSettings.manual.targetNodeCount Target node
   * count. The desired number of compute nodes in the Cluster. Default is 0.
   *
   * @param {string} [options.scaleSettings.manual.nodeDeallocationOption] Node
   * deallocation options. An action to be performed when the cluster size is
   * decreasing. The default value is requeue. Possible values include:
   * 'requeue', 'terminate', 'waitforjobcompletion'
   *
   * @param {object} [options.scaleSettings.autoScale] Auto-scale settings.
   * Auto-scale settings for the cluster.
   *
   * @param {number} options.scaleSettings.autoScale.minimumNodeCount Minimum
   * node count. The minimum number of compute nodes the Batch AI service will
   * try to allocate for the cluster. Note, the actual number of nodes can be
   * less than the specified value if the subscription has not enough quota to
   * fulfill the request.
   *
   * @param {number} options.scaleSettings.autoScale.maximumNodeCount Maximum
   * node count. The maximum number of compute nodes the cluster can have.
   *
   * @param {number} [options.scaleSettings.autoScale.initialNodeCount] Initial
   * node count. The number of compute nodes to allocate on cluster creation.
   * Note that this value is used only during cluster creation. Default: 0.
   *
   * @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 {Cluster} - 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 Cluster} 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, workspaceName, clusterName, 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, workspaceName, clusterName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, workspaceName, clusterName, options, optionalCallback);
    }
  }

  /**
   * Deletes a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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, workspaceName, clusterName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, workspaceName, clusterName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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, workspaceName, clusterName, 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, workspaceName, clusterName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, workspaceName, clusterName, options, optionalCallback);
    }
  }

  /**
   * Gets information about a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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<Cluster>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, workspaceName, clusterName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, workspaceName, clusterName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets information about a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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 {Cluster} - 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 Cluster} 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, workspaceName, clusterName, 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, workspaceName, clusterName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, workspaceName, clusterName, options, optionalCallback);
    }
  }

  /**
   * Get the IP address, port of all the compute nodes in the Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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<RemoteLoginInformationListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listRemoteLoginInformationWithHttpOperationResponse(resourceGroupName, workspaceName, clusterName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listRemoteLoginInformation(resourceGroupName, workspaceName, clusterName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get the IP address, port of all the compute nodes in the Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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 {RemoteLoginInformationListResult} - 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 RemoteLoginInformationListResult} 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.
   */
  listRemoteLoginInformation(resourceGroupName, workspaceName, clusterName, 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._listRemoteLoginInformation(resourceGroupName, workspaceName, clusterName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listRemoteLoginInformation(resourceGroupName, workspaceName, clusterName, options, optionalCallback);
    }
  }

  /**
   * Gets information about Clusters associated with the given Workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.clustersListByWorkspaceOptions] Additional
   * parameters for the operation
   *
   * @param {number} [options.clustersListByWorkspaceOptions.maxResults] The
   * maximum number of items to return in the response. A maximum of 1000 files
   * can be returned.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ClusterListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByWorkspaceWithHttpOperationResponse(resourceGroupName, workspaceName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByWorkspace(resourceGroupName, workspaceName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets information about Clusters associated with the given Workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.clustersListByWorkspaceOptions] Additional
   * parameters for the operation
   *
   * @param {number} [options.clustersListByWorkspaceOptions.maxResults] The
   * maximum number of items to return in the response. A maximum of 1000 files
   * can be returned.
   *
   * @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 {ClusterListResult} - 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 ClusterListResult} 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.
   */
  listByWorkspace(resourceGroupName, workspaceName, 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._listByWorkspace(resourceGroupName, workspaceName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByWorkspace(resourceGroupName, workspaceName, options, optionalCallback);
    }
  }

  /**
   * Creates a Cluster in the given Workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for the Cluster
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machines
   * in the cluster. All nodes in a cluster have the same VM size. For
   * information about available VM sizes for clusters using images from the
   * Virtual Machines Marketplace see Sizes for Virtual Machines (Linux). Batch
   * AI service supports all Azure VM sizes except STANDARD_A0 and those with
   * premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {string} [parameters.vmPriority] VM priority. VM priority. Allowed
   * values are: dedicated (default) and lowpriority. Possible values include:
   * 'dedicated', 'lowpriority'
   *
   * @param {object} [parameters.scaleSettings] Scale settings. Scale settings
   * for the cluster. Batch AI service supports manual and auto scale clusters.
   *
   * @param {object} [parameters.scaleSettings.manual] Manual scale settings.
   * Manual scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.manual.targetNodeCount Target node
   * count. The desired number of compute nodes in the Cluster. Default is 0.
   *
   * @param {string} [parameters.scaleSettings.manual.nodeDeallocationOption]
   * Node deallocation options. An action to be performed when the cluster size
   * is decreasing. The default value is requeue. Possible values include:
   * 'requeue', 'terminate', 'waitforjobcompletion'
   *
   * @param {object} [parameters.scaleSettings.autoScale] Auto-scale settings.
   * Auto-scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.autoScale.minimumNodeCount Minimum
   * node count. The minimum number of compute nodes the Batch AI service will
   * try to allocate for the cluster. Note, the actual number of nodes can be
   * less than the specified value if the subscription has not enough quota to
   * fulfill the request.
   *
   * @param {number} parameters.scaleSettings.autoScale.maximumNodeCount Maximum
   * node count. The maximum number of compute nodes the cluster can have.
   *
   * @param {number} [parameters.scaleSettings.autoScale.initialNodeCount]
   * Initial node count. The number of compute nodes to allocate on cluster
   * creation. Note that this value is used only during cluster creation.
   * Default: 0.
   *
   * @param {object} [parameters.virtualMachineConfiguration] VM configuration.
   * OS image configuration for cluster nodes. All nodes in a cluster have the
   * same OS image.
   *
   * @param {object} [parameters.virtualMachineConfiguration.imageReference]
   * Image reference. OS image reference for cluster nodes.
   *
   * @param {string}
   * parameters.virtualMachineConfiguration.imageReference.publisher Publisher.
   * Publisher of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.offer
   * Offer. Offer of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.sku
   * SKU. SKU of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.version] Version.
   * Version of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.virtualMachineImageId]
   * Custom VM image resource ID. The ARM resource identifier of the virtual
   * machine image for the compute nodes. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
   * The virtual machine image must be in the same region and subscription as the
   * cluster. For information about the firewall settings for the Batch node
   * agent to communicate with the Batch service see
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
   * Note, you need to provide publisher, offer and sku of the base OS image of
   * which the custom image has been derived from.
   *
   * @param {object} [parameters.nodeSetup] Node setup. Setup to be performed on
   * each compute node in the cluster.
   *
   * @param {object} [parameters.nodeSetup.setupTask] Setup task. Setup task to
   * run on cluster nodes when nodes got created or rebooted. The setup task code
   * needs to be idempotent. Generally the setup task is used to download static
   * data that is required for all jobs that run on the cluster VMs and/or to
   * download/install software.
   *
   * @param {string} parameters.nodeSetup.setupTask.commandLine Command line. The
   * command line to be executed on each cluster's node after it being allocated
   * or rebooted. The command is executed in a bash subshell as a root.
   *
   * @param {array} [parameters.nodeSetup.setupTask.environmentVariables]
   * Environment variables. A collection of user defined environment variables to
   * be set for setup task.
   *
   * @param {array} [parameters.nodeSetup.setupTask.secrets] Secrets. A
   * collection of user defined environment variables with secret values to be
   * set for the setup task. Server will never report values of these variables
   * back.
   *
   * @param {string} parameters.nodeSetup.setupTask.stdOutErrPathPrefix Output
   * path prefix. The prefix of a path where the Batch AI service will upload the
   * stdout, stderr and execution log of the setup task.
   *
   * @param {object} [parameters.nodeSetup.mountVolumes] Mount volumes. Mount
   * volumes to be available to setup task and all jobs executing on the cluster.
   * The volumes will be mounted at location specified by $AZ_BATCHAI_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureFileShares] Azure
   * File Shares. A collection of Azure File Shares that are to be mounted to the
   * cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureBlobFileSystems]
   * Azure Blob file systems. A collection of Azure Blob Containers that are to
   * be mounted to the cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.fileServers] File Servers.
   * A collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.unmanagedFileSystems]
   * Unmanaged file systems. A collection of unmanaged file systems that are to
   * be mounted to the cluster nodes.
   *
   * @param {object} [parameters.nodeSetup.performanceCountersSettings]
   * Performance counters settings. Settings for performance counters collecting
   * and uploading.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference Azure
   * Application Insights reference. Azure Application Insights information for
   * performance counters reporting. If provided, Batch AI will upload node
   * performance counters to the corresponding Azure Application Insights
   * account.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.component
   * Component ID. Azure Application Insights component resource ID.
   *
   * @param {string}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKey]
   * Instrumentation Key. Value of the Azure Application Insights instrumentation
   * key.
   *
   * @param {object}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference]
   * Instrumentation key KeyVault Secret reference. KeyVault Store and Secret
   * which contains Azure Application Insights instrumentation key. One of
   * instrumentationKey or instrumentationKeySecretReference must be specified.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {object} parameters.userAccountSettings User account settings.
   * Settings for an administrator user account that will be created on each
   * compute node in the cluster.
   *
   * @param {string} parameters.userAccountSettings.adminUserName User name. Name
   * of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string} [parameters.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string} [parameters.userAccountSettings.adminUserPassword] Password.
   * Password of the administrator user account.
   *
   * @param {object} [parameters.subnet] Subnet. Existing virtual network subnet
   * to put the cluster nodes in. Note, if a File Server mount configured in node
   * setup, the File Server's subnet will be used automatically.
   *
   * @param {string} parameters.subnet.id The ID 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<Cluster>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateWithHttpOperationResponse(resourceGroupName, workspaceName, clusterName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreate(resourceGroupName, workspaceName, clusterName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a Cluster in the given Workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for the Cluster
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machines
   * in the cluster. All nodes in a cluster have the same VM size. For
   * information about available VM sizes for clusters using images from the
   * Virtual Machines Marketplace see Sizes for Virtual Machines (Linux). Batch
   * AI service supports all Azure VM sizes except STANDARD_A0 and those with
   * premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {string} [parameters.vmPriority] VM priority. VM priority. Allowed
   * values are: dedicated (default) and lowpriority. Possible values include:
   * 'dedicated', 'lowpriority'
   *
   * @param {object} [parameters.scaleSettings] Scale settings. Scale settings
   * for the cluster. Batch AI service supports manual and auto scale clusters.
   *
   * @param {object} [parameters.scaleSettings.manual] Manual scale settings.
   * Manual scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.manual.targetNodeCount Target node
   * count. The desired number of compute nodes in the Cluster. Default is 0.
   *
   * @param {string} [parameters.scaleSettings.manual.nodeDeallocationOption]
   * Node deallocation options. An action to be performed when the cluster size
   * is decreasing. The default value is requeue. Possible values include:
   * 'requeue', 'terminate', 'waitforjobcompletion'
   *
   * @param {object} [parameters.scaleSettings.autoScale] Auto-scale settings.
   * Auto-scale settings for the cluster.
   *
   * @param {number} parameters.scaleSettings.autoScale.minimumNodeCount Minimum
   * node count. The minimum number of compute nodes the Batch AI service will
   * try to allocate for the cluster. Note, the actual number of nodes can be
   * less than the specified value if the subscription has not enough quota to
   * fulfill the request.
   *
   * @param {number} parameters.scaleSettings.autoScale.maximumNodeCount Maximum
   * node count. The maximum number of compute nodes the cluster can have.
   *
   * @param {number} [parameters.scaleSettings.autoScale.initialNodeCount]
   * Initial node count. The number of compute nodes to allocate on cluster
   * creation. Note that this value is used only during cluster creation.
   * Default: 0.
   *
   * @param {object} [parameters.virtualMachineConfiguration] VM configuration.
   * OS image configuration for cluster nodes. All nodes in a cluster have the
   * same OS image.
   *
   * @param {object} [parameters.virtualMachineConfiguration.imageReference]
   * Image reference. OS image reference for cluster nodes.
   *
   * @param {string}
   * parameters.virtualMachineConfiguration.imageReference.publisher Publisher.
   * Publisher of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.offer
   * Offer. Offer of the image.
   *
   * @param {string} parameters.virtualMachineConfiguration.imageReference.sku
   * SKU. SKU of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.version] Version.
   * Version of the image.
   *
   * @param {string}
   * [parameters.virtualMachineConfiguration.imageReference.virtualMachineImageId]
   * Custom VM image resource ID. The ARM resource identifier of the virtual
   * machine image for the compute nodes. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}.
   * The virtual machine image must be in the same region and subscription as the
   * cluster. For information about the firewall settings for the Batch node
   * agent to communicate with the Batch service see
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration.
   * Note, you need to provide publisher, offer and sku of the base OS image of
   * which the custom image has been derived from.
   *
   * @param {object} [parameters.nodeSetup] Node setup. Setup to be performed on
   * each compute node in the cluster.
   *
   * @param {object} [parameters.nodeSetup.setupTask] Setup task. Setup task to
   * run on cluster nodes when nodes got created or rebooted. The setup task code
   * needs to be idempotent. Generally the setup task is used to download static
   * data that is required for all jobs that run on the cluster VMs and/or to
   * download/install software.
   *
   * @param {string} parameters.nodeSetup.setupTask.commandLine Command line. The
   * command line to be executed on each cluster's node after it being allocated
   * or rebooted. The command is executed in a bash subshell as a root.
   *
   * @param {array} [parameters.nodeSetup.setupTask.environmentVariables]
   * Environment variables. A collection of user defined environment variables to
   * be set for setup task.
   *
   * @param {array} [parameters.nodeSetup.setupTask.secrets] Secrets. A
   * collection of user defined environment variables with secret values to be
   * set for the setup task. Server will never report values of these variables
   * back.
   *
   * @param {string} parameters.nodeSetup.setupTask.stdOutErrPathPrefix Output
   * path prefix. The prefix of a path where the Batch AI service will upload the
   * stdout, stderr and execution log of the setup task.
   *
   * @param {object} [parameters.nodeSetup.mountVolumes] Mount volumes. Mount
   * volumes to be available to setup task and all jobs executing on the cluster.
   * The volumes will be mounted at location specified by $AZ_BATCHAI_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureFileShares] Azure
   * File Shares. A collection of Azure File Shares that are to be mounted to the
   * cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.azureBlobFileSystems]
   * Azure Blob file systems. A collection of Azure Blob Containers that are to
   * be mounted to the cluster nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.fileServers] File Servers.
   * A collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.nodeSetup.mountVolumes.unmanagedFileSystems]
   * Unmanaged file systems. A collection of unmanaged file systems that are to
   * be mounted to the cluster nodes.
   *
   * @param {object} [parameters.nodeSetup.performanceCountersSettings]
   * Performance counters settings. Settings for performance counters collecting
   * and uploading.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference Azure
   * Application Insights reference. Azure Application Insights information for
   * performance counters reporting. If provided, Batch AI will upload node
   * performance counters to the corresponding Azure Application Insights
   * account.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.component
   * Component ID. Azure Application Insights component resource ID.
   *
   * @param {string}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKey]
   * Instrumentation Key. Value of the Azure Application Insights instrumentation
   * key.
   *
   * @param {object}
   * [parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference]
   * Instrumentation key KeyVault Secret reference. KeyVault Store and Secret
   * which contains Azure Application Insights instrumentation key. One of
   * instrumentationKey or instrumentationKeySecretReference must be specified.
   *
   * @param {object}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.nodeSetup.performanceCountersSettings.appInsightsReference.instrumentationKeySecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {object} parameters.userAccountSettings User account settings.
   * Settings for an administrator user account that will be created on each
   * compute node in the cluster.
   *
   * @param {string} parameters.userAccountSettings.adminUserName User name. Name
   * of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string} [parameters.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string} [parameters.userAccountSettings.adminUserPassword] Password.
   * Password of the administrator user account.
   *
   * @param {object} [parameters.subnet] Subnet. Existing virtual network subnet
   * to put the cluster nodes in. Note, if a File Server mount configured in node
   * setup, the File Server's subnet will be used automatically.
   *
   * @param {string} parameters.subnet.id The ID 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 {Cluster} - 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 Cluster} 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.
   */
  beginCreate(resourceGroupName, workspaceName, clusterName, parameters, 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._beginCreate(resourceGroupName, workspaceName, clusterName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreate(resourceGroupName, workspaceName, clusterName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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, workspaceName, clusterName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, workspaceName, clusterName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a Cluster.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} clusterName The name of the cluster within the specified
   * resource group. Cluster names can only contain a combination of alphanumeric
   * characters along with dash (-) and underscore (_). The name must be from 1
   * through 64 characters long.
   *
   * @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, workspaceName, clusterName, 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, workspaceName, clusterName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, workspaceName, clusterName, options, optionalCallback);
    }
  }

  /**
   * Get the IP address, port of all the compute nodes in the Cluster.
   *
   * @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<RemoteLoginInformationListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listRemoteLoginInformationNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listRemoteLoginInformationNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get the IP address, port of all the compute nodes in the Cluster.
   *
   * @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 {RemoteLoginInformationListResult} - 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 RemoteLoginInformationListResult} 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.
   */
  listRemoteLoginInformationNext(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._listRemoteLoginInformationNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listRemoteLoginInformationNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * Gets information about Clusters associated with the given Workspace.
   *
   * @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<ClusterListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByWorkspaceNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByWorkspaceNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets information about Clusters associated with the given Workspace.
   *
   * @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 {ClusterListResult} - 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 ClusterListResult} 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.
   */
  listByWorkspaceNext(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._listByWorkspaceNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByWorkspaceNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = Clusters;
