/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

'use strict';

const msRest = require('ms-rest');
const msRestAzure = require('ms-rest-azure');
const WebResource = msRest.WebResource;

/**
 * Lists all the jobs available under the subscription.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.skipToken] $skipToken is supported on Get list of
 * jobs, which provides the next page in the list of jobs.
 *
 * @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 JobResourceList} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _list(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 skipToken = (options && options.skipToken !== undefined) ? options.skipToken : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (skipToken !== null && skipToken !== undefined && typeof skipToken.valueOf() !== 'string') {
      throw new Error('skipToken must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.DataBox/jobs';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (skipToken !== null && skipToken !== undefined) {
    queryParameters.push('$skipToken=' + encodeURIComponent(skipToken));
  }
  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['JobResourceList']().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);
  });
}

/**
 * Lists all the jobs available under the given resource group.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.skipToken] $skipToken is supported on Get list of
 * jobs, which provides the next page in the list of jobs.
 *
 * @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 JobResourceList} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listByResourceGroup(resourceGroupName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let skipToken = (options && options.skipToken !== undefined) ? options.skipToken : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 (skipToken !== null && skipToken !== undefined && typeof skipToken.valueOf() !== 'string') {
      throw new Error('skipToken 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.DataBox/jobs';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (skipToken !== null && skipToken !== undefined) {
    queryParameters.push('$skipToken=' + encodeURIComponent(skipToken));
  }
  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['JobResourceList']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Gets information about the specified job.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] $expand is supported on details parameter
 * for job, which provides details on the job stages.
 *
 * @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 JobResource} 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, 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.');
  }
  let expand = (options && options.expand !== undefined) ? options.expand : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand 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.DataBox/jobs/{jobName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  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['JobResource']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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


/**
 * Creates a new job with the specified parameters. Existing job cannot be
 * updated with this API and should instead be updated with the Update job API.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {object} jobResource Job details from request body.
 *
 * @param {object} [jobResource.details] Details of a job run. This field will
 * only be sent for expand details filter.
 *
 * @param {number} [jobResource.details.expectedDataSizeInTeraBytes] The
 * expected size of the data, which needs to be transfered in this job, in tera
 * bytes.
 *
 * @param {object} jobResource.details.contactDetails Contact details for
 * notification and shipping.
 *
 * @param {string} jobResource.details.contactDetails.contactName Contact name
 * of the person.
 *
 * @param {string} jobResource.details.contactDetails.phone Phone number of the
 * contact person.
 *
 * @param {string} [jobResource.details.contactDetails.phoneExtension] Phone
 * extension number of the contact person.
 *
 * @param {string} [jobResource.details.contactDetails.mobile] Mobile number of
 * the contact person.
 *
 * @param {array} jobResource.details.contactDetails.emailList List of
 * Email-ids to be notified about job progress.
 *
 * @param {array} [jobResource.details.contactDetails.notificationPreference]
 * Notification preference for a job stage.
 *
 * @param {object} jobResource.details.shippingAddress Shipping address of the
 * customer.
 *
 * @param {string} jobResource.details.shippingAddress.streetAddress1 Street
 * Address line 1.
 *
 * @param {string} [jobResource.details.shippingAddress.streetAddress2] Street
 * Address line 2.
 *
 * @param {string} [jobResource.details.shippingAddress.streetAddress3] Street
 * Address line 3.
 *
 * @param {string} [jobResource.details.shippingAddress.city] Name of the City.
 *
 * @param {string} [jobResource.details.shippingAddress.stateOrProvince] Name
 * of the State or Province.
 *
 * @param {string} jobResource.details.shippingAddress.country Name of the
 * Country.
 *
 * @param {string} jobResource.details.shippingAddress.postalCode Postal code.
 *
 * @param {string} [jobResource.details.shippingAddress.zipExtendedCode]
 * Extended Zip Code.
 *
 * @param {string} [jobResource.details.shippingAddress.companyName] Name of
 * the company.
 *
 * @param {string} [jobResource.details.shippingAddress.addressType] Type of
 * address. Possible values include: 'None', 'Residential', 'Commercial'
 *
 * @param {array} jobResource.details.destinationAccountDetails Destination
 * account details.
 *
 * @param {object} [jobResource.details.preferences] Preferences for the order.
 *
 * @param {array} [jobResource.details.preferences.preferredDataCenterRegion]
 *
 * @param {string} jobResource.details.jobDetailsType Polymorphic Discriminator
 *
 * @param {string} jobResource.location The location of the resource. This will
 * be one of the supported and registered Azure Regions (e.g. West US, East US,
 * Southeast Asia, etc.). The region of a resource cannot be changed once it is
 * created, but if an identical region is specified on update the request will
 * succeed.
 *
 * @param {object} [jobResource.tags] The list of key value pairs that describe
 * the resource. These tags can be used in viewing and grouping this resource
 * (across resource groups).
 *
 * @param {object} jobResource.sku The sku type.
 *
 * @param {string} jobResource.sku.name The sku name. Possible values include:
 * 'DataBox', 'DataBoxDisk', 'DataBoxHeavy'
 *
 * @param {string} [jobResource.sku.displayName] The display name of the sku.
 *
 * @param {string} [jobResource.sku.family] The sku family.
 *
 * @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 JobResource} 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, jobName, jobResource, 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, jobName, jobResource, 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['JobResource']().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 The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @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, 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, 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);
    });
  });
}


/**
 * Updates the properties of an existing job.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {object} jobResourceUpdateParameter Job update parameters from
 * request body.
 *
 * @param {object} [jobResourceUpdateParameter.details] Details of a job to be
 * updated.
 *
 * @param {object} [jobResourceUpdateParameter.details.contactDetails] Contact
 * details for notification and shipping.
 *
 * @param {string}
 * jobResourceUpdateParameter.details.contactDetails.contactName Contact name
 * of the person.
 *
 * @param {string} jobResourceUpdateParameter.details.contactDetails.phone
 * Phone number of the contact person.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.contactDetails.phoneExtension] Phone
 * extension number of the contact person.
 *
 * @param {string} [jobResourceUpdateParameter.details.contactDetails.mobile]
 * Mobile number of the contact person.
 *
 * @param {array} jobResourceUpdateParameter.details.contactDetails.emailList
 * List of Email-ids to be notified about job progress.
 *
 * @param {array}
 * [jobResourceUpdateParameter.details.contactDetails.notificationPreference]
 * Notification preference for a job stage.
 *
 * @param {object} [jobResourceUpdateParameter.details.shippingAddress]
 * Shipping address of the customer.
 *
 * @param {string}
 * jobResourceUpdateParameter.details.shippingAddress.streetAddress1 Street
 * Address line 1.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.streetAddress2] Street
 * Address line 2.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.streetAddress3] Street
 * Address line 3.
 *
 * @param {string} [jobResourceUpdateParameter.details.shippingAddress.city]
 * Name of the City.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.stateOrProvince] Name of
 * the State or Province.
 *
 * @param {string} jobResourceUpdateParameter.details.shippingAddress.country
 * Name of the Country.
 *
 * @param {string}
 * jobResourceUpdateParameter.details.shippingAddress.postalCode Postal code.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.zipExtendedCode]
 * Extended Zip Code.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.companyName] Name of the
 * company.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.addressType] Type of
 * address. Possible values include: 'None', 'Residential', 'Commercial'
 *
 * @param {array} [jobResourceUpdateParameter.destinationAccountDetails]
 * Destination account details.
 *
 * @param {object} [jobResourceUpdateParameter.tags] The list of key value
 * pairs that describe the resource. These tags can be used in viewing and
 * grouping this resource (across resource groups).
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] Defines the If-Match condition. The patch
 * will be performed only if the ETag of the job on the server matches this
 * value.
 *
 * @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 JobResource} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _update(resourceGroupName, jobName, jobResourceUpdateParameter, 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.beginUpdate(resourceGroupName, jobName, jobResourceUpdateParameter, 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['JobResource']().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);
    });
  });
}

/**
 * Book shipment pick up.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {object} shipmentPickUpRequest Details of shipment pick up request.
 *
 * @param {date} shipmentPickUpRequest.startTime Minimum date after which the
 * pick up should commence, this must be in local time of pick up area.
 *
 * @param {date} shipmentPickUpRequest.endTime Maximum date before which the
 * pick up should commence, this must be in local time of pick up area.
 *
 * @param {string} shipmentPickUpRequest.shipmentLocation Shipment Location in
 * the pickup place. Eg.front desk
 *
 * @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 ShipmentPickUpResponse} 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 _bookShipmentPickUp(resourceGroupName, jobName, shipmentPickUpRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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 (shipmentPickUpRequest === null || shipmentPickUpRequest === undefined) {
      throw new Error('shipmentPickUpRequest 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);
  }

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

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

/**
 * CancelJob.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {string} reason Reason for cancellation.
 *
 * @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 _cancel(resourceGroupName, jobName, reason, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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 (reason === null || reason === undefined || typeof reason.valueOf() !== 'string') {
      throw new Error('reason 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 cancellationReason;
  if (reason !== null && reason !== undefined) {
    cancellationReason = new client.models['CancellationReason']();
    cancellationReason.reason = reason;
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (cancellationReason !== null && cancellationReason !== undefined) {
      let requestModelMapper = new client.models['CancellationReason']().mapper();
      requestModel = client.serialize(requestModelMapper, cancellationReason, 'cancellationReason');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(cancellationReason, 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 !== 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);
  });
}

/**
 * This method gets the unencrypted secrets related to the job.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @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 UnencryptedCredentialsList} 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 _listCredentials(resourceGroupName, 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 (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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.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.DataBox/jobs/{jobName}/listCredentials';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  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['UnencryptedCredentialsList']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Creates a new job with the specified parameters. Existing job cannot be
 * updated with this API and should instead be updated with the Update job API.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {object} jobResource Job details from request body.
 *
 * @param {object} [jobResource.details] Details of a job run. This field will
 * only be sent for expand details filter.
 *
 * @param {number} [jobResource.details.expectedDataSizeInTeraBytes] The
 * expected size of the data, which needs to be transfered in this job, in tera
 * bytes.
 *
 * @param {object} jobResource.details.contactDetails Contact details for
 * notification and shipping.
 *
 * @param {string} jobResource.details.contactDetails.contactName Contact name
 * of the person.
 *
 * @param {string} jobResource.details.contactDetails.phone Phone number of the
 * contact person.
 *
 * @param {string} [jobResource.details.contactDetails.phoneExtension] Phone
 * extension number of the contact person.
 *
 * @param {string} [jobResource.details.contactDetails.mobile] Mobile number of
 * the contact person.
 *
 * @param {array} jobResource.details.contactDetails.emailList List of
 * Email-ids to be notified about job progress.
 *
 * @param {array} [jobResource.details.contactDetails.notificationPreference]
 * Notification preference for a job stage.
 *
 * @param {object} jobResource.details.shippingAddress Shipping address of the
 * customer.
 *
 * @param {string} jobResource.details.shippingAddress.streetAddress1 Street
 * Address line 1.
 *
 * @param {string} [jobResource.details.shippingAddress.streetAddress2] Street
 * Address line 2.
 *
 * @param {string} [jobResource.details.shippingAddress.streetAddress3] Street
 * Address line 3.
 *
 * @param {string} [jobResource.details.shippingAddress.city] Name of the City.
 *
 * @param {string} [jobResource.details.shippingAddress.stateOrProvince] Name
 * of the State or Province.
 *
 * @param {string} jobResource.details.shippingAddress.country Name of the
 * Country.
 *
 * @param {string} jobResource.details.shippingAddress.postalCode Postal code.
 *
 * @param {string} [jobResource.details.shippingAddress.zipExtendedCode]
 * Extended Zip Code.
 *
 * @param {string} [jobResource.details.shippingAddress.companyName] Name of
 * the company.
 *
 * @param {string} [jobResource.details.shippingAddress.addressType] Type of
 * address. Possible values include: 'None', 'Residential', 'Commercial'
 *
 * @param {array} jobResource.details.destinationAccountDetails Destination
 * account details.
 *
 * @param {object} [jobResource.details.preferences] Preferences for the order.
 *
 * @param {array} [jobResource.details.preferences.preferredDataCenterRegion]
 *
 * @param {string} jobResource.details.jobDetailsType Polymorphic Discriminator
 *
 * @param {string} jobResource.location The location of the resource. This will
 * be one of the supported and registered Azure Regions (e.g. West US, East US,
 * Southeast Asia, etc.). The region of a resource cannot be changed once it is
 * created, but if an identical region is specified on update the request will
 * succeed.
 *
 * @param {object} [jobResource.tags] The list of key value pairs that describe
 * the resource. These tags can be used in viewing and grouping this resource
 * (across resource groups).
 *
 * @param {object} jobResource.sku The sku type.
 *
 * @param {string} jobResource.sku.name The sku name. Possible values include:
 * 'DataBox', 'DataBoxDisk', 'DataBoxHeavy'
 *
 * @param {string} [jobResource.sku.displayName] The display name of the sku.
 *
 * @param {string} [jobResource.sku.family] The sku family.
 *
 * @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 JobResource} 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, jobName, jobResource, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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 (jobResource === null || jobResource === undefined) {
      throw new Error('jobResource 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);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataBox/jobs/{jobName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  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 (jobResource !== null && jobResource !== undefined) {
      let requestModelMapper = new client.models['JobResource']().mapper();
      requestModel = client.serialize(requestModelMapper, jobResource, 'jobResource');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(jobResource, 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['JobResource']().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 The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @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, 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 (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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.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.DataBox/jobs/{jobName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  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 !== 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);
  });
}

/**
 * Updates the properties of an existing job.
 *
 * @param {string} resourceGroupName The Resource Group Name
 *
 * @param {string} jobName The name of the job Resource within the specified
 * resource group. job names must be between 3 and 24 characters in length and
 * use any alphanumeric and underscore only
 *
 * @param {object} jobResourceUpdateParameter Job update parameters from
 * request body.
 *
 * @param {object} [jobResourceUpdateParameter.details] Details of a job to be
 * updated.
 *
 * @param {object} [jobResourceUpdateParameter.details.contactDetails] Contact
 * details for notification and shipping.
 *
 * @param {string}
 * jobResourceUpdateParameter.details.contactDetails.contactName Contact name
 * of the person.
 *
 * @param {string} jobResourceUpdateParameter.details.contactDetails.phone
 * Phone number of the contact person.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.contactDetails.phoneExtension] Phone
 * extension number of the contact person.
 *
 * @param {string} [jobResourceUpdateParameter.details.contactDetails.mobile]
 * Mobile number of the contact person.
 *
 * @param {array} jobResourceUpdateParameter.details.contactDetails.emailList
 * List of Email-ids to be notified about job progress.
 *
 * @param {array}
 * [jobResourceUpdateParameter.details.contactDetails.notificationPreference]
 * Notification preference for a job stage.
 *
 * @param {object} [jobResourceUpdateParameter.details.shippingAddress]
 * Shipping address of the customer.
 *
 * @param {string}
 * jobResourceUpdateParameter.details.shippingAddress.streetAddress1 Street
 * Address line 1.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.streetAddress2] Street
 * Address line 2.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.streetAddress3] Street
 * Address line 3.
 *
 * @param {string} [jobResourceUpdateParameter.details.shippingAddress.city]
 * Name of the City.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.stateOrProvince] Name of
 * the State or Province.
 *
 * @param {string} jobResourceUpdateParameter.details.shippingAddress.country
 * Name of the Country.
 *
 * @param {string}
 * jobResourceUpdateParameter.details.shippingAddress.postalCode Postal code.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.zipExtendedCode]
 * Extended Zip Code.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.companyName] Name of the
 * company.
 *
 * @param {string}
 * [jobResourceUpdateParameter.details.shippingAddress.addressType] Type of
 * address. Possible values include: 'None', 'Residential', 'Commercial'
 *
 * @param {array} [jobResourceUpdateParameter.destinationAccountDetails]
 * Destination account details.
 *
 * @param {object} [jobResourceUpdateParameter.tags] The list of key value
 * pairs that describe the resource. These tags can be used in viewing and
 * grouping this resource (across resource groups).
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] Defines the If-Match condition. The patch
 * will be performed only if the ETag of the job on the server matches this
 * value.
 *
 * @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 JobResource} 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 _beginUpdate(resourceGroupName, jobName, jobResourceUpdateParameter, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (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 > 24)
      {
        throw new Error('"jobName" should satisfy the constraint - "MaxLength": 24');
      }
      if (jobName.length < 3)
      {
        throw new Error('"jobName" should satisfy the constraint - "MinLength": 3');
      }
      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 (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
      throw new Error('ifMatch must be of type string.');
    }
    if (jobResourceUpdateParameter === null || jobResourceUpdateParameter === undefined) {
      throw new Error('jobResourceUpdateParameter 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);
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'PATCH';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (ifMatch !== undefined && ifMatch !== null) {
    httpRequest.headers['If-Match'] = ifMatch;
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (jobResourceUpdateParameter !== null && jobResourceUpdateParameter !== undefined) {
      let requestModelMapper = new client.models['JobResourceUpdateParameter']().mapper();
      requestModel = client.serialize(requestModelMapper, jobResourceUpdateParameter, 'jobResourceUpdateParameter');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(jobResourceUpdateParameter, 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['JobResource']().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);
  });
}

/**
 * Lists all the jobs available under the subscription.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link JobResourceList} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // 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['JobResourceList']().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);
  });
}

/**
 * Lists all the jobs available under the given resource group.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link JobResourceList} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listByResourceGroupNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['JobResourceList']().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 {DataBoxManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._list = _list;
    this._listByResourceGroup = _listByResourceGroup;
    this._get = _get;
    this._create = _create;
    this._deleteMethod = _deleteMethod;
    this._update = _update;
    this._bookShipmentPickUp = _bookShipmentPickUp;
    this._cancel = _cancel;
    this._listCredentials = _listCredentials;
    this._beginCreate = _beginCreate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginUpdate = _beginUpdate;
    this._listNext = _listNext;
    this._listByResourceGroupNext = _listByResourceGroupNext;
  }

  /**
   * Lists all the jobs available under the subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.skipToken] $skipToken is supported on Get list of
   * jobs, which provides the next page in the list of jobs.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResourceList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listWithHttpOperationResponse(options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._list(options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all the jobs available under the subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.skipToken] $skipToken is supported on Get list of
   * jobs, which provides the next page in the list of jobs.
   *
   * @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 {JobResourceList} - 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 JobResourceList} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  list(options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._list(options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._list(options, optionalCallback);
    }
  }

  /**
   * Lists all the jobs available under the given resource group.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.skipToken] $skipToken is supported on Get list of
   * jobs, which provides the next page in the list of jobs.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResourceList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all the jobs available under the given resource group.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.skipToken] $skipToken is supported on Get list of
   * jobs, which provides the next page in the list of jobs.
   *
   * @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 {JobResourceList} - 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 JobResourceList} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listByResourceGroup(resourceGroupName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByResourceGroup(resourceGroupName, options, optionalCallback);
    }
  }

  /**
   * Gets information about the specified job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] $expand is supported on details parameter
   * for job, which provides details on the job stages.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, 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 the specified job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] $expand is supported on details parameter
   * for job, which provides details on the job stages.
   *
   * @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 {JobResource} - 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 JobResource} 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, 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, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Creates a new job with the specified parameters. Existing job cannot be
   * updated with this API and should instead be updated with the Update job API.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResource Job details from request body.
   *
   * @param {object} [jobResource.details] Details of a job run. This field will
   * only be sent for expand details filter.
   *
   * @param {number} [jobResource.details.expectedDataSizeInTeraBytes] The
   * expected size of the data, which needs to be transfered in this job, in tera
   * bytes.
   *
   * @param {object} jobResource.details.contactDetails Contact details for
   * notification and shipping.
   *
   * @param {string} jobResource.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResource.details.contactDetails.phone Phone number of the
   * contact person.
   *
   * @param {string} [jobResource.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResource.details.contactDetails.mobile] Mobile number of
   * the contact person.
   *
   * @param {array} jobResource.details.contactDetails.emailList List of
   * Email-ids to be notified about job progress.
   *
   * @param {array} [jobResource.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} jobResource.details.shippingAddress Shipping address of the
   * customer.
   *
   * @param {string} jobResource.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResource.details.shippingAddress.city] Name of the City.
   *
   * @param {string} [jobResource.details.shippingAddress.stateOrProvince] Name
   * of the State or Province.
   *
   * @param {string} jobResource.details.shippingAddress.country Name of the
   * Country.
   *
   * @param {string} jobResource.details.shippingAddress.postalCode Postal code.
   *
   * @param {string} [jobResource.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string} [jobResource.details.shippingAddress.companyName] Name of
   * the company.
   *
   * @param {string} [jobResource.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} jobResource.details.destinationAccountDetails Destination
   * account details.
   *
   * @param {object} [jobResource.details.preferences] Preferences for the order.
   *
   * @param {array} [jobResource.details.preferences.preferredDataCenterRegion]
   *
   * @param {string} jobResource.details.jobDetailsType Polymorphic Discriminator
   *
   * @param {string} jobResource.location The location of the resource. This will
   * be one of the supported and registered Azure Regions (e.g. West US, East US,
   * Southeast Asia, etc.). The region of a resource cannot be changed once it is
   * created, but if an identical region is specified on update the request will
   * succeed.
   *
   * @param {object} [jobResource.tags] The list of key value pairs that describe
   * the resource. These tags can be used in viewing and grouping this resource
   * (across resource groups).
   *
   * @param {object} jobResource.sku The sku type.
   *
   * @param {string} jobResource.sku.name The sku name. Possible values include:
   * 'DataBox', 'DataBoxDisk', 'DataBoxHeavy'
   *
   * @param {string} [jobResource.sku.displayName] The display name of the sku.
   *
   * @param {string} [jobResource.sku.family] The sku family.
   *
   * @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<JobResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(resourceGroupName, jobName, jobResource, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(resourceGroupName, jobName, jobResource, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a new job with the specified parameters. Existing job cannot be
   * updated with this API and should instead be updated with the Update job API.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResource Job details from request body.
   *
   * @param {object} [jobResource.details] Details of a job run. This field will
   * only be sent for expand details filter.
   *
   * @param {number} [jobResource.details.expectedDataSizeInTeraBytes] The
   * expected size of the data, which needs to be transfered in this job, in tera
   * bytes.
   *
   * @param {object} jobResource.details.contactDetails Contact details for
   * notification and shipping.
   *
   * @param {string} jobResource.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResource.details.contactDetails.phone Phone number of the
   * contact person.
   *
   * @param {string} [jobResource.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResource.details.contactDetails.mobile] Mobile number of
   * the contact person.
   *
   * @param {array} jobResource.details.contactDetails.emailList List of
   * Email-ids to be notified about job progress.
   *
   * @param {array} [jobResource.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} jobResource.details.shippingAddress Shipping address of the
   * customer.
   *
   * @param {string} jobResource.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResource.details.shippingAddress.city] Name of the City.
   *
   * @param {string} [jobResource.details.shippingAddress.stateOrProvince] Name
   * of the State or Province.
   *
   * @param {string} jobResource.details.shippingAddress.country Name of the
   * Country.
   *
   * @param {string} jobResource.details.shippingAddress.postalCode Postal code.
   *
   * @param {string} [jobResource.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string} [jobResource.details.shippingAddress.companyName] Name of
   * the company.
   *
   * @param {string} [jobResource.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} jobResource.details.destinationAccountDetails Destination
   * account details.
   *
   * @param {object} [jobResource.details.preferences] Preferences for the order.
   *
   * @param {array} [jobResource.details.preferences.preferredDataCenterRegion]
   *
   * @param {string} jobResource.details.jobDetailsType Polymorphic Discriminator
   *
   * @param {string} jobResource.location The location of the resource. This will
   * be one of the supported and registered Azure Regions (e.g. West US, East US,
   * Southeast Asia, etc.). The region of a resource cannot be changed once it is
   * created, but if an identical region is specified on update the request will
   * succeed.
   *
   * @param {object} [jobResource.tags] The list of key value pairs that describe
   * the resource. These tags can be used in viewing and grouping this resource
   * (across resource groups).
   *
   * @param {object} jobResource.sku The sku type.
   *
   * @param {string} jobResource.sku.name The sku name. Possible values include:
   * 'DataBox', 'DataBoxDisk', 'DataBoxHeavy'
   *
   * @param {string} [jobResource.sku.displayName] The display name of the sku.
   *
   * @param {string} [jobResource.sku.family] The sku family.
   *
   * @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 {JobResource} - 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 JobResource} 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, jobName, jobResource, 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, jobName, jobResource, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(resourceGroupName, jobName, jobResource, options, optionalCallback);
    }
  }

  /**
   * Deletes a job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @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, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, 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 The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @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, 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, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Updates the properties of an existing job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResourceUpdateParameter Job update parameters from
   * request body.
   *
   * @param {object} [jobResourceUpdateParameter.details] Details of a job to be
   * updated.
   *
   * @param {object} [jobResourceUpdateParameter.details.contactDetails] Contact
   * details for notification and shipping.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResourceUpdateParameter.details.contactDetails.phone
   * Phone number of the contact person.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResourceUpdateParameter.details.contactDetails.mobile]
   * Mobile number of the contact person.
   *
   * @param {array} jobResourceUpdateParameter.details.contactDetails.emailList
   * List of Email-ids to be notified about job progress.
   *
   * @param {array}
   * [jobResourceUpdateParameter.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} [jobResourceUpdateParameter.details.shippingAddress]
   * Shipping address of the customer.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResourceUpdateParameter.details.shippingAddress.city]
   * Name of the City.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.stateOrProvince] Name of
   * the State or Province.
   *
   * @param {string} jobResourceUpdateParameter.details.shippingAddress.country
   * Name of the Country.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.postalCode Postal code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.companyName] Name of the
   * company.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} [jobResourceUpdateParameter.destinationAccountDetails]
   * Destination account details.
   *
   * @param {object} [jobResourceUpdateParameter.tags] The list of key value
   * pairs that describe the resource. These tags can be used in viewing and
   * grouping this resource (across resource groups).
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] Defines the If-Match condition. The patch
   * will be performed only if the ETag of the job on the server matches this
   * value.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, jobName, jobResourceUpdateParameter, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, jobName, jobResourceUpdateParameter, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates the properties of an existing job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResourceUpdateParameter Job update parameters from
   * request body.
   *
   * @param {object} [jobResourceUpdateParameter.details] Details of a job to be
   * updated.
   *
   * @param {object} [jobResourceUpdateParameter.details.contactDetails] Contact
   * details for notification and shipping.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResourceUpdateParameter.details.contactDetails.phone
   * Phone number of the contact person.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResourceUpdateParameter.details.contactDetails.mobile]
   * Mobile number of the contact person.
   *
   * @param {array} jobResourceUpdateParameter.details.contactDetails.emailList
   * List of Email-ids to be notified about job progress.
   *
   * @param {array}
   * [jobResourceUpdateParameter.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} [jobResourceUpdateParameter.details.shippingAddress]
   * Shipping address of the customer.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResourceUpdateParameter.details.shippingAddress.city]
   * Name of the City.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.stateOrProvince] Name of
   * the State or Province.
   *
   * @param {string} jobResourceUpdateParameter.details.shippingAddress.country
   * Name of the Country.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.postalCode Postal code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.companyName] Name of the
   * company.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} [jobResourceUpdateParameter.destinationAccountDetails]
   * Destination account details.
   *
   * @param {object} [jobResourceUpdateParameter.tags] The list of key value
   * pairs that describe the resource. These tags can be used in viewing and
   * grouping this resource (across resource groups).
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] Defines the If-Match condition. The patch
   * will be performed only if the ETag of the job on the server matches this
   * value.
   *
   * @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 {JobResource} - 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 JobResource} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  update(resourceGroupName, jobName, jobResourceUpdateParameter, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._update(resourceGroupName, jobName, jobResourceUpdateParameter, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, jobName, jobResourceUpdateParameter, options, optionalCallback);
    }
  }

  /**
   * Book shipment pick up.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} shipmentPickUpRequest Details of shipment pick up request.
   *
   * @param {date} shipmentPickUpRequest.startTime Minimum date after which the
   * pick up should commence, this must be in local time of pick up area.
   *
   * @param {date} shipmentPickUpRequest.endTime Maximum date before which the
   * pick up should commence, this must be in local time of pick up area.
   *
   * @param {string} shipmentPickUpRequest.shipmentLocation Shipment Location in
   * the pickup place. Eg.front desk
   *
   * @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<ShipmentPickUpResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  bookShipmentPickUpWithHttpOperationResponse(resourceGroupName, jobName, shipmentPickUpRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._bookShipmentPickUp(resourceGroupName, jobName, shipmentPickUpRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Book shipment pick up.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} shipmentPickUpRequest Details of shipment pick up request.
   *
   * @param {date} shipmentPickUpRequest.startTime Minimum date after which the
   * pick up should commence, this must be in local time of pick up area.
   *
   * @param {date} shipmentPickUpRequest.endTime Maximum date before which the
   * pick up should commence, this must be in local time of pick up area.
   *
   * @param {string} shipmentPickUpRequest.shipmentLocation Shipment Location in
   * the pickup place. Eg.front desk
   *
   * @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 {ShipmentPickUpResponse} - 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 ShipmentPickUpResponse} 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.
   */
  bookShipmentPickUp(resourceGroupName, jobName, shipmentPickUpRequest, 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._bookShipmentPickUp(resourceGroupName, jobName, shipmentPickUpRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._bookShipmentPickUp(resourceGroupName, jobName, shipmentPickUpRequest, options, optionalCallback);
    }
  }

  /**
   * CancelJob.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {string} reason Reason for cancellation.
   *
   * @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.
   */
  cancelWithHttpOperationResponse(resourceGroupName, jobName, reason, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._cancel(resourceGroupName, jobName, reason, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * CancelJob.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {string} reason Reason for cancellation.
   *
   * @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.
   */
  cancel(resourceGroupName, jobName, reason, 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._cancel(resourceGroupName, jobName, reason, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._cancel(resourceGroupName, jobName, reason, options, optionalCallback);
    }
  }

  /**
   * This method gets the unencrypted secrets related to the job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @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<UnencryptedCredentialsList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listCredentialsWithHttpOperationResponse(resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listCredentials(resourceGroupName, jobName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * This method gets the unencrypted secrets related to the job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @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 {UnencryptedCredentialsList} - 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 UnencryptedCredentialsList} 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.
   */
  listCredentials(resourceGroupName, 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._listCredentials(resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listCredentials(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Creates a new job with the specified parameters. Existing job cannot be
   * updated with this API and should instead be updated with the Update job API.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResource Job details from request body.
   *
   * @param {object} [jobResource.details] Details of a job run. This field will
   * only be sent for expand details filter.
   *
   * @param {number} [jobResource.details.expectedDataSizeInTeraBytes] The
   * expected size of the data, which needs to be transfered in this job, in tera
   * bytes.
   *
   * @param {object} jobResource.details.contactDetails Contact details for
   * notification and shipping.
   *
   * @param {string} jobResource.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResource.details.contactDetails.phone Phone number of the
   * contact person.
   *
   * @param {string} [jobResource.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResource.details.contactDetails.mobile] Mobile number of
   * the contact person.
   *
   * @param {array} jobResource.details.contactDetails.emailList List of
   * Email-ids to be notified about job progress.
   *
   * @param {array} [jobResource.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} jobResource.details.shippingAddress Shipping address of the
   * customer.
   *
   * @param {string} jobResource.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResource.details.shippingAddress.city] Name of the City.
   *
   * @param {string} [jobResource.details.shippingAddress.stateOrProvince] Name
   * of the State or Province.
   *
   * @param {string} jobResource.details.shippingAddress.country Name of the
   * Country.
   *
   * @param {string} jobResource.details.shippingAddress.postalCode Postal code.
   *
   * @param {string} [jobResource.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string} [jobResource.details.shippingAddress.companyName] Name of
   * the company.
   *
   * @param {string} [jobResource.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} jobResource.details.destinationAccountDetails Destination
   * account details.
   *
   * @param {object} [jobResource.details.preferences] Preferences for the order.
   *
   * @param {array} [jobResource.details.preferences.preferredDataCenterRegion]
   *
   * @param {string} jobResource.details.jobDetailsType Polymorphic Discriminator
   *
   * @param {string} jobResource.location The location of the resource. This will
   * be one of the supported and registered Azure Regions (e.g. West US, East US,
   * Southeast Asia, etc.). The region of a resource cannot be changed once it is
   * created, but if an identical region is specified on update the request will
   * succeed.
   *
   * @param {object} [jobResource.tags] The list of key value pairs that describe
   * the resource. These tags can be used in viewing and grouping this resource
   * (across resource groups).
   *
   * @param {object} jobResource.sku The sku type.
   *
   * @param {string} jobResource.sku.name The sku name. Possible values include:
   * 'DataBox', 'DataBoxDisk', 'DataBoxHeavy'
   *
   * @param {string} [jobResource.sku.displayName] The display name of the sku.
   *
   * @param {string} [jobResource.sku.family] The sku family.
   *
   * @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<JobResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateWithHttpOperationResponse(resourceGroupName, jobName, jobResource, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreate(resourceGroupName, jobName, jobResource, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a new job with the specified parameters. Existing job cannot be
   * updated with this API and should instead be updated with the Update job API.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResource Job details from request body.
   *
   * @param {object} [jobResource.details] Details of a job run. This field will
   * only be sent for expand details filter.
   *
   * @param {number} [jobResource.details.expectedDataSizeInTeraBytes] The
   * expected size of the data, which needs to be transfered in this job, in tera
   * bytes.
   *
   * @param {object} jobResource.details.contactDetails Contact details for
   * notification and shipping.
   *
   * @param {string} jobResource.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResource.details.contactDetails.phone Phone number of the
   * contact person.
   *
   * @param {string} [jobResource.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResource.details.contactDetails.mobile] Mobile number of
   * the contact person.
   *
   * @param {array} jobResource.details.contactDetails.emailList List of
   * Email-ids to be notified about job progress.
   *
   * @param {array} [jobResource.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} jobResource.details.shippingAddress Shipping address of the
   * customer.
   *
   * @param {string} jobResource.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string} [jobResource.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResource.details.shippingAddress.city] Name of the City.
   *
   * @param {string} [jobResource.details.shippingAddress.stateOrProvince] Name
   * of the State or Province.
   *
   * @param {string} jobResource.details.shippingAddress.country Name of the
   * Country.
   *
   * @param {string} jobResource.details.shippingAddress.postalCode Postal code.
   *
   * @param {string} [jobResource.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string} [jobResource.details.shippingAddress.companyName] Name of
   * the company.
   *
   * @param {string} [jobResource.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} jobResource.details.destinationAccountDetails Destination
   * account details.
   *
   * @param {object} [jobResource.details.preferences] Preferences for the order.
   *
   * @param {array} [jobResource.details.preferences.preferredDataCenterRegion]
   *
   * @param {string} jobResource.details.jobDetailsType Polymorphic Discriminator
   *
   * @param {string} jobResource.location The location of the resource. This will
   * be one of the supported and registered Azure Regions (e.g. West US, East US,
   * Southeast Asia, etc.). The region of a resource cannot be changed once it is
   * created, but if an identical region is specified on update the request will
   * succeed.
   *
   * @param {object} [jobResource.tags] The list of key value pairs that describe
   * the resource. These tags can be used in viewing and grouping this resource
   * (across resource groups).
   *
   * @param {object} jobResource.sku The sku type.
   *
   * @param {string} jobResource.sku.name The sku name. Possible values include:
   * 'DataBox', 'DataBoxDisk', 'DataBoxHeavy'
   *
   * @param {string} [jobResource.sku.displayName] The display name of the sku.
   *
   * @param {string} [jobResource.sku.family] The sku family.
   *
   * @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 {JobResource} - 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 JobResource} 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, jobName, jobResource, 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, jobName, jobResource, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreate(resourceGroupName, jobName, jobResource, options, optionalCallback);
    }
  }

  /**
   * Deletes a job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @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, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, 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 The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @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, 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, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Updates the properties of an existing job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResourceUpdateParameter Job update parameters from
   * request body.
   *
   * @param {object} [jobResourceUpdateParameter.details] Details of a job to be
   * updated.
   *
   * @param {object} [jobResourceUpdateParameter.details.contactDetails] Contact
   * details for notification and shipping.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResourceUpdateParameter.details.contactDetails.phone
   * Phone number of the contact person.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResourceUpdateParameter.details.contactDetails.mobile]
   * Mobile number of the contact person.
   *
   * @param {array} jobResourceUpdateParameter.details.contactDetails.emailList
   * List of Email-ids to be notified about job progress.
   *
   * @param {array}
   * [jobResourceUpdateParameter.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} [jobResourceUpdateParameter.details.shippingAddress]
   * Shipping address of the customer.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResourceUpdateParameter.details.shippingAddress.city]
   * Name of the City.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.stateOrProvince] Name of
   * the State or Province.
   *
   * @param {string} jobResourceUpdateParameter.details.shippingAddress.country
   * Name of the Country.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.postalCode Postal code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.companyName] Name of the
   * company.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} [jobResourceUpdateParameter.destinationAccountDetails]
   * Destination account details.
   *
   * @param {object} [jobResourceUpdateParameter.tags] The list of key value
   * pairs that describe the resource. These tags can be used in viewing and
   * grouping this resource (across resource groups).
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] Defines the If-Match condition. The patch
   * will be performed only if the ETag of the job on the server matches this
   * value.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateWithHttpOperationResponse(resourceGroupName, jobName, jobResourceUpdateParameter, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdate(resourceGroupName, jobName, jobResourceUpdateParameter, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates the properties of an existing job.
   *
   * @param {string} resourceGroupName The Resource Group Name
   *
   * @param {string} jobName The name of the job Resource within the specified
   * resource group. job names must be between 3 and 24 characters in length and
   * use any alphanumeric and underscore only
   *
   * @param {object} jobResourceUpdateParameter Job update parameters from
   * request body.
   *
   * @param {object} [jobResourceUpdateParameter.details] Details of a job to be
   * updated.
   *
   * @param {object} [jobResourceUpdateParameter.details.contactDetails] Contact
   * details for notification and shipping.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.contactDetails.contactName Contact name
   * of the person.
   *
   * @param {string} jobResourceUpdateParameter.details.contactDetails.phone
   * Phone number of the contact person.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.contactDetails.phoneExtension] Phone
   * extension number of the contact person.
   *
   * @param {string} [jobResourceUpdateParameter.details.contactDetails.mobile]
   * Mobile number of the contact person.
   *
   * @param {array} jobResourceUpdateParameter.details.contactDetails.emailList
   * List of Email-ids to be notified about job progress.
   *
   * @param {array}
   * [jobResourceUpdateParameter.details.contactDetails.notificationPreference]
   * Notification preference for a job stage.
   *
   * @param {object} [jobResourceUpdateParameter.details.shippingAddress]
   * Shipping address of the customer.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.streetAddress1 Street
   * Address line 1.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress2] Street
   * Address line 2.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.streetAddress3] Street
   * Address line 3.
   *
   * @param {string} [jobResourceUpdateParameter.details.shippingAddress.city]
   * Name of the City.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.stateOrProvince] Name of
   * the State or Province.
   *
   * @param {string} jobResourceUpdateParameter.details.shippingAddress.country
   * Name of the Country.
   *
   * @param {string}
   * jobResourceUpdateParameter.details.shippingAddress.postalCode Postal code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.zipExtendedCode]
   * Extended Zip Code.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.companyName] Name of the
   * company.
   *
   * @param {string}
   * [jobResourceUpdateParameter.details.shippingAddress.addressType] Type of
   * address. Possible values include: 'None', 'Residential', 'Commercial'
   *
   * @param {array} [jobResourceUpdateParameter.destinationAccountDetails]
   * Destination account details.
   *
   * @param {object} [jobResourceUpdateParameter.tags] The list of key value
   * pairs that describe the resource. These tags can be used in viewing and
   * grouping this resource (across resource groups).
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] Defines the If-Match condition. The patch
   * will be performed only if the ETag of the job on the server matches this
   * value.
   *
   * @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 {JobResource} - 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 JobResource} 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.
   */
  beginUpdate(resourceGroupName, jobName, jobResourceUpdateParameter, 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._beginUpdate(resourceGroupName, jobName, jobResourceUpdateParameter, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdate(resourceGroupName, jobName, jobResourceUpdateParameter, options, optionalCallback);
    }
  }

  /**
   * Lists all the jobs available under the subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResourceList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all the jobs available under the subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {JobResourceList} - 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 JobResourceList} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * Lists all the jobs available under the given resource group.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<JobResourceList>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all the jobs available under the given resource group.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {JobResourceList} - 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 JobResourceList} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listByResourceGroupNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByResourceGroupNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = Jobs;
