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

/**
 * Gets a list of Jobs within the specified Experiment.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.jobsListByExperimentOptions] Additional parameters
 * for the operation
 *
 * @param {number} [options.jobsListByExperimentOptions.maxResults] The maximum
 * number of items to return in the response. A maximum of 1000 files can be
 * returned.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link JobListResult} 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 _listByExperiment(resourceGroupName, workspaceName, experimentName, 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 jobsListByExperimentOptions = (options && options.jobsListByExperimentOptions !== undefined) ? options.jobsListByExperimentOptions : undefined;
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }
  let maxResults;
  try {
    if (jobsListByExperimentOptions !== null && jobsListByExperimentOptions !== undefined)
    {
      maxResults = jobsListByExperimentOptions.maxResults;
      if (maxResults !== null && maxResults !== undefined && typeof maxResults !== 'number') {
        throw new Error('maxResults must be of type number.');
      }
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (maxResults !== null && maxResults !== undefined) {
    queryParameters.push('maxresults=' + encodeURIComponent(maxResults.toString()));
  }
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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


/**
 * Creates a Job in the given Experiment.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} parameters The parameters to provide for job creation.
 *
 * @param {string} [parameters.schedulingPriority] Scheduling priority.
 * Scheduling priority associated with the job. Possible values: low, normal,
 * high. Possible values include: 'low', 'normal', 'high'
 *
 * @param {object} parameters.cluster Cluster. Resource ID of the cluster on
 * which this job will run.
 *
 * @param {object} [parameters.mountVolumes] Mount volumes. Information on
 * mount volumes to be used by the job. These volumes will be mounted before
 * the job execution and will be unmouted after the job completion. The volumes
 * will be mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT
 * environment variable.
 *
 * @param {array} [parameters.mountVolumes.azureFileShares] Azure File Shares.
 * A collection of Azure File Shares that are to be mounted to the cluster
 * nodes.
 *
 * @param {array} [parameters.mountVolumes.azureBlobFileSystems] Azure Blob
 * file systems. A collection of Azure Blob Containers that are to be mounted
 * to the cluster nodes.
 *
 * @param {array} [parameters.mountVolumes.fileServers] File Servers. A
 * collection of Batch AI File Servers that are to be mounted to the cluster
 * nodes.
 *
 * @param {array} [parameters.mountVolumes.unmanagedFileSystems] Unmanaged file
 * systems. A collection of unmanaged file systems that are to be mounted to
 * the cluster nodes.
 *
 * @param {number} parameters.nodeCount Node count. Number of compute nodes to
 * run the job on. The job will be gang scheduled on that many compute nodes.
 *
 * @param {object} [parameters.containerSettings] Container settings. Docker
 * container settings for the job. If not provided, the job will run directly
 * on the node.
 *
 * @param {object} parameters.containerSettings.imageSourceRegistry Image
 * source registry. Information about docker image and docker registry to
 * download the container from.
 *
 * @param {string} [parameters.containerSettings.imageSourceRegistry.serverUrl]
 * Server URL. URL for image repository.
 *
 * @param {string} parameters.containerSettings.imageSourceRegistry.image
 * Image. The name of the image in the image repository.
 *
 * @param {object}
 * [parameters.containerSettings.imageSourceRegistry.credentials] Credentials.
 * Credentials to access the private docker repository.
 *
 * @param {string}
 * parameters.containerSettings.imageSourceRegistry.credentials.username User
 * name. User name to login to the repository.
 *
 * @param {string}
 * [parameters.containerSettings.imageSourceRegistry.credentials.password]
 * Password. User password to login to the docker repository. One of password
 * or passwordSecretReference must be specified.
 *
 * @param {object}
 * [parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
 * Password secret reference. KeyVault Secret storing the password. Users can
 * store their secrets in Azure KeyVault and pass it to the Batch AI service to
 * integrate with KeyVault. One of password or passwordSecretReference must be
 * specified.
 *
 * @param {object}
 * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault
 * Key Vault resource identifier. Fully qualified resource indentifier of the
 * Key Vault.
 *
 * @param {string}
 * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id
 * The ID of the resource
 *
 * @param {string}
 * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl
 * Secret URL. The URL referencing a secret in the Key Vault.
 *
 * @param {string} [parameters.containerSettings.shmSize] /dev/shm size. Size
 * of /dev/shm. Please refer to docker documentation for supported argument
 * formats.
 *
 * @param {object} [parameters.cntkSettings] CNTK settings. Settings for CNTK
 * (aka Microsoft Cognitive Toolkit) job.
 *
 * @param {string} [parameters.cntkSettings.languageType] Language type. The
 * language to use for launching CNTK (aka Microsoft Cognitive Toolkit) job.
 * Valid values are 'BrainScript' or 'Python'.
 *
 * @param {string} [parameters.cntkSettings.configFilePath] Config file path.
 * Specifies the path of the BrainScript config file. This property can be
 * specified only if the languageType is 'BrainScript'.
 *
 * @param {string} [parameters.cntkSettings.pythonScriptFilePath] Python script
 * file path. Python script to execute. This property can be specified only if
 * the languageType is 'Python'.
 *
 * @param {string} [parameters.cntkSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter. This property can be
 * specified only if the languageType is 'Python'.
 *
 * @param {string} [parameters.cntkSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script or cntk executable.
 *
 * @param {number} [parameters.cntkSettings.processCount] Process count. Number
 * of processes to launch for the job execution. The default value for this
 * property is equal to nodeCount property
 *
 * @param {object} [parameters.pyTorchSettings] pyTorch settings. Settings for
 * pyTorch job.
 *
 * @param {string} parameters.pyTorchSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.pyTorchSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.pyTorchSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {number} [parameters.pyTorchSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {string} [parameters.pyTorchSettings.communicationBackend]
 * Communication backend. Type of the communication backend for distributed
 * jobs. Valid values are 'TCP', 'Gloo' or 'MPI'. Not required for
 * non-distributed jobs.
 *
 * @param {object} [parameters.tensorFlowSettings] TensorFlow settings.
 * Settings for Tensor Flow job.
 *
 * @param {string} parameters.tensorFlowSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.tensorFlowSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.tensorFlowSettings.masterCommandLineArgs] Master
 * command line arguments. Command line arguments that need to be passed to the
 * python script for the master task.
 *
 * @param {string} [parameters.tensorFlowSettings.workerCommandLineArgs] Worker
 * command line arguments. Command line arguments that need to be passed to the
 * python script for the worker task. Optional for single process jobs.
 *
 * @param {string}
 * [parameters.tensorFlowSettings.parameterServerCommandLineArgs] Parameter
 * server command line arguments. Command line arguments that need to be passed
 * to the python script for the parameter server. Optional for single process
 * jobs.
 *
 * @param {number} [parameters.tensorFlowSettings.workerCount] Worker count.
 * The number of worker tasks. If specified, the value must be less than or
 * equal to (nodeCount * numberOfGPUs per VM). If not specified, the default
 * value is equal to nodeCount. This property can be specified only for
 * distributed TensorFlow training.
 *
 * @param {number} [parameters.tensorFlowSettings.parameterServerCount]
 * Parameter server count. The number of parameter server tasks. If specified,
 * the value must be less than or equal to nodeCount. If not specified, the
 * default value is equal to 1 for distributed TensorFlow training. This
 * property can be specified only for distributed TensorFlow training.
 *
 * @param {object} [parameters.caffeSettings] Caffe settings. Settings for
 * Caffe job.
 *
 * @param {string} [parameters.caffeSettings.configFilePath] Config file path.
 * Path of the config file for the job. This property cannot be specified if
 * pythonScriptFilePath is specified.
 *
 * @param {string} [parameters.caffeSettings.pythonScriptFilePath] Python
 * script file path. Python script to execute. This property cannot be
 * specified if configFilePath is specified.
 *
 * @param {string} [parameters.caffeSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter. The property can be
 * specified only if the pythonScriptFilePath is specified.
 *
 * @param {string} [parameters.caffeSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the Caffe job.
 *
 * @param {number} [parameters.caffeSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.caffe2Settings] Caffe2 settings. Settings for
 * Caffe2 job.
 *
 * @param {string} parameters.caffe2Settings.pythonScriptFilePath Python script
 * file path. The python script to execute.
 *
 * @param {string} [parameters.caffe2Settings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.caffe2Settings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {object} [parameters.chainerSettings] Chainer settings. Settings for
 * Chainer job.
 *
 * @param {string} parameters.chainerSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.chainerSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.chainerSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {number} [parameters.chainerSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.customToolkitSettings] Custom tool kit job.
 * Settings for custom tool kit job.
 *
 * @param {string} [parameters.customToolkitSettings.commandLine] Command line.
 * The command line to execute on the master node.
 *
 * @param {object} [parameters.customMpiSettings] Custom MPI settings. Settings
 * for custom MPI job.
 *
 * @param {string} parameters.customMpiSettings.commandLine Command line. The
 * command line to be executed by mpi runtime on each compute node.
 *
 * @param {number} [parameters.customMpiSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.horovodSettings] Horovod settings. Settings for
 * Horovod job.
 *
 * @param {string} parameters.horovodSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.horovodSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.horovodSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {number} [parameters.horovodSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.jobPreparation] Job preparation. A command line
 * to be executed on each node allocated for the job before tool kit is
 * launched.
 *
 * @param {string} parameters.jobPreparation.commandLine Command line. The
 * command line to execute. If containerSettings is specified on the job, this
 * commandLine will be executed in the same container as job. Otherwise it will
 * be executed on the node.
 *
 * @param {string} parameters.stdOutErrPathPrefix Standard output path prefix.
 * The path where the Batch AI service will store stdout, stderror and
 * execution log of the job.
 *
 * @param {array} [parameters.inputDirectories] Input directories. A list of
 * input directories for the job.
 *
 * @param {array} [parameters.outputDirectories] Output directories. A list of
 * output directories for the job.
 *
 * @param {array} [parameters.environmentVariables] Environment variables. A
 * list of user defined environment variables which will be setup for the job.
 *
 * @param {array} [parameters.secrets] Secrets. A list of user defined
 * environment variables with secret values which will be setup for the job.
 * Server will never report values of these variables back.
 *
 * @param {object} [parameters.constraints] Constraints associated with the
 * Job.
 *
 * @param {moment.duration} [parameters.constraints.maxWallClockTime] Max wall
 * clock time. Max time the job can run. Default value: 1 week.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link Job} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _create(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginCreate(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

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

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


/**
 * Deletes a Job.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _deleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

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

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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

/**
 * Gets information about a Job.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link Job} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _get(resourceGroupName, workspaceName, experimentName, jobName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
      throw new Error('jobName cannot be null or undefined and it must be of type string.');
    }
    if (jobName !== null && jobName !== undefined) {
      if (jobName.length > 64)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 64');
      }
      if (jobName.length < 1)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 1');
      }
      if (jobName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"jobName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs/{jobName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * List all directories and files inside the given directory of the Job's
 * output directory (if the output directory is on Azure File Share or Azure
 * Storage Container).
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} jobsListOutputFilesOptions Additional parameters for the
 * operation
 *
 * @param {string} jobsListOutputFilesOptions.outputdirectoryid Id of the job
 * output directory. This is the OutputDirectory-->id parameter that is given
 * by the user during Create Job.
 *
 * @param {string} [jobsListOutputFilesOptions.directory] The path to the
 * directory.
 *
 * @param {number} [jobsListOutputFilesOptions.linkexpiryinminutes] The number
 * of minutes after which the download link will expire.
 *
 * @param {number} [jobsListOutputFilesOptions.maxResults] The maximum number
 * of items to return in the response. A maximum of 1000 files can be returned.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link FileListResult} 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 _listOutputFiles(resourceGroupName, workspaceName, experimentName, jobName, jobsListOutputFilesOptions, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
      throw new Error('jobName cannot be null or undefined and it must be of type string.');
    }
    if (jobName !== null && jobName !== undefined) {
      if (jobName.length > 64)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 64');
      }
      if (jobName.length < 1)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 1');
      }
      if (jobName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"jobName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (jobsListOutputFilesOptions === null || jobsListOutputFilesOptions === undefined) {
      throw new Error('jobsListOutputFilesOptions cannot be null or undefined.');
    }
    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 outputdirectoryid;
  let directory;
  let linkexpiryinminutes;
  let maxResults;
  try {
    if (jobsListOutputFilesOptions !== null && jobsListOutputFilesOptions !== undefined)
    {
      outputdirectoryid = jobsListOutputFilesOptions.outputdirectoryid;
      if (outputdirectoryid === null || outputdirectoryid === undefined || typeof outputdirectoryid.valueOf() !== 'string') {
        throw new Error('outputdirectoryid cannot be null or undefined and it must be of type string.');
      }
    }
    if (jobsListOutputFilesOptions !== null && jobsListOutputFilesOptions !== undefined)
    {
      directory = jobsListOutputFilesOptions.directory;
      if (directory !== null && directory !== undefined && typeof directory.valueOf() !== 'string') {
        throw new Error('directory must be of type string.');
      }
    }
    if (jobsListOutputFilesOptions !== null && jobsListOutputFilesOptions !== undefined)
    {
      linkexpiryinminutes = jobsListOutputFilesOptions.linkexpiryinminutes;
      if (linkexpiryinminutes !== null && linkexpiryinminutes !== undefined && typeof linkexpiryinminutes !== 'number') {
        throw new Error('linkexpiryinminutes must be of type number.');
      }
    }
    if (jobsListOutputFilesOptions !== null && jobsListOutputFilesOptions !== undefined)
    {
      maxResults = jobsListOutputFilesOptions.maxResults;
      if (maxResults !== null && maxResults !== undefined && typeof maxResults !== 'number') {
        throw new Error('maxResults must be of type number.');
      }
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs/{jobName}/listOutputFiles';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  queryParameters.push('outputdirectoryid=' + encodeURIComponent(outputdirectoryid));
  if (directory !== null && directory !== undefined) {
    queryParameters.push('directory=' + encodeURIComponent(directory));
  }
  if (linkexpiryinminutes !== null && linkexpiryinminutes !== undefined) {
    queryParameters.push('linkexpiryinminutes=' + encodeURIComponent(linkexpiryinminutes.toString()));
  }
  if (maxResults !== null && maxResults !== undefined) {
    queryParameters.push('maxresults=' + encodeURIComponent(maxResults.toString()));
  }
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Gets a list of currently existing nodes which were used for the Job
 * execution. The returned information contains the node ID, its public IP and
 * SSH port.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link RemoteLoginInformationListResult} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listRemoteLoginInformation(resourceGroupName, workspaceName, experimentName, jobName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
      throw new Error('jobName cannot be null or undefined and it must be of type string.');
    }
    if (jobName !== null && jobName !== undefined) {
      if (jobName.length > 64)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 64');
      }
      if (jobName.length < 1)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 1');
      }
      if (jobName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"jobName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs/{jobName}/listRemoteLoginInformation';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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


/**
 * Terminates a job.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _terminate(resourceGroupName, workspaceName, experimentName, jobName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginTerminate(resourceGroupName, workspaceName, experimentName, jobName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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

/**
 * Creates a Job in the given Experiment.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} parameters The parameters to provide for job creation.
 *
 * @param {string} [parameters.schedulingPriority] Scheduling priority.
 * Scheduling priority associated with the job. Possible values: low, normal,
 * high. Possible values include: 'low', 'normal', 'high'
 *
 * @param {object} parameters.cluster Cluster. Resource ID of the cluster on
 * which this job will run.
 *
 * @param {object} [parameters.mountVolumes] Mount volumes. Information on
 * mount volumes to be used by the job. These volumes will be mounted before
 * the job execution and will be unmouted after the job completion. The volumes
 * will be mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT
 * environment variable.
 *
 * @param {array} [parameters.mountVolumes.azureFileShares] Azure File Shares.
 * A collection of Azure File Shares that are to be mounted to the cluster
 * nodes.
 *
 * @param {array} [parameters.mountVolumes.azureBlobFileSystems] Azure Blob
 * file systems. A collection of Azure Blob Containers that are to be mounted
 * to the cluster nodes.
 *
 * @param {array} [parameters.mountVolumes.fileServers] File Servers. A
 * collection of Batch AI File Servers that are to be mounted to the cluster
 * nodes.
 *
 * @param {array} [parameters.mountVolumes.unmanagedFileSystems] Unmanaged file
 * systems. A collection of unmanaged file systems that are to be mounted to
 * the cluster nodes.
 *
 * @param {number} parameters.nodeCount Node count. Number of compute nodes to
 * run the job on. The job will be gang scheduled on that many compute nodes.
 *
 * @param {object} [parameters.containerSettings] Container settings. Docker
 * container settings for the job. If not provided, the job will run directly
 * on the node.
 *
 * @param {object} parameters.containerSettings.imageSourceRegistry Image
 * source registry. Information about docker image and docker registry to
 * download the container from.
 *
 * @param {string} [parameters.containerSettings.imageSourceRegistry.serverUrl]
 * Server URL. URL for image repository.
 *
 * @param {string} parameters.containerSettings.imageSourceRegistry.image
 * Image. The name of the image in the image repository.
 *
 * @param {object}
 * [parameters.containerSettings.imageSourceRegistry.credentials] Credentials.
 * Credentials to access the private docker repository.
 *
 * @param {string}
 * parameters.containerSettings.imageSourceRegistry.credentials.username User
 * name. User name to login to the repository.
 *
 * @param {string}
 * [parameters.containerSettings.imageSourceRegistry.credentials.password]
 * Password. User password to login to the docker repository. One of password
 * or passwordSecretReference must be specified.
 *
 * @param {object}
 * [parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
 * Password secret reference. KeyVault Secret storing the password. Users can
 * store their secrets in Azure KeyVault and pass it to the Batch AI service to
 * integrate with KeyVault. One of password or passwordSecretReference must be
 * specified.
 *
 * @param {object}
 * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault
 * Key Vault resource identifier. Fully qualified resource indentifier of the
 * Key Vault.
 *
 * @param {string}
 * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id
 * The ID of the resource
 *
 * @param {string}
 * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl
 * Secret URL. The URL referencing a secret in the Key Vault.
 *
 * @param {string} [parameters.containerSettings.shmSize] /dev/shm size. Size
 * of /dev/shm. Please refer to docker documentation for supported argument
 * formats.
 *
 * @param {object} [parameters.cntkSettings] CNTK settings. Settings for CNTK
 * (aka Microsoft Cognitive Toolkit) job.
 *
 * @param {string} [parameters.cntkSettings.languageType] Language type. The
 * language to use for launching CNTK (aka Microsoft Cognitive Toolkit) job.
 * Valid values are 'BrainScript' or 'Python'.
 *
 * @param {string} [parameters.cntkSettings.configFilePath] Config file path.
 * Specifies the path of the BrainScript config file. This property can be
 * specified only if the languageType is 'BrainScript'.
 *
 * @param {string} [parameters.cntkSettings.pythonScriptFilePath] Python script
 * file path. Python script to execute. This property can be specified only if
 * the languageType is 'Python'.
 *
 * @param {string} [parameters.cntkSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter. This property can be
 * specified only if the languageType is 'Python'.
 *
 * @param {string} [parameters.cntkSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script or cntk executable.
 *
 * @param {number} [parameters.cntkSettings.processCount] Process count. Number
 * of processes to launch for the job execution. The default value for this
 * property is equal to nodeCount property
 *
 * @param {object} [parameters.pyTorchSettings] pyTorch settings. Settings for
 * pyTorch job.
 *
 * @param {string} parameters.pyTorchSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.pyTorchSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.pyTorchSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {number} [parameters.pyTorchSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {string} [parameters.pyTorchSettings.communicationBackend]
 * Communication backend. Type of the communication backend for distributed
 * jobs. Valid values are 'TCP', 'Gloo' or 'MPI'. Not required for
 * non-distributed jobs.
 *
 * @param {object} [parameters.tensorFlowSettings] TensorFlow settings.
 * Settings for Tensor Flow job.
 *
 * @param {string} parameters.tensorFlowSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.tensorFlowSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.tensorFlowSettings.masterCommandLineArgs] Master
 * command line arguments. Command line arguments that need to be passed to the
 * python script for the master task.
 *
 * @param {string} [parameters.tensorFlowSettings.workerCommandLineArgs] Worker
 * command line arguments. Command line arguments that need to be passed to the
 * python script for the worker task. Optional for single process jobs.
 *
 * @param {string}
 * [parameters.tensorFlowSettings.parameterServerCommandLineArgs] Parameter
 * server command line arguments. Command line arguments that need to be passed
 * to the python script for the parameter server. Optional for single process
 * jobs.
 *
 * @param {number} [parameters.tensorFlowSettings.workerCount] Worker count.
 * The number of worker tasks. If specified, the value must be less than or
 * equal to (nodeCount * numberOfGPUs per VM). If not specified, the default
 * value is equal to nodeCount. This property can be specified only for
 * distributed TensorFlow training.
 *
 * @param {number} [parameters.tensorFlowSettings.parameterServerCount]
 * Parameter server count. The number of parameter server tasks. If specified,
 * the value must be less than or equal to nodeCount. If not specified, the
 * default value is equal to 1 for distributed TensorFlow training. This
 * property can be specified only for distributed TensorFlow training.
 *
 * @param {object} [parameters.caffeSettings] Caffe settings. Settings for
 * Caffe job.
 *
 * @param {string} [parameters.caffeSettings.configFilePath] Config file path.
 * Path of the config file for the job. This property cannot be specified if
 * pythonScriptFilePath is specified.
 *
 * @param {string} [parameters.caffeSettings.pythonScriptFilePath] Python
 * script file path. Python script to execute. This property cannot be
 * specified if configFilePath is specified.
 *
 * @param {string} [parameters.caffeSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter. The property can be
 * specified only if the pythonScriptFilePath is specified.
 *
 * @param {string} [parameters.caffeSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the Caffe job.
 *
 * @param {number} [parameters.caffeSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.caffe2Settings] Caffe2 settings. Settings for
 * Caffe2 job.
 *
 * @param {string} parameters.caffe2Settings.pythonScriptFilePath Python script
 * file path. The python script to execute.
 *
 * @param {string} [parameters.caffe2Settings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.caffe2Settings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {object} [parameters.chainerSettings] Chainer settings. Settings for
 * Chainer job.
 *
 * @param {string} parameters.chainerSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.chainerSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.chainerSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {number} [parameters.chainerSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.customToolkitSettings] Custom tool kit job.
 * Settings for custom tool kit job.
 *
 * @param {string} [parameters.customToolkitSettings.commandLine] Command line.
 * The command line to execute on the master node.
 *
 * @param {object} [parameters.customMpiSettings] Custom MPI settings. Settings
 * for custom MPI job.
 *
 * @param {string} parameters.customMpiSettings.commandLine Command line. The
 * command line to be executed by mpi runtime on each compute node.
 *
 * @param {number} [parameters.customMpiSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.horovodSettings] Horovod settings. Settings for
 * Horovod job.
 *
 * @param {string} parameters.horovodSettings.pythonScriptFilePath Python
 * script file path. The python script to execute.
 *
 * @param {string} [parameters.horovodSettings.pythonInterpreterPath] Python
 * interpreter path. The path to the Python interpreter.
 *
 * @param {string} [parameters.horovodSettings.commandLineArgs] Command line
 * arguments. Command line arguments that need to be passed to the python
 * script.
 *
 * @param {number} [parameters.horovodSettings.processCount] Process count.
 * Number of processes to launch for the job execution. The default value for
 * this property is equal to nodeCount property
 *
 * @param {object} [parameters.jobPreparation] Job preparation. A command line
 * to be executed on each node allocated for the job before tool kit is
 * launched.
 *
 * @param {string} parameters.jobPreparation.commandLine Command line. The
 * command line to execute. If containerSettings is specified on the job, this
 * commandLine will be executed in the same container as job. Otherwise it will
 * be executed on the node.
 *
 * @param {string} parameters.stdOutErrPathPrefix Standard output path prefix.
 * The path where the Batch AI service will store stdout, stderror and
 * execution log of the job.
 *
 * @param {array} [parameters.inputDirectories] Input directories. A list of
 * input directories for the job.
 *
 * @param {array} [parameters.outputDirectories] Output directories. A list of
 * output directories for the job.
 *
 * @param {array} [parameters.environmentVariables] Environment variables. A
 * list of user defined environment variables which will be setup for the job.
 *
 * @param {array} [parameters.secrets] Secrets. A list of user defined
 * environment variables with secret values which will be setup for the job.
 * Server will never report values of these variables back.
 *
 * @param {object} [parameters.constraints] Constraints associated with the
 * Job.
 *
 * @param {moment.duration} [parameters.constraints.maxWallClockTime] Max wall
 * clock time. Max time the job can run. Default value: 1 week.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link Job} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginCreate(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
      throw new Error('jobName cannot be null or undefined and it must be of type string.');
    }
    if (jobName !== null && jobName !== undefined) {
      if (jobName.length > 64)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 64');
      }
      if (jobName.length < 1)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 1');
      }
      if (jobName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"jobName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs/{jobName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Deletes a Job.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDeleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
      throw new Error('jobName cannot be null or undefined and it must be of type string.');
    }
    if (jobName !== null && jobName !== undefined) {
      if (jobName.length > 64)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 64');
      }
      if (jobName.length < 1)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 1');
      }
      if (jobName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"jobName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs/{jobName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Terminates a job.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} experimentName The name of the experiment. Experiment names
 * can only contain a combination of alphanumeric characters along with dash
 * (-) and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} jobName The name of the job within the specified resource
 * group. Job names can only contain a combination of alphanumeric characters
 * along with dash (-) and underscore (_). The name must be from 1 through 64
 * characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginTerminate(resourceGroupName, workspaceName, experimentName, jobName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (experimentName === null || experimentName === undefined || typeof experimentName.valueOf() !== 'string') {
      throw new Error('experimentName cannot be null or undefined and it must be of type string.');
    }
    if (experimentName !== null && experimentName !== undefined) {
      if (experimentName.length > 64)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MaxLength": 64');
      }
      if (experimentName.length < 1)
      {
        throw new Error('"experimentName" should satisfy the constraint - "MinLength": 1');
      }
      if (experimentName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"experimentName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
      throw new Error('jobName cannot be null or undefined and it must be of type string.');
    }
    if (jobName !== null && jobName !== undefined) {
      if (jobName.length > 64)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 64');
      }
      if (jobName.length < 1)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 1');
      }
      if (jobName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"jobName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/experiments/{experimentName}/jobs/{jobName}/terminate';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{experimentName}', encodeURIComponent(experimentName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Gets a list of Jobs within the specified Experiment.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link JobListResult} 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 _listByExperimentNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

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

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

/**
 * List all directories and files inside the given directory of the Job's
 * output directory (if the output directory is on Azure File Share or Azure
 * Storage Container).
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link FileListResult} 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 _listOutputFilesNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

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

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

/**
 * Gets a list of currently existing nodes which were used for the Job
 * execution. The returned information contains the node ID, its public IP and
 * SSH port.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link RemoteLoginInformationListResult} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listRemoteLoginInformationNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

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

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

/** Class representing a Jobs. */
class Jobs {
  /**
   * Create a Jobs.
   * @param {BatchAIManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listByExperiment = _listByExperiment;
    this._create = _create;
    this._deleteMethod = _deleteMethod;
    this._get = _get;
    this._listOutputFiles = _listOutputFiles;
    this._listRemoteLoginInformation = _listRemoteLoginInformation;
    this._terminate = _terminate;
    this._beginCreate = _beginCreate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginTerminate = _beginTerminate;
    this._listByExperimentNext = _listByExperimentNext;
    this._listOutputFilesNext = _listOutputFilesNext;
    this._listRemoteLoginInformationNext = _listRemoteLoginInformationNext;
  }

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

  /**
   * Gets a list of Jobs within the specified Experiment.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.jobsListByExperimentOptions] Additional parameters
   * for the operation
   *
   * @param {number} [options.jobsListByExperimentOptions.maxResults] The maximum
   * number of items to return in the response. A maximum of 1000 files can be
   * returned.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {JobListResult} - 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 JobListResult} 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.
   */
  listByExperiment(resourceGroupName, workspaceName, experimentName, 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._listByExperiment(resourceGroupName, workspaceName, experimentName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByExperiment(resourceGroupName, workspaceName, experimentName, options, optionalCallback);
    }
  }

