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

/**
 * Lists all of the pools in the specified account.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {number} [options.maxresults] The maximum number of items to return
 * in the response.
 *
 * @param {string} [options.select] Comma separated list of properties that
 * should be returned. e.g. "properties/provisioningState". Only top level
 * properties under properties/ are valid for selection.
 *
 * @param {string} [options.filter] OData filter expression. Valid properties
 * for filtering are:
 *
 * name
 * properties/allocationState
 * properties/allocationStateTransitionTime
 * properties/creationTime
 * properties/provisioningState
 * properties/provisioningStateTransitionTime
 * properties/lastModified
 * properties/vmSize
 * properties/interNodeCommunication
 * properties/scaleSettings/autoScale
 * properties/scaleSettings/fixedScale
 *
 * @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 ListPoolsResult} 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 _listByBatchAccount(resourceGroupName, accountName, 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 maxresults = (options && options.maxresults !== undefined) ? options.maxresults : undefined;
  let select = (options && options.select !== undefined) ? options.select : undefined;
  let filter = (options && options.filter !== undefined) ? options.filter : 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (maxresults !== null && maxresults !== undefined && typeof maxresults !== 'number') {
      throw new Error('maxresults must be of type number.');
    }
    if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') {
      throw new Error('select must be of type string.');
    }
    if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
      throw new Error('filter must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.Batch/batchAccounts/{accountName}/pools';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  if (maxresults !== null && maxresults !== undefined) {
    queryParameters.push('maxresults=' + encodeURIComponent(maxresults.toString()));
  }
  if (select !== null && select !== undefined) {
    queryParameters.push('$select=' + encodeURIComponent(select));
  }
  if (filter !== null && filter !== undefined) {
    queryParameters.push('$filter=' + encodeURIComponent(filter));
  }
  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['ListPoolsResult']().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 new pool inside the specified account.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @param {object} parameters Additional parameters for pool creation.
 *
 * @param {string} [parameters.displayName] The display name for the pool. The
 * display name need not be unique and can contain any Unicode characters up to
 * a maximum length of 1024.
 *
 * @param {string} [parameters.vmSize] The size of virtual machines in the
 * pool. All VMs in a pool are the same size. For information about available
 * sizes of virtual machines for Cloud Services pools (pools created with
 * cloudServiceConfiguration), see Sizes for Cloud Services
 * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
 * Batch supports all Cloud Services VM sizes except ExtraSmall. For
 * information about available VM sizes for pools using images from the Virtual
 * Machines Marketplace (pools created with virtualMachineConfiguration) see
 * Sizes for Virtual Machines (Linux)
 * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
 * or Sizes for Virtual Machines (Windows)
 * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
 * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
 * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
 *
 * @param {object} [parameters.deploymentConfiguration] This property describes
 * how the pool nodes will be deployed - using Cloud Services or Virtual
 * Machines. Using CloudServiceConfiguration specifies that the nodes should be
 * creating using Azure Cloud Services (PaaS), while
 * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
 *
 * @param {object}
 * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
 * service configuration for the pool. This property and
 * virtualMachineConfiguration are mutually exclusive and one of the properties
 * must be specified. This property cannot be specified if the Batch account
 * was created with its poolAllocationMode property set to 'UserSubscription'.
 *
 * @param {string}
 * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
 * Azure Guest OS family to be installed on the virtual machines in the pool.
 * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
 * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
 * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
 * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
 * information, see Azure Guest OS Releases
 * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
 *
 * @param {string}
 * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
 * Azure Guest OS version to be installed on the virtual machines in the pool.
 * The default value is * which specifies the latest operating system version
 * for the specified OS family.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
 * machine configuration for the pool. This property and
 * cloudServiceConfiguration are mutually exclusive and one of the properties
 * must be specified.
 *
 * @param {object}
 * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
 * A reference to the Azure Virtual Machines Marketplace Image or the custom
 * Virtual Machine Image to use.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
 * The publisher of the Azure Virtual Machines Marketplace image. For example,
 * Canonical or MicrosoftWindowsServer.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
 * The offer type of the Azure Virtual Machines Marketplace image. For example,
 * UbuntuServer or WindowsServer.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
 * The SKU of the Azure Virtual Machines Marketplace image. For example,
 * 18.04-LTS or 2019-Datacenter.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
 * The version of the Azure Virtual Machines Marketplace image. A value of
 * 'latest' can be specified to select the latest version of an image. If
 * omitted, the default is 'latest'.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
 * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
 * in the Pool will be created using this Image Id. This is of the form
 * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
 * This property is mutually exclusive with other properties. The Shared Image
 * Gallery image must have replicas in the same region as the Azure Batch
 * account. 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.
 *
 * @param {string}
 * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
 * The SKU of the Batch node agent to be provisioned on compute nodes in the
 * pool. The Batch node agent is a program that runs on each node in the pool,
 * and provides the command-and-control interface between the node and the
 * Batch service. There are different implementations of the node agent, known
 * as SKUs, for different operating systems. You must specify a node agent SKU
 * which matches the selected image reference. To get the list of supported
 * node agent SKUs along with their list of verified image references, see the
 * 'List supported node agent SKUs' operation.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
 * Windows operating system settings on the virtual machine. This property must
 * not be specified if the imageReference specifies a Linux OS image.
 *
 * @param {boolean}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
 * Whether automatic updates are enabled on the virtual machine. If omitted,
 * the default value is true.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
 * The configuration for data disks attached to the compute nodes in the pool.
 * This property must be specified if the compute nodes in the pool need to
 * have empty data disks attached to them.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
 * The type of on-premises license to be used when deploying the operating
 * system. This only applies to images that contain the Windows operating
 * system, and should only be used when you hold valid on-premises licenses for
 * the nodes which will be deployed. If omitted, no on-premises licensing
 * discount is applied. Values are:
 *
 * Windows_Server - The on-premises license is for Windows Server.
 * Windows_Client - The on-premises license is for Windows Client.
 *
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
 * The container configuration for the pool. If specified, setup is performed
 * on each node in the pool to allow tasks to run in containers. All regular
 * tasks and job manager tasks run on this pool must specify the
 * containerSettings property, and all other tasks may specify it.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
 * The collection of container image names. This is the full image reference,
 * as would be specified to "docker pull". An image will be sourced from the
 * default Docker registry unless the image is fully qualified with an
 * alternative registry.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
 * Additional private registries from which containers can be pulled. If any
 * images must be downloaded from a private registry which requires
 * credentials, then those credentials must be provided here.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
 * The disk encryption configuration for the pool. If specified, encryption is
 * performed on each node in the pool during node provisioning.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
 * The list of disk targets Batch Service will encrypt on the compute node On
 * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
 * "TemporaryDisk" must be specified.
 *
 * @param {object} [parameters.scaleSettings] Settings which configure the
 * number of nodes in the pool.
 *
 * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
 * for the pool. This property and autoScale are mutually exclusive and one of
 * the properties must be specified.
 *
 * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
 * The timeout for allocation of compute nodes to the pool. The default value
 * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
 * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
 * than 5 minutes, the Batch service rejects the request with an error; if you
 * are calling the REST API directly, the HTTP status code is 400 (Bad
 * Request).
 *
 * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
 * The desired number of dedicated compute nodes in the pool. At least one of
 * targetDedicatedNodes, targetLowPriorityNodes must be set.
 *
 * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
 * The desired number of low-priority compute nodes in the pool. At least one
 * of targetDedicatedNodes, targetLowPriorityNodes must be set.
 *
 * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
 * Determines what to do with a node and its running task(s) if the pool size
 * is decreasing. If omitted, the default value is Requeue. Possible values
 * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
 *
 * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
 * the pool. This property and fixedScale are mutually exclusive and one of the
 * properties must be specified.
 *
 * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
 * desired number of compute nodes in the pool.
 *
 * @param {moment.duration}
 * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
 * which to automatically adjust the pool size according to the autoscale
 * formula. If omitted, the default value is 15 minutes (PT15M).
 *
 * @param {string} [parameters.interNodeCommunication] Whether the pool permits
 * direct communication between nodes. This imposes restrictions on which nodes
 * can be assigned to the pool. Enabling this value can reduce the chance of
 * the requested number of nodes to be allocated in the pool. If not specified,
 * this value defaults to 'Disabled'. Possible values include: 'Enabled',
 * 'Disabled'
 *
 * @param {object} [parameters.networkConfiguration] The network configuration
 * for the pool.
 *
 * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
 * identifier of the virtual network subnet which the compute nodes of the pool
 * will join. This is of the form
 * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
 * The virtual network must be in the same region and subscription as the Azure
 * Batch account. The specified subnet should have enough free IP addresses to
 * accommodate the number of nodes in the pool. If the subnet doesn't have
 * enough free IP addresses, the pool will partially allocate compute nodes and
 * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
 * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
 * (RBAC) role for the specified VNet. The specified subnet must allow
 * communication from the Azure Batch service to be able to schedule tasks on
 * the compute nodes. This can be verified by checking if the specified VNet
 * has any associated Network Security Groups (NSG). If communication to the
 * compute nodes in the specified subnet is denied by an NSG, then the Batch
 * service will set the state of the compute nodes to unusable. If the
 * specified VNet has any associated Network Security Groups (NSG), then a few
 * reserved system ports must be enabled for inbound communication. For pools
 * created with a virtual machine configuration, enable ports 29876 and 29877,
 * as well as port 22 for Linux and port 3389 for Windows. For pools created
 * with a cloud service configuration, enable ports 10100, 20100, and 30100.
 * Also enable outbound connections to Azure Storage on port 443. For
 * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
 * more details see:
 * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
 *
 * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
 * configuration for endpoints on compute nodes in the Batch pool. Pool
 * endpoint configuration is only supported on pools with the
 * virtualMachineConfiguration property.
 *
 * @param {array}
 * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
 * of inbound NAT pools that can be used to address specific ports on an
 * individual compute node externally. The maximum number of inbound NAT pools
 * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
 * the request fails with HTTP status code 400.
 *
 * @param {object}
 * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
 * IPAddress configuration for Compute Nodes in the Batch Pool. This property
 * is only supported on Pools with the virtualMachineConfiguration property.
 *
 * @param {string}
 * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
 * provisioning type for Public IP Addresses for the pool The default value is
 * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
 * 'NoPublicIPAddresses'
 *
 * @param {array}
 * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
 * The list of public IPs which the Batch service will use when provisioning
 * Compute Nodes. The number of IPs specified here limits the maximum size of
 * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
 * each public IP. For example, a pool needing 150 dedicated VMs would need at
 * least 3 public IPs specified. Each element of this collection is of the
 * form:
 * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
 *
 * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
 * that can run concurrently on a single compute node in the pool. The default
 * value is 1. The maximum value is the smaller of 4 times the number of cores
 * of the vmSize of the pool or 256.
 *
 * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
 * across compute nodes in a pool. If not specified, the default is spread.
 *
 * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
 * should be distributed across compute nodes. Possible values include:
 * 'Spread', 'Pack'
 *
 * @param {array} [parameters.userAccounts] The list of user accounts to be
 * created on each node in the pool.
 *
 * @param {array} [parameters.metadata] A list of name-value pairs associated
 * with the pool as metadata. The Batch service does not assign any meaning to
 * metadata; it is solely for the use of user code.
 *
 * @param {object} [parameters.startTask] A task specified to run on each
 * compute node as it joins the pool. In an PATCH (update) operation, this
 * property can be set to an empty object to remove the start task from the
 * pool.
 *
 * @param {string} [parameters.startTask.commandLine] The command line of the
 * start task. The command line does not run under a shell, and therefore
 * cannot take advantage of shell features such as environment variable
 * expansion. If you want to take advantage of such features, you should invoke
 * the shell in the command line, for example using "cmd /c MyCommand" in
 * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
 * of the startTask are specified.
 *
 * @param {array} [parameters.startTask.resourceFiles] A list of files that the
 * Batch service will download to the compute node before running the command
 * line.
 *
 * @param {array} [parameters.startTask.environmentSettings] A list of
 * environment variable settings for the start task.
 *
 * @param {object} [parameters.startTask.userIdentity] The user identity under
 * which the start task runs. If omitted, the task runs as a non-administrative
 * user unique to the task.
 *
 * @param {string} [parameters.startTask.userIdentity.userName] The name of the
 * user identity under which the task is run. The userName and autoUser
 * properties are mutually exclusive; you must specify one but not both.
 *
 * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
 * under which the task is run. The userName and autoUser properties are
 * mutually exclusive; you must specify one but not both.
 *
 * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
 * for the auto user The default value is Pool. If the pool is running Windows
 * a value of Task should be specified if stricter isolation between tasks is
 * required. For example, if the task mutates the registry in a way which could
 * impact other tasks, or if certificates have been specified on the pool which
 * should not be accessible by normal tasks but should be accessible by start
 * tasks. Possible values include: 'Task', 'Pool'
 *
 * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
 * The elevation level of the auto user. The default value is nonAdmin.
 * Possible values include: 'NonAdmin', 'Admin'
 *
 * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
 * of times the task may be retried. The Batch service retries a task if its
 * exit code is nonzero. Note that this value specifically controls the number
 * of retries. The Batch service will try the task once, and may then retry up
 * to this limit. For example, if the maximum retry count is 3, Batch tries the
 * task up to 4 times (one initial try and 3 retries). If the maximum retry
 * count is 0, the Batch service does not retry the task. If the maximum retry
 * count is -1, the Batch service retries the task without limit.
 *
 * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
 * service should wait for the start task to complete successfully (that is, to
 * exit with exit code 0) before scheduling any tasks on the compute node. If
 * true and the start task fails on a compute node, the Batch service retries
 * the start task up to its maximum retry count (maxTaskRetryCount). If the
 * task has still not completed successfully after all retries, then the Batch
 * service marks the compute node unusable, and will not schedule tasks to it.
 * This condition can be detected via the node state and scheduling error
 * detail. If false, the Batch service will not wait for the start task to
 * complete. In this case, other tasks can start executing on the compute node
 * while the start task is still running; and even if the start task fails, new
 * tasks will continue to be scheduled on the node. The default is true.
 *
 * @param {object} [parameters.startTask.containerSettings] The settings for
 * the container under which the start task runs. When this is specified, all
 * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
 * Batch directories on the node) are mapped into the container, all task
 * environment variables are mapped into the container, and the task command
 * line is executed in the container.
 *
 * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
 * Additional options to the container create command. These additional options
 * are supplied as arguments to the "docker create" command, in addition to
 * those controlled by the Batch Service.
 *
 * @param {string} parameters.startTask.containerSettings.imageName The image
 * to use to create the container in which the task will run. This is the full
 * image reference, as would be specified to "docker pull". If no tag is
 * provided as part of the image name, the tag ":latest" is used as a default.
 *
 * @param {object} [parameters.startTask.containerSettings.registry] The
 * private registry which contains the container image. This setting can be
 * omitted if was already provided at pool creation.
 *
 * @param {string}
 * [parameters.startTask.containerSettings.registry.registryServer] The
 * registry URL. If omitted, the default is "docker.io".
 *
 * @param {string} parameters.startTask.containerSettings.registry.userName The
 * user name to log into the registry server.
 *
 * @param {string} parameters.startTask.containerSettings.registry.password The
 * password to log into the registry server.
 *
 * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
 * flag to indicate where the container task working directory is. The default
 * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
 * 'ContainerImageDefault'
 *
 * @param {array} [parameters.certificates] The list of certificates to be
 * installed on each compute node in the pool. For Windows compute nodes, the
 * Batch service installs the certificates to the specified certificate store
 * and location. For Linux compute nodes, the certificates are stored in a
 * directory inside the task working directory and an environment variable
 * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
 * location. For certificates with visibility of 'remoteUser', a 'certs'
 * directory is created in the user's home directory (e.g.,
 * /home/{user-name}/certs) and certificates are placed in that directory.
 *
 * @param {array} [parameters.applicationPackages] The list of application
 * packages to be installed on each compute node in the pool. Changes to
 * application package references affect all new compute nodes joining the
 * pool, but do not affect compute nodes that are already in the pool until
 * they are rebooted or reimaged. There is a maximum of 10 application package
 * references on any given pool.
 *
 * @param {array} [parameters.applicationLicenses] The list of application
 * licenses the Batch service will make available on each compute node in the
 * pool. The list of application licenses must be a subset of available Batch
 * service application licenses. If a license is requested which is not
 * supported, pool creation will fail.
 *
 * @param {array} [parameters.mountConfiguration] A list of file systems to
 * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
 * and Blobfuse.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] The entity state (ETag) version of the
 * pool to update. A value of "*" can be used to apply the operation only if
 * the pool already exists. If omitted, this operation will always be applied.
 *
 * @param {string} [options.ifNoneMatch] Set to '*' to allow a new pool to be
 * created, but to prevent updating an existing pool. Other values will be
 * ignored.
 *
 * @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 Pool} 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, accountName, poolName, 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, accountName, poolName, 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['Pool']().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 the properties of an existing pool.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @param {object} parameters Pool properties that should be updated.
 * Properties that are supplied will be updated, any property not supplied will
 * be unchanged.
 *
 * @param {string} [parameters.displayName] The display name for the pool. The
 * display name need not be unique and can contain any Unicode characters up to
 * a maximum length of 1024.
 *
 * @param {string} [parameters.vmSize] The size of virtual machines in the
 * pool. All VMs in a pool are the same size. For information about available
 * sizes of virtual machines for Cloud Services pools (pools created with
 * cloudServiceConfiguration), see Sizes for Cloud Services
 * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
 * Batch supports all Cloud Services VM sizes except ExtraSmall. For
 * information about available VM sizes for pools using images from the Virtual
 * Machines Marketplace (pools created with virtualMachineConfiguration) see
 * Sizes for Virtual Machines (Linux)
 * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
 * or Sizes for Virtual Machines (Windows)
 * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
 * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
 * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
 *
 * @param {object} [parameters.deploymentConfiguration] This property describes
 * how the pool nodes will be deployed - using Cloud Services or Virtual
 * Machines. Using CloudServiceConfiguration specifies that the nodes should be
 * creating using Azure Cloud Services (PaaS), while
 * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
 *
 * @param {object}
 * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
 * service configuration for the pool. This property and
 * virtualMachineConfiguration are mutually exclusive and one of the properties
 * must be specified. This property cannot be specified if the Batch account
 * was created with its poolAllocationMode property set to 'UserSubscription'.
 *
 * @param {string}
 * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
 * Azure Guest OS family to be installed on the virtual machines in the pool.
 * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
 * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
 * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
 * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
 * information, see Azure Guest OS Releases
 * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
 *
 * @param {string}
 * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
 * Azure Guest OS version to be installed on the virtual machines in the pool.
 * The default value is * which specifies the latest operating system version
 * for the specified OS family.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
 * machine configuration for the pool. This property and
 * cloudServiceConfiguration are mutually exclusive and one of the properties
 * must be specified.
 *
 * @param {object}
 * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
 * A reference to the Azure Virtual Machines Marketplace Image or the custom
 * Virtual Machine Image to use.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
 * The publisher of the Azure Virtual Machines Marketplace image. For example,
 * Canonical or MicrosoftWindowsServer.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
 * The offer type of the Azure Virtual Machines Marketplace image. For example,
 * UbuntuServer or WindowsServer.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
 * The SKU of the Azure Virtual Machines Marketplace image. For example,
 * 18.04-LTS or 2019-Datacenter.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
 * The version of the Azure Virtual Machines Marketplace image. A value of
 * 'latest' can be specified to select the latest version of an image. If
 * omitted, the default is 'latest'.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
 * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
 * in the Pool will be created using this Image Id. This is of the form
 * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
 * This property is mutually exclusive with other properties. The Shared Image
 * Gallery image must have replicas in the same region as the Azure Batch
 * account. 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.
 *
 * @param {string}
 * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
 * The SKU of the Batch node agent to be provisioned on compute nodes in the
 * pool. The Batch node agent is a program that runs on each node in the pool,
 * and provides the command-and-control interface between the node and the
 * Batch service. There are different implementations of the node agent, known
 * as SKUs, for different operating systems. You must specify a node agent SKU
 * which matches the selected image reference. To get the list of supported
 * node agent SKUs along with their list of verified image references, see the
 * 'List supported node agent SKUs' operation.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
 * Windows operating system settings on the virtual machine. This property must
 * not be specified if the imageReference specifies a Linux OS image.
 *
 * @param {boolean}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
 * Whether automatic updates are enabled on the virtual machine. If omitted,
 * the default value is true.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
 * The configuration for data disks attached to the compute nodes in the pool.
 * This property must be specified if the compute nodes in the pool need to
 * have empty data disks attached to them.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
 * The type of on-premises license to be used when deploying the operating
 * system. This only applies to images that contain the Windows operating
 * system, and should only be used when you hold valid on-premises licenses for
 * the nodes which will be deployed. If omitted, no on-premises licensing
 * discount is applied. Values are:
 *
 * Windows_Server - The on-premises license is for Windows Server.
 * Windows_Client - The on-premises license is for Windows Client.
 *
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
 * The container configuration for the pool. If specified, setup is performed
 * on each node in the pool to allow tasks to run in containers. All regular
 * tasks and job manager tasks run on this pool must specify the
 * containerSettings property, and all other tasks may specify it.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
 * The collection of container image names. This is the full image reference,
 * as would be specified to "docker pull". An image will be sourced from the
 * default Docker registry unless the image is fully qualified with an
 * alternative registry.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
 * Additional private registries from which containers can be pulled. If any
 * images must be downloaded from a private registry which requires
 * credentials, then those credentials must be provided here.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
 * The disk encryption configuration for the pool. If specified, encryption is
 * performed on each node in the pool during node provisioning.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
 * The list of disk targets Batch Service will encrypt on the compute node On
 * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
 * "TemporaryDisk" must be specified.
 *
 * @param {object} [parameters.scaleSettings] Settings which configure the
 * number of nodes in the pool.
 *
 * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
 * for the pool. This property and autoScale are mutually exclusive and one of
 * the properties must be specified.
 *
 * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
 * The timeout for allocation of compute nodes to the pool. The default value
 * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
 * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
 * than 5 minutes, the Batch service rejects the request with an error; if you
 * are calling the REST API directly, the HTTP status code is 400 (Bad
 * Request).
 *
 * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
 * The desired number of dedicated compute nodes in the pool. At least one of
 * targetDedicatedNodes, targetLowPriorityNodes must be set.
 *
 * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
 * The desired number of low-priority compute nodes in the pool. At least one
 * of targetDedicatedNodes, targetLowPriorityNodes must be set.
 *
 * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
 * Determines what to do with a node and its running task(s) if the pool size
 * is decreasing. If omitted, the default value is Requeue. Possible values
 * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
 *
 * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
 * the pool. This property and fixedScale are mutually exclusive and one of the
 * properties must be specified.
 *
 * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
 * desired number of compute nodes in the pool.
 *
 * @param {moment.duration}
 * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
 * which to automatically adjust the pool size according to the autoscale
 * formula. If omitted, the default value is 15 minutes (PT15M).
 *
 * @param {string} [parameters.interNodeCommunication] Whether the pool permits
 * direct communication between nodes. This imposes restrictions on which nodes
 * can be assigned to the pool. Enabling this value can reduce the chance of
 * the requested number of nodes to be allocated in the pool. If not specified,
 * this value defaults to 'Disabled'. Possible values include: 'Enabled',
 * 'Disabled'
 *
 * @param {object} [parameters.networkConfiguration] The network configuration
 * for the pool.
 *
 * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
 * identifier of the virtual network subnet which the compute nodes of the pool
 * will join. This is of the form
 * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
 * The virtual network must be in the same region and subscription as the Azure
 * Batch account. The specified subnet should have enough free IP addresses to
 * accommodate the number of nodes in the pool. If the subnet doesn't have
 * enough free IP addresses, the pool will partially allocate compute nodes and
 * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
 * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
 * (RBAC) role for the specified VNet. The specified subnet must allow
 * communication from the Azure Batch service to be able to schedule tasks on
 * the compute nodes. This can be verified by checking if the specified VNet
 * has any associated Network Security Groups (NSG). If communication to the
 * compute nodes in the specified subnet is denied by an NSG, then the Batch
 * service will set the state of the compute nodes to unusable. If the
 * specified VNet has any associated Network Security Groups (NSG), then a few
 * reserved system ports must be enabled for inbound communication. For pools
 * created with a virtual machine configuration, enable ports 29876 and 29877,
 * as well as port 22 for Linux and port 3389 for Windows. For pools created
 * with a cloud service configuration, enable ports 10100, 20100, and 30100.
 * Also enable outbound connections to Azure Storage on port 443. For
 * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
 * more details see:
 * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
 *
 * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
 * configuration for endpoints on compute nodes in the Batch pool. Pool
 * endpoint configuration is only supported on pools with the
 * virtualMachineConfiguration property.
 *
 * @param {array}
 * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
 * of inbound NAT pools that can be used to address specific ports on an
 * individual compute node externally. The maximum number of inbound NAT pools
 * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
 * the request fails with HTTP status code 400.
 *
 * @param {object}
 * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
 * IPAddress configuration for Compute Nodes in the Batch Pool. This property
 * is only supported on Pools with the virtualMachineConfiguration property.
 *
 * @param {string}
 * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
 * provisioning type for Public IP Addresses for the pool The default value is
 * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
 * 'NoPublicIPAddresses'
 *
 * @param {array}
 * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
 * The list of public IPs which the Batch service will use when provisioning
 * Compute Nodes. The number of IPs specified here limits the maximum size of
 * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
 * each public IP. For example, a pool needing 150 dedicated VMs would need at
 * least 3 public IPs specified. Each element of this collection is of the
 * form:
 * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
 *
 * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
 * that can run concurrently on a single compute node in the pool. The default
 * value is 1. The maximum value is the smaller of 4 times the number of cores
 * of the vmSize of the pool or 256.
 *
 * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
 * across compute nodes in a pool. If not specified, the default is spread.
 *
 * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
 * should be distributed across compute nodes. Possible values include:
 * 'Spread', 'Pack'
 *
 * @param {array} [parameters.userAccounts] The list of user accounts to be
 * created on each node in the pool.
 *
 * @param {array} [parameters.metadata] A list of name-value pairs associated
 * with the pool as metadata. The Batch service does not assign any meaning to
 * metadata; it is solely for the use of user code.
 *
 * @param {object} [parameters.startTask] A task specified to run on each
 * compute node as it joins the pool. In an PATCH (update) operation, this
 * property can be set to an empty object to remove the start task from the
 * pool.
 *
 * @param {string} [parameters.startTask.commandLine] The command line of the
 * start task. The command line does not run under a shell, and therefore
 * cannot take advantage of shell features such as environment variable
 * expansion. If you want to take advantage of such features, you should invoke
 * the shell in the command line, for example using "cmd /c MyCommand" in
 * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
 * of the startTask are specified.
 *
 * @param {array} [parameters.startTask.resourceFiles] A list of files that the
 * Batch service will download to the compute node before running the command
 * line.
 *
 * @param {array} [parameters.startTask.environmentSettings] A list of
 * environment variable settings for the start task.
 *
 * @param {object} [parameters.startTask.userIdentity] The user identity under
 * which the start task runs. If omitted, the task runs as a non-administrative
 * user unique to the task.
 *
 * @param {string} [parameters.startTask.userIdentity.userName] The name of the
 * user identity under which the task is run. The userName and autoUser
 * properties are mutually exclusive; you must specify one but not both.
 *
 * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
 * under which the task is run. The userName and autoUser properties are
 * mutually exclusive; you must specify one but not both.
 *
 * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
 * for the auto user The default value is Pool. If the pool is running Windows
 * a value of Task should be specified if stricter isolation between tasks is
 * required. For example, if the task mutates the registry in a way which could
 * impact other tasks, or if certificates have been specified on the pool which
 * should not be accessible by normal tasks but should be accessible by start
 * tasks. Possible values include: 'Task', 'Pool'
 *
 * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
 * The elevation level of the auto user. The default value is nonAdmin.
 * Possible values include: 'NonAdmin', 'Admin'
 *
 * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
 * of times the task may be retried. The Batch service retries a task if its
 * exit code is nonzero. Note that this value specifically controls the number
 * of retries. The Batch service will try the task once, and may then retry up
 * to this limit. For example, if the maximum retry count is 3, Batch tries the
 * task up to 4 times (one initial try and 3 retries). If the maximum retry
 * count is 0, the Batch service does not retry the task. If the maximum retry
 * count is -1, the Batch service retries the task without limit.
 *
 * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
 * service should wait for the start task to complete successfully (that is, to
 * exit with exit code 0) before scheduling any tasks on the compute node. If
 * true and the start task fails on a compute node, the Batch service retries
 * the start task up to its maximum retry count (maxTaskRetryCount). If the
 * task has still not completed successfully after all retries, then the Batch
 * service marks the compute node unusable, and will not schedule tasks to it.
 * This condition can be detected via the node state and scheduling error
 * detail. If false, the Batch service will not wait for the start task to
 * complete. In this case, other tasks can start executing on the compute node
 * while the start task is still running; and even if the start task fails, new
 * tasks will continue to be scheduled on the node. The default is true.
 *
 * @param {object} [parameters.startTask.containerSettings] The settings for
 * the container under which the start task runs. When this is specified, all
 * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
 * Batch directories on the node) are mapped into the container, all task
 * environment variables are mapped into the container, and the task command
 * line is executed in the container.
 *
 * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
 * Additional options to the container create command. These additional options
 * are supplied as arguments to the "docker create" command, in addition to
 * those controlled by the Batch Service.
 *
 * @param {string} parameters.startTask.containerSettings.imageName The image
 * to use to create the container in which the task will run. This is the full
 * image reference, as would be specified to "docker pull". If no tag is
 * provided as part of the image name, the tag ":latest" is used as a default.
 *
 * @param {object} [parameters.startTask.containerSettings.registry] The
 * private registry which contains the container image. This setting can be
 * omitted if was already provided at pool creation.
 *
 * @param {string}
 * [parameters.startTask.containerSettings.registry.registryServer] The
 * registry URL. If omitted, the default is "docker.io".
 *
 * @param {string} parameters.startTask.containerSettings.registry.userName The
 * user name to log into the registry server.
 *
 * @param {string} parameters.startTask.containerSettings.registry.password The
 * password to log into the registry server.
 *
 * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
 * flag to indicate where the container task working directory is. The default
 * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
 * 'ContainerImageDefault'
 *
 * @param {array} [parameters.certificates] The list of certificates to be
 * installed on each compute node in the pool. For Windows compute nodes, the
 * Batch service installs the certificates to the specified certificate store
 * and location. For Linux compute nodes, the certificates are stored in a
 * directory inside the task working directory and an environment variable
 * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
 * location. For certificates with visibility of 'remoteUser', a 'certs'
 * directory is created in the user's home directory (e.g.,
 * /home/{user-name}/certs) and certificates are placed in that directory.
 *
 * @param {array} [parameters.applicationPackages] The list of application
 * packages to be installed on each compute node in the pool. Changes to
 * application package references affect all new compute nodes joining the
 * pool, but do not affect compute nodes that are already in the pool until
 * they are rebooted or reimaged. There is a maximum of 10 application package
 * references on any given pool.
 *
 * @param {array} [parameters.applicationLicenses] The list of application
 * licenses the Batch service will make available on each compute node in the
 * pool. The list of application licenses must be a subset of available Batch
 * service application licenses. If a license is requested which is not
 * supported, pool creation will fail.
 *
 * @param {array} [parameters.mountConfiguration] A list of file systems to
 * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
 * and Blobfuse.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] The entity state (ETag) version of the
 * pool to update. This value can be omitted or set to "*" to apply the
 * operation unconditionally.
 *
 * @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 Pool} 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, accountName, poolName, 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.');
  }
  let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined;
  if (parameters === null || parameters === undefined)
  {
    parameters = {};
  }
  // 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (poolName === null || poolName === undefined || typeof poolName.valueOf() !== 'string') {
      throw new Error('poolName cannot be null or undefined and it must be of type string.');
    }
    if (poolName !== null && poolName !== undefined) {
      if (poolName.length > 64)
      {
        throw new Error('"poolName" should satisfy the constraint - "MaxLength": 64');
      }
      if (poolName.length < 1)
      {
        throw new Error('"poolName" should satisfy the constraint - "MinLength": 1');
      }
      if (poolName.match(/^[a-zA-Z0-9_-]+$/) === null)
      {
        throw new Error('"poolName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_-]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
      throw new Error('ifMatch must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.Batch/batchAccounts/{accountName}/pools/{poolName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{poolName}', encodeURIComponent(poolName));
  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 (ifMatch !== undefined && ifMatch !== null) {
    httpRequest.headers['If-Match'] = ifMatch;
  }
  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['Pool']().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['Pool']().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 the specified pool.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @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, accountName, poolName, 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, accountName, poolName, 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 the specified pool.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @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 Pool} 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, accountName, poolName, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (poolName === null || poolName === undefined || typeof poolName.valueOf() !== 'string') {
      throw new Error('poolName cannot be null or undefined and it must be of type string.');
    }
    if (poolName !== null && poolName !== undefined) {
      if (poolName.length > 64)
      {
        throw new Error('"poolName" should satisfy the constraint - "MaxLength": 64');
      }
      if (poolName.length < 1)
      {
        throw new Error('"poolName" should satisfy the constraint - "MinLength": 1');
      }
      if (poolName.match(/^[a-zA-Z0-9_-]+$/) === null)
      {
        throw new Error('"poolName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_-]+$/');
      }
    }
    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.Batch/batchAccounts/{accountName}/pools/{poolName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{poolName}', encodeURIComponent(poolName));
  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['Pool']().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);
  });
}

/**
 * Disables automatic scaling for a pool.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @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 Pool} 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 _disableAutoScale(resourceGroupName, accountName, poolName, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (poolName === null || poolName === undefined || typeof poolName.valueOf() !== 'string') {
      throw new Error('poolName cannot be null or undefined and it must be of type string.');
    }
    if (poolName !== null && poolName !== undefined) {
      if (poolName.length > 64)
      {
        throw new Error('"poolName" should satisfy the constraint - "MaxLength": 64');
      }
      if (poolName.length < 1)
      {
        throw new Error('"poolName" should satisfy the constraint - "MinLength": 1');
      }
      if (poolName.match(/^[a-zA-Z0-9_-]+$/) === null)
      {
        throw new Error('"poolName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_-]+$/');
      }
    }
    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.Batch/batchAccounts/{accountName}/pools/{poolName}/disableAutoScale';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{poolName}', encodeURIComponent(poolName));
  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['Pool']().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);
  });
}

/**
 * @summary Stops an ongoing resize operation on the pool.
 *
 * This does not restore the pool to its previous state before the resize
 * operation: it only stops any further changes being made, and the pool
 * maintains its current state. After stopping, the pool stabilizes at the
 * number of nodes it was at when the stop operation was done. During the stop
 * operation, the pool allocation state changes first to stopping and then to
 * steady. A resize operation need not be an explicit resize pool request; this
 * API can also be used to halt the initial sizing of the pool when it is
 * created.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @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 Pool} 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 _stopResize(resourceGroupName, accountName, poolName, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (poolName === null || poolName === undefined || typeof poolName.valueOf() !== 'string') {
      throw new Error('poolName cannot be null or undefined and it must be of type string.');
    }
    if (poolName !== null && poolName !== undefined) {
      if (poolName.length > 64)
      {
        throw new Error('"poolName" should satisfy the constraint - "MaxLength": 64');
      }
      if (poolName.length < 1)
      {
        throw new Error('"poolName" should satisfy the constraint - "MinLength": 1');
      }
      if (poolName.match(/^[a-zA-Z0-9_-]+$/) === null)
      {
        throw new Error('"poolName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_-]+$/');
      }
    }
    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.Batch/batchAccounts/{accountName}/pools/{poolName}/stopResize';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{poolName}', encodeURIComponent(poolName));
  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['Pool']().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 new pool inside the specified account.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @param {object} parameters Additional parameters for pool creation.
 *
 * @param {string} [parameters.displayName] The display name for the pool. The
 * display name need not be unique and can contain any Unicode characters up to
 * a maximum length of 1024.
 *
 * @param {string} [parameters.vmSize] The size of virtual machines in the
 * pool. All VMs in a pool are the same size. For information about available
 * sizes of virtual machines for Cloud Services pools (pools created with
 * cloudServiceConfiguration), see Sizes for Cloud Services
 * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
 * Batch supports all Cloud Services VM sizes except ExtraSmall. For
 * information about available VM sizes for pools using images from the Virtual
 * Machines Marketplace (pools created with virtualMachineConfiguration) see
 * Sizes for Virtual Machines (Linux)
 * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
 * or Sizes for Virtual Machines (Windows)
 * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
 * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
 * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
 *
 * @param {object} [parameters.deploymentConfiguration] This property describes
 * how the pool nodes will be deployed - using Cloud Services or Virtual
 * Machines. Using CloudServiceConfiguration specifies that the nodes should be
 * creating using Azure Cloud Services (PaaS), while
 * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
 *
 * @param {object}
 * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
 * service configuration for the pool. This property and
 * virtualMachineConfiguration are mutually exclusive and one of the properties
 * must be specified. This property cannot be specified if the Batch account
 * was created with its poolAllocationMode property set to 'UserSubscription'.
 *
 * @param {string}
 * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
 * Azure Guest OS family to be installed on the virtual machines in the pool.
 * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
 * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
 * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
 * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
 * information, see Azure Guest OS Releases
 * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
 *
 * @param {string}
 * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
 * Azure Guest OS version to be installed on the virtual machines in the pool.
 * The default value is * which specifies the latest operating system version
 * for the specified OS family.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
 * machine configuration for the pool. This property and
 * cloudServiceConfiguration are mutually exclusive and one of the properties
 * must be specified.
 *
 * @param {object}
 * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
 * A reference to the Azure Virtual Machines Marketplace Image or the custom
 * Virtual Machine Image to use.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
 * The publisher of the Azure Virtual Machines Marketplace image. For example,
 * Canonical or MicrosoftWindowsServer.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
 * The offer type of the Azure Virtual Machines Marketplace image. For example,
 * UbuntuServer or WindowsServer.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
 * The SKU of the Azure Virtual Machines Marketplace image. For example,
 * 18.04-LTS or 2019-Datacenter.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
 * The version of the Azure Virtual Machines Marketplace image. A value of
 * 'latest' can be specified to select the latest version of an image. If
 * omitted, the default is 'latest'.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
 * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
 * in the Pool will be created using this Image Id. This is of the form
 * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
 * This property is mutually exclusive with other properties. The Shared Image
 * Gallery image must have replicas in the same region as the Azure Batch
 * account. 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.
 *
 * @param {string}
 * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
 * The SKU of the Batch node agent to be provisioned on compute nodes in the
 * pool. The Batch node agent is a program that runs on each node in the pool,
 * and provides the command-and-control interface between the node and the
 * Batch service. There are different implementations of the node agent, known
 * as SKUs, for different operating systems. You must specify a node agent SKU
 * which matches the selected image reference. To get the list of supported
 * node agent SKUs along with their list of verified image references, see the
 * 'List supported node agent SKUs' operation.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
 * Windows operating system settings on the virtual machine. This property must
 * not be specified if the imageReference specifies a Linux OS image.
 *
 * @param {boolean}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
 * Whether automatic updates are enabled on the virtual machine. If omitted,
 * the default value is true.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
 * The configuration for data disks attached to the compute nodes in the pool.
 * This property must be specified if the compute nodes in the pool need to
 * have empty data disks attached to them.
 *
 * @param {string}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
 * The type of on-premises license to be used when deploying the operating
 * system. This only applies to images that contain the Windows operating
 * system, and should only be used when you hold valid on-premises licenses for
 * the nodes which will be deployed. If omitted, no on-premises licensing
 * discount is applied. Values are:
 *
 * Windows_Server - The on-premises license is for Windows Server.
 * Windows_Client - The on-premises license is for Windows Client.
 *
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
 * The container configuration for the pool. If specified, setup is performed
 * on each node in the pool to allow tasks to run in containers. All regular
 * tasks and job manager tasks run on this pool must specify the
 * containerSettings property, and all other tasks may specify it.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
 * The collection of container image names. This is the full image reference,
 * as would be specified to "docker pull". An image will be sourced from the
 * default Docker registry unless the image is fully qualified with an
 * alternative registry.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
 * Additional private registries from which containers can be pulled. If any
 * images must be downloaded from a private registry which requires
 * credentials, then those credentials must be provided here.
 *
 * @param {object}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
 * The disk encryption configuration for the pool. If specified, encryption is
 * performed on each node in the pool during node provisioning.
 *
 * @param {array}
 * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
 * The list of disk targets Batch Service will encrypt on the compute node On
 * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
 * "TemporaryDisk" must be specified.
 *
 * @param {object} [parameters.scaleSettings] Settings which configure the
 * number of nodes in the pool.
 *
 * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
 * for the pool. This property and autoScale are mutually exclusive and one of
 * the properties must be specified.
 *
 * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
 * The timeout for allocation of compute nodes to the pool. The default value
 * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
 * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
 * than 5 minutes, the Batch service rejects the request with an error; if you
 * are calling the REST API directly, the HTTP status code is 400 (Bad
 * Request).
 *
 * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
 * The desired number of dedicated compute nodes in the pool. At least one of
 * targetDedicatedNodes, targetLowPriorityNodes must be set.
 *
 * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
 * The desired number of low-priority compute nodes in the pool. At least one
 * of targetDedicatedNodes, targetLowPriorityNodes must be set.
 *
 * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
 * Determines what to do with a node and its running task(s) if the pool size
 * is decreasing. If omitted, the default value is Requeue. Possible values
 * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
 *
 * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
 * the pool. This property and fixedScale are mutually exclusive and one of the
 * properties must be specified.
 *
 * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
 * desired number of compute nodes in the pool.
 *
 * @param {moment.duration}
 * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
 * which to automatically adjust the pool size according to the autoscale
 * formula. If omitted, the default value is 15 minutes (PT15M).
 *
 * @param {string} [parameters.interNodeCommunication] Whether the pool permits
 * direct communication between nodes. This imposes restrictions on which nodes
 * can be assigned to the pool. Enabling this value can reduce the chance of
 * the requested number of nodes to be allocated in the pool. If not specified,
 * this value defaults to 'Disabled'. Possible values include: 'Enabled',
 * 'Disabled'
 *
 * @param {object} [parameters.networkConfiguration] The network configuration
 * for the pool.
 *
 * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
 * identifier of the virtual network subnet which the compute nodes of the pool
 * will join. This is of the form
 * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
 * The virtual network must be in the same region and subscription as the Azure
 * Batch account. The specified subnet should have enough free IP addresses to
 * accommodate the number of nodes in the pool. If the subnet doesn't have
 * enough free IP addresses, the pool will partially allocate compute nodes and
 * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
 * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
 * (RBAC) role for the specified VNet. The specified subnet must allow
 * communication from the Azure Batch service to be able to schedule tasks on
 * the compute nodes. This can be verified by checking if the specified VNet
 * has any associated Network Security Groups (NSG). If communication to the
 * compute nodes in the specified subnet is denied by an NSG, then the Batch
 * service will set the state of the compute nodes to unusable. If the
 * specified VNet has any associated Network Security Groups (NSG), then a few
 * reserved system ports must be enabled for inbound communication. For pools
 * created with a virtual machine configuration, enable ports 29876 and 29877,
 * as well as port 22 for Linux and port 3389 for Windows. For pools created
 * with a cloud service configuration, enable ports 10100, 20100, and 30100.
 * Also enable outbound connections to Azure Storage on port 443. For
 * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
 * more details see:
 * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
 *
 * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
 * configuration for endpoints on compute nodes in the Batch pool. Pool
 * endpoint configuration is only supported on pools with the
 * virtualMachineConfiguration property.
 *
 * @param {array}
 * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
 * of inbound NAT pools that can be used to address specific ports on an
 * individual compute node externally. The maximum number of inbound NAT pools
 * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
 * the request fails with HTTP status code 400.
 *
 * @param {object}
 * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
 * IPAddress configuration for Compute Nodes in the Batch Pool. This property
 * is only supported on Pools with the virtualMachineConfiguration property.
 *
 * @param {string}
 * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
 * provisioning type for Public IP Addresses for the pool The default value is
 * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
 * 'NoPublicIPAddresses'
 *
 * @param {array}
 * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
 * The list of public IPs which the Batch service will use when provisioning
 * Compute Nodes. The number of IPs specified here limits the maximum size of
 * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
 * each public IP. For example, a pool needing 150 dedicated VMs would need at
 * least 3 public IPs specified. Each element of this collection is of the
 * form:
 * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
 *
 * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
 * that can run concurrently on a single compute node in the pool. The default
 * value is 1. The maximum value is the smaller of 4 times the number of cores
 * of the vmSize of the pool or 256.
 *
 * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
 * across compute nodes in a pool. If not specified, the default is spread.
 *
 * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
 * should be distributed across compute nodes. Possible values include:
 * 'Spread', 'Pack'
 *
 * @param {array} [parameters.userAccounts] The list of user accounts to be
 * created on each node in the pool.
 *
 * @param {array} [parameters.metadata] A list of name-value pairs associated
 * with the pool as metadata. The Batch service does not assign any meaning to
 * metadata; it is solely for the use of user code.
 *
 * @param {object} [parameters.startTask] A task specified to run on each
 * compute node as it joins the pool. In an PATCH (update) operation, this
 * property can be set to an empty object to remove the start task from the
 * pool.
 *
 * @param {string} [parameters.startTask.commandLine] The command line of the
 * start task. The command line does not run under a shell, and therefore
 * cannot take advantage of shell features such as environment variable
 * expansion. If you want to take advantage of such features, you should invoke
 * the shell in the command line, for example using "cmd /c MyCommand" in
 * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
 * of the startTask are specified.
 *
 * @param {array} [parameters.startTask.resourceFiles] A list of files that the
 * Batch service will download to the compute node before running the command
 * line.
 *
 * @param {array} [parameters.startTask.environmentSettings] A list of
 * environment variable settings for the start task.
 *
 * @param {object} [parameters.startTask.userIdentity] The user identity under
 * which the start task runs. If omitted, the task runs as a non-administrative
 * user unique to the task.
 *
 * @param {string} [parameters.startTask.userIdentity.userName] The name of the
 * user identity under which the task is run. The userName and autoUser
 * properties are mutually exclusive; you must specify one but not both.
 *
 * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
 * under which the task is run. The userName and autoUser properties are
 * mutually exclusive; you must specify one but not both.
 *
 * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
 * for the auto user The default value is Pool. If the pool is running Windows
 * a value of Task should be specified if stricter isolation between tasks is
 * required. For example, if the task mutates the registry in a way which could
 * impact other tasks, or if certificates have been specified on the pool which
 * should not be accessible by normal tasks but should be accessible by start
 * tasks. Possible values include: 'Task', 'Pool'
 *
 * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
 * The elevation level of the auto user. The default value is nonAdmin.
 * Possible values include: 'NonAdmin', 'Admin'
 *
 * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
 * of times the task may be retried. The Batch service retries a task if its
 * exit code is nonzero. Note that this value specifically controls the number
 * of retries. The Batch service will try the task once, and may then retry up
 * to this limit. For example, if the maximum retry count is 3, Batch tries the
 * task up to 4 times (one initial try and 3 retries). If the maximum retry
 * count is 0, the Batch service does not retry the task. If the maximum retry
 * count is -1, the Batch service retries the task without limit.
 *
 * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
 * service should wait for the start task to complete successfully (that is, to
 * exit with exit code 0) before scheduling any tasks on the compute node. If
 * true and the start task fails on a compute node, the Batch service retries
 * the start task up to its maximum retry count (maxTaskRetryCount). If the
 * task has still not completed successfully after all retries, then the Batch
 * service marks the compute node unusable, and will not schedule tasks to it.
 * This condition can be detected via the node state and scheduling error
 * detail. If false, the Batch service will not wait for the start task to
 * complete. In this case, other tasks can start executing on the compute node
 * while the start task is still running; and even if the start task fails, new
 * tasks will continue to be scheduled on the node. The default is true.
 *
 * @param {object} [parameters.startTask.containerSettings] The settings for
 * the container under which the start task runs. When this is specified, all
 * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
 * Batch directories on the node) are mapped into the container, all task
 * environment variables are mapped into the container, and the task command
 * line is executed in the container.
 *
 * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
 * Additional options to the container create command. These additional options
 * are supplied as arguments to the "docker create" command, in addition to
 * those controlled by the Batch Service.
 *
 * @param {string} parameters.startTask.containerSettings.imageName The image
 * to use to create the container in which the task will run. This is the full
 * image reference, as would be specified to "docker pull". If no tag is
 * provided as part of the image name, the tag ":latest" is used as a default.
 *
 * @param {object} [parameters.startTask.containerSettings.registry] The
 * private registry which contains the container image. This setting can be
 * omitted if was already provided at pool creation.
 *
 * @param {string}
 * [parameters.startTask.containerSettings.registry.registryServer] The
 * registry URL. If omitted, the default is "docker.io".
 *
 * @param {string} parameters.startTask.containerSettings.registry.userName The
 * user name to log into the registry server.
 *
 * @param {string} parameters.startTask.containerSettings.registry.password The
 * password to log into the registry server.
 *
 * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
 * flag to indicate where the container task working directory is. The default
 * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
 * 'ContainerImageDefault'
 *
 * @param {array} [parameters.certificates] The list of certificates to be
 * installed on each compute node in the pool. For Windows compute nodes, the
 * Batch service installs the certificates to the specified certificate store
 * and location. For Linux compute nodes, the certificates are stored in a
 * directory inside the task working directory and an environment variable
 * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
 * location. For certificates with visibility of 'remoteUser', a 'certs'
 * directory is created in the user's home directory (e.g.,
 * /home/{user-name}/certs) and certificates are placed in that directory.
 *
 * @param {array} [parameters.applicationPackages] The list of application
 * packages to be installed on each compute node in the pool. Changes to
 * application package references affect all new compute nodes joining the
 * pool, but do not affect compute nodes that are already in the pool until
 * they are rebooted or reimaged. There is a maximum of 10 application package
 * references on any given pool.
 *
 * @param {array} [parameters.applicationLicenses] The list of application
 * licenses the Batch service will make available on each compute node in the
 * pool. The list of application licenses must be a subset of available Batch
 * service application licenses. If a license is requested which is not
 * supported, pool creation will fail.
 *
 * @param {array} [parameters.mountConfiguration] A list of file systems to
 * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
 * and Blobfuse.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] The entity state (ETag) version of the
 * pool to update. A value of "*" can be used to apply the operation only if
 * the pool already exists. If omitted, this operation will always be applied.
 *
 * @param {string} [options.ifNoneMatch] Set to '*' to allow a new pool to be
 * created, but to prevent updating an existing pool. Other values will be
 * ignored.
 *
 * @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 Pool} 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, accountName, poolName, 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.');
  }
  let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined;
  let ifNoneMatch = (options && options.ifNoneMatch !== undefined) ? options.ifNoneMatch : undefined;
  if (parameters === null || parameters === undefined)
  {
    parameters = {};
  }
  // 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (poolName === null || poolName === undefined || typeof poolName.valueOf() !== 'string') {
      throw new Error('poolName cannot be null or undefined and it must be of type string.');
    }
    if (poolName !== null && poolName !== undefined) {
      if (poolName.length > 64)
      {
        throw new Error('"poolName" should satisfy the constraint - "MaxLength": 64');
      }
      if (poolName.length < 1)
      {
        throw new Error('"poolName" should satisfy the constraint - "MinLength": 1');
      }
      if (poolName.match(/^[a-zA-Z0-9_-]+$/) === null)
      {
        throw new Error('"poolName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_-]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
      throw new Error('ifMatch must be of type string.');
    }
    if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
      throw new Error('ifNoneMatch must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.Batch/batchAccounts/{accountName}/pools/{poolName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{poolName}', encodeURIComponent(poolName));
  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 (ifMatch !== undefined && ifMatch !== null) {
    httpRequest.headers['If-Match'] = ifMatch;
  }
  if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
    httpRequest.headers['If-None-Match'] = ifNoneMatch;
  }
  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['Pool']().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['Pool']().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 the specified pool.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the Batch account.
 *
 * @param {string} accountName The name of the Batch account.
 *
 * @param {string} poolName The pool name. This must be unique within the
 * account.
 *
 * @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, accountName, poolName, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (accountName !== null && accountName !== undefined) {
      if (accountName.length > 24)
      {
        throw new Error('"accountName" should satisfy the constraint - "MaxLength": 24');
      }
      if (accountName.length < 3)
      {
        throw new Error('"accountName" should satisfy the constraint - "MinLength": 3');
      }
      if (accountName.match(/^[a-zA-Z0-9]+$/) === null)
      {
        throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+$/');
      }
    }
    if (poolName === null || poolName === undefined || typeof poolName.valueOf() !== 'string') {
      throw new Error('poolName cannot be null or undefined and it must be of type string.');
    }
    if (poolName !== null && poolName !== undefined) {
      if (poolName.length > 64)
      {
        throw new Error('"poolName" should satisfy the constraint - "MaxLength": 64');
      }
      if (poolName.length < 1)
      {
        throw new Error('"poolName" should satisfy the constraint - "MinLength": 1');
      }
      if (poolName.match(/^[a-zA-Z0-9_-]+$/) === null)
      {
        throw new Error('"poolName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_-]+$/');
      }
    }
    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.Batch/batchAccounts/{accountName}/pools/{poolName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName));
  requestUrl = requestUrl.replace('{poolName}', encodeURIComponent(poolName));
  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);
  });
}

/**
 * Lists all of the pools in the specified account.
 *
 * @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 ListPoolsResult} 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 _listByBatchAccountNext(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['ListPoolsResult']().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 PoolOperations. */
