text: /*
   * 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;
  const moment = require('moment');
  
  /**
   * @summary Adds a task to the specified job.
   *
   * The maximum lifetime of a task from addition to completion is 7 days. If a
   * task has not completed within 7 days of being added it will be terminated by
   * the Batch service and left in whatever state it was in at that time.
   *
   * @param {string} jobId The ID of the job to which the task is to be added.
   *
   * @param {object} task The task to be added.
   *
   * @param {string} task.id A string that uniquely identifies the task within
   * the job. The ID can contain any combination of alphanumeric characters
   * including hyphens and underscores, and cannot contain more than 64
   * characters. The ID is case-preserving and case-insensitive (that is, you may
   * not have two IDs within a job that differ only by case).
   *
   * @param {string} [task.displayName] A display name for the task. The display
   * name need not be unique and can contain any Unicode characters up to a
   * maximum length of 1024.
   *
   * @param {string} task.commandLine The command line of the task. For
   * multi-instance tasks, the command line is executed as the primary task,
   * after the primary task and all subtasks have finished executing the
   * coordination command line. 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. If the command
   * line refers to file paths, it should use a relative path (relative to the
   * task working directory), or use the Batch provided environment variable
   * (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
   *
   * @param {object} [task.containerSettings] The settings for the container
   * under which the task runs. If the pool that will run this task has
   * containerConfiguration set, this must be set as well. If the pool that will
   * run this task doesn't have containerConfiguration set, this must not be set.
   * 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} [task.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} task.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} [task.containerSettings.registry] The private registry which
   * contains the container image. This setting can be omitted if was already
   * provided at pool creation.
   *
   * @param {string} [task.containerSettings.registry.registryServer] The
   * registry URL. If omitted, the default is "docker.io".
   *
   * @param {string} task.containerSettings.registry.userName The user name to
   * log into the registry server.
   *
   * @param {string} task.containerSettings.registry.password The password to log
   * into the registry server.
   *
   * @param {object} [task.exitConditions] How the Batch service should respond
   * when the task completes.
   *
   * @param {array} [task.exitConditions.exitCodes] A list of individual task
   * exit codes and how the Batch service should respond to them.
   *
   * @param {array} [task.exitConditions.exitCodeRanges] A list of task exit code
   * ranges and how the Batch service should respond to them.
   *
   * @param {object} [task.exitConditions.preProcessingError] How the Batch
   * service should respond if the task fails to start due to an error.
   *
   * @param {object} [task.exitConditions.fileUploadError] How the Batch service
   * should respond if a file upload error occurs. If the task exited with an
   * exit code that was specified via exitCodes or exitCodeRanges, and then
   * encountered a file upload error, then the action specified by the exit code
   * takes precedence.
   *
   * @param {object} [task.exitConditions.default] How the Batch service should
   * respond if the task fails with an exit condition not covered by any of the
   * other properties. This value is used if the task exits with any nonzero exit
   * code not listed in the exitCodes or exitCodeRanges collection, with a
   * pre-processing error if the preProcessingError property is not present, or
   * with a file upload error if the fileUploadError property is not present. If
   * you want non-default behaviour on exit code 0, you must list it explicitly
   * using the exitCodes or exitCodeRanges collection.
   *
   * @param {string} [task.exitConditions.default.jobAction] An action to take on
   * the job containing the task, if the task completes with the given exit
   * condition and the job's onTaskFailed property is
   * 'performExitOptionsJobAction'. The default is none for exit code 0 and
   * terminate for all other exit conditions. If the job's onTaskFailed property
   * is noaction, then specifying this property returns an error and the add task
   * request fails with an invalid property value error; if you are calling the
   * REST API directly, the HTTP status code is 400 (Bad Request). Possible
   * values include: 'none', 'disable', 'terminate'
   *
   * @param {string} [task.exitConditions.default.dependencyAction] An action
   * that the Batch service performs on tasks that depend on this task. The
   * default is 'satisfy' for exit code 0, and 'block' for all other exit
   * conditions. If the job's usesTaskDependencies property is set to false, then
   * specifying the dependencyAction property returns an error and the add task
   * request fails with an invalid property value error; if you are calling the
   * REST API directly, the HTTP status code is 400  (Bad Request). Possible
   * values include: 'satisfy', 'block'
   *
   * @param {array} [task.resourceFiles] A list of files that the Batch service
   * will download to the compute node before running the command line. For
   * multi-instance tasks, the resource files will only be downloaded to the
   * compute node on which the primary task is executed. There is a maximum size
   * for the list of resource files.  When the max size is exceeded, the request
   * will fail and the response error code will be RequestEntityTooLarge. If this
   * occurs, the collection of ResourceFiles must be reduced in size. This can be
   * achieved using .zip files, Application Packages, or Docker Containers.
   *
   * @param {array} [task.outputFiles] A list of files that the Batch service
   * will upload from the compute node after running the command line. For
   * multi-instance tasks, the files will only be uploaded from the compute node
   * on which the primary task is executed.
   *
   * @param {array} [task.environmentSettings] A list of environment variable
   * settings for the task.
   *
   * @param {object} [task.affinityInfo] A locality hint that can be used by the
   * Batch service to select a compute node on which to start the new task.
   *
   * @param {string} task.affinityInfo.affinityId An opaque string representing
   * the location of a compute node or a task that has run previously. You can
   * pass the affinityId of a compute node to indicate that this task needs to
   * run on that compute node. Note that this is just a soft affinity. If the
   * target node is busy or unavailable at the time the task is scheduled, then
   * the task will be scheduled elsewhere.
   *
   * @param {object} [task.constraints] The execution constraints that apply to
   * this task. If you do not specify constraints, the maxTaskRetryCount is the
   * maxTaskRetryCount specified for the job, and the maxWallClockTime and
   * retentionTime are infinite.
   *
   * @param {moment.duration} [task.constraints.maxWallClockTime] The maximum
   * elapsed time that the task may run, measured from the time the task starts.
   * If the task does not complete within the time limit, the Batch service
   * terminates it. If this is not specified, there is no time limit on how long
   * the task may run.
   *
   * @param {moment.duration} [task.constraints.retentionTime] The minimum time
   * to retain the task directory on the compute node where it ran, from the time
   * it completes execution. After this time, the Batch service may delete the
   * task directory and all its contents. The default is infinite, i.e. the task
   * directory will be retained until the compute node is removed or reimaged.
   *
   * @param {number} [task.constraints.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 for the task executable due to a nonzero exit code. 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 after the first attempt. If the maximum
   * retry count is -1, the Batch service retries the task without limit.
   * Resource files and application packages are only downloaded again if the
   * task is retried on a new compute node.
   *
   * @param {object} [task.userIdentity] The user identity under which the task
   * runs. If omitted, the task runs as a non-administrative user unique to the
   * task.
   *
   * @param {string} [task.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} [task.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} [task.userIdentity.autoUser.scope] The scope for the auto
   * user The default value is task. Possible values include: 'task', 'pool'
   *
   * @param {string} [task.userIdentity.autoUser.elevationLevel] The elevation
   * level of the auto user. The default value is nonAdmin. Possible values
   * include: 'nonAdmin', 'admin'
   *
   * @param {object} [task.multiInstanceSettings] An object that indicates that
   * the task is a multi-instance task, and contains information about how to run
   * the multi-instance task.
   *
   * @param {number} [task.multiInstanceSettings.numberOfInstances] The number of
   * compute nodes required by the task. If omitted, the default is 1.
   *
   * @param {string} task.multiInstanceSettings.coordinationCommandLine The
   * command line to run on all the compute nodes to enable them to coordinate
   * when the primary runs the main task command. A typical coordination command
   * line launches a background service and verifies that the service is ready to
   * process inter-node messages.
   *
   * @param {array} [task.multiInstanceSettings.commonResourceFiles] A list of
   * files that the Batch service will download before running the coordination
   * command line. The difference between common resource files and task resource
   * files is that common resource files are downloaded for all subtasks
   * including the primary, whereas task resource files are downloaded only for
   * the primary. Also note that these resource files are not downloaded to the
   * task working directory, but instead are downloaded to the task root
   * directory (one directory above the working directory).  There is a maximum
   * size for the list of resource files.  When the max size is exceeded, the
   * request will fail and the response error code will be RequestEntityTooLarge.
   * If this occurs, the collection of ResourceFiles must be reduced in size.
   * This can be achieved using .zip files, Application Packages, or Docker
   * Containers.
   *
   * @param {object} [task.dependsOn] The tasks that this task depends on. This
   * task will not be scheduled until all tasks that it depends on have completed
   * successfully. If any of those tasks fail and exhaust their retry counts,
   * this task will never be scheduled. If the job does not have
   * usesTaskDependencies set to true, and this element is present, the request
   * fails with error code TaskDependenciesNotSpecifiedOnJob.
   *
   * @param {array} [task.dependsOn.taskIds] The list of task IDs that this task
   * depends on. All tasks in this list must complete successfully before the
   * dependent task can be scheduled. The taskIds collection is limited to 64000
   * characters total (i.e. the combined length of all task IDs). If the taskIds
   * collection exceeds the maximum length, the Add Task request fails with error
   * code TaskDependencyListTooLong. In this case consider using task ID ranges
   * instead.
   *
   * @param {array} [task.dependsOn.taskIdRanges] The list of task ID ranges that
   * this task depends on. All tasks in all ranges must complete successfully
   * before the dependent task can be scheduled.
   *
   * @param {array} [task.applicationPackageReferences] A list of application
   * packages that the Batch service will deploy to the compute node before
   * running the command line. Application packages are downloaded and deployed
   * to a shared directory, not the task working directory. Therefore, if a
   * referenced package is already on the compute node, and is up to date, then
   * it is not re-downloaded; the existing copy on the compute node is used. If a
   * referenced application package cannot be installed, for example because the
   * package has been deleted or because download failed, the task fails.
   *
   * @param {object} [task.authenticationTokenSettings] The settings for an
   * authentication token that the task can use to perform Batch service
   * operations. If this property is set, the Batch service provides the task
   * with an authentication token which can be used to authenticate Batch service
   * operations without requiring an account access key. The token is provided
   * via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations
   * that the task can carry out using the token depend on the settings. For
   * example, a task can request job permissions in order to add other tasks to
   * the job, or check the status of the job or of other tasks under the job.
   *
   * @param {array} [task.authenticationTokenSettings.access] The Batch resources
   * to which the token grants access. The authentication token grants access to
   * a limited set of Batch service operations. Currently the only supported
   * value for the access property is 'job', which grants access to all
   * operations related to the job which contains the task.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskAddOptions] Additional parameters for the
   * operation
   *
   * @param {number} [options.taskAddOptions.timeout] The maximum time that the
   * server can spend processing the request, in seconds. The default is 30
   * seconds.
   *
   * @param {uuid} [options.taskAddOptions.clientRequestId] The caller-generated
   * request identity, in the form of a GUID with no decoration such as curly
   * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskAddOptions.returnClientRequestId] Whether the
   * server should return the client-request-id in the response.
   *
   * @param {date} [options.taskAddOptions.ocpDate] The time the request was
   * issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @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 _add(jobId, task, 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 taskAddOptions = (options && options.taskAddOptions !== undefined) ? options.taskAddOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (task === null || task === undefined) {
        throw new Error('task cannot be null or undefined.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    try {
      if (taskAddOptions !== null && taskAddOptions !== undefined)
      {
        timeout = taskAddOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskAddOptions !== null && taskAddOptions !== undefined)
      {
        clientRequestId = taskAddOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskAddOptions !== null && taskAddOptions !== undefined)
      {
        returnClientRequestId = taskAddOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskAddOptions !== null && taskAddOptions !== undefined)
      {
        ocpDate = taskAddOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    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; odata=minimalmetadata; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    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 (task !== null && task !== undefined) {
        let requestModelMapper = new client.models['TaskAddParameter']().mapper();
        requestModel = client.serialize(requestModelMapper, task, 'task');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(task, 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 !== 201) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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);
    });
  }
  
  /**
   * @summary Lists all of the tasks that are associated with the specified job.
   *
   * For multi-instance tasks, information such as affinityId, executionInfo and
   * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
   * information about subtasks.
   *
   * @param {string} jobId The ID of the job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskListOptions] Additional parameters for the
   * operation
   *
   * @param {string} [options.taskListOptions.filter] An OData $filter clause.
   * For more information on constructing this filter, see
   * https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-tasks.
   *
   * @param {string} [options.taskListOptions.select] An OData $select clause.
   *
   * @param {string} [options.taskListOptions.expand] An OData $expand clause.
   *
   * @param {number} [options.taskListOptions.maxResults] The maximum number of
   * items to return in the response. A maximum of 1000 tasks can be returned.
   *
   * @param {number} [options.taskListOptions.timeout] The maximum time that the
   * server can spend processing the request, in seconds. The default is 30
   * seconds.
   *
   * @param {uuid} [options.taskListOptions.clientRequestId] The caller-generated
   * request identity, in the form of a GUID with no decoration such as curly
   * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskListOptions.returnClientRequestId] Whether the
   * server should return the client-request-id in the response.
   *
   * @param {date} [options.taskListOptions.ocpDate] The time the request was
   * issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @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 CloudTaskListResult} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _list(jobId, 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 taskListOptions = (options && options.taskListOptions !== undefined) ? options.taskListOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let filter;
    let select;
    let expand;
    let maxResults;
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    try {
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        filter = taskListOptions.filter;
        if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
          throw new Error('filter must be of type string.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        select = taskListOptions.select;
        if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') {
          throw new Error('select must be of type string.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        expand = taskListOptions.expand;
        if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
          throw new Error('expand must be of type string.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        maxResults = taskListOptions.maxResults;
        if (maxResults !== null && maxResults !== undefined && typeof maxResults !== 'number') {
          throw new Error('maxResults must be of type number.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        timeout = taskListOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        clientRequestId = taskListOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        returnClientRequestId = taskListOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskListOptions !== null && taskListOptions !== undefined)
      {
        ocpDate = taskListOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (filter !== null && filter !== undefined) {
      queryParameters.push('$filter=' + encodeURIComponent(filter));
    }
    if (select !== null && select !== undefined) {
      queryParameters.push('$select=' + encodeURIComponent(select));
    }
    if (expand !== null && expand !== undefined) {
      queryParameters.push('$expand=' + encodeURIComponent(expand));
    }
    if (maxResults !== null && maxResults !== undefined) {
      queryParameters.push('maxresults=' + encodeURIComponent(maxResults.toString()));
    }
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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['CloudTaskListResult']().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 Adds a collection of tasks to the specified job.
   *
   * Note that each task must have a unique ID. The Batch service may not return
   * the results for each task in the same order the tasks were submitted in this
   * request. If the server times out or the connection is closed during the
   * request, the request may have been partially or fully processed, or not at
   * all. In such cases, the user should re-issue the request. Note that it is up
   * to the user to correctly handle failures when re-issuing a request. For
   * example, you should use the same task IDs during a retry so that if the
   * prior operation succeeded, the retry will not create extra tasks
   * unexpectedly. If the response contains any tasks which failed to add, a
   * client can retry the request. In a retry, it is most efficient to resubmit
   * only tasks that failed to add, and to omit tasks that were successfully
   * added on the first attempt. The maximum lifetime of a task from addition to
   * completion is 7 days. If a task has not completed within 7 days of being
   * added it will be terminated by the Batch service and left in whatever state
   * it was in at that time.
   *
   * @param {string} jobId The ID of the job to which the task collection is to
   * be added.
   *
   * @param {array} value The collection of tasks to add. The maximum count of
   * tasks is 100. The total serialized size of this collection must be less than
   * 1MB. If it is greater than 1MB (for example if each task has 100's of
   * resource files or environment variables), the request will fail with code
   * 'RequestBodyTooLarge' and should be retried again with fewer tasks.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskAddCollectionOptions] Additional parameters for
   * the operation
   *
   * @param {number} [options.taskAddCollectionOptions.timeout] The maximum time
   * that the server can spend processing the request, in seconds. The default is
   * 30 seconds.
   *
   * @param {uuid} [options.taskAddCollectionOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskAddCollectionOptions.returnClientRequestId]
   * Whether the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskAddCollectionOptions.ocpDate] The time the
   * request was issued. Client libraries typically set this to the current
   * system clock time; set it explicitly if you are calling the REST API
   * directly.
   *
   * @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 TaskAddCollectionResult} 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 _addCollection(jobId, value, 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 taskAddCollectionOptions = (options && options.taskAddCollectionOptions !== undefined) ? options.taskAddCollectionOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (value !== null && value !== undefined) {
        if (value.length > 100)
        {
          throw new Error('"value" should satisfy the constraint - "MaxItems": 100');
        }
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    let taskCollection = new client.models['TaskAddCollectionParameter']();
    try {
      if (taskAddCollectionOptions !== null && taskAddCollectionOptions !== undefined)
      {
        timeout = taskAddCollectionOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskAddCollectionOptions !== null && taskAddCollectionOptions !== undefined)
      {
        clientRequestId = taskAddCollectionOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskAddCollectionOptions !== null && taskAddCollectionOptions !== undefined)
      {
        returnClientRequestId = taskAddCollectionOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskAddCollectionOptions !== null && taskAddCollectionOptions !== undefined)
      {
        ocpDate = taskAddCollectionOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
      if (value !== null && value !== undefined)
      {
        taskCollection.value = value;
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/addtaskcollection';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    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; odata=minimalmetadata; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    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 (taskCollection !== null && taskCollection !== undefined) {
        let requestModelMapper = new client.models['TaskAddCollectionParameter']().mapper();
        requestModel = client.serialize(requestModelMapper, taskCollection, 'taskCollection');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(taskCollection, 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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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['TaskAddCollectionResult']().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 Deletes a task from the specified job.
   *
   * When a task is deleted, all of the files in its directory on the compute
   * node where it ran are also deleted (regardless of the retention time). For
   * multi-instance tasks, the delete task operation applies synchronously to the
   * primary task; subtasks and their files are then deleted asynchronously in
   * the background.
   *
   * @param {string} jobId The ID of the job from which to delete the task.
   *
   * @param {string} taskId The ID of the task to delete.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskDeleteMethodOptions] Additional parameters for
   * the operation
   *
   * @param {number} [options.taskDeleteMethodOptions.timeout] The maximum time
   * that the server can spend processing the request, in seconds. The default is
   * 30 seconds.
   *
   * @param {uuid} [options.taskDeleteMethodOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskDeleteMethodOptions.returnClientRequestId]
   * Whether the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskDeleteMethodOptions.ocpDate] The time the request
   * was issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @param {string} [options.taskDeleteMethodOptions.ifMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service exactly matches the value specified by the client.
   *
   * @param {string} [options.taskDeleteMethodOptions.ifNoneMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service does not match the value specified by the client.
   *
   * @param {date} [options.taskDeleteMethodOptions.ifModifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has been
   * modified since the specified time.
   *
   * @param {date} [options.taskDeleteMethodOptions.ifUnmodifiedSince] A
   * timestamp indicating the last modified time of the resource known to the
   * client. The operation will be performed only if the resource on the service
   * has not been modified since the specified time.
   *
   * @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(jobId, taskId, 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 taskDeleteMethodOptions = (options && options.taskDeleteMethodOptions !== undefined) ? options.taskDeleteMethodOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (taskId === null || taskId === undefined || typeof taskId.valueOf() !== 'string') {
        throw new Error('taskId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    let ifMatch;
    let ifNoneMatch;
    let ifModifiedSince;
    let ifUnmodifiedSince;
    try {
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        timeout = taskDeleteMethodOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        clientRequestId = taskDeleteMethodOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        returnClientRequestId = taskDeleteMethodOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        ocpDate = taskDeleteMethodOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        ifMatch = taskDeleteMethodOptions.ifMatch;
        if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
          throw new Error('ifMatch must be of type string.');
        }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        ifNoneMatch = taskDeleteMethodOptions.ifNoneMatch;
        if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
          throw new Error('ifNoneMatch must be of type string.');
        }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        ifModifiedSince = taskDeleteMethodOptions.ifModifiedSince;
        if (ifModifiedSince && !(ifModifiedSince instanceof Date ||
            (typeof ifModifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifModifiedSince))))) {
              throw new Error('ifModifiedSince must be of type date.');
            }
      }
      if (taskDeleteMethodOptions !== null && taskDeleteMethodOptions !== undefined)
      {
        ifUnmodifiedSince = taskDeleteMethodOptions.ifUnmodifiedSince;
        if (ifUnmodifiedSince && !(ifUnmodifiedSince instanceof Date ||
            (typeof ifUnmodifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifUnmodifiedSince))))) {
              throw new Error('ifUnmodifiedSince must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks/{taskId}';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    requestUrl = requestUrl.replace('{taskId}', encodeURIComponent(taskId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    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['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    if (ifMatch !== undefined && ifMatch !== null) {
      httpRequest.headers['If-Match'] = ifMatch;
    }
    if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
      httpRequest.headers['If-None-Match'] = ifNoneMatch;
    }
    if (ifModifiedSince !== undefined && ifModifiedSince !== null) {
      httpRequest.headers['If-Modified-Since'] = ifModifiedSince.toUTCString();
    }
    if (ifUnmodifiedSince !== undefined && ifUnmodifiedSince !== null) {
      httpRequest.headers['If-Unmodified-Since'] = ifUnmodifiedSince.toUTCString();
    }
    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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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);
    });
  }
  
  /**
   * @summary Gets information about the specified task.
   *
   * For multi-instance tasks, information such as affinityId, executionInfo and
   * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
   * information about subtasks.
   *
   * @param {string} jobId The ID of the job that contains the task.
   *
   * @param {string} taskId The ID of the task to get information about.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskGetOptions] Additional parameters for the
   * operation
   *
   * @param {string} [options.taskGetOptions.select] An OData $select clause.
   *
   * @param {string} [options.taskGetOptions.expand] An OData $expand clause.
   *
   * @param {number} [options.taskGetOptions.timeout] The maximum time that the
   * server can spend processing the request, in seconds. The default is 30
   * seconds.
   *
   * @param {uuid} [options.taskGetOptions.clientRequestId] The caller-generated
   * request identity, in the form of a GUID with no decoration such as curly
   * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskGetOptions.returnClientRequestId] Whether the
   * server should return the client-request-id in the response.
   *
   * @param {date} [options.taskGetOptions.ocpDate] The time the request was
   * issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @param {string} [options.taskGetOptions.ifMatch] An ETag value associated
   * with the version of the resource known to the client. The operation will be
   * performed only if the resource's current ETag on the service exactly matches
   * the value specified by the client.
   *
   * @param {string} [options.taskGetOptions.ifNoneMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service does not match the value specified by the client.
   *
   * @param {date} [options.taskGetOptions.ifModifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has been
   * modified since the specified time.
   *
   * @param {date} [options.taskGetOptions.ifUnmodifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has not been
   * modified since the specified time.
   *
   * @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 CloudTask} 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(jobId, taskId, 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 taskGetOptions = (options && options.taskGetOptions !== undefined) ? options.taskGetOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (taskId === null || taskId === undefined || typeof taskId.valueOf() !== 'string') {
        throw new Error('taskId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let select;
    let expand;
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    let ifMatch;
    let ifNoneMatch;
    let ifModifiedSince;
    let ifUnmodifiedSince;
    try {
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        select = taskGetOptions.select;
        if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') {
          throw new Error('select must be of type string.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        expand = taskGetOptions.expand;
        if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
          throw new Error('expand must be of type string.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        timeout = taskGetOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        clientRequestId = taskGetOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        returnClientRequestId = taskGetOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        ocpDate = taskGetOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        ifMatch = taskGetOptions.ifMatch;
        if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
          throw new Error('ifMatch must be of type string.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        ifNoneMatch = taskGetOptions.ifNoneMatch;
        if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
          throw new Error('ifNoneMatch must be of type string.');
        }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        ifModifiedSince = taskGetOptions.ifModifiedSince;
        if (ifModifiedSince && !(ifModifiedSince instanceof Date ||
            (typeof ifModifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifModifiedSince))))) {
              throw new Error('ifModifiedSince must be of type date.');
            }
      }
      if (taskGetOptions !== null && taskGetOptions !== undefined)
      {
        ifUnmodifiedSince = taskGetOptions.ifUnmodifiedSince;
        if (ifUnmodifiedSince && !(ifUnmodifiedSince instanceof Date ||
            (typeof ifUnmodifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifUnmodifiedSince))))) {
              throw new Error('ifUnmodifiedSince must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks/{taskId}';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    requestUrl = requestUrl.replace('{taskId}', encodeURIComponent(taskId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (select !== null && select !== undefined) {
      queryParameters.push('$select=' + encodeURIComponent(select));
    }
    if (expand !== null && expand !== undefined) {
      queryParameters.push('$expand=' + encodeURIComponent(expand));
    }
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    if (ifMatch !== undefined && ifMatch !== null) {
      httpRequest.headers['If-Match'] = ifMatch;
    }
    if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
      httpRequest.headers['If-None-Match'] = ifNoneMatch;
    }
    if (ifModifiedSince !== undefined && ifModifiedSince !== null) {
      httpRequest.headers['If-Modified-Since'] = ifModifiedSince.toUTCString();
    }
    if (ifUnmodifiedSince !== undefined && ifUnmodifiedSince !== null) {
      httpRequest.headers['If-Unmodified-Since'] = ifUnmodifiedSince.toUTCString();
    }
    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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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['CloudTask']().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 the specified task.
   *
   * @param {string} jobId The ID of the job containing the task.
   *
   * @param {string} taskId The ID of the task to update.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.constraints] Constraints that apply to this task.
   * If omitted, the task is given the default constraints. For multi-instance
   * tasks, updating the retention time applies only to the primary task and not
   * subtasks.
   *
   * @param {moment.duration} [options.constraints.maxWallClockTime] The maximum
   * elapsed time that the task may run, measured from the time the task starts.
   * If the task does not complete within the time limit, the Batch service
   * terminates it. If this is not specified, there is no time limit on how long
   * the task may run.
   *
   * @param {moment.duration} [options.constraints.retentionTime] The minimum
   * time to retain the task directory on the compute node where it ran, from the
   * time it completes execution. After this time, the Batch service may delete
   * the task directory and all its contents. The default is infinite, i.e. the
   * task directory will be retained until the compute node is removed or
   * reimaged.
   *
   * @param {number} [options.constraints.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 for the task executable due to a nonzero exit code. 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 after the first attempt. If the maximum
   * retry count is -1, the Batch service retries the task without limit.
   * Resource files and application packages are only downloaded again if the
   * task is retried on a new compute node.
   *
   * @param {object} [options.taskUpdateOptions] Additional parameters for the
   * operation
   *
   * @param {number} [options.taskUpdateOptions.timeout] The maximum time that
   * the server can spend processing the request, in seconds. The default is 30
   * seconds.
   *
   * @param {uuid} [options.taskUpdateOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskUpdateOptions.returnClientRequestId] Whether
   * the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskUpdateOptions.ocpDate] The time the request was
   * issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @param {string} [options.taskUpdateOptions.ifMatch] An ETag value associated
   * with the version of the resource known to the client. The operation will be
   * performed only if the resource's current ETag on the service exactly matches
   * the value specified by the client.
   *
   * @param {string} [options.taskUpdateOptions.ifNoneMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service does not match the value specified by the client.
   *
   * @param {date} [options.taskUpdateOptions.ifModifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has been
   * modified since the specified time.
   *
   * @param {date} [options.taskUpdateOptions.ifUnmodifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has not been
   * modified since the specified time.
   *
   * @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 _update(jobId, taskId, 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 constraints = (options && options.constraints !== undefined) ? options.constraints : undefined;
    let taskUpdateOptions = (options && options.taskUpdateOptions !== undefined) ? options.taskUpdateOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (taskId === null || taskId === undefined || typeof taskId.valueOf() !== 'string') {
        throw new Error('taskId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    let ifMatch;
    let ifNoneMatch;
    let ifModifiedSince;
    let ifUnmodifiedSince;
    let taskUpdateParameter = new client.models['TaskUpdateParameter']();
    try {
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        timeout = taskUpdateOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        clientRequestId = taskUpdateOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        returnClientRequestId = taskUpdateOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        ocpDate = taskUpdateOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        ifMatch = taskUpdateOptions.ifMatch;
        if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
          throw new Error('ifMatch must be of type string.');
        }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        ifNoneMatch = taskUpdateOptions.ifNoneMatch;
        if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
          throw new Error('ifNoneMatch must be of type string.');
        }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        ifModifiedSince = taskUpdateOptions.ifModifiedSince;
        if (ifModifiedSince && !(ifModifiedSince instanceof Date ||
            (typeof ifModifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifModifiedSince))))) {
              throw new Error('ifModifiedSince must be of type date.');
            }
      }
      if (taskUpdateOptions !== null && taskUpdateOptions !== undefined)
      {
        ifUnmodifiedSince = taskUpdateOptions.ifUnmodifiedSince;
        if (ifUnmodifiedSince && !(ifUnmodifiedSince instanceof Date ||
            (typeof ifUnmodifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifUnmodifiedSince))))) {
              throw new Error('ifUnmodifiedSince must be of type date.');
            }
      }
      if (constraints !== null && constraints !== undefined)
      {
        taskUpdateParameter.constraints = constraints;
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks/{taskId}';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    requestUrl = requestUrl.replace('{taskId}', encodeURIComponent(taskId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    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; odata=minimalmetadata; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    if (ifMatch !== undefined && ifMatch !== null) {
      httpRequest.headers['If-Match'] = ifMatch;
    }
    if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
      httpRequest.headers['If-None-Match'] = ifNoneMatch;
    }
    if (ifModifiedSince !== undefined && ifModifiedSince !== null) {
      httpRequest.headers['If-Modified-Since'] = ifModifiedSince.toUTCString();
    }
    if (ifUnmodifiedSince !== undefined && ifUnmodifiedSince !== null) {
      httpRequest.headers['If-Unmodified-Since'] = ifUnmodifiedSince.toUTCString();
    }
    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 (taskUpdateParameter !== null && taskUpdateParameter !== undefined) {
        let requestModelMapper = new client.models['TaskUpdateParameter']().mapper();
        requestModel = client.serialize(requestModelMapper, taskUpdateParameter, 'taskUpdateParameter');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(taskUpdateParameter, 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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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);
    });
  }
  
  /**
   * @summary Lists all of the subtasks that are associated with the specified
   * multi-instance task.
   *
   * If the task is not a multi-instance task then this returns an empty
   * collection.
   *
   * @param {string} jobId The ID of the job.
   *
   * @param {string} taskId The ID of the task.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskListSubtasksOptions] Additional parameters for
   * the operation
   *
   * @param {string} [options.taskListSubtasksOptions.select] An OData $select
   * clause.
   *
   * @param {number} [options.taskListSubtasksOptions.timeout] The maximum time
   * that the server can spend processing the request, in seconds. The default is
   * 30 seconds.
   *
   * @param {uuid} [options.taskListSubtasksOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskListSubtasksOptions.returnClientRequestId]
   * Whether the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskListSubtasksOptions.ocpDate] The time the request
   * was issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @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 CloudTaskListSubtasksResult} 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 _listSubtasks(jobId, taskId, 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 taskListSubtasksOptions = (options && options.taskListSubtasksOptions !== undefined) ? options.taskListSubtasksOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (taskId === null || taskId === undefined || typeof taskId.valueOf() !== 'string') {
        throw new Error('taskId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let select;
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    try {
      if (taskListSubtasksOptions !== null && taskListSubtasksOptions !== undefined)
      {
        select = taskListSubtasksOptions.select;
        if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') {
          throw new Error('select must be of type string.');
        }
      }
      if (taskListSubtasksOptions !== null && taskListSubtasksOptions !== undefined)
      {
        timeout = taskListSubtasksOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskListSubtasksOptions !== null && taskListSubtasksOptions !== undefined)
      {
        clientRequestId = taskListSubtasksOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskListSubtasksOptions !== null && taskListSubtasksOptions !== undefined)
      {
        returnClientRequestId = taskListSubtasksOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskListSubtasksOptions !== null && taskListSubtasksOptions !== undefined)
      {
        ocpDate = taskListSubtasksOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks/{taskId}/subtasksinfo';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    requestUrl = requestUrl.replace('{taskId}', encodeURIComponent(taskId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (select !== null && select !== undefined) {
      queryParameters.push('$select=' + encodeURIComponent(select));
    }
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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['CloudTaskListSubtasksResult']().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 Terminates the specified task.
   *
   * When the task has been terminated, it moves to the completed state. For
   * multi-instance tasks, the terminate task operation applies synchronously to
   * the primary task; subtasks are then terminated asynchronously in the
   * background.
   *
   * @param {string} jobId The ID of the job containing the task.
   *
   * @param {string} taskId The ID of the task to terminate.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskTerminateOptions] Additional parameters for the
   * operation
   *
   * @param {number} [options.taskTerminateOptions.timeout] The maximum time that
   * the server can spend processing the request, in seconds. The default is 30
   * seconds.
   *
   * @param {uuid} [options.taskTerminateOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskTerminateOptions.returnClientRequestId]
   * Whether the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskTerminateOptions.ocpDate] The time the request
   * was issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @param {string} [options.taskTerminateOptions.ifMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service exactly matches the value specified by the client.
   *
   * @param {string} [options.taskTerminateOptions.ifNoneMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service does not match the value specified by the client.
   *
   * @param {date} [options.taskTerminateOptions.ifModifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has been
   * modified since the specified time.
   *
   * @param {date} [options.taskTerminateOptions.ifUnmodifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has not been
   * modified since the specified time.
   *
   * @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 _terminate(jobId, taskId, 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 taskTerminateOptions = (options && options.taskTerminateOptions !== undefined) ? options.taskTerminateOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (taskId === null || taskId === undefined || typeof taskId.valueOf() !== 'string') {
        throw new Error('taskId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    let ifMatch;
    let ifNoneMatch;
    let ifModifiedSince;
    let ifUnmodifiedSince;
    try {
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        timeout = taskTerminateOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        clientRequestId = taskTerminateOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        returnClientRequestId = taskTerminateOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        ocpDate = taskTerminateOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        ifMatch = taskTerminateOptions.ifMatch;
        if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
          throw new Error('ifMatch must be of type string.');
        }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        ifNoneMatch = taskTerminateOptions.ifNoneMatch;
        if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
          throw new Error('ifNoneMatch must be of type string.');
        }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        ifModifiedSince = taskTerminateOptions.ifModifiedSince;
        if (ifModifiedSince && !(ifModifiedSince instanceof Date ||
            (typeof ifModifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifModifiedSince))))) {
              throw new Error('ifModifiedSince must be of type date.');
            }
      }
      if (taskTerminateOptions !== null && taskTerminateOptions !== undefined)
      {
        ifUnmodifiedSince = taskTerminateOptions.ifUnmodifiedSince;
        if (ifUnmodifiedSince && !(ifUnmodifiedSince instanceof Date ||
            (typeof ifUnmodifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifUnmodifiedSince))))) {
              throw new Error('ifUnmodifiedSince must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks/{taskId}/terminate';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    requestUrl = requestUrl.replace('{taskId}', encodeURIComponent(taskId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    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['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    if (ifMatch !== undefined && ifMatch !== null) {
      httpRequest.headers['If-Match'] = ifMatch;
    }
    if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
      httpRequest.headers['If-None-Match'] = ifNoneMatch;
    }
    if (ifModifiedSince !== undefined && ifModifiedSince !== null) {
      httpRequest.headers['If-Modified-Since'] = ifModifiedSince.toUTCString();
    }
    if (ifUnmodifiedSince !== undefined && ifUnmodifiedSince !== null) {
      httpRequest.headers['If-Unmodified-Since'] = ifUnmodifiedSince.toUTCString();
    }
    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 !== 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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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);
    });
  }
  
  /**
   * @summary Reactivates a task, allowing it to run again even if its retry
   * count has been exhausted.
   *
   * Reactivation makes a task eligible to be retried again up to its maximum
   * retry count. The task's state is changed to active. As the task is no longer
   * in the completed state, any previous exit code or failure information is no
   * longer available after reactivation. Each time a task is reactivated, its
   * retry count is reset to 0. Reactivation will fail for tasks that are not
   * completed or that previously completed successfully (with an exit code of
   * 0). Additionally, it will fail if the job has completed (or is terminating
   * or deleting).
   *
   * @param {string} jobId The ID of the job containing the task.
   *
   * @param {string} taskId The ID of the task to reactivate.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskReactivateOptions] Additional parameters for
   * the operation
   *
   * @param {number} [options.taskReactivateOptions.timeout] The maximum time
   * that the server can spend processing the request, in seconds. The default is
   * 30 seconds.
   *
   * @param {uuid} [options.taskReactivateOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskReactivateOptions.returnClientRequestId]
   * Whether the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskReactivateOptions.ocpDate] The time the request
   * was issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @param {string} [options.taskReactivateOptions.ifMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service exactly matches the value specified by the client.
   *
   * @param {string} [options.taskReactivateOptions.ifNoneMatch] An ETag value
   * associated with the version of the resource known to the client. The
   * operation will be performed only if the resource's current ETag on the
   * service does not match the value specified by the client.
   *
   * @param {date} [options.taskReactivateOptions.ifModifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has been
   * modified since the specified time.
   *
   * @param {date} [options.taskReactivateOptions.ifUnmodifiedSince] A timestamp
   * indicating the last modified time of the resource known to the client. The
   * operation will be performed only if the resource on the service has not been
   * modified since the specified time.
   *
   * @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 _reactivate(jobId, taskId, 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 taskReactivateOptions = (options && options.taskReactivateOptions !== undefined) ? options.taskReactivateOptions : undefined;
    // Validate
    try {
      if (jobId === null || jobId === undefined || typeof jobId.valueOf() !== 'string') {
        throw new Error('jobId cannot be null or undefined and it must be of type string.');
      }
      if (taskId === null || taskId === undefined || typeof taskId.valueOf() !== 'string') {
        throw new Error('taskId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
    let timeout;
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    let ifMatch;
    let ifNoneMatch;
    let ifModifiedSince;
    let ifUnmodifiedSince;
    try {
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        timeout = taskReactivateOptions.timeout;
        if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
          throw new Error('timeout must be of type number.');
        }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        clientRequestId = taskReactivateOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        returnClientRequestId = taskReactivateOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        ocpDate = taskReactivateOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        ifMatch = taskReactivateOptions.ifMatch;
        if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
          throw new Error('ifMatch must be of type string.');
        }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        ifNoneMatch = taskReactivateOptions.ifNoneMatch;
        if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
          throw new Error('ifNoneMatch must be of type string.');
        }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        ifModifiedSince = taskReactivateOptions.ifModifiedSince;
        if (ifModifiedSince && !(ifModifiedSince instanceof Date ||
            (typeof ifModifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifModifiedSince))))) {
              throw new Error('ifModifiedSince must be of type date.');
            }
      }
      if (taskReactivateOptions !== null && taskReactivateOptions !== undefined)
      {
        ifUnmodifiedSince = taskReactivateOptions.ifUnmodifiedSince;
        if (ifUnmodifiedSince && !(ifUnmodifiedSince instanceof Date ||
            (typeof ifUnmodifiedSince.valueOf() === 'string' && !isNaN(Date.parse(ifUnmodifiedSince))))) {
              throw new Error('ifUnmodifiedSince must be of type date.');
            }
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'jobs/{jobId}/tasks/{taskId}/reactivate';
    requestUrl = requestUrl.replace('{jobId}', encodeURIComponent(jobId));
    requestUrl = requestUrl.replace('{taskId}', encodeURIComponent(taskId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (timeout !== null && timeout !== undefined) {
      queryParameters.push('timeout=' + encodeURIComponent(timeout.toString()));
    }
    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['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    if (ifMatch !== undefined && ifMatch !== null) {
      httpRequest.headers['If-Match'] = ifMatch;
    }
    if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
      httpRequest.headers['If-None-Match'] = ifNoneMatch;
    }
    if (ifModifiedSince !== undefined && ifModifiedSince !== null) {
      httpRequest.headers['If-Modified-Since'] = ifModifiedSince.toUTCString();
    }
    if (ifUnmodifiedSince !== undefined && ifUnmodifiedSince !== null) {
      httpRequest.headers['If-Unmodified-Since'] = ifUnmodifiedSince.toUTCString();
    }
    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 !== 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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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);
    });
  }
  
  /**
   * @summary Lists all of the tasks that are associated with the specified job.
   *
   * For multi-instance tasks, information such as affinityId, executionInfo and
   * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
   * information about subtasks.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.taskListNextOptions] Additional parameters for the
   * operation
   *
   * @param {uuid} [options.taskListNextOptions.clientRequestId] The
   * caller-generated request identity, in the form of a GUID with no decoration
   * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
   *
   * @param {boolean} [options.taskListNextOptions.returnClientRequestId] Whether
   * the server should return the client-request-id in the response.
   *
   * @param {date} [options.taskListNextOptions.ocpDate] The time the request was
   * issued. Client libraries typically set this to the current system clock
   * time; set it explicitly if you are calling the REST API directly.
   *
   * @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 CloudTaskListResult} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _listNext(nextPageLink, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let taskListNextOptions = (options && options.taskListNextOptions !== undefined) ? options.taskListNextOptions : undefined;
    // 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);
    }
    let clientRequestId;
    let returnClientRequestId;
    let ocpDate;
    try {
      if (taskListNextOptions !== null && taskListNextOptions !== undefined)
      {
        clientRequestId = taskListNextOptions.clientRequestId;
        if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
          throw new Error('clientRequestId must be of type string and must be a valid uuid.');
        }
      }
      if (taskListNextOptions !== null && taskListNextOptions !== undefined)
      {
        returnClientRequestId = taskListNextOptions.returnClientRequestId;
        if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
          throw new Error('returnClientRequestId must be of type boolean.');
        }
      }
      if (taskListNextOptions !== null && taskListNextOptions !== undefined)
      {
        ocpDate = taskListNextOptions.ocpDate;
        if (ocpDate && !(ocpDate instanceof Date ||
            (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
              throw new Error('ocpDate must be of type date.');
            }
      }
    } 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['client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if (clientRequestId !== undefined && clientRequestId !== null) {
      httpRequest.headers['client-request-id'] = clientRequestId.toString();
    }
    if (returnClientRequestId !== undefined && returnClientRequestId !== null) {
      httpRequest.headers['return-client-request-id'] = returnClientRequestId.toString();
    }
    if (ocpDate !== undefined && ocpDate !== null) {
      httpRequest.headers['ocp-date'] = ocpDate.toUTCString();
    }
    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) {
            let internalError = null;
            if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
            error.code = internalError ? internalError.code : parsedErrorResponse.code;
            error.message = internalError ? internalError.message : parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['BatchError']().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['CloudTaskListResult']().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 Task. */
  class Task {
    /**
     * Create a Task.
     * @param {BatchServiceClient} client Reference to the service client.
     */
    constructor(client) {
      this.client = client;
      this._add = _add;
      this._list = _list;
      this._addCollection = _addCollection;
      this._deleteMethod = _deleteMethod;
      this._get = _get;
      this._update = _update;
      this._listSubtasks = _listSubtasks;
      this._terminate = _terminate;
      this._reactivate = _reactivate;
      this._listNext = _listNext;
    }
  
    /**
     * @summary Adds a task to the specified job.
     *
     * The maximum lifetime of a task from addition to completion is 7 days. If a
     * task has not completed within 7 days of being added it will be terminated by
     * the Batch service and left in whatever state it was in at that time.
     *
     * @param {string} jobId The ID of the job to which the task is to be added.
     *
     * @param {object} task The task to be added.
     *
     * @param {string} task.id A string that uniquely identifies the task within
     * the job. The ID can contain any combination of alphanumeric characters
     * including hyphens and underscores, and cannot contain more than 64
     * characters. The ID is case-preserving and case-insensitive (that is, you may
     * not have two IDs within a job that differ only by case).
     *
     * @param {string} [task.displayName] A display name for the task. The display
     * name need not be unique and can contain any Unicode characters up to a
     * maximum length of 1024.
     *
     * @param {string} task.commandLine The command line of the task. For
     * multi-instance tasks, the command line is executed as the primary task,
     * after the primary task and all subtasks have finished executing the
     * coordination command line. 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. If the command
     * line refers to file paths, it should use a relative path (relative to the
     * task working directory), or use the Batch provided environment variable
     * (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
     *
     * @param {object} [task.containerSettings] The settings for the container
     * under which the task runs. If the pool that will run this task has
     * containerConfiguration set, this must be set as well. If the pool that will
     * run this task doesn't have containerConfiguration set, this must not be set.
     * 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} [task.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} task.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} [task.containerSettings.registry] The private registry which
     * contains the container image. This setting can be omitted if was already
     * provided at pool creation.
     *
     * @param {string} [task.containerSettings.registry.registryServer] The
     * registry URL. If omitted, the default is "docker.io".
     *
     * @param {string} task.containerSettings.registry.userName The user name to
     * log into the registry server.
     *
     * @param {string} task.containerSettings.registry.password The password to log
     * into the registry server.
     *
     * @param {object} [task.exitConditions] How the Batch service should respond
     * when the task completes.
     *
     * @param {array} [task.exitConditions.exitCodes] A list of individual task
     * exit codes and how the Batch service should respond to them.
     *
     * @param {array} [task.exitConditions.exitCodeRanges] A list of task exit code
     * ranges and how the Batch service should respond to them.
     *
     * @param {object} [task.exitConditions.preProcessingError] How the Batch
     * service should respond if the task fails to start due to an error.
     *
     * @param {object} [task.exitConditions.fileUploadError] How the Batch service
     * should respond if a file upload error occurs. If the task exited with an
     * exit code that was specified via exitCodes or exitCodeRanges, and then
     * encountered a file upload error, then the action specified by the exit code
     * takes precedence.
     *
     * @param {object} [task.exitConditions.default] How the Batch service should
     * respond if the task fails with an exit condition not covered by any of the
     * other properties. This value is used if the task exits with any nonzero exit
     * code not listed in the exitCodes or exitCodeRanges collection, with a
     * pre-processing error if the preProcessingError property is not present, or
     * with a file upload error if the fileUploadError property is not present. If
     * you want non-default behaviour on exit code 0, you must list it explicitly
     * using the exitCodes or exitCodeRanges collection.
     *
     * @param {string} [task.exitConditions.default.jobAction] An action to take on
     * the job containing the task, if the task completes with the given exit
     * condition and the job's onTaskFailed property is
     * 'performExitOptionsJobAction'. The default is none for exit code 0 and
     * terminate for all other exit conditions. If the job's onTaskFailed property
     * is noaction, then specifying this property returns an error and the add task
     * request fails with an invalid property value error; if you are calling the
     * REST API directly, the HTTP status code is 400 (Bad Request). Possible
     * values include: 'none', 'disable', 'terminate'
     *
     * @param {string} [task.exitConditions.default.dependencyAction] An action
     * that the Batch service performs on tasks that depend on this task. The
     * default is 'satisfy' for exit code 0, and 'block' for all other exit
     * conditions. If the job's usesTaskDependencies property is set to false, then
     * specifying the dependencyAction property returns an error and the add task
     * request fails with an invalid property value error; if you are calling the
     * REST API directly, the HTTP status code is 400  (Bad Request). Possible
     * values include: 'satisfy', 'block'
     *
     * @param {array} [task.resourceFiles] A list of files that the Batch service
     * will download to the compute node before running the command line. For
     * multi-instance tasks, the resource files will only be downloaded to the
     * compute node on which the primary task is executed. There is a maximum size
     * for the list of resource files.  When the max size is exceeded, the request
     * will fail and the response error code will be RequestEntityTooLarge. If this
     * occurs, the collection of ResourceFiles must be reduced in size. This can be
     * achieved using .zip files, Application Packages, or Docker Containers.
     *
     * @param {array} [task.outputFiles] A list of files that the Batch service
     * will upload from the compute node after running the command line. For
     * multi-instance tasks, the files will only be uploaded from the compute node
     * on which the primary task is executed.
     *
     * @param {array} [task.environmentSettings] A list of environment variable
     * settings for the task.
     *
     * @param {object} [task.affinityInfo] A locality hint that can be used by the
     * Batch service to select a compute node on which to start the new task.
     *
     * @param {string} task.affinityInfo.affinityId An opaque string representing
     * the location of a compute node or a task that has run previously. You can
     * pass the affinityId of a compute node to indicate that this task needs to
     * run on that compute node. Note that this is just a soft affinity. If the
     * target node is busy or unavailable at the time the task is scheduled, then
     * the task will be scheduled elsewhere.
     *
     * @param {object} [task.constraints] The execution constraints that apply to
     * this task. If you do not specify constraints, the maxTaskRetryCount is the
     * maxTaskRetryCount specified for the job, and the maxWallClockTime and
     * retentionTime are infinite.
     *
     * @param {moment.duration} [task.constraints.maxWallClockTime] The maximum
     * elapsed time that the task may run, measured from the time the task starts.
     * If the task does not complete within the time limit, the Batch service
     * terminates it. If this is not specified, there is no time limit on how long
     * the task may run.
     *
     * @param {moment.duration} [task.constraints.retentionTime] The minimum time
     * to retain the task directory on the compute node where it ran, from the time
     * it completes execution. After this time, the Batch service may delete the
     * task directory and all its contents. The default is infinite, i.e. the task
     * directory will be retained until the compute node is removed or reimaged.
     *
     * @param {number} [task.constraints.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 for the task executable due to a nonzero exit code. 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 after the first attempt. If the maximum
     * retry count is -1, the Batch service retries the task without limit.
     * Resource files and application packages are only downloaded again if the
     * task is retried on a new compute node.
     *
     * @param {object} [task.userIdentity] The user identity under which the task
     * runs. If omitted, the task runs as a non-administrative user unique to the
     * task.
     *
     * @param {string} [task.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} [task.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} [task.userIdentity.autoUser.scope] The scope for the auto
     * user The default value is task. Possible values include: 'task', 'pool'
     *
     * @param {string} [task.userIdentity.autoUser.elevationLevel] The elevation
     * level of the auto user. The default value is nonAdmin. Possible values
     * include: 'nonAdmin', 'admin'
     *
     * @param {object} [task.multiInstanceSettings] An object that indicates that
     * the task is a multi-instance task, and contains information about how to run
     * the multi-instance task.
     *
     * @param {number} [task.multiInstanceSettings.numberOfInstances] The number of
     * compute nodes required by the task. If omitted, the default is 1.
     *
     * @param {string} task.multiInstanceSettings.coordinationCommandLine The
     * command line to run on all the compute nodes to enable them to coordinate
     * when the primary runs the main task command. A typical coordination command
     * line launches a background service and verifies that the service is ready to
     * process inter-node messages.
     *
     * @param {array} [task.multiInstanceSettings.commonResourceFiles] A list of
     * files that the Batch service will download before running the coordination
     * command line. The difference between common resource files and task resource
     * files is that common resource files are downloaded for all subtasks
     * including the primary, whereas task resource files are downloaded only for
     * the primary. Also note that these resource files are not downloaded to the
     * task working directory, but instead are downloaded to the task root
     * directory (one directory above the working directory).  There is a maximum
     * size for the list of resource files.  When the max size is exceeded, the
     * request will fail and the response error code will be RequestEntityTooLarge.
     * If this occurs, the collection of ResourceFiles must be reduced in size.
     * This can be achieved using .zip files, Application Packages, or Docker
     * Containers.
     *
     * @param {object} [task.dependsOn] The tasks that this task depends on. This
     * task will not be scheduled until all tasks that it depends on have completed
     * successfully. If any of those tasks fail and exhaust their retry counts,
     * this task will never be scheduled. If the job does not have
     * usesTaskDependencies set to true, and this element is present, the request
     * fails with error code TaskDependenciesNotSpecifiedOnJob.
     *
     * @param {array} [task.dependsOn.taskIds] The list of task IDs that this task
     * depends on. All tasks in this list must complete successfully before the
     * dependent task can be scheduled. The taskIds collection is limited to 64000
     * characters total (i.e. the combined length of all task IDs). If the taskIds
     * collection exceeds the maximum length, the Add Task request fails with error
     * code TaskDependencyListTooLong. In this case consider using task ID ranges
     * instead.
     *
     * @param {array} [task.dependsOn.taskIdRanges] The list of task ID ranges that
     * this task depends on. All tasks in all ranges must complete successfully
     * before the dependent task can be scheduled.
     *
     * @param {array} [task.applicationPackageReferences] A list of application
     * packages that the Batch service will deploy to the compute node before
     * running the command line. Application packages are downloaded and deployed
     * to a shared directory, not the task working directory. Therefore, if a
     * referenced package is already on the compute node, and is up to date, then
     * it is not re-downloaded; the existing copy on the compute node is used. If a
     * referenced application package cannot be installed, for example because the
     * package has been deleted or because download failed, the task fails.
     *
     * @param {object} [task.authenticationTokenSettings] The settings for an
     * authentication token that the task can use to perform Batch service
     * operations. If this property is set, the Batch service provides the task
     * with an authentication token which can be used to authenticate Batch service
     * operations without requiring an account access key. The token is provided
     * via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations
     * that the task can carry out using the token depend on the settings. For
     * example, a task can request job permissions in order to add other tasks to
     * the job, or check the status of the job or of other tasks under the job.
     *
     * @param {array} [task.authenticationTokenSettings.access] The Batch resources
     * to which the token grants access. The authentication token grants access to
     * a limited set of Batch service operations. Currently the only supported
     * value for the access property is 'job', which grants access to all
     * operations related to the job which contains the task.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskAddOptions] Additional parameters for the
     * operation
     *
     * @param {number} [options.taskAddOptions.timeout] The maximum time that the
     * server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskAddOptions.clientRequestId] The caller-generated
     * request identity, in the form of a GUID with no decoration such as curly
     * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskAddOptions.returnClientRequestId] Whether the
     * server should return the client-request-id in the response.
     *
     * @param {date} [options.taskAddOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @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.
     */
    addWithHttpOperationResponse(jobId, task, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._add(jobId, task, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Adds a task to the specified job.
     *
     * The maximum lifetime of a task from addition to completion is 7 days. If a
     * task has not completed within 7 days of being added it will be terminated by
     * the Batch service and left in whatever state it was in at that time.
     *
     * @param {string} jobId The ID of the job to which the task is to be added.
     *
     * @param {object} task The task to be added.
     *
     * @param {string} task.id A string that uniquely identifies the task within
     * the job. The ID can contain any combination of alphanumeric characters
     * including hyphens and underscores, and cannot contain more than 64
     * characters. The ID is case-preserving and case-insensitive (that is, you may
     * not have two IDs within a job that differ only by case).
     *
     * @param {string} [task.displayName] A display name for the task. The display
     * name need not be unique and can contain any Unicode characters up to a
     * maximum length of 1024.
     *
     * @param {string} task.commandLine The command line of the task. For
     * multi-instance tasks, the command line is executed as the primary task,
     * after the primary task and all subtasks have finished executing the
     * coordination command line. 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. If the command
     * line refers to file paths, it should use a relative path (relative to the
     * task working directory), or use the Batch provided environment variable
     * (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
     *
     * @param {object} [task.containerSettings] The settings for the container
     * under which the task runs. If the pool that will run this task has
     * containerConfiguration set, this must be set as well. If the pool that will
     * run this task doesn't have containerConfiguration set, this must not be set.
     * 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} [task.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} task.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} [task.containerSettings.registry] The private registry which
     * contains the container image. This setting can be omitted if was already
     * provided at pool creation.
     *
     * @param {string} [task.containerSettings.registry.registryServer] The
     * registry URL. If omitted, the default is "docker.io".
     *
     * @param {string} task.containerSettings.registry.userName The user name to
     * log into the registry server.
     *
     * @param {string} task.containerSettings.registry.password The password to log
     * into the registry server.
     *
     * @param {object} [task.exitConditions] How the Batch service should respond
     * when the task completes.
     *
     * @param {array} [task.exitConditions.exitCodes] A list of individual task
     * exit codes and how the Batch service should respond to them.
     *
     * @param {array} [task.exitConditions.exitCodeRanges] A list of task exit code
     * ranges and how the Batch service should respond to them.
     *
     * @param {object} [task.exitConditions.preProcessingError] How the Batch
     * service should respond if the task fails to start due to an error.
     *
     * @param {object} [task.exitConditions.fileUploadError] How the Batch service
     * should respond if a file upload error occurs. If the task exited with an
     * exit code that was specified via exitCodes or exitCodeRanges, and then
     * encountered a file upload error, then the action specified by the exit code
     * takes precedence.
     *
     * @param {object} [task.exitConditions.default] How the Batch service should
     * respond if the task fails with an exit condition not covered by any of the
     * other properties. This value is used if the task exits with any nonzero exit
     * code not listed in the exitCodes or exitCodeRanges collection, with a
     * pre-processing error if the preProcessingError property is not present, or
     * with a file upload error if the fileUploadError property is not present. If
     * you want non-default behaviour on exit code 0, you must list it explicitly
     * using the exitCodes or exitCodeRanges collection.
     *
     * @param {string} [task.exitConditions.default.jobAction] An action to take on
     * the job containing the task, if the task completes with the given exit
     * condition and the job's onTaskFailed property is
     * 'performExitOptionsJobAction'. The default is none for exit code 0 and
     * terminate for all other exit conditions. If the job's onTaskFailed property
     * is noaction, then specifying this property returns an error and the add task
     * request fails with an invalid property value error; if you are calling the
     * REST API directly, the HTTP status code is 400 (Bad Request). Possible
     * values include: 'none', 'disable', 'terminate'
     *
     * @param {string} [task.exitConditions.default.dependencyAction] An action
     * that the Batch service performs on tasks that depend on this task. The
     * default is 'satisfy' for exit code 0, and 'block' for all other exit
     * conditions. If the job's usesTaskDependencies property is set to false, then
     * specifying the dependencyAction property returns an error and the add task
     * request fails with an invalid property value error; if you are calling the
     * REST API directly, the HTTP status code is 400  (Bad Request). Possible
     * values include: 'satisfy', 'block'
     *
     * @param {array} [task.resourceFiles] A list of files that the Batch service
     * will download to the compute node before running the command line. For
     * multi-instance tasks, the resource files will only be downloaded to the
     * compute node on which the primary task is executed. There is a maximum size
     * for the list of resource files.  When the max size is exceeded, the request
     * will fail and the response error code will be RequestEntityTooLarge. If this
     * occurs, the collection of ResourceFiles must be reduced in size. This can be
     * achieved using .zip files, Application Packages, or Docker Containers.
     *
     * @param {array} [task.outputFiles] A list of files that the Batch service
     * will upload from the compute node after running the command line. For
     * multi-instance tasks, the files will only be uploaded from the compute node
     * on which the primary task is executed.
     *
     * @param {array} [task.environmentSettings] A list of environment variable
     * settings for the task.
     *
     * @param {object} [task.affinityInfo] A locality hint that can be used by the
     * Batch service to select a compute node on which to start the new task.
     *
     * @param {string} task.affinityInfo.affinityId An opaque string representing
     * the location of a compute node or a task that has run previously. You can
     * pass the affinityId of a compute node to indicate that this task needs to
     * run on that compute node. Note that this is just a soft affinity. If the
     * target node is busy or unavailable at the time the task is scheduled, then
     * the task will be scheduled elsewhere.
     *
     * @param {object} [task.constraints] The execution constraints that apply to
     * this task. If you do not specify constraints, the maxTaskRetryCount is the
     * maxTaskRetryCount specified for the job, and the maxWallClockTime and
     * retentionTime are infinite.
     *
     * @param {moment.duration} [task.constraints.maxWallClockTime] The maximum
     * elapsed time that the task may run, measured from the time the task starts.
     * If the task does not complete within the time limit, the Batch service
     * terminates it. If this is not specified, there is no time limit on how long
     * the task may run.
     *
     * @param {moment.duration} [task.constraints.retentionTime] The minimum time
     * to retain the task directory on the compute node where it ran, from the time
     * it completes execution. After this time, the Batch service may delete the
     * task directory and all its contents. The default is infinite, i.e. the task
     * directory will be retained until the compute node is removed or reimaged.
     *
     * @param {number} [task.constraints.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 for the task executable due to a nonzero exit code. 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 after the first attempt. If the maximum
     * retry count is -1, the Batch service retries the task without limit.
     * Resource files and application packages are only downloaded again if the
     * task is retried on a new compute node.
     *
     * @param {object} [task.userIdentity] The user identity under which the task
     * runs. If omitted, the task runs as a non-administrative user unique to the
     * task.
     *
     * @param {string} [task.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} [task.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} [task.userIdentity.autoUser.scope] The scope for the auto
     * user The default value is task. Possible values include: 'task', 'pool'
     *
     * @param {string} [task.userIdentity.autoUser.elevationLevel] The elevation
     * level of the auto user. The default value is nonAdmin. Possible values
     * include: 'nonAdmin', 'admin'
     *
     * @param {object} [task.multiInstanceSettings] An object that indicates that
     * the task is a multi-instance task, and contains information about how to run
     * the multi-instance task.
     *
     * @param {number} [task.multiInstanceSettings.numberOfInstances] The number of
     * compute nodes required by the task. If omitted, the default is 1.
     *
     * @param {string} task.multiInstanceSettings.coordinationCommandLine The
     * command line to run on all the compute nodes to enable them to coordinate
     * when the primary runs the main task command. A typical coordination command
     * line launches a background service and verifies that the service is ready to
     * process inter-node messages.
     *
     * @param {array} [task.multiInstanceSettings.commonResourceFiles] A list of
     * files that the Batch service will download before running the coordination
     * command line. The difference between common resource files and task resource
     * files is that common resource files are downloaded for all subtasks
     * including the primary, whereas task resource files are downloaded only for
     * the primary. Also note that these resource files are not downloaded to the
     * task working directory, but instead are downloaded to the task root
     * directory (one directory above the working directory).  There is a maximum
     * size for the list of resource files.  When the max size is exceeded, the
     * request will fail and the response error code will be RequestEntityTooLarge.
     * If this occurs, the collection of ResourceFiles must be reduced in size.
     * This can be achieved using .zip files, Application Packages, or Docker
     * Containers.
     *
     * @param {object} [task.dependsOn] The tasks that this task depends on. This
     * task will not be scheduled until all tasks that it depends on have completed
     * successfully. If any of those tasks fail and exhaust their retry counts,
     * this task will never be scheduled. If the job does not have
     * usesTaskDependencies set to true, and this element is present, the request
     * fails with error code TaskDependenciesNotSpecifiedOnJob.
     *
     * @param {array} [task.dependsOn.taskIds] The list of task IDs that this task
     * depends on. All tasks in this list must complete successfully before the
     * dependent task can be scheduled. The taskIds collection is limited to 64000
     * characters total (i.e. the combined length of all task IDs). If the taskIds
     * collection exceeds the maximum length, the Add Task request fails with error
     * code TaskDependencyListTooLong. In this case consider using task ID ranges
     * instead.
     *
     * @param {array} [task.dependsOn.taskIdRanges] The list of task ID ranges that
     * this task depends on. All tasks in all ranges must complete successfully
     * before the dependent task can be scheduled.
     *
     * @param {array} [task.applicationPackageReferences] A list of application
     * packages that the Batch service will deploy to the compute node before
     * running the command line. Application packages are downloaded and deployed
     * to a shared directory, not the task working directory. Therefore, if a
     * referenced package is already on the compute node, and is up to date, then
     * it is not re-downloaded; the existing copy on the compute node is used. If a
     * referenced application package cannot be installed, for example because the
     * package has been deleted or because download failed, the task fails.
     *
     * @param {object} [task.authenticationTokenSettings] The settings for an
     * authentication token that the task can use to perform Batch service
     * operations. If this property is set, the Batch service provides the task
     * with an authentication token which can be used to authenticate Batch service
     * operations without requiring an account access key. The token is provided
     * via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations
     * that the task can carry out using the token depend on the settings. For
     * example, a task can request job permissions in order to add other tasks to
     * the job, or check the status of the job or of other tasks under the job.
     *
     * @param {array} [task.authenticationTokenSettings.access] The Batch resources
     * to which the token grants access. The authentication token grants access to
     * a limited set of Batch service operations. Currently the only supported
     * value for the access property is 'job', which grants access to all
     * operations related to the job which contains the task.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskAddOptions] Additional parameters for the
     * operation
     *
     * @param {number} [options.taskAddOptions.timeout] The maximum time that the
     * server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskAddOptions.clientRequestId] The caller-generated
     * request identity, in the form of a GUID with no decoration such as curly
     * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskAddOptions.returnClientRequestId] Whether the
     * server should return the client-request-id in the response.
     *
     * @param {date} [options.taskAddOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @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.
     */
    add(jobId, task, 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._add(jobId, task, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._add(jobId, task, options, optionalCallback);
      }
    }
  
    /**
     * @summary Lists all of the tasks that are associated with the specified job.
     *
     * For multi-instance tasks, information such as affinityId, executionInfo and
     * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
     * information about subtasks.
     *
     * @param {string} jobId The ID of the job.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskListOptions] Additional parameters for the
     * operation
     *
     * @param {string} [options.taskListOptions.filter] An OData $filter clause.
     * For more information on constructing this filter, see
     * https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-tasks.
     *
     * @param {string} [options.taskListOptions.select] An OData $select clause.
     *
     * @param {string} [options.taskListOptions.expand] An OData $expand clause.
     *
     * @param {number} [options.taskListOptions.maxResults] The maximum number of
     * items to return in the response. A maximum of 1000 tasks can be returned.
     *
     * @param {number} [options.taskListOptions.timeout] The maximum time that the
     * server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskListOptions.clientRequestId] The caller-generated
     * request identity, in the form of a GUID with no decoration such as curly
     * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskListOptions.returnClientRequestId] Whether the
     * server should return the client-request-id in the response.
     *
     * @param {date} [options.taskListOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<CloudTaskListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listWithHttpOperationResponse(jobId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._list(jobId, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Lists all of the tasks that are associated with the specified job.
     *
     * For multi-instance tasks, information such as affinityId, executionInfo and
     * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
     * information about subtasks.
     *
     * @param {string} jobId The ID of the job.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskListOptions] Additional parameters for the
     * operation
     *
     * @param {string} [options.taskListOptions.filter] An OData $filter clause.
     * For more information on constructing this filter, see
     * https://docs.microsoft.com/en-us/rest/api/batchservice/odata-filters-in-batch#list-tasks.
     *
     * @param {string} [options.taskListOptions.select] An OData $select clause.
     *
     * @param {string} [options.taskListOptions.expand] An OData $expand clause.
     *
     * @param {number} [options.taskListOptions.maxResults] The maximum number of
     * items to return in the response. A maximum of 1000 tasks can be returned.
     *
     * @param {number} [options.taskListOptions.timeout] The maximum time that the
     * server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskListOptions.clientRequestId] The caller-generated
     * request identity, in the form of a GUID with no decoration such as curly
     * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskListOptions.returnClientRequestId] Whether the
     * server should return the client-request-id in the response.
     *
     * @param {date} [options.taskListOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @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 {CloudTaskListResult} - 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 CloudTaskListResult} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    list(jobId, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._list(jobId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._list(jobId, options, optionalCallback);
      }
    }
  
    /**
     * @summary Adds a collection of tasks to the specified job.
     *
     * Note that each task must have a unique ID. The Batch service may not return
     * the results for each task in the same order the tasks were submitted in this
     * request. If the server times out or the connection is closed during the
     * request, the request may have been partially or fully processed, or not at
     * all. In such cases, the user should re-issue the request. Note that it is up
     * to the user to correctly handle failures when re-issuing a request. For
     * example, you should use the same task IDs during a retry so that if the
     * prior operation succeeded, the retry will not create extra tasks
     * unexpectedly. If the response contains any tasks which failed to add, a
     * client can retry the request. In a retry, it is most efficient to resubmit
     * only tasks that failed to add, and to omit tasks that were successfully
     * added on the first attempt. The maximum lifetime of a task from addition to
     * completion is 7 days. If a task has not completed within 7 days of being
     * added it will be terminated by the Batch service and left in whatever state
     * it was in at that time.
     *
     * @param {string} jobId The ID of the job to which the task collection is to
     * be added.
     *
     * @param {array} value The collection of tasks to add. The maximum count of
     * tasks is 100. The total serialized size of this collection must be less than
     * 1MB. If it is greater than 1MB (for example if each task has 100's of
     * resource files or environment variables), the request will fail with code
     * 'RequestBodyTooLarge' and should be retried again with fewer tasks.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskAddCollectionOptions] Additional parameters for
     * the operation
     *
     * @param {number} [options.taskAddCollectionOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskAddCollectionOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskAddCollectionOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskAddCollectionOptions.ocpDate] The time the
     * request was issued. Client libraries typically set this to the current
     * system clock time; set it explicitly if you are calling the REST API
     * directly.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<TaskAddCollectionResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    addCollectionWithHttpOperationResponse(jobId, value, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._addCollection(jobId, value, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Adds a collection of tasks to the specified job.
     *
     * Note that each task must have a unique ID. The Batch service may not return
     * the results for each task in the same order the tasks were submitted in this
     * request. If the server times out or the connection is closed during the
     * request, the request may have been partially or fully processed, or not at
     * all. In such cases, the user should re-issue the request. Note that it is up
     * to the user to correctly handle failures when re-issuing a request. For
     * example, you should use the same task IDs during a retry so that if the
     * prior operation succeeded, the retry will not create extra tasks
     * unexpectedly. If the response contains any tasks which failed to add, a
     * client can retry the request. In a retry, it is most efficient to resubmit
     * only tasks that failed to add, and to omit tasks that were successfully
     * added on the first attempt. The maximum lifetime of a task from addition to
     * completion is 7 days. If a task has not completed within 7 days of being
     * added it will be terminated by the Batch service and left in whatever state
     * it was in at that time.
     *
     * @param {string} jobId The ID of the job to which the task collection is to
     * be added.
     *
     * @param {array} value The collection of tasks to add. The maximum count of
     * tasks is 100. The total serialized size of this collection must be less than
     * 1MB. If it is greater than 1MB (for example if each task has 100's of
     * resource files or environment variables), the request will fail with code
     * 'RequestBodyTooLarge' and should be retried again with fewer tasks.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskAddCollectionOptions] Additional parameters for
     * the operation
     *
     * @param {number} [options.taskAddCollectionOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskAddCollectionOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskAddCollectionOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskAddCollectionOptions.ocpDate] The time the
     * request was issued. Client libraries typically set this to the current
     * system clock time; set it explicitly if you are calling the REST API
     * directly.
     *
     * @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 {TaskAddCollectionResult} - 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 TaskAddCollectionResult} 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.
     */
    addCollection(jobId, value, 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._addCollection(jobId, value, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._addCollection(jobId, value, options, optionalCallback);
      }
    }
  
    /**
     * @summary Deletes a task from the specified job.
     *
     * When a task is deleted, all of the files in its directory on the compute
     * node where it ran are also deleted (regardless of the retention time). For
     * multi-instance tasks, the delete task operation applies synchronously to the
     * primary task; subtasks and their files are then deleted asynchronously in
     * the background.
     *
     * @param {string} jobId The ID of the job from which to delete the task.
     *
     * @param {string} taskId The ID of the task to delete.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskDeleteMethodOptions] Additional parameters for
     * the operation
     *
     * @param {number} [options.taskDeleteMethodOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskDeleteMethodOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskDeleteMethodOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskDeleteMethodOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskDeleteMethodOptions.ifMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service exactly matches the value specified by the client.
     *
     * @param {string} [options.taskDeleteMethodOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskDeleteMethodOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskDeleteMethodOptions.ifUnmodifiedSince] A
     * timestamp indicating the last modified time of the resource known to the
     * client. The operation will be performed only if the resource on the service
     * has not been modified since the specified time.
     *
     * @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(jobId, taskId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._deleteMethod(jobId, taskId, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Deletes a task from the specified job.
     *
     * When a task is deleted, all of the files in its directory on the compute
     * node where it ran are also deleted (regardless of the retention time). For
     * multi-instance tasks, the delete task operation applies synchronously to the
     * primary task; subtasks and their files are then deleted asynchronously in
     * the background.
     *
     * @param {string} jobId The ID of the job from which to delete the task.
     *
     * @param {string} taskId The ID of the task to delete.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskDeleteMethodOptions] Additional parameters for
     * the operation
     *
     * @param {number} [options.taskDeleteMethodOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskDeleteMethodOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskDeleteMethodOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskDeleteMethodOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskDeleteMethodOptions.ifMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service exactly matches the value specified by the client.
     *
     * @param {string} [options.taskDeleteMethodOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskDeleteMethodOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskDeleteMethodOptions.ifUnmodifiedSince] A
     * timestamp indicating the last modified time of the resource known to the
     * client. The operation will be performed only if the resource on the service
     * has not been modified since the specified time.
     *
     * @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(jobId, taskId, 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(jobId, taskId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._deleteMethod(jobId, taskId, options, optionalCallback);
      }
    }
  
    /**
     * @summary Gets information about the specified task.
     *
     * For multi-instance tasks, information such as affinityId, executionInfo and
     * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
     * information about subtasks.
     *
     * @param {string} jobId The ID of the job that contains the task.
     *
     * @param {string} taskId The ID of the task to get information about.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskGetOptions] Additional parameters for the
     * operation
     *
     * @param {string} [options.taskGetOptions.select] An OData $select clause.
     *
     * @param {string} [options.taskGetOptions.expand] An OData $expand clause.
     *
     * @param {number} [options.taskGetOptions.timeout] The maximum time that the
     * server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskGetOptions.clientRequestId] The caller-generated
     * request identity, in the form of a GUID with no decoration such as curly
     * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskGetOptions.returnClientRequestId] Whether the
     * server should return the client-request-id in the response.
     *
     * @param {date} [options.taskGetOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskGetOptions.ifMatch] An ETag value associated
     * with the version of the resource known to the client. The operation will be
     * performed only if the resource's current ETag on the service exactly matches
     * the value specified by the client.
     *
     * @param {string} [options.taskGetOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskGetOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskGetOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<CloudTask>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getWithHttpOperationResponse(jobId, taskId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._get(jobId, taskId, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Gets information about the specified task.
     *
     * For multi-instance tasks, information such as affinityId, executionInfo and
     * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
     * information about subtasks.
     *
     * @param {string} jobId The ID of the job that contains the task.
     *
     * @param {string} taskId The ID of the task to get information about.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskGetOptions] Additional parameters for the
     * operation
     *
     * @param {string} [options.taskGetOptions.select] An OData $select clause.
     *
     * @param {string} [options.taskGetOptions.expand] An OData $expand clause.
     *
     * @param {number} [options.taskGetOptions.timeout] The maximum time that the
     * server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskGetOptions.clientRequestId] The caller-generated
     * request identity, in the form of a GUID with no decoration such as curly
     * braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskGetOptions.returnClientRequestId] Whether the
     * server should return the client-request-id in the response.
     *
     * @param {date} [options.taskGetOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskGetOptions.ifMatch] An ETag value associated
     * with the version of the resource known to the client. The operation will be
     * performed only if the resource's current ETag on the service exactly matches
     * the value specified by the client.
     *
     * @param {string} [options.taskGetOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskGetOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskGetOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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 {CloudTask} - 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 CloudTask} 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(jobId, taskId, 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(jobId, taskId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._get(jobId, taskId, options, optionalCallback);
      }
    }
  
    /**
     * Updates the properties of the specified task.
     *
     * @param {string} jobId The ID of the job containing the task.
     *
     * @param {string} taskId The ID of the task to update.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.constraints] Constraints that apply to this task.
     * If omitted, the task is given the default constraints. For multi-instance
     * tasks, updating the retention time applies only to the primary task and not
     * subtasks.
     *
     * @param {moment.duration} [options.constraints.maxWallClockTime] The maximum
     * elapsed time that the task may run, measured from the time the task starts.
     * If the task does not complete within the time limit, the Batch service
     * terminates it. If this is not specified, there is no time limit on how long
     * the task may run.
     *
     * @param {moment.duration} [options.constraints.retentionTime] The minimum
     * time to retain the task directory on the compute node where it ran, from the
     * time it completes execution. After this time, the Batch service may delete
     * the task directory and all its contents. The default is infinite, i.e. the
     * task directory will be retained until the compute node is removed or
     * reimaged.
     *
     * @param {number} [options.constraints.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 for the task executable due to a nonzero exit code. 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 after the first attempt. If the maximum
     * retry count is -1, the Batch service retries the task without limit.
     * Resource files and application packages are only downloaded again if the
     * task is retried on a new compute node.
     *
     * @param {object} [options.taskUpdateOptions] Additional parameters for the
     * operation
     *
     * @param {number} [options.taskUpdateOptions.timeout] The maximum time that
     * the server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskUpdateOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskUpdateOptions.returnClientRequestId] Whether
     * the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskUpdateOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskUpdateOptions.ifMatch] An ETag value associated
     * with the version of the resource known to the client. The operation will be
     * performed only if the resource's current ETag on the service exactly matches
     * the value specified by the client.
     *
     * @param {string} [options.taskUpdateOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskUpdateOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskUpdateOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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.
     */
    updateWithHttpOperationResponse(jobId, taskId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._update(jobId, taskId, 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 the specified task.
     *
     * @param {string} jobId The ID of the job containing the task.
     *
     * @param {string} taskId The ID of the task to update.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.constraints] Constraints that apply to this task.
     * If omitted, the task is given the default constraints. For multi-instance
     * tasks, updating the retention time applies only to the primary task and not
     * subtasks.
     *
     * @param {moment.duration} [options.constraints.maxWallClockTime] The maximum
     * elapsed time that the task may run, measured from the time the task starts.
     * If the task does not complete within the time limit, the Batch service
     * terminates it. If this is not specified, there is no time limit on how long
     * the task may run.
     *
     * @param {moment.duration} [options.constraints.retentionTime] The minimum
     * time to retain the task directory on the compute node where it ran, from the
     * time it completes execution. After this time, the Batch service may delete
     * the task directory and all its contents. The default is infinite, i.e. the
     * task directory will be retained until the compute node is removed or
     * reimaged.
     *
     * @param {number} [options.constraints.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 for the task executable due to a nonzero exit code. 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 after the first attempt. If the maximum
     * retry count is -1, the Batch service retries the task without limit.
     * Resource files and application packages are only downloaded again if the
     * task is retried on a new compute node.
     *
     * @param {object} [options.taskUpdateOptions] Additional parameters for the
     * operation
     *
     * @param {number} [options.taskUpdateOptions.timeout] The maximum time that
     * the server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskUpdateOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskUpdateOptions.returnClientRequestId] Whether
     * the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskUpdateOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskUpdateOptions.ifMatch] An ETag value associated
     * with the version of the resource known to the client. The operation will be
     * performed only if the resource's current ETag on the service exactly matches
     * the value specified by the client.
     *
     * @param {string} [options.taskUpdateOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskUpdateOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskUpdateOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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.
     */
    update(jobId, taskId, 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(jobId, taskId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._update(jobId, taskId, options, optionalCallback);
      }
    }
  
    /**
     * @summary Lists all of the subtasks that are associated with the specified
     * multi-instance task.
     *
     * If the task is not a multi-instance task then this returns an empty
     * collection.
     *
     * @param {string} jobId The ID of the job.
     *
     * @param {string} taskId The ID of the task.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskListSubtasksOptions] Additional parameters for
     * the operation
     *
     * @param {string} [options.taskListSubtasksOptions.select] An OData $select
     * clause.
     *
     * @param {number} [options.taskListSubtasksOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskListSubtasksOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskListSubtasksOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskListSubtasksOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<CloudTaskListSubtasksResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listSubtasksWithHttpOperationResponse(jobId, taskId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listSubtasks(jobId, taskId, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Lists all of the subtasks that are associated with the specified
     * multi-instance task.
     *
     * If the task is not a multi-instance task then this returns an empty
     * collection.
     *
     * @param {string} jobId The ID of the job.
     *
     * @param {string} taskId The ID of the task.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskListSubtasksOptions] Additional parameters for
     * the operation
     *
     * @param {string} [options.taskListSubtasksOptions.select] An OData $select
     * clause.
     *
     * @param {number} [options.taskListSubtasksOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskListSubtasksOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskListSubtasksOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskListSubtasksOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @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 {CloudTaskListSubtasksResult} - 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 CloudTaskListSubtasksResult} 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.
     */
    listSubtasks(jobId, taskId, 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._listSubtasks(jobId, taskId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listSubtasks(jobId, taskId, options, optionalCallback);
      }
    }
  
    /**
     * @summary Terminates the specified task.
     *
     * When the task has been terminated, it moves to the completed state. For
     * multi-instance tasks, the terminate task operation applies synchronously to
     * the primary task; subtasks are then terminated asynchronously in the
     * background.
     *
     * @param {string} jobId The ID of the job containing the task.
     *
     * @param {string} taskId The ID of the task to terminate.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskTerminateOptions] Additional parameters for the
     * operation
     *
     * @param {number} [options.taskTerminateOptions.timeout] The maximum time that
     * the server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskTerminateOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskTerminateOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskTerminateOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskTerminateOptions.ifMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service exactly matches the value specified by the client.
     *
     * @param {string} [options.taskTerminateOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskTerminateOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskTerminateOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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.
     */
    terminateWithHttpOperationResponse(jobId, taskId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._terminate(jobId, taskId, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Terminates the specified task.
     *
     * When the task has been terminated, it moves to the completed state. For
     * multi-instance tasks, the terminate task operation applies synchronously to
     * the primary task; subtasks are then terminated asynchronously in the
     * background.
     *
     * @param {string} jobId The ID of the job containing the task.
     *
     * @param {string} taskId The ID of the task to terminate.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskTerminateOptions] Additional parameters for the
     * operation
     *
     * @param {number} [options.taskTerminateOptions.timeout] The maximum time that
     * the server can spend processing the request, in seconds. The default is 30
     * seconds.
     *
     * @param {uuid} [options.taskTerminateOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskTerminateOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskTerminateOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskTerminateOptions.ifMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service exactly matches the value specified by the client.
     *
     * @param {string} [options.taskTerminateOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskTerminateOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskTerminateOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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.
     */
    terminate(jobId, taskId, 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._terminate(jobId, taskId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._terminate(jobId, taskId, options, optionalCallback);
      }
    }
  
    /**
     * @summary Reactivates a task, allowing it to run again even if its retry
     * count has been exhausted.
     *
     * Reactivation makes a task eligible to be retried again up to its maximum
     * retry count. The task's state is changed to active. As the task is no longer
     * in the completed state, any previous exit code or failure information is no
     * longer available after reactivation. Each time a task is reactivated, its
     * retry count is reset to 0. Reactivation will fail for tasks that are not
     * completed or that previously completed successfully (with an exit code of
     * 0). Additionally, it will fail if the job has completed (or is terminating
     * or deleting).
     *
     * @param {string} jobId The ID of the job containing the task.
     *
     * @param {string} taskId The ID of the task to reactivate.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskReactivateOptions] Additional parameters for
     * the operation
     *
     * @param {number} [options.taskReactivateOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskReactivateOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskReactivateOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskReactivateOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskReactivateOptions.ifMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service exactly matches the value specified by the client.
     *
     * @param {string} [options.taskReactivateOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskReactivateOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskReactivateOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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.
     */
    reactivateWithHttpOperationResponse(jobId, taskId, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._reactivate(jobId, taskId, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Reactivates a task, allowing it to run again even if its retry
     * count has been exhausted.
     *
     * Reactivation makes a task eligible to be retried again up to its maximum
     * retry count. The task's state is changed to active. As the task is no longer
     * in the completed state, any previous exit code or failure information is no
     * longer available after reactivation. Each time a task is reactivated, its
     * retry count is reset to 0. Reactivation will fail for tasks that are not
     * completed or that previously completed successfully (with an exit code of
     * 0). Additionally, it will fail if the job has completed (or is terminating
     * or deleting).
     *
     * @param {string} jobId The ID of the job containing the task.
     *
     * @param {string} taskId The ID of the task to reactivate.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskReactivateOptions] Additional parameters for
     * the operation
     *
     * @param {number} [options.taskReactivateOptions.timeout] The maximum time
     * that the server can spend processing the request, in seconds. The default is
     * 30 seconds.
     *
     * @param {uuid} [options.taskReactivateOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskReactivateOptions.returnClientRequestId]
     * Whether the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskReactivateOptions.ocpDate] The time the request
     * was issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {string} [options.taskReactivateOptions.ifMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service exactly matches the value specified by the client.
     *
     * @param {string} [options.taskReactivateOptions.ifNoneMatch] An ETag value
     * associated with the version of the resource known to the client. The
     * operation will be performed only if the resource's current ETag on the
     * service does not match the value specified by the client.
     *
     * @param {date} [options.taskReactivateOptions.ifModifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has been
     * modified since the specified time.
     *
     * @param {date} [options.taskReactivateOptions.ifUnmodifiedSince] A timestamp
     * indicating the last modified time of the resource known to the client. The
     * operation will be performed only if the resource on the service has not been
     * modified since the specified time.
     *
     * @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.
     */
    reactivate(jobId, taskId, 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._reactivate(jobId, taskId, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._reactivate(jobId, taskId, options, optionalCallback);
      }
    }
  
    /**
     * @summary Lists all of the tasks that are associated with the specified job.
     *
     * For multi-instance tasks, information such as affinityId, executionInfo and
     * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
     * information about subtasks.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskListNextOptions] Additional parameters for the
     * operation
     *
     * @param {uuid} [options.taskListNextOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskListNextOptions.returnClientRequestId] Whether
     * the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskListNextOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<CloudTaskListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * @summary Lists all of the tasks that are associated with the specified job.
     *
     * For multi-instance tasks, information such as affinityId, executionInfo and
     * nodeInfo refer to the primary task. Use the list subtasks API to retrieve
     * information about subtasks.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.taskListNextOptions] Additional parameters for the
     * operation
     *
     * @param {uuid} [options.taskListNextOptions.clientRequestId] The
     * caller-generated request identity, in the form of a GUID with no decoration
     * such as curly braces, e.g. 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0.
     *
     * @param {boolean} [options.taskListNextOptions.returnClientRequestId] Whether
     * the server should return the client-request-id in the response.
     *
     * @param {date} [options.taskListNextOptions.ocpDate] The time the request was
     * issued. Client libraries typically set this to the current system clock
     * time; set it explicitly if you are calling the REST API directly.
     *
     * @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 {CloudTaskListResult} - 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 CloudTaskListResult} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    listNext(nextPageLink, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._listNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listNext(nextPageLink, options, optionalCallback);
      }
    }
  
  }
  
  module.exports = Task;
  