  /**
   * Creates a Job in the given Experiment.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} parameters The parameters to provide for job creation.
   *
   * @param {string} [parameters.schedulingPriority] Scheduling priority.
   * Scheduling priority associated with the job. Possible values: low, normal,
   * high. Possible values include: 'low', 'normal', 'high'
   *
   * @param {object} parameters.cluster Cluster. Resource ID of the cluster on
   * which this job will run.
   *
   * @param {object} [parameters.mountVolumes] Mount volumes. Information on
   * mount volumes to be used by the job. These volumes will be mounted before
   * the job execution and will be unmouted after the job completion. The volumes
   * will be mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.mountVolumes.azureFileShares] Azure File Shares.
   * A collection of Azure File Shares that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.azureBlobFileSystems] Azure Blob
   * file systems. A collection of Azure Blob Containers that are to be mounted
   * to the cluster nodes.
   *
   * @param {array} [parameters.mountVolumes.fileServers] File Servers. A
   * collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.unmanagedFileSystems] Unmanaged file
   * systems. A collection of unmanaged file systems that are to be mounted to
   * the cluster nodes.
   *
   * @param {number} parameters.nodeCount Node count. Number of compute nodes to
   * run the job on. The job will be gang scheduled on that many compute nodes.
   *
   * @param {object} [parameters.containerSettings] Container settings. Docker
   * container settings for the job. If not provided, the job will run directly
   * on the node.
   *
   * @param {object} parameters.containerSettings.imageSourceRegistry Image
   * source registry. Information about docker image and docker registry to
   * download the container from.
   *
   * @param {string} [parameters.containerSettings.imageSourceRegistry.serverUrl]
   * Server URL. URL for image repository.
   *
   * @param {string} parameters.containerSettings.imageSourceRegistry.image
   * Image. The name of the image in the image repository.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials] Credentials.
   * Credentials to access the private docker repository.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.username User
   * name. User name to login to the repository.
   *
   * @param {string}
   * [parameters.containerSettings.imageSourceRegistry.credentials.password]
   * Password. User password to login to the docker repository. One of password
   * or passwordSecretReference must be specified.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
   * Password secret reference. KeyVault Secret storing the password. Users can
   * store their secrets in Azure KeyVault and pass it to the Batch AI service to
   * integrate with KeyVault. One of password or passwordSecretReference must be
   * specified.
   *
   * @param {object}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id
   * The ID of the resource
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {string} [parameters.containerSettings.shmSize] /dev/shm size. Size
   * of /dev/shm. Please refer to docker documentation for supported argument
   * formats.
   *
   * @param {object} [parameters.cntkSettings] CNTK settings. Settings for CNTK
   * (aka Microsoft Cognitive Toolkit) job.
   *
   * @param {string} [parameters.cntkSettings.languageType] Language type. The
   * language to use for launching CNTK (aka Microsoft Cognitive Toolkit) job.
   * Valid values are 'BrainScript' or 'Python'.
   *
   * @param {string} [parameters.cntkSettings.configFilePath] Config file path.
   * Specifies the path of the BrainScript config file. This property can be
   * specified only if the languageType is 'BrainScript'.
   *
   * @param {string} [parameters.cntkSettings.pythonScriptFilePath] Python script
   * file path. Python script to execute. This property can be specified only if
   * the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. This property can be
   * specified only if the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script or cntk executable.
   *
   * @param {number} [parameters.cntkSettings.processCount] Process count. Number
   * of processes to launch for the job execution. The default value for this
   * property is equal to nodeCount property
   *
   * @param {object} [parameters.pyTorchSettings] pyTorch settings. Settings for
   * pyTorch job.
   *
   * @param {string} parameters.pyTorchSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.pyTorchSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.pyTorchSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.pyTorchSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {string} [parameters.pyTorchSettings.communicationBackend]
   * Communication backend. Type of the communication backend for distributed
   * jobs. Valid values are 'TCP', 'Gloo' or 'MPI'. Not required for
   * non-distributed jobs.
   *
   * @param {object} [parameters.tensorFlowSettings] TensorFlow settings.
   * Settings for Tensor Flow job.
   *
   * @param {string} parameters.tensorFlowSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.tensorFlowSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.tensorFlowSettings.masterCommandLineArgs] Master
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the master task.
   *
   * @param {string} [parameters.tensorFlowSettings.workerCommandLineArgs] Worker
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the worker task. Optional for single process jobs.
   *
   * @param {string}
   * [parameters.tensorFlowSettings.parameterServerCommandLineArgs] Parameter
   * server command line arguments. Command line arguments that need to be passed
   * to the python script for the parameter server. Optional for single process
   * jobs.
   *
   * @param {number} [parameters.tensorFlowSettings.workerCount] Worker count.
   * The number of worker tasks. If specified, the value must be less than or
   * equal to (nodeCount * numberOfGPUs per VM). If not specified, the default
   * value is equal to nodeCount. This property can be specified only for
   * distributed TensorFlow training.
   *
   * @param {number} [parameters.tensorFlowSettings.parameterServerCount]
   * Parameter server count. The number of parameter server tasks. If specified,
   * the value must be less than or equal to nodeCount. If not specified, the
   * default value is equal to 1 for distributed TensorFlow training. This
   * property can be specified only for distributed TensorFlow training.
   *
   * @param {object} [parameters.caffeSettings] Caffe settings. Settings for
   * Caffe job.
   *
   * @param {string} [parameters.caffeSettings.configFilePath] Config file path.
   * Path of the config file for the job. This property cannot be specified if
   * pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonScriptFilePath] Python
   * script file path. Python script to execute. This property cannot be
   * specified if configFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. The property can be
   * specified only if the pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the Caffe job.
   *
   * @param {number} [parameters.caffeSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.caffe2Settings] Caffe2 settings. Settings for
   * Caffe2 job.
   *
   * @param {string} parameters.caffe2Settings.pythonScriptFilePath Python script
   * file path. The python script to execute.
   *
   * @param {string} [parameters.caffe2Settings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.caffe2Settings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {object} [parameters.chainerSettings] Chainer settings. Settings for
   * Chainer job.
   *
   * @param {string} parameters.chainerSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.chainerSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.chainerSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.chainerSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.customToolkitSettings] Custom tool kit job.
   * Settings for custom tool kit job.
   *
   * @param {string} [parameters.customToolkitSettings.commandLine] Command line.
   * The command line to execute on the master node.
   *
   * @param {object} [parameters.customMpiSettings] Custom MPI settings. Settings
   * for custom MPI job.
   *
   * @param {string} parameters.customMpiSettings.commandLine Command line. The
   * command line to be executed by mpi runtime on each compute node.
   *
   * @param {number} [parameters.customMpiSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.horovodSettings] Horovod settings. Settings for
   * Horovod job.
   *
   * @param {string} parameters.horovodSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.horovodSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.horovodSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.horovodSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.jobPreparation] Job preparation. A command line
   * to be executed on each node allocated for the job before tool kit is
   * launched.
   *
   * @param {string} parameters.jobPreparation.commandLine Command line. The
   * command line to execute. If containerSettings is specified on the job, this
   * commandLine will be executed in the same container as job. Otherwise it will
   * be executed on the node.
   *
   * @param {string} parameters.stdOutErrPathPrefix Standard output path prefix.
   * The path where the Batch AI service will store stdout, stderror and
   * execution log of the job.
   *
   * @param {array} [parameters.inputDirectories] Input directories. A list of
   * input directories for the job.
   *
   * @param {array} [parameters.outputDirectories] Output directories. A list of
   * output directories for the job.
   *
   * @param {array} [parameters.environmentVariables] Environment variables. A
   * list of user defined environment variables which will be setup for the job.
   *
   * @param {array} [parameters.secrets] Secrets. A list of user defined
   * environment variables with secret values which will be setup for the job.
   * Server will never report values of these variables back.
   *
   * @param {object} [parameters.constraints] Constraints associated with the
   * Job.
   *
   * @param {moment.duration} [parameters.constraints.maxWallClockTime] Max wall
   * clock time. Max time the job can run. Default value: 1 week.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Job>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a Job in the given Experiment.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} parameters The parameters to provide for job creation.
   *
   * @param {string} [parameters.schedulingPriority] Scheduling priority.
   * Scheduling priority associated with the job. Possible values: low, normal,
   * high. Possible values include: 'low', 'normal', 'high'
   *
   * @param {object} parameters.cluster Cluster. Resource ID of the cluster on
   * which this job will run.
   *
   * @param {object} [parameters.mountVolumes] Mount volumes. Information on
   * mount volumes to be used by the job. These volumes will be mounted before
   * the job execution and will be unmouted after the job completion. The volumes
   * will be mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.mountVolumes.azureFileShares] Azure File Shares.
   * A collection of Azure File Shares that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.azureBlobFileSystems] Azure Blob
   * file systems. A collection of Azure Blob Containers that are to be mounted
   * to the cluster nodes.
   *
   * @param {array} [parameters.mountVolumes.fileServers] File Servers. A
   * collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.unmanagedFileSystems] Unmanaged file
   * systems. A collection of unmanaged file systems that are to be mounted to
   * the cluster nodes.
   *
   * @param {number} parameters.nodeCount Node count. Number of compute nodes to
   * run the job on. The job will be gang scheduled on that many compute nodes.
   *
   * @param {object} [parameters.containerSettings] Container settings. Docker
   * container settings for the job. If not provided, the job will run directly
   * on the node.
   *
   * @param {object} parameters.containerSettings.imageSourceRegistry Image
   * source registry. Information about docker image and docker registry to
   * download the container from.
   *
   * @param {string} [parameters.containerSettings.imageSourceRegistry.serverUrl]
   * Server URL. URL for image repository.
   *
   * @param {string} parameters.containerSettings.imageSourceRegistry.image
   * Image. The name of the image in the image repository.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials] Credentials.
   * Credentials to access the private docker repository.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.username User
   * name. User name to login to the repository.
   *
   * @param {string}
   * [parameters.containerSettings.imageSourceRegistry.credentials.password]
   * Password. User password to login to the docker repository. One of password
   * or passwordSecretReference must be specified.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
   * Password secret reference. KeyVault Secret storing the password. Users can
   * store their secrets in Azure KeyVault and pass it to the Batch AI service to
   * integrate with KeyVault. One of password or passwordSecretReference must be
   * specified.
   *
   * @param {object}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id
   * The ID of the resource
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {string} [parameters.containerSettings.shmSize] /dev/shm size. Size
   * of /dev/shm. Please refer to docker documentation for supported argument
   * formats.
   *
   * @param {object} [parameters.cntkSettings] CNTK settings. Settings for CNTK
   * (aka Microsoft Cognitive Toolkit) job.
   *
   * @param {string} [parameters.cntkSettings.languageType] Language type. The
   * language to use for launching CNTK (aka Microsoft Cognitive Toolkit) job.
   * Valid values are 'BrainScript' or 'Python'.
   *
   * @param {string} [parameters.cntkSettings.configFilePath] Config file path.
   * Specifies the path of the BrainScript config file. This property can be
   * specified only if the languageType is 'BrainScript'.
   *
   * @param {string} [parameters.cntkSettings.pythonScriptFilePath] Python script
   * file path. Python script to execute. This property can be specified only if
   * the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. This property can be
   * specified only if the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script or cntk executable.
   *
   * @param {number} [parameters.cntkSettings.processCount] Process count. Number
   * of processes to launch for the job execution. The default value for this
   * property is equal to nodeCount property
   *
   * @param {object} [parameters.pyTorchSettings] pyTorch settings. Settings for
   * pyTorch job.
   *
   * @param {string} parameters.pyTorchSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.pyTorchSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.pyTorchSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.pyTorchSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {string} [parameters.pyTorchSettings.communicationBackend]
   * Communication backend. Type of the communication backend for distributed
   * jobs. Valid values are 'TCP', 'Gloo' or 'MPI'. Not required for
   * non-distributed jobs.
   *
   * @param {object} [parameters.tensorFlowSettings] TensorFlow settings.
   * Settings for Tensor Flow job.
   *
   * @param {string} parameters.tensorFlowSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.tensorFlowSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.tensorFlowSettings.masterCommandLineArgs] Master
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the master task.
   *
   * @param {string} [parameters.tensorFlowSettings.workerCommandLineArgs] Worker
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the worker task. Optional for single process jobs.
   *
   * @param {string}
   * [parameters.tensorFlowSettings.parameterServerCommandLineArgs] Parameter
   * server command line arguments. Command line arguments that need to be passed
   * to the python script for the parameter server. Optional for single process
   * jobs.
   *
   * @param {number} [parameters.tensorFlowSettings.workerCount] Worker count.
   * The number of worker tasks. If specified, the value must be less than or
   * equal to (nodeCount * numberOfGPUs per VM). If not specified, the default
   * value is equal to nodeCount. This property can be specified only for
   * distributed TensorFlow training.
   *
   * @param {number} [parameters.tensorFlowSettings.parameterServerCount]
   * Parameter server count. The number of parameter server tasks. If specified,
   * the value must be less than or equal to nodeCount. If not specified, the
   * default value is equal to 1 for distributed TensorFlow training. This
   * property can be specified only for distributed TensorFlow training.
   *
   * @param {object} [parameters.caffeSettings] Caffe settings. Settings for
   * Caffe job.
   *
   * @param {string} [parameters.caffeSettings.configFilePath] Config file path.
   * Path of the config file for the job. This property cannot be specified if
   * pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonScriptFilePath] Python
   * script file path. Python script to execute. This property cannot be
   * specified if configFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. The property can be
   * specified only if the pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the Caffe job.
   *
   * @param {number} [parameters.caffeSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.caffe2Settings] Caffe2 settings. Settings for
   * Caffe2 job.
   *
   * @param {string} parameters.caffe2Settings.pythonScriptFilePath Python script
   * file path. The python script to execute.
   *
   * @param {string} [parameters.caffe2Settings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.caffe2Settings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {object} [parameters.chainerSettings] Chainer settings. Settings for
   * Chainer job.
   *
   * @param {string} parameters.chainerSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.chainerSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.chainerSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.chainerSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.customToolkitSettings] Custom tool kit job.
   * Settings for custom tool kit job.
   *
   * @param {string} [parameters.customToolkitSettings.commandLine] Command line.
   * The command line to execute on the master node.
   *
   * @param {object} [parameters.customMpiSettings] Custom MPI settings. Settings
   * for custom MPI job.
   *
   * @param {string} parameters.customMpiSettings.commandLine Command line. The
   * command line to be executed by mpi runtime on each compute node.
   *
   * @param {number} [parameters.customMpiSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.horovodSettings] Horovod settings. Settings for
   * Horovod job.
   *
   * @param {string} parameters.horovodSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.horovodSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.horovodSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.horovodSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.jobPreparation] Job preparation. A command line
   * to be executed on each node allocated for the job before tool kit is
   * launched.
   *
   * @param {string} parameters.jobPreparation.commandLine Command line. The
   * command line to execute. If containerSettings is specified on the job, this
   * commandLine will be executed in the same container as job. Otherwise it will
   * be executed on the node.
   *
   * @param {string} parameters.stdOutErrPathPrefix Standard output path prefix.
   * The path where the Batch AI service will store stdout, stderror and
   * execution log of the job.
   *
   * @param {array} [parameters.inputDirectories] Input directories. A list of
   * input directories for the job.
   *
   * @param {array} [parameters.outputDirectories] Output directories. A list of
   * output directories for the job.
   *
   * @param {array} [parameters.environmentVariables] Environment variables. A
   * list of user defined environment variables which will be setup for the job.
   *
   * @param {array} [parameters.secrets] Secrets. A list of user defined
   * environment variables with secret values which will be setup for the job.
   * Server will never report values of these variables back.
   *
   * @param {object} [parameters.constraints] Constraints associated with the
   * Job.
   *
   * @param {moment.duration} [parameters.constraints.maxWallClockTime] Max wall
   * clock time. Max time the job can run. Default value: 1 week.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {Job} - 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 Job} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  create(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._create(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a Job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteMethodWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a Job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback);
    }
  }

  /**
   * Gets information about a Job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Job>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets information about a Job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {Job} - 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 Job} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  get(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback);
    }
  }

  /**
   * List all directories and files inside the given directory of the Job's
   * output directory (if the output directory is on Azure File Share or Azure
   * Storage Container).
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} jobsListOutputFilesOptions Additional parameters for the
   * operation
   *
   * @param {string} jobsListOutputFilesOptions.outputdirectoryid Id of the job
   * output directory. This is the OutputDirectory-->id parameter that is given
   * by the user during Create Job.
   *
   * @param {string} [jobsListOutputFilesOptions.directory] The path to the
   * directory.
   *
   * @param {number} [jobsListOutputFilesOptions.linkexpiryinminutes] The number
   * of minutes after which the download link will expire.
   *
   * @param {number} [jobsListOutputFilesOptions.maxResults] The maximum number
   * of items to return in the response. A maximum of 1000 files can be returned.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listOutputFilesWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, jobsListOutputFilesOptions, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listOutputFiles(resourceGroupName, workspaceName, experimentName, jobName, jobsListOutputFilesOptions, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List all directories and files inside the given directory of the Job's
   * output directory (if the output directory is on Azure File Share or Azure
   * Storage Container).
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} jobsListOutputFilesOptions Additional parameters for the
   * operation
   *
   * @param {string} jobsListOutputFilesOptions.outputdirectoryid Id of the job
   * output directory. This is the OutputDirectory-->id parameter that is given
   * by the user during Create Job.
   *
   * @param {string} [jobsListOutputFilesOptions.directory] The path to the
   * directory.
   *
   * @param {number} [jobsListOutputFilesOptions.linkexpiryinminutes] The number
   * of minutes after which the download link will expire.
   *
   * @param {number} [jobsListOutputFilesOptions.maxResults] The maximum number
   * of items to return in the response. A maximum of 1000 files can be returned.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {FileListResult} - 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 FileListResult} 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.
   */
  listOutputFiles(resourceGroupName, workspaceName, experimentName, jobName, jobsListOutputFilesOptions, 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._listOutputFiles(resourceGroupName, workspaceName, experimentName, jobName, jobsListOutputFilesOptions, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listOutputFiles(resourceGroupName, workspaceName, experimentName, jobName, jobsListOutputFilesOptions, options, optionalCallback);
    }
  }