class PoolOperations {
  /**
   * Create a PoolOperations.
   * @param {BatchManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listByBatchAccount = _listByBatchAccount;
    this._create = _create;
    this._update = _update;
    this._deleteMethod = _deleteMethod;
    this._get = _get;
    this._disableAutoScale = _disableAutoScale;
    this._stopResize = _stopResize;
    this._beginCreate = _beginCreate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._listByBatchAccountNext = _listByBatchAccountNext;
  }

  /**
   * Lists all of the pools in the specified account.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.maxresults] The maximum number of items to return
   * in the response.
   *
   * @param {string} [options.select] Comma separated list of properties that
   * should be returned. e.g. "properties/provisioningState". Only top level
   * properties under properties/ are valid for selection.
   *
   * @param {string} [options.filter] OData filter expression. Valid properties
   * for filtering are:
   *
   * name
   * properties/allocationState
   * properties/allocationStateTransitionTime
   * properties/creationTime
   * properties/provisioningState
   * properties/provisioningStateTransitionTime
   * properties/lastModified
   * properties/vmSize
   * properties/interNodeCommunication
   * properties/scaleSettings/autoScale
   * properties/scaleSettings/fixedScale
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ListPoolsResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByBatchAccountWithHttpOperationResponse(resourceGroupName, accountName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByBatchAccount(resourceGroupName, accountName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all of the pools in the specified account.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.maxresults] The maximum number of items to return
   * in the response.
   *
   * @param {string} [options.select] Comma separated list of properties that
   * should be returned. e.g. "properties/provisioningState". Only top level
   * properties under properties/ are valid for selection.
   *
   * @param {string} [options.filter] OData filter expression. Valid properties
   * for filtering are:
   *
   * name
   * properties/allocationState
   * properties/allocationStateTransitionTime
   * properties/creationTime
   * properties/provisioningState
   * properties/provisioningStateTransitionTime
   * properties/lastModified
   * properties/vmSize
   * properties/interNodeCommunication
   * properties/scaleSettings/autoScale
   * properties/scaleSettings/fixedScale
   *
   * @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 {ListPoolsResult} - 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 ListPoolsResult} 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.
   */
  listByBatchAccount(resourceGroupName, accountName, 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._listByBatchAccount(resourceGroupName, accountName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByBatchAccount(resourceGroupName, accountName, options, optionalCallback);
    }
  }

  /**
   * Creates a new pool inside the specified account.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @param {object} parameters Additional parameters for pool creation.
   *
   * @param {string} [parameters.displayName] The display name for the pool. The
   * display name need not be unique and can contain any Unicode characters up to
   * a maximum length of 1024.
   *
   * @param {string} [parameters.vmSize] The size of virtual machines in the
   * pool. All VMs in a pool are the same size. For information about available
   * sizes of virtual machines for Cloud Services pools (pools created with
   * cloudServiceConfiguration), see Sizes for Cloud Services
   * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
   * Batch supports all Cloud Services VM sizes except ExtraSmall. For
   * information about available VM sizes for pools using images from the Virtual
   * Machines Marketplace (pools created with virtualMachineConfiguration) see
   * Sizes for Virtual Machines (Linux)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
   * or Sizes for Virtual Machines (Windows)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
   * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
   * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {object} [parameters.deploymentConfiguration] This property describes
   * how the pool nodes will be deployed - using Cloud Services or Virtual
   * Machines. Using CloudServiceConfiguration specifies that the nodes should be
   * creating using Azure Cloud Services (PaaS), while
   * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
   *
   * @param {object}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
   * service configuration for the pool. This property and
   * virtualMachineConfiguration are mutually exclusive and one of the properties
   * must be specified. This property cannot be specified if the Batch account
   * was created with its poolAllocationMode property set to 'UserSubscription'.
   *
   * @param {string}
   * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
   * Azure Guest OS family to be installed on the virtual machines in the pool.
   * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
   * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
   * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
   * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
   * information, see Azure Guest OS Releases
   * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
   *
   * @param {string}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
   * Azure Guest OS version to be installed on the virtual machines in the pool.
   * The default value is * which specifies the latest operating system version
   * for the specified OS family.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
   * machine configuration for the pool. This property and
   * cloudServiceConfiguration are mutually exclusive and one of the properties
   * must be specified.
   *
   * @param {object}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
   * A reference to the Azure Virtual Machines Marketplace Image or the custom
   * Virtual Machine Image to use.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
   * The publisher of the Azure Virtual Machines Marketplace image. For example,
   * Canonical or MicrosoftWindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
   * The offer type of the Azure Virtual Machines Marketplace image. For example,
   * UbuntuServer or WindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
   * The SKU of the Azure Virtual Machines Marketplace image. For example,
   * 18.04-LTS or 2019-Datacenter.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
   * The version of the Azure Virtual Machines Marketplace image. A value of
   * 'latest' can be specified to select the latest version of an image. If
   * omitted, the default is 'latest'.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
   * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
   * in the Pool will be created using this Image Id. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
   * This property is mutually exclusive with other properties. The Shared Image
   * Gallery image must have replicas in the same region as the Azure Batch
   * account. 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.
   *
   * @param {string}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
   * The SKU of the Batch node agent to be provisioned on compute nodes in the
   * pool. The Batch node agent is a program that runs on each node in the pool,
   * and provides the command-and-control interface between the node and the
   * Batch service. There are different implementations of the node agent, known
   * as SKUs, for different operating systems. You must specify a node agent SKU
   * which matches the selected image reference. To get the list of supported
   * node agent SKUs along with their list of verified image references, see the
   * 'List supported node agent SKUs' operation.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
   * Windows operating system settings on the virtual machine. This property must
   * not be specified if the imageReference specifies a Linux OS image.
   *
   * @param {boolean}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
   * Whether automatic updates are enabled on the virtual machine. If omitted,
   * the default value is true.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
   * The configuration for data disks attached to the compute nodes in the pool.
   * This property must be specified if the compute nodes in the pool need to
   * have empty data disks attached to them.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
   * The type of on-premises license to be used when deploying the operating
   * system. This only applies to images that contain the Windows operating
   * system, and should only be used when you hold valid on-premises licenses for
   * the nodes which will be deployed. If omitted, no on-premises licensing
   * discount is applied. Values are:
   *
   * Windows_Server - The on-premises license is for Windows Server.
   * Windows_Client - The on-premises license is for Windows Client.
   *
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
   * The container configuration for the pool. If specified, setup is performed
   * on each node in the pool to allow tasks to run in containers. All regular
   * tasks and job manager tasks run on this pool must specify the
   * containerSettings property, and all other tasks may specify it.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
   * The collection of container image names. This is the full image reference,
   * as would be specified to "docker pull". An image will be sourced from the
   * default Docker registry unless the image is fully qualified with an
   * alternative registry.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
   * Additional private registries from which containers can be pulled. If any
   * images must be downloaded from a private registry which requires
   * credentials, then those credentials must be provided here.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
   * The disk encryption configuration for the pool. If specified, encryption is
   * performed on each node in the pool during node provisioning.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
   * The list of disk targets Batch Service will encrypt on the compute node On
   * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
   * "TemporaryDisk" must be specified.
   *
   * @param {object} [parameters.scaleSettings] Settings which configure the
   * number of nodes in the pool.
   *
   * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
   * for the pool. This property and autoScale are mutually exclusive and one of
   * the properties must be specified.
   *
   * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
   * The timeout for allocation of compute nodes to the pool. The default value
   * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
   * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
   * than 5 minutes, the Batch service rejects the request with an error; if you
   * are calling the REST API directly, the HTTP status code is 400 (Bad
   * Request).
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
   * The desired number of dedicated compute nodes in the pool. At least one of
   * targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
   * The desired number of low-priority compute nodes in the pool. At least one
   * of targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
   * Determines what to do with a node and its running task(s) if the pool size
   * is decreasing. If omitted, the default value is Requeue. Possible values
   * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
   *
   * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
   * the pool. This property and fixedScale are mutually exclusive and one of the
   * properties must be specified.
   *
   * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
   * desired number of compute nodes in the pool.
   *
   * @param {moment.duration}
   * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
   * which to automatically adjust the pool size according to the autoscale
   * formula. If omitted, the default value is 15 minutes (PT15M).
   *
   * @param {string} [parameters.interNodeCommunication] Whether the pool permits
   * direct communication between nodes. This imposes restrictions on which nodes
   * can be assigned to the pool. Enabling this value can reduce the chance of
   * the requested number of nodes to be allocated in the pool. If not specified,
   * this value defaults to 'Disabled'. Possible values include: 'Enabled',
   * 'Disabled'
   *
   * @param {object} [parameters.networkConfiguration] The network configuration
   * for the pool.
   *
   * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
   * identifier of the virtual network subnet which the compute nodes of the pool
   * will join. This is of the form
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
   * The virtual network must be in the same region and subscription as the Azure
   * Batch account. The specified subnet should have enough free IP addresses to
   * accommodate the number of nodes in the pool. If the subnet doesn't have
   * enough free IP addresses, the pool will partially allocate compute nodes and
   * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
   * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
   * (RBAC) role for the specified VNet. The specified subnet must allow
   * communication from the Azure Batch service to be able to schedule tasks on
   * the compute nodes. This can be verified by checking if the specified VNet
   * has any associated Network Security Groups (NSG). If communication to the
   * compute nodes in the specified subnet is denied by an NSG, then the Batch
   * service will set the state of the compute nodes to unusable. If the
   * specified VNet has any associated Network Security Groups (NSG), then a few
   * reserved system ports must be enabled for inbound communication. For pools
   * created with a virtual machine configuration, enable ports 29876 and 29877,
   * as well as port 22 for Linux and port 3389 for Windows. For pools created
   * with a cloud service configuration, enable ports 10100, 20100, and 30100.
   * Also enable outbound connections to Azure Storage on port 443. For
   * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
   * more details see:
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
   *
   * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
   * configuration for endpoints on compute nodes in the Batch pool. Pool
   * endpoint configuration is only supported on pools with the
   * virtualMachineConfiguration property.
   *
   * @param {array}
   * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
   * of inbound NAT pools that can be used to address specific ports on an
   * individual compute node externally. The maximum number of inbound NAT pools
   * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
   * the request fails with HTTP status code 400.
   *
   * @param {object}
   * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
   * IPAddress configuration for Compute Nodes in the Batch Pool. This property
   * is only supported on Pools with the virtualMachineConfiguration property.
   *
   * @param {string}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
   * provisioning type for Public IP Addresses for the pool The default value is
   * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
   * 'NoPublicIPAddresses'
   *
   * @param {array}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
   * The list of public IPs which the Batch service will use when provisioning
   * Compute Nodes. The number of IPs specified here limits the maximum size of
   * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
   * each public IP. For example, a pool needing 150 dedicated VMs would need at
   * least 3 public IPs specified. Each element of this collection is of the
   * form:
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
   *
   * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
   * that can run concurrently on a single compute node in the pool. The default
   * value is 1. The maximum value is the smaller of 4 times the number of cores
   * of the vmSize of the pool or 256.
   *
   * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
   * across compute nodes in a pool. If not specified, the default is spread.
   *
   * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
   * should be distributed across compute nodes. Possible values include:
   * 'Spread', 'Pack'
   *
   * @param {array} [parameters.userAccounts] The list of user accounts to be
   * created on each node in the pool.
   *
   * @param {array} [parameters.metadata] A list of name-value pairs associated
   * with the pool as metadata. The Batch service does not assign any meaning to
   * metadata; it is solely for the use of user code.
   *
   * @param {object} [parameters.startTask] A task specified to run on each
   * compute node as it joins the pool. In an PATCH (update) operation, this
   * property can be set to an empty object to remove the start task from the
   * pool.
   *
   * @param {string} [parameters.startTask.commandLine] The command line of the
   * start task. The command line does not run under a shell, and therefore
   * cannot take advantage of shell features such as environment variable
   * expansion. If you want to take advantage of such features, you should invoke
   * the shell in the command line, for example using "cmd /c MyCommand" in
   * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
   * of the startTask are specified.
   *
   * @param {array} [parameters.startTask.resourceFiles] A list of files that the
   * Batch service will download to the compute node before running the command
   * line.
   *
   * @param {array} [parameters.startTask.environmentSettings] A list of
   * environment variable settings for the start task.
   *
   * @param {object} [parameters.startTask.userIdentity] The user identity under
   * which the start task runs. If omitted, the task runs as a non-administrative
   * user unique to the task.
   *
   * @param {string} [parameters.startTask.userIdentity.userName] The name of the
   * user identity under which the task is run. The userName and autoUser
   * properties are mutually exclusive; you must specify one but not both.
   *
   * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
   * under which the task is run. The userName and autoUser properties are
   * mutually exclusive; you must specify one but not both.
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
   * for the auto user The default value is Pool. If the pool is running Windows
   * a value of Task should be specified if stricter isolation between tasks is
   * required. For example, if the task mutates the registry in a way which could
   * impact other tasks, or if certificates have been specified on the pool which
   * should not be accessible by normal tasks but should be accessible by start
   * tasks. Possible values include: 'Task', 'Pool'
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
   * The elevation level of the auto user. The default value is nonAdmin.
   * Possible values include: 'NonAdmin', 'Admin'
   *
   * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
   * of times the task may be retried. The Batch service retries a task if its
   * exit code is nonzero. Note that this value specifically controls the number
   * of retries. The Batch service will try the task once, and may then retry up
   * to this limit. For example, if the maximum retry count is 3, Batch tries the
   * task up to 4 times (one initial try and 3 retries). If the maximum retry
   * count is 0, the Batch service does not retry the task. If the maximum retry
   * count is -1, the Batch service retries the task without limit.
   *
   * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
   * service should wait for the start task to complete successfully (that is, to
   * exit with exit code 0) before scheduling any tasks on the compute node. If
   * true and the start task fails on a compute node, the Batch service retries
   * the start task up to its maximum retry count (maxTaskRetryCount). If the
   * task has still not completed successfully after all retries, then the Batch
   * service marks the compute node unusable, and will not schedule tasks to it.
   * This condition can be detected via the node state and scheduling error
   * detail. If false, the Batch service will not wait for the start task to
   * complete. In this case, other tasks can start executing on the compute node
   * while the start task is still running; and even if the start task fails, new
   * tasks will continue to be scheduled on the node. The default is true.
   *
   * @param {object} [parameters.startTask.containerSettings] The settings for
   * the container under which the start task runs. When this is specified, all
   * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
   * Batch directories on the node) are mapped into the container, all task
   * environment variables are mapped into the container, and the task command
   * line is executed in the container.
   *
   * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
   * Additional options to the container create command. These additional options
   * are supplied as arguments to the "docker create" command, in addition to
   * those controlled by the Batch Service.
   *
   * @param {string} parameters.startTask.containerSettings.imageName The image
   * to use to create the container in which the task will run. This is the full
   * image reference, as would be specified to "docker pull". If no tag is
   * provided as part of the image name, the tag ":latest" is used as a default.
   *
   * @param {object} [parameters.startTask.containerSettings.registry] The
   * private registry which contains the container image. This setting can be
   * omitted if was already provided at pool creation.
   *
   * @param {string}
   * [parameters.startTask.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} parameters.startTask.containerSettings.registry.userName The
   * user name to log into the registry server.
   *
   * @param {string} parameters.startTask.containerSettings.registry.password The
   * password to log into the registry server.
   *
   * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
   * flag to indicate where the container task working directory is. The default
   * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
   * 'ContainerImageDefault'
   *
   * @param {array} [parameters.certificates] The list of certificates to be
   * installed on each compute node in the pool. For Windows compute nodes, the
   * Batch service installs the certificates to the specified certificate store
   * and location. For Linux compute nodes, the certificates are stored in a
   * directory inside the task working directory and an environment variable
   * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
   * location. For certificates with visibility of 'remoteUser', a 'certs'
   * directory is created in the user's home directory (e.g.,
   * /home/{user-name}/certs) and certificates are placed in that directory.
   *
   * @param {array} [parameters.applicationPackages] The list of application
   * packages to be installed on each compute node in the pool. Changes to
   * application package references affect all new compute nodes joining the
   * pool, but do not affect compute nodes that are already in the pool until
   * they are rebooted or reimaged. There is a maximum of 10 application package
   * references on any given pool.
   *
   * @param {array} [parameters.applicationLicenses] The list of application
   * licenses the Batch service will make available on each compute node in the
   * pool. The list of application licenses must be a subset of available Batch
   * service application licenses. If a license is requested which is not
   * supported, pool creation will fail.
   *
   * @param {array} [parameters.mountConfiguration] A list of file systems to
   * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
   * and Blobfuse.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The entity state (ETag) version of the
   * pool to update. A value of "*" can be used to apply the operation only if
   * the pool already exists. If omitted, this operation will always be applied.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new pool to be
   * created, but to prevent updating an existing pool. Other values will be
   * ignored.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Pool>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(resourceGroupName, accountName, poolName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(resourceGroupName, accountName, poolName, 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 new pool inside the specified account.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @param {object} parameters Additional parameters for pool creation.
   *
   * @param {string} [parameters.displayName] The display name for the pool. The
   * display name need not be unique and can contain any Unicode characters up to
   * a maximum length of 1024.
   *
   * @param {string} [parameters.vmSize] The size of virtual machines in the
   * pool. All VMs in a pool are the same size. For information about available
   * sizes of virtual machines for Cloud Services pools (pools created with
   * cloudServiceConfiguration), see Sizes for Cloud Services
   * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
   * Batch supports all Cloud Services VM sizes except ExtraSmall. For
   * information about available VM sizes for pools using images from the Virtual
   * Machines Marketplace (pools created with virtualMachineConfiguration) see
   * Sizes for Virtual Machines (Linux)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
   * or Sizes for Virtual Machines (Windows)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
   * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
   * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {object} [parameters.deploymentConfiguration] This property describes
   * how the pool nodes will be deployed - using Cloud Services or Virtual
   * Machines. Using CloudServiceConfiguration specifies that the nodes should be
   * creating using Azure Cloud Services (PaaS), while
   * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
   *
   * @param {object}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
   * service configuration for the pool. This property and
   * virtualMachineConfiguration are mutually exclusive and one of the properties
   * must be specified. This property cannot be specified if the Batch account
   * was created with its poolAllocationMode property set to 'UserSubscription'.
   *
   * @param {string}
   * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
   * Azure Guest OS family to be installed on the virtual machines in the pool.
   * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
   * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
   * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
   * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
   * information, see Azure Guest OS Releases
   * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
   *
   * @param {string}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
   * Azure Guest OS version to be installed on the virtual machines in the pool.
   * The default value is * which specifies the latest operating system version
   * for the specified OS family.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
   * machine configuration for the pool. This property and
   * cloudServiceConfiguration are mutually exclusive and one of the properties
   * must be specified.
   *
   * @param {object}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
   * A reference to the Azure Virtual Machines Marketplace Image or the custom
   * Virtual Machine Image to use.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
   * The publisher of the Azure Virtual Machines Marketplace image. For example,
   * Canonical or MicrosoftWindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
   * The offer type of the Azure Virtual Machines Marketplace image. For example,
   * UbuntuServer or WindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
   * The SKU of the Azure Virtual Machines Marketplace image. For example,
   * 18.04-LTS or 2019-Datacenter.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
   * The version of the Azure Virtual Machines Marketplace image. A value of
   * 'latest' can be specified to select the latest version of an image. If
   * omitted, the default is 'latest'.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
   * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
   * in the Pool will be created using this Image Id. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
   * This property is mutually exclusive with other properties. The Shared Image
   * Gallery image must have replicas in the same region as the Azure Batch
   * account. 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.
   *
   * @param {string}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
   * The SKU of the Batch node agent to be provisioned on compute nodes in the
   * pool. The Batch node agent is a program that runs on each node in the pool,
   * and provides the command-and-control interface between the node and the
   * Batch service. There are different implementations of the node agent, known
   * as SKUs, for different operating systems. You must specify a node agent SKU
   * which matches the selected image reference. To get the list of supported
   * node agent SKUs along with their list of verified image references, see the
   * 'List supported node agent SKUs' operation.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
   * Windows operating system settings on the virtual machine. This property must
   * not be specified if the imageReference specifies a Linux OS image.
   *
   * @param {boolean}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
   * Whether automatic updates are enabled on the virtual machine. If omitted,
   * the default value is true.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
   * The configuration for data disks attached to the compute nodes in the pool.
   * This property must be specified if the compute nodes in the pool need to
   * have empty data disks attached to them.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
   * The type of on-premises license to be used when deploying the operating
   * system. This only applies to images that contain the Windows operating
   * system, and should only be used when you hold valid on-premises licenses for
   * the nodes which will be deployed. If omitted, no on-premises licensing
   * discount is applied. Values are:
   *
   * Windows_Server - The on-premises license is for Windows Server.
   * Windows_Client - The on-premises license is for Windows Client.
   *
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
   * The container configuration for the pool. If specified, setup is performed
   * on each node in the pool to allow tasks to run in containers. All regular
   * tasks and job manager tasks run on this pool must specify the
   * containerSettings property, and all other tasks may specify it.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
   * The collection of container image names. This is the full image reference,
   * as would be specified to "docker pull". An image will be sourced from the
   * default Docker registry unless the image is fully qualified with an
   * alternative registry.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
   * Additional private registries from which containers can be pulled. If any
   * images must be downloaded from a private registry which requires
   * credentials, then those credentials must be provided here.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
   * The disk encryption configuration for the pool. If specified, encryption is
   * performed on each node in the pool during node provisioning.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
   * The list of disk targets Batch Service will encrypt on the compute node On
   * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
   * "TemporaryDisk" must be specified.
   *
   * @param {object} [parameters.scaleSettings] Settings which configure the
   * number of nodes in the pool.
   *
   * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
   * for the pool. This property and autoScale are mutually exclusive and one of
   * the properties must be specified.
   *
   * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
   * The timeout for allocation of compute nodes to the pool. The default value
   * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
   * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
   * than 5 minutes, the Batch service rejects the request with an error; if you
   * are calling the REST API directly, the HTTP status code is 400 (Bad
   * Request).
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
   * The desired number of dedicated compute nodes in the pool. At least one of
   * targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
   * The desired number of low-priority compute nodes in the pool. At least one
   * of targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
   * Determines what to do with a node and its running task(s) if the pool size
   * is decreasing. If omitted, the default value is Requeue. Possible values
   * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
   *
   * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
   * the pool. This property and fixedScale are mutually exclusive and one of the
   * properties must be specified.
   *
   * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
   * desired number of compute nodes in the pool.
   *
   * @param {moment.duration}
   * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
   * which to automatically adjust the pool size according to the autoscale
   * formula. If omitted, the default value is 15 minutes (PT15M).
   *
   * @param {string} [parameters.interNodeCommunication] Whether the pool permits
   * direct communication between nodes. This imposes restrictions on which nodes
   * can be assigned to the pool. Enabling this value can reduce the chance of
   * the requested number of nodes to be allocated in the pool. If not specified,
   * this value defaults to 'Disabled'. Possible values include: 'Enabled',
   * 'Disabled'
   *
   * @param {object} [parameters.networkConfiguration] The network configuration
   * for the pool.
   *
   * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
   * identifier of the virtual network subnet which the compute nodes of the pool
   * will join. This is of the form
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
   * The virtual network must be in the same region and subscription as the Azure
   * Batch account. The specified subnet should have enough free IP addresses to
   * accommodate the number of nodes in the pool. If the subnet doesn't have
   * enough free IP addresses, the pool will partially allocate compute nodes and
   * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
   * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
   * (RBAC) role for the specified VNet. The specified subnet must allow
   * communication from the Azure Batch service to be able to schedule tasks on
   * the compute nodes. This can be verified by checking if the specified VNet
   * has any associated Network Security Groups (NSG). If communication to the
   * compute nodes in the specified subnet is denied by an NSG, then the Batch
   * service will set the state of the compute nodes to unusable. If the
   * specified VNet has any associated Network Security Groups (NSG), then a few
   * reserved system ports must be enabled for inbound communication. For pools
   * created with a virtual machine configuration, enable ports 29876 and 29877,
   * as well as port 22 for Linux and port 3389 for Windows. For pools created
   * with a cloud service configuration, enable ports 10100, 20100, and 30100.
   * Also enable outbound connections to Azure Storage on port 443. For
   * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
   * more details see:
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
   *
   * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
   * configuration for endpoints on compute nodes in the Batch pool. Pool
   * endpoint configuration is only supported on pools with the
   * virtualMachineConfiguration property.
   *
   * @param {array}
   * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
   * of inbound NAT pools that can be used to address specific ports on an
   * individual compute node externally. The maximum number of inbound NAT pools
   * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
   * the request fails with HTTP status code 400.
   *
   * @param {object}
   * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
   * IPAddress configuration for Compute Nodes in the Batch Pool. This property
   * is only supported on Pools with the virtualMachineConfiguration property.
   *
   * @param {string}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
   * provisioning type for Public IP Addresses for the pool The default value is
   * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
   * 'NoPublicIPAddresses'
   *
   * @param {array}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
   * The list of public IPs which the Batch service will use when provisioning
   * Compute Nodes. The number of IPs specified here limits the maximum size of
   * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
   * each public IP. For example, a pool needing 150 dedicated VMs would need at
   * least 3 public IPs specified. Each element of this collection is of the
   * form:
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
   *
   * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
   * that can run concurrently on a single compute node in the pool. The default
   * value is 1. The maximum value is the smaller of 4 times the number of cores
   * of the vmSize of the pool or 256.
   *
   * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
   * across compute nodes in a pool. If not specified, the default is spread.
   *
   * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
   * should be distributed across compute nodes. Possible values include:
   * 'Spread', 'Pack'
   *
   * @param {array} [parameters.userAccounts] The list of user accounts to be
   * created on each node in the pool.
   *
   * @param {array} [parameters.metadata] A list of name-value pairs associated
   * with the pool as metadata. The Batch service does not assign any meaning to
   * metadata; it is solely for the use of user code.
   *
   * @param {object} [parameters.startTask] A task specified to run on each
   * compute node as it joins the pool. In an PATCH (update) operation, this
   * property can be set to an empty object to remove the start task from the
   * pool.
   *
   * @param {string} [parameters.startTask.commandLine] The command line of the
   * start task. The command line does not run under a shell, and therefore
   * cannot take advantage of shell features such as environment variable
   * expansion. If you want to take advantage of such features, you should invoke
   * the shell in the command line, for example using "cmd /c MyCommand" in
   * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
   * of the startTask are specified.
   *
   * @param {array} [parameters.startTask.resourceFiles] A list of files that the
   * Batch service will download to the compute node before running the command
   * line.
   *
   * @param {array} [parameters.startTask.environmentSettings] A list of
   * environment variable settings for the start task.
   *
   * @param {object} [parameters.startTask.userIdentity] The user identity under
   * which the start task runs. If omitted, the task runs as a non-administrative
   * user unique to the task.
   *
   * @param {string} [parameters.startTask.userIdentity.userName] The name of the
   * user identity under which the task is run. The userName and autoUser
   * properties are mutually exclusive; you must specify one but not both.
   *
   * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
   * under which the task is run. The userName and autoUser properties are
   * mutually exclusive; you must specify one but not both.
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
   * for the auto user The default value is Pool. If the pool is running Windows
   * a value of Task should be specified if stricter isolation between tasks is
   * required. For example, if the task mutates the registry in a way which could
   * impact other tasks, or if certificates have been specified on the pool which
   * should not be accessible by normal tasks but should be accessible by start
   * tasks. Possible values include: 'Task', 'Pool'
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
   * The elevation level of the auto user. The default value is nonAdmin.
   * Possible values include: 'NonAdmin', 'Admin'
   *
   * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
   * of times the task may be retried. The Batch service retries a task if its
   * exit code is nonzero. Note that this value specifically controls the number
   * of retries. The Batch service will try the task once, and may then retry up
   * to this limit. For example, if the maximum retry count is 3, Batch tries the
   * task up to 4 times (one initial try and 3 retries). If the maximum retry
   * count is 0, the Batch service does not retry the task. If the maximum retry
   * count is -1, the Batch service retries the task without limit.
   *
   * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
   * service should wait for the start task to complete successfully (that is, to
   * exit with exit code 0) before scheduling any tasks on the compute node. If
   * true and the start task fails on a compute node, the Batch service retries
   * the start task up to its maximum retry count (maxTaskRetryCount). If the
   * task has still not completed successfully after all retries, then the Batch
   * service marks the compute node unusable, and will not schedule tasks to it.
   * This condition can be detected via the node state and scheduling error
   * detail. If false, the Batch service will not wait for the start task to
   * complete. In this case, other tasks can start executing on the compute node
   * while the start task is still running; and even if the start task fails, new
   * tasks will continue to be scheduled on the node. The default is true.
   *
   * @param {object} [parameters.startTask.containerSettings] The settings for
   * the container under which the start task runs. When this is specified, all
   * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
   * Batch directories on the node) are mapped into the container, all task
   * environment variables are mapped into the container, and the task command
   * line is executed in the container.
   *
   * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
   * Additional options to the container create command. These additional options
   * are supplied as arguments to the "docker create" command, in addition to
   * those controlled by the Batch Service.
   *
   * @param {string} parameters.startTask.containerSettings.imageName The image
   * to use to create the container in which the task will run. This is the full
   * image reference, as would be specified to "docker pull". If no tag is
   * provided as part of the image name, the tag ":latest" is used as a default.
   *
   * @param {object} [parameters.startTask.containerSettings.registry] The
   * private registry which contains the container image. This setting can be
   * omitted if was already provided at pool creation.
   *
   * @param {string}
   * [parameters.startTask.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} parameters.startTask.containerSettings.registry.userName The
   * user name to log into the registry server.
   *
   * @param {string} parameters.startTask.containerSettings.registry.password The
   * password to log into the registry server.
   *
   * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
   * flag to indicate where the container task working directory is. The default
   * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
   * 'ContainerImageDefault'
   *
   * @param {array} [parameters.certificates] The list of certificates to be
   * installed on each compute node in the pool. For Windows compute nodes, the
   * Batch service installs the certificates to the specified certificate store
   * and location. For Linux compute nodes, the certificates are stored in a
   * directory inside the task working directory and an environment variable
   * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
   * location. For certificates with visibility of 'remoteUser', a 'certs'
   * directory is created in the user's home directory (e.g.,
   * /home/{user-name}/certs) and certificates are placed in that directory.
   *
   * @param {array} [parameters.applicationPackages] The list of application
   * packages to be installed on each compute node in the pool. Changes to
   * application package references affect all new compute nodes joining the
   * pool, but do not affect compute nodes that are already in the pool until
   * they are rebooted or reimaged. There is a maximum of 10 application package
   * references on any given pool.
   *
   * @param {array} [parameters.applicationLicenses] The list of application
   * licenses the Batch service will make available on each compute node in the
   * pool. The list of application licenses must be a subset of available Batch
   * service application licenses. If a license is requested which is not
   * supported, pool creation will fail.
   *
   * @param {array} [parameters.mountConfiguration] A list of file systems to
   * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
   * and Blobfuse.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The entity state (ETag) version of the
   * pool to update. A value of "*" can be used to apply the operation only if
   * the pool already exists. If omitted, this operation will always be applied.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new pool to be
   * created, but to prevent updating an existing pool. Other values will be
   * ignored.
   *
   * @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 {Pool} - 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 Pool} 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, accountName, poolName, 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, accountName, poolName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(resourceGroupName, accountName, poolName, parameters, options, optionalCallback);
    }
  }

  /**
   * Updates the properties of an existing pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @param {object} parameters Pool properties that should be updated.
   * Properties that are supplied will be updated, any property not supplied will
   * be unchanged.
   *
   * @param {string} [parameters.displayName] The display name for the pool. The
   * display name need not be unique and can contain any Unicode characters up to
   * a maximum length of 1024.
   *
   * @param {string} [parameters.vmSize] The size of virtual machines in the
   * pool. All VMs in a pool are the same size. For information about available
   * sizes of virtual machines for Cloud Services pools (pools created with
   * cloudServiceConfiguration), see Sizes for Cloud Services
   * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
   * Batch supports all Cloud Services VM sizes except ExtraSmall. For
   * information about available VM sizes for pools using images from the Virtual
   * Machines Marketplace (pools created with virtualMachineConfiguration) see
   * Sizes for Virtual Machines (Linux)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
   * or Sizes for Virtual Machines (Windows)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
   * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
   * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {object} [parameters.deploymentConfiguration] This property describes
   * how the pool nodes will be deployed - using Cloud Services or Virtual
   * Machines. Using CloudServiceConfiguration specifies that the nodes should be
   * creating using Azure Cloud Services (PaaS), while
   * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
   *
   * @param {object}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
   * service configuration for the pool. This property and
   * virtualMachineConfiguration are mutually exclusive and one of the properties
   * must be specified. This property cannot be specified if the Batch account
   * was created with its poolAllocationMode property set to 'UserSubscription'.
   *
   * @param {string}
   * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
   * Azure Guest OS family to be installed on the virtual machines in the pool.
   * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
   * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
   * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
   * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
   * information, see Azure Guest OS Releases
   * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
   *
   * @param {string}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
   * Azure Guest OS version to be installed on the virtual machines in the pool.
   * The default value is * which specifies the latest operating system version
   * for the specified OS family.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
   * machine configuration for the pool. This property and
   * cloudServiceConfiguration are mutually exclusive and one of the properties
   * must be specified.
   *
   * @param {object}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
   * A reference to the Azure Virtual Machines Marketplace Image or the custom
   * Virtual Machine Image to use.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
   * The publisher of the Azure Virtual Machines Marketplace image. For example,
   * Canonical or MicrosoftWindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
   * The offer type of the Azure Virtual Machines Marketplace image. For example,
   * UbuntuServer or WindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
   * The SKU of the Azure Virtual Machines Marketplace image. For example,
   * 18.04-LTS or 2019-Datacenter.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
   * The version of the Azure Virtual Machines Marketplace image. A value of
   * 'latest' can be specified to select the latest version of an image. If
   * omitted, the default is 'latest'.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
   * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
   * in the Pool will be created using this Image Id. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
   * This property is mutually exclusive with other properties. The Shared Image
   * Gallery image must have replicas in the same region as the Azure Batch
   * account. 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.
   *
   * @param {string}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
   * The SKU of the Batch node agent to be provisioned on compute nodes in the
   * pool. The Batch node agent is a program that runs on each node in the pool,
   * and provides the command-and-control interface between the node and the
   * Batch service. There are different implementations of the node agent, known
   * as SKUs, for different operating systems. You must specify a node agent SKU
   * which matches the selected image reference. To get the list of supported
   * node agent SKUs along with their list of verified image references, see the
   * 'List supported node agent SKUs' operation.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
   * Windows operating system settings on the virtual machine. This property must
   * not be specified if the imageReference specifies a Linux OS image.
   *
   * @param {boolean}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
   * Whether automatic updates are enabled on the virtual machine. If omitted,
   * the default value is true.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
   * The configuration for data disks attached to the compute nodes in the pool.
   * This property must be specified if the compute nodes in the pool need to
   * have empty data disks attached to them.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
   * The type of on-premises license to be used when deploying the operating
   * system. This only applies to images that contain the Windows operating
   * system, and should only be used when you hold valid on-premises licenses for
   * the nodes which will be deployed. If omitted, no on-premises licensing
   * discount is applied. Values are:
   *
   * Windows_Server - The on-premises license is for Windows Server.
   * Windows_Client - The on-premises license is for Windows Client.
   *
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
   * The container configuration for the pool. If specified, setup is performed
   * on each node in the pool to allow tasks to run in containers. All regular
   * tasks and job manager tasks run on this pool must specify the
   * containerSettings property, and all other tasks may specify it.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
   * The collection of container image names. This is the full image reference,
   * as would be specified to "docker pull". An image will be sourced from the
   * default Docker registry unless the image is fully qualified with an
   * alternative registry.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
   * Additional private registries from which containers can be pulled. If any
   * images must be downloaded from a private registry which requires
   * credentials, then those credentials must be provided here.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
   * The disk encryption configuration for the pool. If specified, encryption is
   * performed on each node in the pool during node provisioning.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
   * The list of disk targets Batch Service will encrypt on the compute node On
   * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
   * "TemporaryDisk" must be specified.
   *
   * @param {object} [parameters.scaleSettings] Settings which configure the
   * number of nodes in the pool.
   *
   * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
   * for the pool. This property and autoScale are mutually exclusive and one of
   * the properties must be specified.
   *
   * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
   * The timeout for allocation of compute nodes to the pool. The default value
   * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
   * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
   * than 5 minutes, the Batch service rejects the request with an error; if you
   * are calling the REST API directly, the HTTP status code is 400 (Bad
   * Request).
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
   * The desired number of dedicated compute nodes in the pool. At least one of
   * targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
   * The desired number of low-priority compute nodes in the pool. At least one
   * of targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
   * Determines what to do with a node and its running task(s) if the pool size
   * is decreasing. If omitted, the default value is Requeue. Possible values
   * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
   *
   * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
   * the pool. This property and fixedScale are mutually exclusive and one of the
   * properties must be specified.
   *
   * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
   * desired number of compute nodes in the pool.
   *
   * @param {moment.duration}
   * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
   * which to automatically adjust the pool size according to the autoscale
   * formula. If omitted, the default value is 15 minutes (PT15M).
   *
   * @param {string} [parameters.interNodeCommunication] Whether the pool permits
   * direct communication between nodes. This imposes restrictions on which nodes
   * can be assigned to the pool. Enabling this value can reduce the chance of
   * the requested number of nodes to be allocated in the pool. If not specified,
   * this value defaults to 'Disabled'. Possible values include: 'Enabled',
   * 'Disabled'
   *
   * @param {object} [parameters.networkConfiguration] The network configuration
   * for the pool.
   *
   * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
   * identifier of the virtual network subnet which the compute nodes of the pool
   * will join. This is of the form
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
   * The virtual network must be in the same region and subscription as the Azure
   * Batch account. The specified subnet should have enough free IP addresses to
   * accommodate the number of nodes in the pool. If the subnet doesn't have
   * enough free IP addresses, the pool will partially allocate compute nodes and
   * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
   * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
   * (RBAC) role for the specified VNet. The specified subnet must allow
   * communication from the Azure Batch service to be able to schedule tasks on
   * the compute nodes. This can be verified by checking if the specified VNet
   * has any associated Network Security Groups (NSG). If communication to the
   * compute nodes in the specified subnet is denied by an NSG, then the Batch
   * service will set the state of the compute nodes to unusable. If the
   * specified VNet has any associated Network Security Groups (NSG), then a few
   * reserved system ports must be enabled for inbound communication. For pools
   * created with a virtual machine configuration, enable ports 29876 and 29877,
   * as well as port 22 for Linux and port 3389 for Windows. For pools created
   * with a cloud service configuration, enable ports 10100, 20100, and 30100.
   * Also enable outbound connections to Azure Storage on port 443. For
   * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
   * more details see:
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
   *
   * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
   * configuration for endpoints on compute nodes in the Batch pool. Pool
   * endpoint configuration is only supported on pools with the
   * virtualMachineConfiguration property.
   *
   * @param {array}
   * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
   * of inbound NAT pools that can be used to address specific ports on an
   * individual compute node externally. The maximum number of inbound NAT pools
   * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
   * the request fails with HTTP status code 400.
   *
   * @param {object}
   * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
   * IPAddress configuration for Compute Nodes in the Batch Pool. This property
   * is only supported on Pools with the virtualMachineConfiguration property.
   *
   * @param {string}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
   * provisioning type for Public IP Addresses for the pool The default value is
   * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
   * 'NoPublicIPAddresses'
   *
   * @param {array}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
   * The list of public IPs which the Batch service will use when provisioning
   * Compute Nodes. The number of IPs specified here limits the maximum size of
   * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
   * each public IP. For example, a pool needing 150 dedicated VMs would need at
   * least 3 public IPs specified. Each element of this collection is of the
   * form:
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
   *
   * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
   * that can run concurrently on a single compute node in the pool. The default
   * value is 1. The maximum value is the smaller of 4 times the number of cores
   * of the vmSize of the pool or 256.
   *
   * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
   * across compute nodes in a pool. If not specified, the default is spread.
   *
   * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
   * should be distributed across compute nodes. Possible values include:
   * 'Spread', 'Pack'
   *
   * @param {array} [parameters.userAccounts] The list of user accounts to be
   * created on each node in the pool.
   *
   * @param {array} [parameters.metadata] A list of name-value pairs associated
   * with the pool as metadata. The Batch service does not assign any meaning to
   * metadata; it is solely for the use of user code.
   *
   * @param {object} [parameters.startTask] A task specified to run on each
   * compute node as it joins the pool. In an PATCH (update) operation, this
   * property can be set to an empty object to remove the start task from the
   * pool.
   *
   * @param {string} [parameters.startTask.commandLine] The command line of the
   * start task. The command line does not run under a shell, and therefore
   * cannot take advantage of shell features such as environment variable
   * expansion. If you want to take advantage of such features, you should invoke
   * the shell in the command line, for example using "cmd /c MyCommand" in
   * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
   * of the startTask are specified.
   *
   * @param {array} [parameters.startTask.resourceFiles] A list of files that the
   * Batch service will download to the compute node before running the command
   * line.
   *
   * @param {array} [parameters.startTask.environmentSettings] A list of
   * environment variable settings for the start task.
   *
   * @param {object} [parameters.startTask.userIdentity] The user identity under
   * which the start task runs. If omitted, the task runs as a non-administrative
   * user unique to the task.
   *
   * @param {string} [parameters.startTask.userIdentity.userName] The name of the
   * user identity under which the task is run. The userName and autoUser
   * properties are mutually exclusive; you must specify one but not both.
   *
   * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
   * under which the task is run. The userName and autoUser properties are
   * mutually exclusive; you must specify one but not both.
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
   * for the auto user The default value is Pool. If the pool is running Windows
   * a value of Task should be specified if stricter isolation between tasks is
   * required. For example, if the task mutates the registry in a way which could
   * impact other tasks, or if certificates have been specified on the pool which
   * should not be accessible by normal tasks but should be accessible by start
   * tasks. Possible values include: 'Task', 'Pool'
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
   * The elevation level of the auto user. The default value is nonAdmin.
   * Possible values include: 'NonAdmin', 'Admin'
   *
   * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
   * of times the task may be retried. The Batch service retries a task if its
   * exit code is nonzero. Note that this value specifically controls the number
   * of retries. The Batch service will try the task once, and may then retry up
   * to this limit. For example, if the maximum retry count is 3, Batch tries the
   * task up to 4 times (one initial try and 3 retries). If the maximum retry
   * count is 0, the Batch service does not retry the task. If the maximum retry
   * count is -1, the Batch service retries the task without limit.
   *
   * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
   * service should wait for the start task to complete successfully (that is, to
   * exit with exit code 0) before scheduling any tasks on the compute node. If
   * true and the start task fails on a compute node, the Batch service retries
   * the start task up to its maximum retry count (maxTaskRetryCount). If the
   * task has still not completed successfully after all retries, then the Batch
   * service marks the compute node unusable, and will not schedule tasks to it.
   * This condition can be detected via the node state and scheduling error
   * detail. If false, the Batch service will not wait for the start task to
   * complete. In this case, other tasks can start executing on the compute node
   * while the start task is still running; and even if the start task fails, new
   * tasks will continue to be scheduled on the node. The default is true.
   *
   * @param {object} [parameters.startTask.containerSettings] The settings for
   * the container under which the start task runs. When this is specified, all
   * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
   * Batch directories on the node) are mapped into the container, all task
   * environment variables are mapped into the container, and the task command
   * line is executed in the container.
   *
   * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
   * Additional options to the container create command. These additional options
   * are supplied as arguments to the "docker create" command, in addition to
   * those controlled by the Batch Service.
   *
   * @param {string} parameters.startTask.containerSettings.imageName The image
   * to use to create the container in which the task will run. This is the full
   * image reference, as would be specified to "docker pull". If no tag is
   * provided as part of the image name, the tag ":latest" is used as a default.
   *
   * @param {object} [parameters.startTask.containerSettings.registry] The
   * private registry which contains the container image. This setting can be
   * omitted if was already provided at pool creation.
   *
   * @param {string}
   * [parameters.startTask.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} parameters.startTask.containerSettings.registry.userName The
   * user name to log into the registry server.
   *
   * @param {string} parameters.startTask.containerSettings.registry.password The
   * password to log into the registry server.
   *
   * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
   * flag to indicate where the container task working directory is. The default
   * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
   * 'ContainerImageDefault'
   *
   * @param {array} [parameters.certificates] The list of certificates to be
   * installed on each compute node in the pool. For Windows compute nodes, the
   * Batch service installs the certificates to the specified certificate store
   * and location. For Linux compute nodes, the certificates are stored in a
   * directory inside the task working directory and an environment variable
   * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
   * location. For certificates with visibility of 'remoteUser', a 'certs'
   * directory is created in the user's home directory (e.g.,
   * /home/{user-name}/certs) and certificates are placed in that directory.
   *
   * @param {array} [parameters.applicationPackages] The list of application
   * packages to be installed on each compute node in the pool. Changes to
   * application package references affect all new compute nodes joining the
   * pool, but do not affect compute nodes that are already in the pool until
   * they are rebooted or reimaged. There is a maximum of 10 application package
   * references on any given pool.
   *
   * @param {array} [parameters.applicationLicenses] The list of application
   * licenses the Batch service will make available on each compute node in the
   * pool. The list of application licenses must be a subset of available Batch
   * service application licenses. If a license is requested which is not
   * supported, pool creation will fail.
   *
   * @param {array} [parameters.mountConfiguration] A list of file systems to
   * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
   * and Blobfuse.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The entity state (ETag) version of the
   * pool to update. This value can be omitted or set to "*" to apply the
   * operation unconditionally.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Pool>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, accountName, poolName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, accountName, poolName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates the properties of an existing pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @param {object} parameters Pool properties that should be updated.
   * Properties that are supplied will be updated, any property not supplied will
   * be unchanged.
   *
   * @param {string} [parameters.displayName] The display name for the pool. The
   * display name need not be unique and can contain any Unicode characters up to
   * a maximum length of 1024.
   *
   * @param {string} [parameters.vmSize] The size of virtual machines in the
   * pool. All VMs in a pool are the same size. For information about available
   * sizes of virtual machines for Cloud Services pools (pools created with
   * cloudServiceConfiguration), see Sizes for Cloud Services
   * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
   * Batch supports all Cloud Services VM sizes except ExtraSmall. For
   * information about available VM sizes for pools using images from the Virtual
   * Machines Marketplace (pools created with virtualMachineConfiguration) see
   * Sizes for Virtual Machines (Linux)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
   * or Sizes for Virtual Machines (Windows)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
   * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
   * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {object} [parameters.deploymentConfiguration] This property describes
   * how the pool nodes will be deployed - using Cloud Services or Virtual
   * Machines. Using CloudServiceConfiguration specifies that the nodes should be
   * creating using Azure Cloud Services (PaaS), while
   * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
   *
   * @param {object}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
   * service configuration for the pool. This property and
   * virtualMachineConfiguration are mutually exclusive and one of the properties
   * must be specified. This property cannot be specified if the Batch account
   * was created with its poolAllocationMode property set to 'UserSubscription'.
   *
   * @param {string}
   * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
   * Azure Guest OS family to be installed on the virtual machines in the pool.
   * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
   * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
   * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
   * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
   * information, see Azure Guest OS Releases
   * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
   *
   * @param {string}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
   * Azure Guest OS version to be installed on the virtual machines in the pool.
   * The default value is * which specifies the latest operating system version
   * for the specified OS family.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
   * machine configuration for the pool. This property and
   * cloudServiceConfiguration are mutually exclusive and one of the properties
   * must be specified.
   *
   * @param {object}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
   * A reference to the Azure Virtual Machines Marketplace Image or the custom
   * Virtual Machine Image to use.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
   * The publisher of the Azure Virtual Machines Marketplace image. For example,
   * Canonical or MicrosoftWindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
   * The offer type of the Azure Virtual Machines Marketplace image. For example,
   * UbuntuServer or WindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
   * The SKU of the Azure Virtual Machines Marketplace image. For example,
   * 18.04-LTS or 2019-Datacenter.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
   * The version of the Azure Virtual Machines Marketplace image. A value of
   * 'latest' can be specified to select the latest version of an image. If
   * omitted, the default is 'latest'.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
   * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
   * in the Pool will be created using this Image Id. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
   * This property is mutually exclusive with other properties. The Shared Image
   * Gallery image must have replicas in the same region as the Azure Batch
   * account. 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.
   *
   * @param {string}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
   * The SKU of the Batch node agent to be provisioned on compute nodes in the
   * pool. The Batch node agent is a program that runs on each node in the pool,
   * and provides the command-and-control interface between the node and the
   * Batch service. There are different implementations of the node agent, known
   * as SKUs, for different operating systems. You must specify a node agent SKU
   * which matches the selected image reference. To get the list of supported
   * node agent SKUs along with their list of verified image references, see the
   * 'List supported node agent SKUs' operation.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
   * Windows operating system settings on the virtual machine. This property must
   * not be specified if the imageReference specifies a Linux OS image.
   *
   * @param {boolean}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
   * Whether automatic updates are enabled on the virtual machine. If omitted,
   * the default value is true.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
   * The configuration for data disks attached to the compute nodes in the pool.
   * This property must be specified if the compute nodes in the pool need to
   * have empty data disks attached to them.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
   * The type of on-premises license to be used when deploying the operating
   * system. This only applies to images that contain the Windows operating
   * system, and should only be used when you hold valid on-premises licenses for
   * the nodes which will be deployed. If omitted, no on-premises licensing
   * discount is applied. Values are:
   *
   * Windows_Server - The on-premises license is for Windows Server.
   * Windows_Client - The on-premises license is for Windows Client.
   *
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
   * The container configuration for the pool. If specified, setup is performed
   * on each node in the pool to allow tasks to run in containers. All regular
   * tasks and job manager tasks run on this pool must specify the
   * containerSettings property, and all other tasks may specify it.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
   * The collection of container image names. This is the full image reference,
   * as would be specified to "docker pull". An image will be sourced from the
   * default Docker registry unless the image is fully qualified with an
   * alternative registry.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
   * Additional private registries from which containers can be pulled. If any
   * images must be downloaded from a private registry which requires
   * credentials, then those credentials must be provided here.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
   * The disk encryption configuration for the pool. If specified, encryption is
   * performed on each node in the pool during node provisioning.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
   * The list of disk targets Batch Service will encrypt on the compute node On
   * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
   * "TemporaryDisk" must be specified.
   *
   * @param {object} [parameters.scaleSettings] Settings which configure the
   * number of nodes in the pool.
   *
   * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
   * for the pool. This property and autoScale are mutually exclusive and one of
   * the properties must be specified.
   *
   * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
   * The timeout for allocation of compute nodes to the pool. The default value
   * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
   * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
   * than 5 minutes, the Batch service rejects the request with an error; if you
   * are calling the REST API directly, the HTTP status code is 400 (Bad
   * Request).
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
   * The desired number of dedicated compute nodes in the pool. At least one of
   * targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
   * The desired number of low-priority compute nodes in the pool. At least one
   * of targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
   * Determines what to do with a node and its running task(s) if the pool size
   * is decreasing. If omitted, the default value is Requeue. Possible values
   * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
   *
   * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
   * the pool. This property and fixedScale are mutually exclusive and one of the
   * properties must be specified.
   *
   * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
   * desired number of compute nodes in the pool.
   *
   * @param {moment.duration}
   * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
   * which to automatically adjust the pool size according to the autoscale
   * formula. If omitted, the default value is 15 minutes (PT15M).
   *
   * @param {string} [parameters.interNodeCommunication] Whether the pool permits
   * direct communication between nodes. This imposes restrictions on which nodes
   * can be assigned to the pool. Enabling this value can reduce the chance of
   * the requested number of nodes to be allocated in the pool. If not specified,
   * this value defaults to 'Disabled'. Possible values include: 'Enabled',
   * 'Disabled'
   *
   * @param {object} [parameters.networkConfiguration] The network configuration
   * for the pool.
   *
   * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
   * identifier of the virtual network subnet which the compute nodes of the pool
   * will join. This is of the form
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
   * The virtual network must be in the same region and subscription as the Azure
   * Batch account. The specified subnet should have enough free IP addresses to
   * accommodate the number of nodes in the pool. If the subnet doesn't have
   * enough free IP addresses, the pool will partially allocate compute nodes and
   * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
   * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
   * (RBAC) role for the specified VNet. The specified subnet must allow
   * communication from the Azure Batch service to be able to schedule tasks on
   * the compute nodes. This can be verified by checking if the specified VNet
   * has any associated Network Security Groups (NSG). If communication to the
   * compute nodes in the specified subnet is denied by an NSG, then the Batch
   * service will set the state of the compute nodes to unusable. If the
   * specified VNet has any associated Network Security Groups (NSG), then a few
   * reserved system ports must be enabled for inbound communication. For pools
   * created with a virtual machine configuration, enable ports 29876 and 29877,
   * as well as port 22 for Linux and port 3389 for Windows. For pools created
   * with a cloud service configuration, enable ports 10100, 20100, and 30100.
   * Also enable outbound connections to Azure Storage on port 443. For
   * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
   * more details see:
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
   *
   * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
   * configuration for endpoints on compute nodes in the Batch pool. Pool
   * endpoint configuration is only supported on pools with the
   * virtualMachineConfiguration property.
   *
   * @param {array}
   * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
   * of inbound NAT pools that can be used to address specific ports on an
   * individual compute node externally. The maximum number of inbound NAT pools
   * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
   * the request fails with HTTP status code 400.
   *
   * @param {object}
   * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
   * IPAddress configuration for Compute Nodes in the Batch Pool. This property
   * is only supported on Pools with the virtualMachineConfiguration property.
   *
   * @param {string}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
   * provisioning type for Public IP Addresses for the pool The default value is
   * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
   * 'NoPublicIPAddresses'
   *
   * @param {array}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
   * The list of public IPs which the Batch service will use when provisioning
   * Compute Nodes. The number of IPs specified here limits the maximum size of
   * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
   * each public IP. For example, a pool needing 150 dedicated VMs would need at
   * least 3 public IPs specified. Each element of this collection is of the
   * form:
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
   *
   * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
   * that can run concurrently on a single compute node in the pool. The default
   * value is 1. The maximum value is the smaller of 4 times the number of cores
   * of the vmSize of the pool or 256.
   *
   * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
   * across compute nodes in a pool. If not specified, the default is spread.
   *
   * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
   * should be distributed across compute nodes. Possible values include:
   * 'Spread', 'Pack'
   *
   * @param {array} [parameters.userAccounts] The list of user accounts to be
   * created on each node in the pool.
   *
   * @param {array} [parameters.metadata] A list of name-value pairs associated
   * with the pool as metadata. The Batch service does not assign any meaning to
   * metadata; it is solely for the use of user code.
   *
   * @param {object} [parameters.startTask] A task specified to run on each
   * compute node as it joins the pool. In an PATCH (update) operation, this
   * property can be set to an empty object to remove the start task from the
   * pool.
   *
   * @param {string} [parameters.startTask.commandLine] The command line of the
   * start task. The command line does not run under a shell, and therefore
   * cannot take advantage of shell features such as environment variable
   * expansion. If you want to take advantage of such features, you should invoke
   * the shell in the command line, for example using "cmd /c MyCommand" in
   * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
   * of the startTask are specified.
   *
   * @param {array} [parameters.startTask.resourceFiles] A list of files that the
   * Batch service will download to the compute node before running the command
   * line.
   *
   * @param {array} [parameters.startTask.environmentSettings] A list of
   * environment variable settings for the start task.
   *
   * @param {object} [parameters.startTask.userIdentity] The user identity under
   * which the start task runs. If omitted, the task runs as a non-administrative
   * user unique to the task.
   *
   * @param {string} [parameters.startTask.userIdentity.userName] The name of the
   * user identity under which the task is run. The userName and autoUser
   * properties are mutually exclusive; you must specify one but not both.
   *
   * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
   * under which the task is run. The userName and autoUser properties are
   * mutually exclusive; you must specify one but not both.
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
   * for the auto user The default value is Pool. If the pool is running Windows
   * a value of Task should be specified if stricter isolation between tasks is
   * required. For example, if the task mutates the registry in a way which could
   * impact other tasks, or if certificates have been specified on the pool which
   * should not be accessible by normal tasks but should be accessible by start
   * tasks. Possible values include: 'Task', 'Pool'
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
   * The elevation level of the auto user. The default value is nonAdmin.
   * Possible values include: 'NonAdmin', 'Admin'
   *
   * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
   * of times the task may be retried. The Batch service retries a task if its
   * exit code is nonzero. Note that this value specifically controls the number
   * of retries. The Batch service will try the task once, and may then retry up
   * to this limit. For example, if the maximum retry count is 3, Batch tries the
   * task up to 4 times (one initial try and 3 retries). If the maximum retry
   * count is 0, the Batch service does not retry the task. If the maximum retry
   * count is -1, the Batch service retries the task without limit.
   *
   * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
   * service should wait for the start task to complete successfully (that is, to
   * exit with exit code 0) before scheduling any tasks on the compute node. If
   * true and the start task fails on a compute node, the Batch service retries
   * the start task up to its maximum retry count (maxTaskRetryCount). If the
   * task has still not completed successfully after all retries, then the Batch
   * service marks the compute node unusable, and will not schedule tasks to it.
   * This condition can be detected via the node state and scheduling error
   * detail. If false, the Batch service will not wait for the start task to
   * complete. In this case, other tasks can start executing on the compute node
   * while the start task is still running; and even if the start task fails, new
   * tasks will continue to be scheduled on the node. The default is true.
   *
   * @param {object} [parameters.startTask.containerSettings] The settings for
   * the container under which the start task runs. When this is specified, all
   * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
   * Batch directories on the node) are mapped into the container, all task
   * environment variables are mapped into the container, and the task command
   * line is executed in the container.
   *
   * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
   * Additional options to the container create command. These additional options
   * are supplied as arguments to the "docker create" command, in addition to
   * those controlled by the Batch Service.
   *
   * @param {string} parameters.startTask.containerSettings.imageName The image
   * to use to create the container in which the task will run. This is the full
   * image reference, as would be specified to "docker pull". If no tag is
   * provided as part of the image name, the tag ":latest" is used as a default.
   *
   * @param {object} [parameters.startTask.containerSettings.registry] The
   * private registry which contains the container image. This setting can be
   * omitted if was already provided at pool creation.
   *
   * @param {string}
   * [parameters.startTask.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} parameters.startTask.containerSettings.registry.userName The
   * user name to log into the registry server.
   *
   * @param {string} parameters.startTask.containerSettings.registry.password The
   * password to log into the registry server.
   *
   * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
   * flag to indicate where the container task working directory is. The default
   * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
   * 'ContainerImageDefault'
   *
   * @param {array} [parameters.certificates] The list of certificates to be
   * installed on each compute node in the pool. For Windows compute nodes, the
   * Batch service installs the certificates to the specified certificate store
   * and location. For Linux compute nodes, the certificates are stored in a
   * directory inside the task working directory and an environment variable
   * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
   * location. For certificates with visibility of 'remoteUser', a 'certs'
   * directory is created in the user's home directory (e.g.,
   * /home/{user-name}/certs) and certificates are placed in that directory.
   *
   * @param {array} [parameters.applicationPackages] The list of application
   * packages to be installed on each compute node in the pool. Changes to
   * application package references affect all new compute nodes joining the
   * pool, but do not affect compute nodes that are already in the pool until
   * they are rebooted or reimaged. There is a maximum of 10 application package
   * references on any given pool.
   *
   * @param {array} [parameters.applicationLicenses] The list of application
   * licenses the Batch service will make available on each compute node in the
   * pool. The list of application licenses must be a subset of available Batch
   * service application licenses. If a license is requested which is not
   * supported, pool creation will fail.
   *
   * @param {array} [parameters.mountConfiguration] A list of file systems to
   * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
   * and Blobfuse.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The entity state (ETag) version of the
   * pool to update. This value can be omitted or set to "*" to apply the
   * operation unconditionally.
   *
   * @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 {Pool} - 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 Pool} 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, accountName, poolName, 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._update(resourceGroupName, accountName, poolName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, accountName, poolName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes the specified pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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, accountName, poolName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, accountName, poolName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes the specified pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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, accountName, poolName, 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, accountName, poolName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, accountName, poolName, options, optionalCallback);
    }
  }

  /**
   * Gets information about the specified pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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<Pool>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, accountName, poolName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, accountName, poolName, 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 the specified pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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 {Pool} - 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 Pool} 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, accountName, poolName, 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, accountName, poolName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, accountName, poolName, options, optionalCallback);
    }
  }

  /**
   * Disables automatic scaling for a pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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<Pool>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  disableAutoScaleWithHttpOperationResponse(resourceGroupName, accountName, poolName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._disableAutoScale(resourceGroupName, accountName, poolName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Disables automatic scaling for a pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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 {Pool} - 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 Pool} 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.
   */
  disableAutoScale(resourceGroupName, accountName, poolName, 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._disableAutoScale(resourceGroupName, accountName, poolName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._disableAutoScale(resourceGroupName, accountName, poolName, options, optionalCallback);
    }
  }