  /**
   * Gets a list of currently existing nodes which were used for the Job
   * execution. The returned information contains the node ID, its public IP and
   * SSH port.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<RemoteLoginInformationListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listRemoteLoginInformationWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listRemoteLoginInformation(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a list of currently existing nodes which were used for the Job
   * execution. The returned information contains the node ID, its public IP and
   * SSH port.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {RemoteLoginInformationListResult} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link RemoteLoginInformationListResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listRemoteLoginInformation(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listRemoteLoginInformation(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listRemoteLoginInformation(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback);
    }
  }

  /**
   * Terminates a job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  terminateWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._terminate(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Terminates a job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  terminate(resourceGroupName, workspaceName, experimentName, jobName, 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(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._terminate(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback);
    }
  }

  /**
   * Creates a Job in the given Experiment.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} parameters The parameters to provide for job creation.
   *
   * @param {string} [parameters.schedulingPriority] Scheduling priority.
   * Scheduling priority associated with the job. Possible values: low, normal,
   * high. Possible values include: 'low', 'normal', 'high'
   *
   * @param {object} parameters.cluster Cluster. Resource ID of the cluster on
   * which this job will run.
   *
   * @param {object} [parameters.mountVolumes] Mount volumes. Information on
   * mount volumes to be used by the job. These volumes will be mounted before
   * the job execution and will be unmouted after the job completion. The volumes
   * will be mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.mountVolumes.azureFileShares] Azure File Shares.
   * A collection of Azure File Shares that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.azureBlobFileSystems] Azure Blob
   * file systems. A collection of Azure Blob Containers that are to be mounted
   * to the cluster nodes.
   *
   * @param {array} [parameters.mountVolumes.fileServers] File Servers. A
   * collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.unmanagedFileSystems] Unmanaged file
   * systems. A collection of unmanaged file systems that are to be mounted to
   * the cluster nodes.
   *
   * @param {number} parameters.nodeCount Node count. Number of compute nodes to
   * run the job on. The job will be gang scheduled on that many compute nodes.
   *
   * @param {object} [parameters.containerSettings] Container settings. Docker
   * container settings for the job. If not provided, the job will run directly
   * on the node.
   *
   * @param {object} parameters.containerSettings.imageSourceRegistry Image
   * source registry. Information about docker image and docker registry to
   * download the container from.
   *
   * @param {string} [parameters.containerSettings.imageSourceRegistry.serverUrl]
   * Server URL. URL for image repository.
   *
   * @param {string} parameters.containerSettings.imageSourceRegistry.image
   * Image. The name of the image in the image repository.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials] Credentials.
   * Credentials to access the private docker repository.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.username User
   * name. User name to login to the repository.
   *
   * @param {string}
   * [parameters.containerSettings.imageSourceRegistry.credentials.password]
   * Password. User password to login to the docker repository. One of password
   * or passwordSecretReference must be specified.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
   * Password secret reference. KeyVault Secret storing the password. Users can
   * store their secrets in Azure KeyVault and pass it to the Batch AI service to
   * integrate with KeyVault. One of password or passwordSecretReference must be
   * specified.
   *
   * @param {object}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id
   * The ID of the resource
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {string} [parameters.containerSettings.shmSize] /dev/shm size. Size
   * of /dev/shm. Please refer to docker documentation for supported argument
   * formats.
   *
   * @param {object} [parameters.cntkSettings] CNTK settings. Settings for CNTK
   * (aka Microsoft Cognitive Toolkit) job.
   *
   * @param {string} [parameters.cntkSettings.languageType] Language type. The
   * language to use for launching CNTK (aka Microsoft Cognitive Toolkit) job.
   * Valid values are 'BrainScript' or 'Python'.
   *
   * @param {string} [parameters.cntkSettings.configFilePath] Config file path.
   * Specifies the path of the BrainScript config file. This property can be
   * specified only if the languageType is 'BrainScript'.
   *
   * @param {string} [parameters.cntkSettings.pythonScriptFilePath] Python script
   * file path. Python script to execute. This property can be specified only if
   * the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. This property can be
   * specified only if the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script or cntk executable.
   *
   * @param {number} [parameters.cntkSettings.processCount] Process count. Number
   * of processes to launch for the job execution. The default value for this
   * property is equal to nodeCount property
   *
   * @param {object} [parameters.pyTorchSettings] pyTorch settings. Settings for
   * pyTorch job.
   *
   * @param {string} parameters.pyTorchSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.pyTorchSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.pyTorchSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.pyTorchSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {string} [parameters.pyTorchSettings.communicationBackend]
   * Communication backend. Type of the communication backend for distributed
   * jobs. Valid values are 'TCP', 'Gloo' or 'MPI'. Not required for
   * non-distributed jobs.
   *
   * @param {object} [parameters.tensorFlowSettings] TensorFlow settings.
   * Settings for Tensor Flow job.
   *
   * @param {string} parameters.tensorFlowSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.tensorFlowSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.tensorFlowSettings.masterCommandLineArgs] Master
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the master task.
   *
   * @param {string} [parameters.tensorFlowSettings.workerCommandLineArgs] Worker
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the worker task. Optional for single process jobs.
   *
   * @param {string}
   * [parameters.tensorFlowSettings.parameterServerCommandLineArgs] Parameter
   * server command line arguments. Command line arguments that need to be passed
   * to the python script for the parameter server. Optional for single process
   * jobs.
   *
   * @param {number} [parameters.tensorFlowSettings.workerCount] Worker count.
   * The number of worker tasks. If specified, the value must be less than or
   * equal to (nodeCount * numberOfGPUs per VM). If not specified, the default
   * value is equal to nodeCount. This property can be specified only for
   * distributed TensorFlow training.
   *
   * @param {number} [parameters.tensorFlowSettings.parameterServerCount]
   * Parameter server count. The number of parameter server tasks. If specified,
   * the value must be less than or equal to nodeCount. If not specified, the
   * default value is equal to 1 for distributed TensorFlow training. This
   * property can be specified only for distributed TensorFlow training.
   *
   * @param {object} [parameters.caffeSettings] Caffe settings. Settings for
   * Caffe job.
   *
   * @param {string} [parameters.caffeSettings.configFilePath] Config file path.
   * Path of the config file for the job. This property cannot be specified if
   * pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonScriptFilePath] Python
   * script file path. Python script to execute. This property cannot be
   * specified if configFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. The property can be
   * specified only if the pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the Caffe job.
   *
   * @param {number} [parameters.caffeSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.caffe2Settings] Caffe2 settings. Settings for
   * Caffe2 job.
   *
   * @param {string} parameters.caffe2Settings.pythonScriptFilePath Python script
   * file path. The python script to execute.
   *
   * @param {string} [parameters.caffe2Settings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.caffe2Settings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {object} [parameters.chainerSettings] Chainer settings. Settings for
   * Chainer job.
   *
   * @param {string} parameters.chainerSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.chainerSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.chainerSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.chainerSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.customToolkitSettings] Custom tool kit job.
   * Settings for custom tool kit job.
   *
   * @param {string} [parameters.customToolkitSettings.commandLine] Command line.
   * The command line to execute on the master node.
   *
   * @param {object} [parameters.customMpiSettings] Custom MPI settings. Settings
   * for custom MPI job.
   *
   * @param {string} parameters.customMpiSettings.commandLine Command line. The
   * command line to be executed by mpi runtime on each compute node.
   *
   * @param {number} [parameters.customMpiSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.horovodSettings] Horovod settings. Settings for
   * Horovod job.
   *
   * @param {string} parameters.horovodSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.horovodSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.horovodSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.horovodSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.jobPreparation] Job preparation. A command line
   * to be executed on each node allocated for the job before tool kit is
   * launched.
   *
   * @param {string} parameters.jobPreparation.commandLine Command line. The
   * command line to execute. If containerSettings is specified on the job, this
   * commandLine will be executed in the same container as job. Otherwise it will
   * be executed on the node.
   *
   * @param {string} parameters.stdOutErrPathPrefix Standard output path prefix.
   * The path where the Batch AI service will store stdout, stderror and
   * execution log of the job.
   *
   * @param {array} [parameters.inputDirectories] Input directories. A list of
   * input directories for the job.
   *
   * @param {array} [parameters.outputDirectories] Output directories. A list of
   * output directories for the job.
   *
   * @param {array} [parameters.environmentVariables] Environment variables. A
   * list of user defined environment variables which will be setup for the job.
   *
   * @param {array} [parameters.secrets] Secrets. A list of user defined
   * environment variables with secret values which will be setup for the job.
   * Server will never report values of these variables back.
   *
   * @param {object} [parameters.constraints] Constraints associated with the
   * Job.
   *
   * @param {moment.duration} [parameters.constraints.maxWallClockTime] Max wall
   * clock time. Max time the job can run. Default value: 1 week.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Job>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreate(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a Job in the given Experiment.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} parameters The parameters to provide for job creation.
   *
   * @param {string} [parameters.schedulingPriority] Scheduling priority.
   * Scheduling priority associated with the job. Possible values: low, normal,
   * high. Possible values include: 'low', 'normal', 'high'
   *
   * @param {object} parameters.cluster Cluster. Resource ID of the cluster on
   * which this job will run.
   *
   * @param {object} [parameters.mountVolumes] Mount volumes. Information on
   * mount volumes to be used by the job. These volumes will be mounted before
   * the job execution and will be unmouted after the job completion. The volumes
   * will be mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT
   * environment variable.
   *
   * @param {array} [parameters.mountVolumes.azureFileShares] Azure File Shares.
   * A collection of Azure File Shares that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.azureBlobFileSystems] Azure Blob
   * file systems. A collection of Azure Blob Containers that are to be mounted
   * to the cluster nodes.
   *
   * @param {array} [parameters.mountVolumes.fileServers] File Servers. A
   * collection of Batch AI File Servers that are to be mounted to the cluster
   * nodes.
   *
   * @param {array} [parameters.mountVolumes.unmanagedFileSystems] Unmanaged file
   * systems. A collection of unmanaged file systems that are to be mounted to
   * the cluster nodes.
   *
   * @param {number} parameters.nodeCount Node count. Number of compute nodes to
   * run the job on. The job will be gang scheduled on that many compute nodes.
   *
   * @param {object} [parameters.containerSettings] Container settings. Docker
   * container settings for the job. If not provided, the job will run directly
   * on the node.
   *
   * @param {object} parameters.containerSettings.imageSourceRegistry Image
   * source registry. Information about docker image and docker registry to
   * download the container from.
   *
   * @param {string} [parameters.containerSettings.imageSourceRegistry.serverUrl]
   * Server URL. URL for image repository.
   *
   * @param {string} parameters.containerSettings.imageSourceRegistry.image
   * Image. The name of the image in the image repository.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials] Credentials.
   * Credentials to access the private docker repository.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.username User
   * name. User name to login to the repository.
   *
   * @param {string}
   * [parameters.containerSettings.imageSourceRegistry.credentials.password]
   * Password. User password to login to the docker repository. One of password
   * or passwordSecretReference must be specified.
   *
   * @param {object}
   * [parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
   * Password secret reference. KeyVault Secret storing the password. Users can
   * store their secrets in Azure KeyVault and pass it to the Batch AI service to
   * integrate with KeyVault. One of password or passwordSecretReference must be
   * specified.
   *
   * @param {object}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault
   * Key Vault resource identifier. Fully qualified resource indentifier of the
   * Key Vault.
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id
   * The ID of the resource
   *
   * @param {string}
   * parameters.containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl
   * Secret URL. The URL referencing a secret in the Key Vault.
   *
   * @param {string} [parameters.containerSettings.shmSize] /dev/shm size. Size
   * of /dev/shm. Please refer to docker documentation for supported argument
   * formats.
   *
   * @param {object} [parameters.cntkSettings] CNTK settings. Settings for CNTK
   * (aka Microsoft Cognitive Toolkit) job.
   *
   * @param {string} [parameters.cntkSettings.languageType] Language type. The
   * language to use for launching CNTK (aka Microsoft Cognitive Toolkit) job.
   * Valid values are 'BrainScript' or 'Python'.
   *
   * @param {string} [parameters.cntkSettings.configFilePath] Config file path.
   * Specifies the path of the BrainScript config file. This property can be
   * specified only if the languageType is 'BrainScript'.
   *
   * @param {string} [parameters.cntkSettings.pythonScriptFilePath] Python script
   * file path. Python script to execute. This property can be specified only if
   * the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. This property can be
   * specified only if the languageType is 'Python'.
   *
   * @param {string} [parameters.cntkSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script or cntk executable.
   *
   * @param {number} [parameters.cntkSettings.processCount] Process count. Number
   * of processes to launch for the job execution. The default value for this
   * property is equal to nodeCount property
   *
   * @param {object} [parameters.pyTorchSettings] pyTorch settings. Settings for
   * pyTorch job.
   *
   * @param {string} parameters.pyTorchSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.pyTorchSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.pyTorchSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.pyTorchSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {string} [parameters.pyTorchSettings.communicationBackend]
   * Communication backend. Type of the communication backend for distributed
   * jobs. Valid values are 'TCP', 'Gloo' or 'MPI'. Not required for
   * non-distributed jobs.
   *
   * @param {object} [parameters.tensorFlowSettings] TensorFlow settings.
   * Settings for Tensor Flow job.
   *
   * @param {string} parameters.tensorFlowSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.tensorFlowSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.tensorFlowSettings.masterCommandLineArgs] Master
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the master task.
   *
   * @param {string} [parameters.tensorFlowSettings.workerCommandLineArgs] Worker
   * command line arguments. Command line arguments that need to be passed to the
   * python script for the worker task. Optional for single process jobs.
   *
   * @param {string}
   * [parameters.tensorFlowSettings.parameterServerCommandLineArgs] Parameter
   * server command line arguments. Command line arguments that need to be passed
   * to the python script for the parameter server. Optional for single process
   * jobs.
   *
   * @param {number} [parameters.tensorFlowSettings.workerCount] Worker count.
   * The number of worker tasks. If specified, the value must be less than or
   * equal to (nodeCount * numberOfGPUs per VM). If not specified, the default
   * value is equal to nodeCount. This property can be specified only for
   * distributed TensorFlow training.
   *
   * @param {number} [parameters.tensorFlowSettings.parameterServerCount]
   * Parameter server count. The number of parameter server tasks. If specified,
   * the value must be less than or equal to nodeCount. If not specified, the
   * default value is equal to 1 for distributed TensorFlow training. This
   * property can be specified only for distributed TensorFlow training.
   *
   * @param {object} [parameters.caffeSettings] Caffe settings. Settings for
   * Caffe job.
   *
   * @param {string} [parameters.caffeSettings.configFilePath] Config file path.
   * Path of the config file for the job. This property cannot be specified if
   * pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonScriptFilePath] Python
   * script file path. Python script to execute. This property cannot be
   * specified if configFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter. The property can be
   * specified only if the pythonScriptFilePath is specified.
   *
   * @param {string} [parameters.caffeSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the Caffe job.
   *
   * @param {number} [parameters.caffeSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.caffe2Settings] Caffe2 settings. Settings for
   * Caffe2 job.
   *
   * @param {string} parameters.caffe2Settings.pythonScriptFilePath Python script
   * file path. The python script to execute.
   *
   * @param {string} [parameters.caffe2Settings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.caffe2Settings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {object} [parameters.chainerSettings] Chainer settings. Settings for
   * Chainer job.
   *
   * @param {string} parameters.chainerSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.chainerSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.chainerSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.chainerSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.customToolkitSettings] Custom tool kit job.
   * Settings for custom tool kit job.
   *
   * @param {string} [parameters.customToolkitSettings.commandLine] Command line.
   * The command line to execute on the master node.
   *
   * @param {object} [parameters.customMpiSettings] Custom MPI settings. Settings
   * for custom MPI job.
   *
   * @param {string} parameters.customMpiSettings.commandLine Command line. The
   * command line to be executed by mpi runtime on each compute node.
   *
   * @param {number} [parameters.customMpiSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.horovodSettings] Horovod settings. Settings for
   * Horovod job.
   *
   * @param {string} parameters.horovodSettings.pythonScriptFilePath Python
   * script file path. The python script to execute.
   *
   * @param {string} [parameters.horovodSettings.pythonInterpreterPath] Python
   * interpreter path. The path to the Python interpreter.
   *
   * @param {string} [parameters.horovodSettings.commandLineArgs] Command line
   * arguments. Command line arguments that need to be passed to the python
   * script.
   *
   * @param {number} [parameters.horovodSettings.processCount] Process count.
   * Number of processes to launch for the job execution. The default value for
   * this property is equal to nodeCount property
   *
   * @param {object} [parameters.jobPreparation] Job preparation. A command line
   * to be executed on each node allocated for the job before tool kit is
   * launched.
   *
   * @param {string} parameters.jobPreparation.commandLine Command line. The
   * command line to execute. If containerSettings is specified on the job, this
   * commandLine will be executed in the same container as job. Otherwise it will
   * be executed on the node.
   *
   * @param {string} parameters.stdOutErrPathPrefix Standard output path prefix.
   * The path where the Batch AI service will store stdout, stderror and
   * execution log of the job.
   *
   * @param {array} [parameters.inputDirectories] Input directories. A list of
   * input directories for the job.
   *
   * @param {array} [parameters.outputDirectories] Output directories. A list of
   * output directories for the job.
   *
   * @param {array} [parameters.environmentVariables] Environment variables. A
   * list of user defined environment variables which will be setup for the job.
   *
   * @param {array} [parameters.secrets] Secrets. A list of user defined
   * environment variables with secret values which will be setup for the job.
   * Server will never report values of these variables back.
   *
   * @param {object} [parameters.constraints] Constraints associated with the
   * Job.
   *
   * @param {moment.duration} [parameters.constraints.maxWallClockTime] Max wall
   * clock time. Max time the job can run. Default value: 1 week.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {Job} - 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 Job} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginCreate(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginCreate(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreate(resourceGroupName, workspaceName, experimentName, jobName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a Job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a Job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback);
    }
  }

  /**
   * Terminates a job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginTerminateWithHttpOperationResponse(resourceGroupName, workspaceName, experimentName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginTerminate(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Terminates a job.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} experimentName The name of the experiment. Experiment names
   * can only contain a combination of alphanumeric characters along with dash
   * (-) and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} jobName The name of the job within the specified resource
   * group. Job names can only contain a combination of alphanumeric characters
   * along with dash (-) and underscore (_). The name must be from 1 through 64
   * characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginTerminate(resourceGroupName, workspaceName, experimentName, jobName, 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._beginTerminate(resourceGroupName, workspaceName, experimentName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginTerminate(resourceGroupName, workspaceName, experimentName, jobName, options, optionalCallback);
    }
  }

  /**
   * Gets a list of Jobs within the specified Experiment.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByExperimentNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByExperimentNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a list of Jobs within the specified Experiment.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {JobListResult} - 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 JobListResult} 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.
   */
  listByExperimentNext(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._listByExperimentNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByExperimentNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * List all directories and files inside the given directory of the Job's
   * output directory (if the output directory is on Azure File Share or Azure
   * Storage Container).
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listOutputFilesNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listOutputFilesNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * List all directories and files inside the given directory of the Job's
   * output directory (if the output directory is on Azure File Share or Azure
   * Storage Container).
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {FileListResult} - 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 FileListResult} 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.
   */
  listOutputFilesNext(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._listOutputFilesNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listOutputFilesNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * Gets a list of currently existing nodes which were used for the Job
   * execution. The returned information contains the node ID, its public IP and
   * SSH port.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<RemoteLoginInformationListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listRemoteLoginInformationNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listRemoteLoginInformationNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a list of currently existing nodes which were used for the Job
   * execution. The returned information contains the node ID, its public IP and
   * SSH port.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {RemoteLoginInformationListResult} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link RemoteLoginInformationListResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listRemoteLoginInformationNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listRemoteLoginInformationNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listRemoteLoginInformationNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = Jobs;