  /**
   * @summary Stops an ongoing resize operation on the pool.
   *
   * This does not restore the pool to its previous state before the resize
   * operation: it only stops any further changes being made, and the pool
   * maintains its current state. After stopping, the pool stabilizes at the
   * number of nodes it was at when the stop operation was done. During the stop
   * operation, the pool allocation state changes first to stopping and then to
   * steady. A resize operation need not be an explicit resize pool request; this
   * API can also be used to halt the initial sizing of the pool when it is
   * created.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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<Pool>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  stopResizeWithHttpOperationResponse(resourceGroupName, accountName, poolName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._stopResize(resourceGroupName, accountName, poolName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Stops an ongoing resize operation on the pool.
   *
   * This does not restore the pool to its previous state before the resize
   * operation: it only stops any further changes being made, and the pool
   * maintains its current state. After stopping, the pool stabilizes at the
   * number of nodes it was at when the stop operation was done. During the stop
   * operation, the pool allocation state changes first to stopping and then to
   * steady. A resize operation need not be an explicit resize pool request; this
   * API can also be used to halt the initial sizing of the pool when it is
   * created.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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 {Pool} - 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 Pool} 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.
   */
  stopResize(resourceGroupName, accountName, poolName, 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._stopResize(resourceGroupName, accountName, poolName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._stopResize(resourceGroupName, accountName, poolName, options, optionalCallback);
    }
  }

  /**
   * Creates a new pool inside the specified account.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @param {object} parameters Additional parameters for pool creation.
   *
   * @param {string} [parameters.displayName] The display name for the pool. The
   * display name need not be unique and can contain any Unicode characters up to
   * a maximum length of 1024.
   *
   * @param {string} [parameters.vmSize] The size of virtual machines in the
   * pool. All VMs in a pool are the same size. For information about available
   * sizes of virtual machines for Cloud Services pools (pools created with
   * cloudServiceConfiguration), see Sizes for Cloud Services
   * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
   * Batch supports all Cloud Services VM sizes except ExtraSmall. For
   * information about available VM sizes for pools using images from the Virtual
   * Machines Marketplace (pools created with virtualMachineConfiguration) see
   * Sizes for Virtual Machines (Linux)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
   * or Sizes for Virtual Machines (Windows)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
   * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
   * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {object} [parameters.deploymentConfiguration] This property describes
   * how the pool nodes will be deployed - using Cloud Services or Virtual
   * Machines. Using CloudServiceConfiguration specifies that the nodes should be
   * creating using Azure Cloud Services (PaaS), while
   * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
   *
   * @param {object}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
   * service configuration for the pool. This property and
   * virtualMachineConfiguration are mutually exclusive and one of the properties
   * must be specified. This property cannot be specified if the Batch account
   * was created with its poolAllocationMode property set to 'UserSubscription'.
   *
   * @param {string}
   * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
   * Azure Guest OS family to be installed on the virtual machines in the pool.
   * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
   * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
   * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
   * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
   * information, see Azure Guest OS Releases
   * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
   *
   * @param {string}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
   * Azure Guest OS version to be installed on the virtual machines in the pool.
   * The default value is * which specifies the latest operating system version
   * for the specified OS family.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
   * machine configuration for the pool. This property and
   * cloudServiceConfiguration are mutually exclusive and one of the properties
   * must be specified.
   *
   * @param {object}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
   * A reference to the Azure Virtual Machines Marketplace Image or the custom
   * Virtual Machine Image to use.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
   * The publisher of the Azure Virtual Machines Marketplace image. For example,
   * Canonical or MicrosoftWindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
   * The offer type of the Azure Virtual Machines Marketplace image. For example,
   * UbuntuServer or WindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
   * The SKU of the Azure Virtual Machines Marketplace image. For example,
   * 18.04-LTS or 2019-Datacenter.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
   * The version of the Azure Virtual Machines Marketplace image. A value of
   * 'latest' can be specified to select the latest version of an image. If
   * omitted, the default is 'latest'.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
   * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
   * in the Pool will be created using this Image Id. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
   * This property is mutually exclusive with other properties. The Shared Image
   * Gallery image must have replicas in the same region as the Azure Batch
   * account. 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.
   *
   * @param {string}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
   * The SKU of the Batch node agent to be provisioned on compute nodes in the
   * pool. The Batch node agent is a program that runs on each node in the pool,
   * and provides the command-and-control interface between the node and the
   * Batch service. There are different implementations of the node agent, known
   * as SKUs, for different operating systems. You must specify a node agent SKU
   * which matches the selected image reference. To get the list of supported
   * node agent SKUs along with their list of verified image references, see the
   * 'List supported node agent SKUs' operation.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
   * Windows operating system settings on the virtual machine. This property must
   * not be specified if the imageReference specifies a Linux OS image.
   *
   * @param {boolean}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
   * Whether automatic updates are enabled on the virtual machine. If omitted,
   * the default value is true.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
   * The configuration for data disks attached to the compute nodes in the pool.
   * This property must be specified if the compute nodes in the pool need to
   * have empty data disks attached to them.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
   * The type of on-premises license to be used when deploying the operating
   * system. This only applies to images that contain the Windows operating
   * system, and should only be used when you hold valid on-premises licenses for
   * the nodes which will be deployed. If omitted, no on-premises licensing
   * discount is applied. Values are:
   *
   * Windows_Server - The on-premises license is for Windows Server.
   * Windows_Client - The on-premises license is for Windows Client.
   *
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
   * The container configuration for the pool. If specified, setup is performed
   * on each node in the pool to allow tasks to run in containers. All regular
   * tasks and job manager tasks run on this pool must specify the
   * containerSettings property, and all other tasks may specify it.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
   * The collection of container image names. This is the full image reference,
   * as would be specified to "docker pull". An image will be sourced from the
   * default Docker registry unless the image is fully qualified with an
   * alternative registry.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
   * Additional private registries from which containers can be pulled. If any
   * images must be downloaded from a private registry which requires
   * credentials, then those credentials must be provided here.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
   * The disk encryption configuration for the pool. If specified, encryption is
   * performed on each node in the pool during node provisioning.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
   * The list of disk targets Batch Service will encrypt on the compute node On
   * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
   * "TemporaryDisk" must be specified.
   *
   * @param {object} [parameters.scaleSettings] Settings which configure the
   * number of nodes in the pool.
   *
   * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
   * for the pool. This property and autoScale are mutually exclusive and one of
   * the properties must be specified.
   *
   * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
   * The timeout for allocation of compute nodes to the pool. The default value
   * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
   * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
   * than 5 minutes, the Batch service rejects the request with an error; if you
   * are calling the REST API directly, the HTTP status code is 400 (Bad
   * Request).
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
   * The desired number of dedicated compute nodes in the pool. At least one of
   * targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
   * The desired number of low-priority compute nodes in the pool. At least one
   * of targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
   * Determines what to do with a node and its running task(s) if the pool size
   * is decreasing. If omitted, the default value is Requeue. Possible values
   * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
   *
   * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
   * the pool. This property and fixedScale are mutually exclusive and one of the
   * properties must be specified.
   *
   * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
   * desired number of compute nodes in the pool.
   *
   * @param {moment.duration}
   * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
   * which to automatically adjust the pool size according to the autoscale
   * formula. If omitted, the default value is 15 minutes (PT15M).
   *
   * @param {string} [parameters.interNodeCommunication] Whether the pool permits
   * direct communication between nodes. This imposes restrictions on which nodes
   * can be assigned to the pool. Enabling this value can reduce the chance of
   * the requested number of nodes to be allocated in the pool. If not specified,
   * this value defaults to 'Disabled'. Possible values include: 'Enabled',
   * 'Disabled'
   *
   * @param {object} [parameters.networkConfiguration] The network configuration
   * for the pool.
   *
   * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
   * identifier of the virtual network subnet which the compute nodes of the pool
   * will join. This is of the form
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
   * The virtual network must be in the same region and subscription as the Azure
   * Batch account. The specified subnet should have enough free IP addresses to
   * accommodate the number of nodes in the pool. If the subnet doesn't have
   * enough free IP addresses, the pool will partially allocate compute nodes and
   * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
   * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
   * (RBAC) role for the specified VNet. The specified subnet must allow
   * communication from the Azure Batch service to be able to schedule tasks on
   * the compute nodes. This can be verified by checking if the specified VNet
   * has any associated Network Security Groups (NSG). If communication to the
   * compute nodes in the specified subnet is denied by an NSG, then the Batch
   * service will set the state of the compute nodes to unusable. If the
   * specified VNet has any associated Network Security Groups (NSG), then a few
   * reserved system ports must be enabled for inbound communication. For pools
   * created with a virtual machine configuration, enable ports 29876 and 29877,
   * as well as port 22 for Linux and port 3389 for Windows. For pools created
   * with a cloud service configuration, enable ports 10100, 20100, and 30100.
   * Also enable outbound connections to Azure Storage on port 443. For
   * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
   * more details see:
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
   *
   * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
   * configuration for endpoints on compute nodes in the Batch pool. Pool
   * endpoint configuration is only supported on pools with the
   * virtualMachineConfiguration property.
   *
   * @param {array}
   * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
   * of inbound NAT pools that can be used to address specific ports on an
   * individual compute node externally. The maximum number of inbound NAT pools
   * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
   * the request fails with HTTP status code 400.
   *
   * @param {object}
   * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
   * IPAddress configuration for Compute Nodes in the Batch Pool. This property
   * is only supported on Pools with the virtualMachineConfiguration property.
   *
   * @param {string}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
   * provisioning type for Public IP Addresses for the pool The default value is
   * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
   * 'NoPublicIPAddresses'
   *
   * @param {array}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
   * The list of public IPs which the Batch service will use when provisioning
   * Compute Nodes. The number of IPs specified here limits the maximum size of
   * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
   * each public IP. For example, a pool needing 150 dedicated VMs would need at
   * least 3 public IPs specified. Each element of this collection is of the
   * form:
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
   *
   * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
   * that can run concurrently on a single compute node in the pool. The default
   * value is 1. The maximum value is the smaller of 4 times the number of cores
   * of the vmSize of the pool or 256.
   *
   * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
   * across compute nodes in a pool. If not specified, the default is spread.
   *
   * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
   * should be distributed across compute nodes. Possible values include:
   * 'Spread', 'Pack'
   *
   * @param {array} [parameters.userAccounts] The list of user accounts to be
   * created on each node in the pool.
   *
   * @param {array} [parameters.metadata] A list of name-value pairs associated
   * with the pool as metadata. The Batch service does not assign any meaning to
   * metadata; it is solely for the use of user code.
   *
   * @param {object} [parameters.startTask] A task specified to run on each
   * compute node as it joins the pool. In an PATCH (update) operation, this
   * property can be set to an empty object to remove the start task from the
   * pool.
   *
   * @param {string} [parameters.startTask.commandLine] The command line of the
   * start task. The command line does not run under a shell, and therefore
   * cannot take advantage of shell features such as environment variable
   * expansion. If you want to take advantage of such features, you should invoke
   * the shell in the command line, for example using "cmd /c MyCommand" in
   * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
   * of the startTask are specified.
   *
   * @param {array} [parameters.startTask.resourceFiles] A list of files that the
   * Batch service will download to the compute node before running the command
   * line.
   *
   * @param {array} [parameters.startTask.environmentSettings] A list of
   * environment variable settings for the start task.
   *
   * @param {object} [parameters.startTask.userIdentity] The user identity under
   * which the start task runs. If omitted, the task runs as a non-administrative
   * user unique to the task.
   *
   * @param {string} [parameters.startTask.userIdentity.userName] The name of the
   * user identity under which the task is run. The userName and autoUser
   * properties are mutually exclusive; you must specify one but not both.
   *
   * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
   * under which the task is run. The userName and autoUser properties are
   * mutually exclusive; you must specify one but not both.
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
   * for the auto user The default value is Pool. If the pool is running Windows
   * a value of Task should be specified if stricter isolation between tasks is
   * required. For example, if the task mutates the registry in a way which could
   * impact other tasks, or if certificates have been specified on the pool which
   * should not be accessible by normal tasks but should be accessible by start
   * tasks. Possible values include: 'Task', 'Pool'
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
   * The elevation level of the auto user. The default value is nonAdmin.
   * Possible values include: 'NonAdmin', 'Admin'
   *
   * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
   * of times the task may be retried. The Batch service retries a task if its
   * exit code is nonzero. Note that this value specifically controls the number
   * of retries. The Batch service will try the task once, and may then retry up
   * to this limit. For example, if the maximum retry count is 3, Batch tries the
   * task up to 4 times (one initial try and 3 retries). If the maximum retry
   * count is 0, the Batch service does not retry the task. If the maximum retry
   * count is -1, the Batch service retries the task without limit.
   *
   * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
   * service should wait for the start task to complete successfully (that is, to
   * exit with exit code 0) before scheduling any tasks on the compute node. If
   * true and the start task fails on a compute node, the Batch service retries
   * the start task up to its maximum retry count (maxTaskRetryCount). If the
   * task has still not completed successfully after all retries, then the Batch
   * service marks the compute node unusable, and will not schedule tasks to it.
   * This condition can be detected via the node state and scheduling error
   * detail. If false, the Batch service will not wait for the start task to
   * complete. In this case, other tasks can start executing on the compute node
   * while the start task is still running; and even if the start task fails, new
   * tasks will continue to be scheduled on the node. The default is true.
   *
   * @param {object} [parameters.startTask.containerSettings] The settings for
   * the container under which the start task runs. When this is specified, all
   * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
   * Batch directories on the node) are mapped into the container, all task
   * environment variables are mapped into the container, and the task command
   * line is executed in the container.
   *
   * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
   * Additional options to the container create command. These additional options
   * are supplied as arguments to the "docker create" command, in addition to
   * those controlled by the Batch Service.
   *
   * @param {string} parameters.startTask.containerSettings.imageName The image
   * to use to create the container in which the task will run. This is the full
   * image reference, as would be specified to "docker pull". If no tag is
   * provided as part of the image name, the tag ":latest" is used as a default.
   *
   * @param {object} [parameters.startTask.containerSettings.registry] The
   * private registry which contains the container image. This setting can be
   * omitted if was already provided at pool creation.
   *
   * @param {string}
   * [parameters.startTask.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} parameters.startTask.containerSettings.registry.userName The
   * user name to log into the registry server.
   *
   * @param {string} parameters.startTask.containerSettings.registry.password The
   * password to log into the registry server.
   *
   * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
   * flag to indicate where the container task working directory is. The default
   * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
   * 'ContainerImageDefault'
   *
   * @param {array} [parameters.certificates] The list of certificates to be
   * installed on each compute node in the pool. For Windows compute nodes, the
   * Batch service installs the certificates to the specified certificate store
   * and location. For Linux compute nodes, the certificates are stored in a
   * directory inside the task working directory and an environment variable
   * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
   * location. For certificates with visibility of 'remoteUser', a 'certs'
   * directory is created in the user's home directory (e.g.,
   * /home/{user-name}/certs) and certificates are placed in that directory.
   *
   * @param {array} [parameters.applicationPackages] The list of application
   * packages to be installed on each compute node in the pool. Changes to
   * application package references affect all new compute nodes joining the
   * pool, but do not affect compute nodes that are already in the pool until
   * they are rebooted or reimaged. There is a maximum of 10 application package
   * references on any given pool.
   *
   * @param {array} [parameters.applicationLicenses] The list of application
   * licenses the Batch service will make available on each compute node in the
   * pool. The list of application licenses must be a subset of available Batch
   * service application licenses. If a license is requested which is not
   * supported, pool creation will fail.
   *
   * @param {array} [parameters.mountConfiguration] A list of file systems to
   * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
   * and Blobfuse.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The entity state (ETag) version of the
   * pool to update. A value of "*" can be used to apply the operation only if
   * the pool already exists. If omitted, this operation will always be applied.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new pool to be
   * created, but to prevent updating an existing pool. Other values will be
   * ignored.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Pool>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateWithHttpOperationResponse(resourceGroupName, accountName, poolName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreate(resourceGroupName, accountName, poolName, 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 new pool inside the specified account.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @param {object} parameters Additional parameters for pool creation.
   *
   * @param {string} [parameters.displayName] The display name for the pool. The
   * display name need not be unique and can contain any Unicode characters up to
   * a maximum length of 1024.
   *
   * @param {string} [parameters.vmSize] The size of virtual machines in the
   * pool. All VMs in a pool are the same size. For information about available
   * sizes of virtual machines for Cloud Services pools (pools created with
   * cloudServiceConfiguration), see Sizes for Cloud Services
   * (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/).
   * Batch supports all Cloud Services VM sizes except ExtraSmall. For
   * information about available VM sizes for pools using images from the Virtual
   * Machines Marketplace (pools created with virtualMachineConfiguration) see
   * Sizes for Virtual Machines (Linux)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/)
   * or Sizes for Virtual Machines (Windows)
   * (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/).
   * Batch supports all Azure VM sizes except STANDARD_A0 and those with premium
   * storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series).
   *
   * @param {object} [parameters.deploymentConfiguration] This property describes
   * how the pool nodes will be deployed - using Cloud Services or Virtual
   * Machines. Using CloudServiceConfiguration specifies that the nodes should be
   * creating using Azure Cloud Services (PaaS), while
   * VirtualMachineConfiguration uses Azure Virtual Machines (IaaS).
   *
   * @param {object}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration] The cloud
   * service configuration for the pool. This property and
   * virtualMachineConfiguration are mutually exclusive and one of the properties
   * must be specified. This property cannot be specified if the Batch account
   * was created with its poolAllocationMode property set to 'UserSubscription'.
   *
   * @param {string}
   * parameters.deploymentConfiguration.cloudServiceConfiguration.osFamily The
   * Azure Guest OS family to be installed on the virtual machines in the pool.
   * Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2
   * SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4,
   * equivalent to Windows Server 2012 R2. 5 - OS Family 5, equivalent to Windows
   * Server 2016. 6 - OS Family 6, equivalent to Windows Server 2019. For more
   * information, see Azure Guest OS Releases
   * (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases).
   *
   * @param {string}
   * [parameters.deploymentConfiguration.cloudServiceConfiguration.osVersion] The
   * Azure Guest OS version to be installed on the virtual machines in the pool.
   * The default value is * which specifies the latest operating system version
   * for the specified OS family.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration] The virtual
   * machine configuration for the pool. This property and
   * cloudServiceConfiguration are mutually exclusive and one of the properties
   * must be specified.
   *
   * @param {object}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference
   * A reference to the Azure Virtual Machines Marketplace Image or the custom
   * Virtual Machine Image to use.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.publisher]
   * The publisher of the Azure Virtual Machines Marketplace image. For example,
   * Canonical or MicrosoftWindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.offer]
   * The offer type of the Azure Virtual Machines Marketplace image. For example,
   * UbuntuServer or WindowsServer.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.sku]
   * The SKU of the Azure Virtual Machines Marketplace image. For example,
   * 18.04-LTS or 2019-Datacenter.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.version]
   * The version of the Azure Virtual Machines Marketplace image. A value of
   * 'latest' can be specified to select the latest version of an image. If
   * omitted, the default is 'latest'.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.imageReference.id]
   * The ARM resource identifier of the Shared Image Gallery Image. Compute Nodes
   * in the Pool will be created using this Image Id. This is of the form
   * /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionId}.
   * This property is mutually exclusive with other properties. The Shared Image
   * Gallery image must have replicas in the same region as the Azure Batch
   * account. 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.
   *
   * @param {string}
   * parameters.deploymentConfiguration.virtualMachineConfiguration.nodeAgentSkuId
   * The SKU of the Batch node agent to be provisioned on compute nodes in the
   * pool. The Batch node agent is a program that runs on each node in the pool,
   * and provides the command-and-control interface between the node and the
   * Batch service. There are different implementations of the node agent, known
   * as SKUs, for different operating systems. You must specify a node agent SKU
   * which matches the selected image reference. To get the list of supported
   * node agent SKUs along with their list of verified image references, see the
   * 'List supported node agent SKUs' operation.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration]
   * Windows operating system settings on the virtual machine. This property must
   * not be specified if the imageReference specifies a Linux OS image.
   *
   * @param {boolean}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.windowsConfiguration.enableAutomaticUpdates]
   * Whether automatic updates are enabled on the virtual machine. If omitted,
   * the default value is true.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.dataDisks]
   * The configuration for data disks attached to the compute nodes in the pool.
   * This property must be specified if the compute nodes in the pool need to
   * have empty data disks attached to them.
   *
   * @param {string}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.licenseType]
   * The type of on-premises license to be used when deploying the operating
   * system. This only applies to images that contain the Windows operating
   * system, and should only be used when you hold valid on-premises licenses for
   * the nodes which will be deployed. If omitted, no on-premises licensing
   * discount is applied. Values are:
   *
   * Windows_Server - The on-premises license is for Windows Server.
   * Windows_Client - The on-premises license is for Windows Client.
   *
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration]
   * The container configuration for the pool. If specified, setup is performed
   * on each node in the pool to allow tasks to run in containers. All regular
   * tasks and job manager tasks run on this pool must specify the
   * containerSettings property, and all other tasks may specify it.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerImageNames]
   * The collection of container image names. This is the full image reference,
   * as would be specified to "docker pull". An image will be sourced from the
   * default Docker registry unless the image is fully qualified with an
   * alternative registry.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.containerConfiguration.containerRegistries]
   * Additional private registries from which containers can be pulled. If any
   * images must be downloaded from a private registry which requires
   * credentials, then those credentials must be provided here.
   *
   * @param {object}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration]
   * The disk encryption configuration for the pool. If specified, encryption is
   * performed on each node in the pool during node provisioning.
   *
   * @param {array}
   * [parameters.deploymentConfiguration.virtualMachineConfiguration.diskEncryptionConfiguration.targets]
   * The list of disk targets Batch Service will encrypt on the compute node On
   * Linux pool, only "TemporaryDisk" is supported; on Windows pool, "OsDisk" and
   * "TemporaryDisk" must be specified.
   *
   * @param {object} [parameters.scaleSettings] Settings which configure the
   * number of nodes in the pool.
   *
   * @param {object} [parameters.scaleSettings.fixedScale] Fixed scale settings
   * for the pool. This property and autoScale are mutually exclusive and one of
   * the properties must be specified.
   *
   * @param {moment.duration} [parameters.scaleSettings.fixedScale.resizeTimeout]
   * The timeout for allocation of compute nodes to the pool. The default value
   * is 15 minutes. Timeout values use ISO 8601 format. For example, use PT10M
   * for 10 minutes. The minimum value is 5 minutes. If you specify a value less
   * than 5 minutes, the Batch service rejects the request with an error; if you
   * are calling the REST API directly, the HTTP status code is 400 (Bad
   * Request).
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetDedicatedNodes]
   * The desired number of dedicated compute nodes in the pool. At least one of
   * targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {number} [parameters.scaleSettings.fixedScale.targetLowPriorityNodes]
   * The desired number of low-priority compute nodes in the pool. At least one
   * of targetDedicatedNodes, targetLowPriorityNodes must be set.
   *
   * @param {string} [parameters.scaleSettings.fixedScale.nodeDeallocationOption]
   * Determines what to do with a node and its running task(s) if the pool size
   * is decreasing. If omitted, the default value is Requeue. Possible values
   * include: 'Requeue', 'Terminate', 'TaskCompletion', 'RetainedData'
   *
   * @param {object} [parameters.scaleSettings.autoScale] AutoScale settings for
   * the pool. This property and fixedScale are mutually exclusive and one of the
   * properties must be specified.
   *
   * @param {string} parameters.scaleSettings.autoScale.formula A formula for the
   * desired number of compute nodes in the pool.
   *
   * @param {moment.duration}
   * [parameters.scaleSettings.autoScale.evaluationInterval] The time interval at
   * which to automatically adjust the pool size according to the autoscale
   * formula. If omitted, the default value is 15 minutes (PT15M).
   *
   * @param {string} [parameters.interNodeCommunication] Whether the pool permits
   * direct communication between nodes. This imposes restrictions on which nodes
   * can be assigned to the pool. Enabling this value can reduce the chance of
   * the requested number of nodes to be allocated in the pool. If not specified,
   * this value defaults to 'Disabled'. Possible values include: 'Enabled',
   * 'Disabled'
   *
   * @param {object} [parameters.networkConfiguration] The network configuration
   * for the pool.
   *
   * @param {string} [parameters.networkConfiguration.subnetId] The ARM resource
   * identifier of the virtual network subnet which the compute nodes of the pool
   * will join. This is of the form
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.
   * The virtual network must be in the same region and subscription as the Azure
   * Batch account. The specified subnet should have enough free IP addresses to
   * accommodate the number of nodes in the pool. If the subnet doesn't have
   * enough free IP addresses, the pool will partially allocate compute nodes and
   * a resize error will occur. The 'MicrosoftAzureBatch' service principal must
   * have the 'Classic Virtual Machine Contributor' Role-Based Access Control
   * (RBAC) role for the specified VNet. The specified subnet must allow
   * communication from the Azure Batch service to be able to schedule tasks on
   * the compute nodes. This can be verified by checking if the specified VNet
   * has any associated Network Security Groups (NSG). If communication to the
   * compute nodes in the specified subnet is denied by an NSG, then the Batch
   * service will set the state of the compute nodes to unusable. If the
   * specified VNet has any associated Network Security Groups (NSG), then a few
   * reserved system ports must be enabled for inbound communication. For pools
   * created with a virtual machine configuration, enable ports 29876 and 29877,
   * as well as port 22 for Linux and port 3389 for Windows. For pools created
   * with a cloud service configuration, enable ports 10100, 20100, and 30100.
   * Also enable outbound connections to Azure Storage on port 443. For
   * cloudServiceConfiguration pools, only 'classic' VNETs are supported. For
   * more details see:
   * https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration
   *
   * @param {object} [parameters.networkConfiguration.endpointConfiguration] The
   * configuration for endpoints on compute nodes in the Batch pool. Pool
   * endpoint configuration is only supported on pools with the
   * virtualMachineConfiguration property.
   *
   * @param {array}
   * parameters.networkConfiguration.endpointConfiguration.inboundNatPools A list
   * of inbound NAT pools that can be used to address specific ports on an
   * individual compute node externally. The maximum number of inbound NAT pools
   * per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded
   * the request fails with HTTP status code 400.
   *
   * @param {object}
   * [parameters.networkConfiguration.publicIPAddressConfiguration] The Public
   * IPAddress configuration for Compute Nodes in the Batch Pool. This property
   * is only supported on Pools with the virtualMachineConfiguration property.
   *
   * @param {string}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.provision] The
   * provisioning type for Public IP Addresses for the pool The default value is
   * BatchManaged. Possible values include: 'BatchManaged', 'UserManaged',
   * 'NoPublicIPAddresses'
   *
   * @param {array}
   * [parameters.networkConfiguration.publicIPAddressConfiguration.ipAddressIds]
   * The list of public IPs which the Batch service will use when provisioning
   * Compute Nodes. The number of IPs specified here limits the maximum size of
   * the Pool - 50 dedicated nodes or 20 low-priority nodes can be allocated for
   * each public IP. For example, a pool needing 150 dedicated VMs would need at
   * least 3 public IPs specified. Each element of this collection is of the
   * form:
   * /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}.
   *
   * @param {number} [parameters.maxTasksPerNode] The maximum number of tasks
   * that can run concurrently on a single compute node in the pool. The default
   * value is 1. The maximum value is the smaller of 4 times the number of cores
   * of the vmSize of the pool or 256.
   *
   * @param {object} [parameters.taskSchedulingPolicy] How tasks are distributed
   * across compute nodes in a pool. If not specified, the default is spread.
   *
   * @param {string} parameters.taskSchedulingPolicy.nodeFillType How tasks
   * should be distributed across compute nodes. Possible values include:
   * 'Spread', 'Pack'
   *
   * @param {array} [parameters.userAccounts] The list of user accounts to be
   * created on each node in the pool.
   *
   * @param {array} [parameters.metadata] A list of name-value pairs associated
   * with the pool as metadata. The Batch service does not assign any meaning to
   * metadata; it is solely for the use of user code.
   *
   * @param {object} [parameters.startTask] A task specified to run on each
   * compute node as it joins the pool. In an PATCH (update) operation, this
   * property can be set to an empty object to remove the start task from the
   * pool.
   *
   * @param {string} [parameters.startTask.commandLine] The command line of the
   * start task. The command line does not run under a shell, and therefore
   * cannot take advantage of shell features such as environment variable
   * expansion. If you want to take advantage of such features, you should invoke
   * the shell in the command line, for example using "cmd /c MyCommand" in
   * Windows or "/bin/sh -c MyCommand" in Linux. Required if any other properties
   * of the startTask are specified.
   *
   * @param {array} [parameters.startTask.resourceFiles] A list of files that the
   * Batch service will download to the compute node before running the command
   * line.
   *
   * @param {array} [parameters.startTask.environmentSettings] A list of
   * environment variable settings for the start task.
   *
   * @param {object} [parameters.startTask.userIdentity] The user identity under
   * which the start task runs. If omitted, the task runs as a non-administrative
   * user unique to the task.
   *
   * @param {string} [parameters.startTask.userIdentity.userName] The name of the
   * user identity under which the task is run. The userName and autoUser
   * properties are mutually exclusive; you must specify one but not both.
   *
   * @param {object} [parameters.startTask.userIdentity.autoUser] The auto user
   * under which the task is run. The userName and autoUser properties are
   * mutually exclusive; you must specify one but not both.
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.scope] The scope
   * for the auto user The default value is Pool. If the pool is running Windows
   * a value of Task should be specified if stricter isolation between tasks is
   * required. For example, if the task mutates the registry in a way which could
   * impact other tasks, or if certificates have been specified on the pool which
   * should not be accessible by normal tasks but should be accessible by start
   * tasks. Possible values include: 'Task', 'Pool'
   *
   * @param {string} [parameters.startTask.userIdentity.autoUser.elevationLevel]
   * The elevation level of the auto user. The default value is nonAdmin.
   * Possible values include: 'NonAdmin', 'Admin'
   *
   * @param {number} [parameters.startTask.maxTaskRetryCount] The maximum number
   * of times the task may be retried. The Batch service retries a task if its
   * exit code is nonzero. Note that this value specifically controls the number
   * of retries. The Batch service will try the task once, and may then retry up
   * to this limit. For example, if the maximum retry count is 3, Batch tries the
   * task up to 4 times (one initial try and 3 retries). If the maximum retry
   * count is 0, the Batch service does not retry the task. If the maximum retry
   * count is -1, the Batch service retries the task without limit.
   *
   * @param {boolean} [parameters.startTask.waitForSuccess] Whether the Batch
   * service should wait for the start task to complete successfully (that is, to
   * exit with exit code 0) before scheduling any tasks on the compute node. If
   * true and the start task fails on a compute node, the Batch service retries
   * the start task up to its maximum retry count (maxTaskRetryCount). If the
   * task has still not completed successfully after all retries, then the Batch
   * service marks the compute node unusable, and will not schedule tasks to it.
   * This condition can be detected via the node state and scheduling error
   * detail. If false, the Batch service will not wait for the start task to
   * complete. In this case, other tasks can start executing on the compute node
   * while the start task is still running; and even if the start task fails, new
   * tasks will continue to be scheduled on the node. The default is true.
   *
   * @param {object} [parameters.startTask.containerSettings] The settings for
   * the container under which the start task runs. When this is specified, all
   * directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure
   * Batch directories on the node) are mapped into the container, all task
   * environment variables are mapped into the container, and the task command
   * line is executed in the container.
   *
   * @param {string} [parameters.startTask.containerSettings.containerRunOptions]
   * Additional options to the container create command. These additional options
   * are supplied as arguments to the "docker create" command, in addition to
   * those controlled by the Batch Service.
   *
   * @param {string} parameters.startTask.containerSettings.imageName The image
   * to use to create the container in which the task will run. This is the full
   * image reference, as would be specified to "docker pull". If no tag is
   * provided as part of the image name, the tag ":latest" is used as a default.
   *
   * @param {object} [parameters.startTask.containerSettings.registry] The
   * private registry which contains the container image. This setting can be
   * omitted if was already provided at pool creation.
   *
   * @param {string}
   * [parameters.startTask.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} parameters.startTask.containerSettings.registry.userName The
   * user name to log into the registry server.
   *
   * @param {string} parameters.startTask.containerSettings.registry.password The
   * password to log into the registry server.
   *
   * @param {string} [parameters.startTask.containerSettings.workingDirectory] A
   * flag to indicate where the container task working directory is. The default
   * is 'taskWorkingDirectory'. Possible values include: 'TaskWorkingDirectory',
   * 'ContainerImageDefault'
   *
   * @param {array} [parameters.certificates] The list of certificates to be
   * installed on each compute node in the pool. For Windows compute nodes, the
   * Batch service installs the certificates to the specified certificate store
   * and location. For Linux compute nodes, the certificates are stored in a
   * directory inside the task working directory and an environment variable
   * AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this
   * location. For certificates with visibility of 'remoteUser', a 'certs'
   * directory is created in the user's home directory (e.g.,
   * /home/{user-name}/certs) and certificates are placed in that directory.
   *
   * @param {array} [parameters.applicationPackages] The list of application
   * packages to be installed on each compute node in the pool. Changes to
   * application package references affect all new compute nodes joining the
   * pool, but do not affect compute nodes that are already in the pool until
   * they are rebooted or reimaged. There is a maximum of 10 application package
   * references on any given pool.
   *
   * @param {array} [parameters.applicationLicenses] The list of application
   * licenses the Batch service will make available on each compute node in the
   * pool. The list of application licenses must be a subset of available Batch
   * service application licenses. If a license is requested which is not
   * supported, pool creation will fail.
   *
   * @param {array} [parameters.mountConfiguration] A list of file systems to
   * mount on each node in the pool. This supports Azure Files, NFS, CIFS/SMB,
   * and Blobfuse.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The entity state (ETag) version of the
   * pool to update. A value of "*" can be used to apply the operation only if
   * the pool already exists. If omitted, this operation will always be applied.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new pool to be
   * created, but to prevent updating an existing pool. Other values will be
   * ignored.
   *
   * @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 {Pool} - 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 Pool} 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, accountName, poolName, 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, accountName, poolName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreate(resourceGroupName, accountName, poolName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes the specified pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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, accountName, poolName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, accountName, poolName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes the specified pool.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the Batch account.
   *
   * @param {string} accountName The name of the Batch account.
   *
   * @param {string} poolName The pool name. This must be unique within the
   * account.
   *
   * @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, accountName, poolName, 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, accountName, poolName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, accountName, poolName, options, optionalCallback);
    }
  }

  /**
   * Lists all of the pools in the specified account.
   *
   * @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<ListPoolsResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByBatchAccountNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByBatchAccountNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all of the pools in the specified account.
   *
   * @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 {ListPoolsResult} - 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 ListPoolsResult} 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.
   */
  listByBatchAccountNext(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._listByBatchAccountNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByBatchAccountNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = PoolOperations;
