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

'use strict';

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


/**
 * Creates a streaming job or replaces an already existing streaming job.
 *
 * @param {object} streamingJob The definition of the streaming job that will
 * be used to create a new streaming job or replace the existing one.
 *
 * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
 * Required on PUT (CreateOrReplace) requests.
 *
 * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
 * (CreateOrReplace) requests. Possible values include: 'Standard'
 *
 * @param {string} [streamingJob.outputStartMode] This property should only be
 * utilized when it is desired that the job be started immediately upon
 * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
 * indicate whether the starting point of the output event stream should start
 * whenever the job is started, start at a custom user time stamp specified via
 * the outputStartTime property, or start from the last event output time.
 * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
 *
 * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
 * formatted time stamp that indicates the starting point of the output event
 * stream, or null to indicate that the output event stream will start whenever
 * the streaming job is started. This property must have a value if
 * outputStartMode is set to CustomTime.
 *
 * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
 * to apply to events that arrive out of order in the input event stream.
 * Possible values include: 'Adjust', 'Drop'
 *
 * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
 * apply to events that arrive at the output and cannot be written to the
 * external storage due to being malformed (missing column values, column
 * values of wrong type or size). Possible values include: 'Stop', 'Drop'
 *
 * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
 * tolerable delay in seconds where out-of-order events can be adjusted to be
 * back in order.
 *
 * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
 * maximum tolerable delay in seconds where events arriving late could be
 * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
 * used to specify wait indefinitely. If the property is absent, it is
 * interpreted to have a value of -1.
 *
 * @param {string} [streamingJob.dataLocale] The data locale of the stream
 * analytics job. Value should be the name of a supported .NET Culture from the
 * set
 * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
 * Defaults to 'en-US' if none specified.
 *
 * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
 * behaviors of the streaming job. Possible values include: '1.0'
 *
 * @param {array} [streamingJob.inputs] A list of one or more inputs to the
 * streaming job. The name property for each input is required when specifying
 * this property in a PUT request. This property cannot be modify via a PATCH
 * operation. You must use the PATCH API available for the individual input.
 *
 * @param {object} [streamingJob.transformation] Indicates the query and the
 * number of streaming units to use for the streaming job. The name property of
 * the transformation is required when specifying this property in a PUT
 * request. This property cannot be modify via a PATCH operation. You must use
 * the PATCH API available for the individual tranformation.
 *
 * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
 * number of streaming units that the streaming job uses.
 *
 * @param {string} [streamingJob.transformation.query] Specifies the query that
 * will be run in the streaming job. You can learn more about the Stream
 * Analytics Query Language (SAQL) here:
 * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
 * (CreateOrReplace) requests.
 *
 * @param {string} [streamingJob.transformation.name] Resource name
 *
 * @param {array} [streamingJob.outputs] A list of one or more outputs for the
 * streaming job. The name property for each output is required when specifying
 * this property in a PUT request. This property cannot be modify via a PATCH
 * operation. You must use the PATCH API available for the individual output.
 *
 * @param {array} [streamingJob.functions] A list of one or more functions for
 * the streaming job. The name property for each function is required when
 * specifying this property in a PUT request. This property cannot be modify
 * via a PATCH operation. You must use the PATCH API available for the
 * individual transformation.
 *
 * @param {string} [streamingJob.location] Resource location. Required on PUT
 * (CreateOrReplace) requests.
 *
 * @param {object} [streamingJob.tags] Resource tags
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
 * value to always overwrite the current record set. Specify the last-seen ETag
 * value to prevent accidentally overwritting concurrent changes.
 *
 * @param {string} [options.ifNoneMatch] Set to '*' to allow a new streaming
 * job to be created, but to prevent updating an existing record set. Other
 * values will result in a 412 Pre-condition Failed response.
 *
 * @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 StreamingJob} 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 _createOrReplace(streamingJob, 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.beginCreateOrReplace(streamingJob, 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
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['StreamingJob']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }

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

/**
 * Updates an existing streaming job. This can be used to partially update (ie.
 * update one or two properties) a streaming job without affecting the rest the
 * job definition.
 *
 * @param {object} streamingJob A streaming job object. The properties
 * specified here will overwrite the corresponding properties in the existing
 * streaming job (ie. Those properties will be updated). Any properties that
 * are set to null here will mean that the corresponding property in the
 * existing input will remain the same and not change as a result of this PATCH
 * operation.
 *
 * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
 * Required on PUT (CreateOrReplace) requests.
 *
 * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
 * (CreateOrReplace) requests. Possible values include: 'Standard'
 *
 * @param {string} [streamingJob.outputStartMode] This property should only be
 * utilized when it is desired that the job be started immediately upon
 * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
 * indicate whether the starting point of the output event stream should start
 * whenever the job is started, start at a custom user time stamp specified via
 * the outputStartTime property, or start from the last event output time.
 * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
 *
 * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
 * formatted time stamp that indicates the starting point of the output event
 * stream, or null to indicate that the output event stream will start whenever
 * the streaming job is started. This property must have a value if
 * outputStartMode is set to CustomTime.
 *
 * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
 * to apply to events that arrive out of order in the input event stream.
 * Possible values include: 'Adjust', 'Drop'
 *
 * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
 * apply to events that arrive at the output and cannot be written to the
 * external storage due to being malformed (missing column values, column
 * values of wrong type or size). Possible values include: 'Stop', 'Drop'
 *
 * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
 * tolerable delay in seconds where out-of-order events can be adjusted to be
 * back in order.
 *
 * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
 * maximum tolerable delay in seconds where events arriving late could be
 * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
 * used to specify wait indefinitely. If the property is absent, it is
 * interpreted to have a value of -1.
 *
 * @param {string} [streamingJob.dataLocale] The data locale of the stream
 * analytics job. Value should be the name of a supported .NET Culture from the
 * set
 * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
 * Defaults to 'en-US' if none specified.
 *
 * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
 * behaviors of the streaming job. Possible values include: '1.0'
 *
 * @param {array} [streamingJob.inputs] A list of one or more inputs to the
 * streaming job. The name property for each input is required when specifying
 * this property in a PUT request. This property cannot be modify via a PATCH
 * operation. You must use the PATCH API available for the individual input.
 *
 * @param {object} [streamingJob.transformation] Indicates the query and the
 * number of streaming units to use for the streaming job. The name property of
 * the transformation is required when specifying this property in a PUT
 * request. This property cannot be modify via a PATCH operation. You must use
 * the PATCH API available for the individual tranformation.
 *
 * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
 * number of streaming units that the streaming job uses.
 *
 * @param {string} [streamingJob.transformation.query] Specifies the query that
 * will be run in the streaming job. You can learn more about the Stream
 * Analytics Query Language (SAQL) here:
 * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
 * (CreateOrReplace) requests.
 *
 * @param {string} [streamingJob.transformation.name] Resource name
 *
 * @param {array} [streamingJob.outputs] A list of one or more outputs for the
 * streaming job. The name property for each output is required when specifying
 * this property in a PUT request. This property cannot be modify via a PATCH
 * operation. You must use the PATCH API available for the individual output.
 *
 * @param {array} [streamingJob.functions] A list of one or more functions for
 * the streaming job. The name property for each function is required when
 * specifying this property in a PUT request. This property cannot be modify
 * via a PATCH operation. You must use the PATCH API available for the
 * individual transformation.
 *
 * @param {string} [streamingJob.location] Resource location. Required on PUT
 * (CreateOrReplace) requests.
 *
 * @param {object} [streamingJob.tags] Resource tags
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
 * value to always overwrite the current record set. Specify the last-seen ETag
 * value to prevent accidentally overwritting concurrent changes.
 *
 * @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 StreamingJob} 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(streamingJob, 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 ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined;
  // Validate
  try {
    if (streamingJob === null || streamingJob === undefined) {
      throw new Error('streamingJob cannot be null or undefined.');
    }
    if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
      throw new Error('ifMatch must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (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.StreamAnalytics/streamingjobs/{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 (streamingJob !== null && streamingJob !== undefined) {
      let requestModelMapper = new client.models['StreamingJob']().mapper();
      requestModel = client.serialize(requestModelMapper, streamingJob, 'streamingJob');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(streamingJob, 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['StreamingJob']().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 streaming job.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @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);
    });
  });
}

/**
 * Gets details about the specified streaming job.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] The $expand OData query parameter. This is
 * a comma-separated list of additional streaming job properties to include in
 * the response, beyond the default set returned when this parameter is absent.
 * The default set is all streaming job properties other than 'inputs',
 * 'transformation', 'outputs', and 'functions'.
 *
 * @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 StreamingJob} 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 (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (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.StreamAnalytics/streamingjobs/{jobName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
  let queryParameters = [];
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['StreamingJob']().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 of the streaming jobs in the specified resource group.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] The $expand OData query parameter. This is
 * a comma-separated list of additional streaming job properties to include in
 * the response, beyond the default set returned when this parameter is absent.
 * The default set is all streaming job properties other than 'inputs',
 * 'transformation', 'outputs', and 'functions'.
 *
 * @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 StreamingJobListResult} 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 expand = (options && options.expand !== undefined) ? options.expand : undefined;
  // Validate
  try {
    if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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.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.StreamAnalytics/streamingjobs';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  let queryParameters = [];
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['StreamingJobListResult']().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 of the streaming jobs in the given subscription.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.expand] The $expand OData query parameter. This is
 * a comma-separated list of additional streaming job properties to include in
 * the response, beyond the default set returned when this parameter is absent.
 * The default set is all streaming job properties other than 'inputs',
 * 'transformation', 'outputs', and 'functions'.
 *
 * @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 StreamingJobListResult} 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 expand = (options && options.expand !== undefined) ? options.expand : undefined;
  // Validate
  try {
    if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.StreamAnalytics/streamingjobs';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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


/**
 * Starts a streaming job. Once a job is started it will start processing input
 * events and produce output.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.startJobParameters] Parameters applicable to a
 * start streaming job operation.
 *
 * @param {string} [options.startJobParameters.outputStartMode] Value may be
 * JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the
 * starting point of the output event stream should start whenever the job is
 * started, start at a custom user time stamp specified via the outputStartTime
 * property, or start from the last event output time. Possible values include:
 * 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
 *
 * @param {date} [options.startJobParameters.outputStartTime] Value is either
 * an ISO-8601 formatted time stamp that indicates the starting point of the
 * output event stream, or null to indicate that the output event stream will
 * start whenever the streaming job is started. This property must have a value
 * if outputStartMode is set to CustomTime.
 *
 * @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 _start(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.beginStart(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);
    });
  });
}


/**
 * Stops a running streaming job. This will cause a running streaming job to
 * stop processing input events and producing output.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @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 _stop(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.beginStop(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);
    });
  });
}

/**
 * Creates a streaming job or replaces an already existing streaming job.
 *
 * @param {object} streamingJob The definition of the streaming job that will
 * be used to create a new streaming job or replace the existing one.
 *
 * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
 * Required on PUT (CreateOrReplace) requests.
 *
 * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
 * (CreateOrReplace) requests. Possible values include: 'Standard'
 *
 * @param {string} [streamingJob.outputStartMode] This property should only be
 * utilized when it is desired that the job be started immediately upon
 * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
 * indicate whether the starting point of the output event stream should start
 * whenever the job is started, start at a custom user time stamp specified via
 * the outputStartTime property, or start from the last event output time.
 * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
 *
 * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
 * formatted time stamp that indicates the starting point of the output event
 * stream, or null to indicate that the output event stream will start whenever
 * the streaming job is started. This property must have a value if
 * outputStartMode is set to CustomTime.
 *
 * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
 * to apply to events that arrive out of order in the input event stream.
 * Possible values include: 'Adjust', 'Drop'
 *
 * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
 * apply to events that arrive at the output and cannot be written to the
 * external storage due to being malformed (missing column values, column
 * values of wrong type or size). Possible values include: 'Stop', 'Drop'
 *
 * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
 * tolerable delay in seconds where out-of-order events can be adjusted to be
 * back in order.
 *
 * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
 * maximum tolerable delay in seconds where events arriving late could be
 * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
 * used to specify wait indefinitely. If the property is absent, it is
 * interpreted to have a value of -1.
 *
 * @param {string} [streamingJob.dataLocale] The data locale of the stream
 * analytics job. Value should be the name of a supported .NET Culture from the
 * set
 * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
 * Defaults to 'en-US' if none specified.
 *
 * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
 * behaviors of the streaming job. Possible values include: '1.0'
 *
 * @param {array} [streamingJob.inputs] A list of one or more inputs to the
 * streaming job. The name property for each input is required when specifying
 * this property in a PUT request. This property cannot be modify via a PATCH
 * operation. You must use the PATCH API available for the individual input.
 *
 * @param {object} [streamingJob.transformation] Indicates the query and the
 * number of streaming units to use for the streaming job. The name property of
 * the transformation is required when specifying this property in a PUT
 * request. This property cannot be modify via a PATCH operation. You must use
 * the PATCH API available for the individual tranformation.
 *
 * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
 * number of streaming units that the streaming job uses.
 *
 * @param {string} [streamingJob.transformation.query] Specifies the query that
 * will be run in the streaming job. You can learn more about the Stream
 * Analytics Query Language (SAQL) here:
 * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
 * (CreateOrReplace) requests.
 *
 * @param {string} [streamingJob.transformation.name] Resource name
 *
 * @param {array} [streamingJob.outputs] A list of one or more outputs for the
 * streaming job. The name property for each output is required when specifying
 * this property in a PUT request. This property cannot be modify via a PATCH
 * operation. You must use the PATCH API available for the individual output.
 *
 * @param {array} [streamingJob.functions] A list of one or more functions for
 * the streaming job. The name property for each function is required when
 * specifying this property in a PUT request. This property cannot be modify
 * via a PATCH operation. You must use the PATCH API available for the
 * individual transformation.
 *
 * @param {string} [streamingJob.location] Resource location. Required on PUT
 * (CreateOrReplace) requests.
 *
 * @param {object} [streamingJob.tags] Resource tags
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
 * value to always overwrite the current record set. Specify the last-seen ETag
 * value to prevent accidentally overwritting concurrent changes.
 *
 * @param {string} [options.ifNoneMatch] Set to '*' to allow a new streaming
 * job to be created, but to prevent updating an existing record set. Other
 * values will result in a 412 Pre-condition Failed response.
 *
 * @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 StreamingJob} 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 _beginCreateOrReplace(streamingJob, 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 ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined;
  let ifNoneMatch = (options && options.ifNoneMatch !== undefined) ? options.ifNoneMatch : undefined;
  // Validate
  try {
    if (streamingJob === null || streamingJob === undefined) {
      throw new Error('streamingJob cannot be null or undefined.');
    }
    if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
      throw new Error('ifMatch must be of type string.');
    }
    if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
      throw new Error('ifNoneMatch must be of type string.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (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.StreamAnalytics/streamingjobs/{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 (ifMatch !== undefined && ifMatch !== null) {
    httpRequest.headers['If-Match'] = ifMatch;
  }
  if (ifNoneMatch !== undefined && ifNoneMatch !== null) {
    httpRequest.headers['If-None-Match'] = ifNoneMatch;
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (streamingJob !== null && streamingJob !== undefined) {
      let requestModelMapper = new client.models['StreamingJob']().mapper();
      requestModel = client.serialize(requestModelMapper, streamingJob, 'streamingJob');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(streamingJob, 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 !== 201) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          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['StreamingJob']().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);
      }
    }
    // Deserialize Response
    if (statusCode === 201) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['StreamingJob']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError1.request = msRest.stripRequest(httpRequest);
        deserializationError1.response = msRest.stripResponse(response);
        return callback(deserializationError1);
      }
    }

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

/**
 * Deletes a streaming job.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @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.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (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.StreamAnalytics/streamingjobs/{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 !== 200 && statusCode !== 202 && statusCode !== 204) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

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

/**
 * Starts a streaming job. Once a job is started it will start processing input
 * events and produce output.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.startJobParameters] Parameters applicable to a
 * start streaming job operation.
 *
 * @param {string} [options.startJobParameters.outputStartMode] Value may be
 * JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the
 * starting point of the output event stream should start whenever the job is
 * started, start at a custom user time stamp specified via the outputStartTime
 * property, or start from the last event output time. Possible values include:
 * 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
 *
 * @param {date} [options.startJobParameters.outputStartTime] Value is either
 * an ISO-8601 formatted time stamp that indicates the starting point of the
 * output event stream, or null to indicate that the output event stream will
 * start whenever the streaming job is started. This property must have a value
 * if outputStartMode is set to CustomTime.
 *
 * @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 _beginStart(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 startJobParameters = (options && options.startJobParameters !== undefined) ? options.startJobParameters : undefined;
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (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.StreamAnalytics/streamingjobs/{jobName}/start';
  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 (startJobParameters !== null && startJobParameters !== undefined) {
      let requestModelMapper = new client.models['StartStreamingJobParameters']().mapper();
      requestModel = client.serialize(requestModelMapper, startJobParameters, 'startJobParameters');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(startJobParameters, 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;

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

/**
 * Stops a running streaming job. This will cause a running streaming job to
 * stop processing input events and producing output.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource. You can obtain this value from the Azure Resource
 * Manager API or the portal.
 *
 * @param {string} jobName The name of the streaming job.
 *
 * @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 _beginStop(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.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (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 (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.StreamAnalytics/streamingjobs/{jobName}/stop';
  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 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

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

/**
 * Lists all of the streaming jobs in the specified 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 StreamingJobListResult} 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['StreamingJobListResult']().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 of the streaming jobs in the given 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 StreamingJobListResult} 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['StreamingJobListResult']().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 StreamingJobs. */
class StreamingJobs {
  /**
   * Create a StreamingJobs.
   * @param {StreamAnalyticsManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._createOrReplace = _createOrReplace;
    this._update = _update;
    this._deleteMethod = _deleteMethod;
    this._get = _get;
    this._listByResourceGroup = _listByResourceGroup;
    this._list = _list;
    this._start = _start;
    this._stop = _stop;
    this._beginCreateOrReplace = _beginCreateOrReplace;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginStart = _beginStart;
    this._beginStop = _beginStop;
    this._listByResourceGroupNext = _listByResourceGroupNext;
    this._listNext = _listNext;
  }

  /**
   * Creates a streaming job or replaces an already existing streaming job.
   *
   * @param {object} streamingJob The definition of the streaming job that will
   * be used to create a new streaming job or replace the existing one.
   *
   * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
   * Required on PUT (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
   * (CreateOrReplace) requests. Possible values include: 'Standard'
   *
   * @param {string} [streamingJob.outputStartMode] This property should only be
   * utilized when it is desired that the job be started immediately upon
   * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
   * indicate whether the starting point of the output event stream should start
   * whenever the job is started, start at a custom user time stamp specified via
   * the outputStartTime property, or start from the last event output time.
   * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
   * formatted time stamp that indicates the starting point of the output event
   * stream, or null to indicate that the output event stream will start whenever
   * the streaming job is started. This property must have a value if
   * outputStartMode is set to CustomTime.
   *
   * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
   * to apply to events that arrive out of order in the input event stream.
   * Possible values include: 'Adjust', 'Drop'
   *
   * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
   * apply to events that arrive at the output and cannot be written to the
   * external storage due to being malformed (missing column values, column
   * values of wrong type or size). Possible values include: 'Stop', 'Drop'
   *
   * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
   * tolerable delay in seconds where out-of-order events can be adjusted to be
   * back in order.
   *
   * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
   * maximum tolerable delay in seconds where events arriving late could be
   * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
   * used to specify wait indefinitely. If the property is absent, it is
   * interpreted to have a value of -1.
   *
   * @param {string} [streamingJob.dataLocale] The data locale of the stream
   * analytics job. Value should be the name of a supported .NET Culture from the
   * set
   * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
   * Defaults to 'en-US' if none specified.
   *
   * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
   * behaviors of the streaming job. Possible values include: '1.0'
   *
   * @param {array} [streamingJob.inputs] A list of one or more inputs to the
   * streaming job. The name property for each input is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual input.
   *
   * @param {object} [streamingJob.transformation] Indicates the query and the
   * number of streaming units to use for the streaming job. The name property of
   * the transformation is required when specifying this property in a PUT
   * request. This property cannot be modify via a PATCH operation. You must use
   * the PATCH API available for the individual tranformation.
   *
   * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
   * number of streaming units that the streaming job uses.
   *
   * @param {string} [streamingJob.transformation.query] Specifies the query that
   * will be run in the streaming job. You can learn more about the Stream
   * Analytics Query Language (SAQL) here:
   * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.transformation.name] Resource name
   *
   * @param {array} [streamingJob.outputs] A list of one or more outputs for the
   * streaming job. The name property for each output is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual output.
   *
   * @param {array} [streamingJob.functions] A list of one or more functions for
   * the streaming job. The name property for each function is required when
   * specifying this property in a PUT request. This property cannot be modify
   * via a PATCH operation. You must use the PATCH API available for the
   * individual transformation.
   *
   * @param {string} [streamingJob.location] Resource location. Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {object} [streamingJob.tags] Resource tags
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
   * value to always overwrite the current record set. Specify the last-seen ETag
   * value to prevent accidentally overwritting concurrent changes.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new streaming
   * job to be created, but to prevent updating an existing record set. Other
   * values will result in a 412 Pre-condition Failed response.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<StreamingJob>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrReplaceWithHttpOperationResponse(streamingJob, resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrReplace(streamingJob, 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;
      });
    });
  }

  /**
   * Creates a streaming job or replaces an already existing streaming job.
   *
   * @param {object} streamingJob The definition of the streaming job that will
   * be used to create a new streaming job or replace the existing one.
   *
   * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
   * Required on PUT (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
   * (CreateOrReplace) requests. Possible values include: 'Standard'
   *
   * @param {string} [streamingJob.outputStartMode] This property should only be
   * utilized when it is desired that the job be started immediately upon
   * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
   * indicate whether the starting point of the output event stream should start
   * whenever the job is started, start at a custom user time stamp specified via
   * the outputStartTime property, or start from the last event output time.
   * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
   * formatted time stamp that indicates the starting point of the output event
   * stream, or null to indicate that the output event stream will start whenever
   * the streaming job is started. This property must have a value if
   * outputStartMode is set to CustomTime.
   *
   * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
   * to apply to events that arrive out of order in the input event stream.
   * Possible values include: 'Adjust', 'Drop'
   *
   * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
   * apply to events that arrive at the output and cannot be written to the
   * external storage due to being malformed (missing column values, column
   * values of wrong type or size). Possible values include: 'Stop', 'Drop'
   *
   * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
   * tolerable delay in seconds where out-of-order events can be adjusted to be
   * back in order.
   *
   * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
   * maximum tolerable delay in seconds where events arriving late could be
   * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
   * used to specify wait indefinitely. If the property is absent, it is
   * interpreted to have a value of -1.
   *
   * @param {string} [streamingJob.dataLocale] The data locale of the stream
   * analytics job. Value should be the name of a supported .NET Culture from the
   * set
   * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
   * Defaults to 'en-US' if none specified.
   *
   * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
   * behaviors of the streaming job. Possible values include: '1.0'
   *
   * @param {array} [streamingJob.inputs] A list of one or more inputs to the
   * streaming job. The name property for each input is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual input.
   *
   * @param {object} [streamingJob.transformation] Indicates the query and the
   * number of streaming units to use for the streaming job. The name property of
   * the transformation is required when specifying this property in a PUT
   * request. This property cannot be modify via a PATCH operation. You must use
   * the PATCH API available for the individual tranformation.
   *
   * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
   * number of streaming units that the streaming job uses.
   *
   * @param {string} [streamingJob.transformation.query] Specifies the query that
   * will be run in the streaming job. You can learn more about the Stream
   * Analytics Query Language (SAQL) here:
   * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.transformation.name] Resource name
   *
   * @param {array} [streamingJob.outputs] A list of one or more outputs for the
   * streaming job. The name property for each output is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual output.
   *
   * @param {array} [streamingJob.functions] A list of one or more functions for
   * the streaming job. The name property for each function is required when
   * specifying this property in a PUT request. This property cannot be modify
   * via a PATCH operation. You must use the PATCH API available for the
   * individual transformation.
   *
   * @param {string} [streamingJob.location] Resource location. Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {object} [streamingJob.tags] Resource tags
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
   * value to always overwrite the current record set. Specify the last-seen ETag
   * value to prevent accidentally overwritting concurrent changes.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new streaming
   * job to be created, but to prevent updating an existing record set. Other
   * values will result in a 412 Pre-condition Failed response.
   *
   * @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 {StreamingJob} - 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 StreamingJob} 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.
   */
  createOrReplace(streamingJob, 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._createOrReplace(streamingJob, resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrReplace(streamingJob, resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Updates an existing streaming job. This can be used to partially update (ie.
   * update one or two properties) a streaming job without affecting the rest the
   * job definition.
   *
   * @param {object} streamingJob A streaming job object. The properties
   * specified here will overwrite the corresponding properties in the existing
   * streaming job (ie. Those properties will be updated). Any properties that
   * are set to null here will mean that the corresponding property in the
   * existing input will remain the same and not change as a result of this PATCH
   * operation.
   *
   * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
   * Required on PUT (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
   * (CreateOrReplace) requests. Possible values include: 'Standard'
   *
   * @param {string} [streamingJob.outputStartMode] This property should only be
   * utilized when it is desired that the job be started immediately upon
   * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
   * indicate whether the starting point of the output event stream should start
   * whenever the job is started, start at a custom user time stamp specified via
   * the outputStartTime property, or start from the last event output time.
   * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
   * formatted time stamp that indicates the starting point of the output event
   * stream, or null to indicate that the output event stream will start whenever
   * the streaming job is started. This property must have a value if
   * outputStartMode is set to CustomTime.
   *
   * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
   * to apply to events that arrive out of order in the input event stream.
   * Possible values include: 'Adjust', 'Drop'
   *
   * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
   * apply to events that arrive at the output and cannot be written to the
   * external storage due to being malformed (missing column values, column
   * values of wrong type or size). Possible values include: 'Stop', 'Drop'
   *
   * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
   * tolerable delay in seconds where out-of-order events can be adjusted to be
   * back in order.
   *
   * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
   * maximum tolerable delay in seconds where events arriving late could be
   * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
   * used to specify wait indefinitely. If the property is absent, it is
   * interpreted to have a value of -1.
   *
   * @param {string} [streamingJob.dataLocale] The data locale of the stream
   * analytics job. Value should be the name of a supported .NET Culture from the
   * set
   * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
   * Defaults to 'en-US' if none specified.
   *
   * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
   * behaviors of the streaming job. Possible values include: '1.0'
   *
   * @param {array} [streamingJob.inputs] A list of one or more inputs to the
   * streaming job. The name property for each input is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual input.
   *
   * @param {object} [streamingJob.transformation] Indicates the query and the
   * number of streaming units to use for the streaming job. The name property of
   * the transformation is required when specifying this property in a PUT
   * request. This property cannot be modify via a PATCH operation. You must use
   * the PATCH API available for the individual tranformation.
   *
   * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
   * number of streaming units that the streaming job uses.
   *
   * @param {string} [streamingJob.transformation.query] Specifies the query that
   * will be run in the streaming job. You can learn more about the Stream
   * Analytics Query Language (SAQL) here:
   * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.transformation.name] Resource name
   *
   * @param {array} [streamingJob.outputs] A list of one or more outputs for the
   * streaming job. The name property for each output is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual output.
   *
   * @param {array} [streamingJob.functions] A list of one or more functions for
   * the streaming job. The name property for each function is required when
   * specifying this property in a PUT request. This property cannot be modify
   * via a PATCH operation. You must use the PATCH API available for the
   * individual transformation.
   *
   * @param {string} [streamingJob.location] Resource location. Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {object} [streamingJob.tags] Resource tags
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
   * value to always overwrite the current record set. Specify the last-seen ETag
   * value to prevent accidentally overwritting concurrent changes.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<StreamingJob>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(streamingJob, resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(streamingJob, 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;
      });
    });
  }

  /**
   * Updates an existing streaming job. This can be used to partially update (ie.
   * update one or two properties) a streaming job without affecting the rest the
   * job definition.
   *
   * @param {object} streamingJob A streaming job object. The properties
   * specified here will overwrite the corresponding properties in the existing
   * streaming job (ie. Those properties will be updated). Any properties that
   * are set to null here will mean that the corresponding property in the
   * existing input will remain the same and not change as a result of this PATCH
   * operation.
   *
   * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
   * Required on PUT (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
   * (CreateOrReplace) requests. Possible values include: 'Standard'
   *
   * @param {string} [streamingJob.outputStartMode] This property should only be
   * utilized when it is desired that the job be started immediately upon
   * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
   * indicate whether the starting point of the output event stream should start
   * whenever the job is started, start at a custom user time stamp specified via
   * the outputStartTime property, or start from the last event output time.
   * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
   * formatted time stamp that indicates the starting point of the output event
   * stream, or null to indicate that the output event stream will start whenever
   * the streaming job is started. This property must have a value if
   * outputStartMode is set to CustomTime.
   *
   * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
   * to apply to events that arrive out of order in the input event stream.
   * Possible values include: 'Adjust', 'Drop'
   *
   * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
   * apply to events that arrive at the output and cannot be written to the
   * external storage due to being malformed (missing column values, column
   * values of wrong type or size). Possible values include: 'Stop', 'Drop'
   *
   * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
   * tolerable delay in seconds where out-of-order events can be adjusted to be
   * back in order.
   *
   * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
   * maximum tolerable delay in seconds where events arriving late could be
   * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
   * used to specify wait indefinitely. If the property is absent, it is
   * interpreted to have a value of -1.
   *
   * @param {string} [streamingJob.dataLocale] The data locale of the stream
   * analytics job. Value should be the name of a supported .NET Culture from the
   * set
   * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
   * Defaults to 'en-US' if none specified.
   *
   * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
   * behaviors of the streaming job. Possible values include: '1.0'
   *
   * @param {array} [streamingJob.inputs] A list of one or more inputs to the
   * streaming job. The name property for each input is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual input.
   *
   * @param {object} [streamingJob.transformation] Indicates the query and the
   * number of streaming units to use for the streaming job. The name property of
   * the transformation is required when specifying this property in a PUT
   * request. This property cannot be modify via a PATCH operation. You must use
   * the PATCH API available for the individual tranformation.
   *
   * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
   * number of streaming units that the streaming job uses.
   *
   * @param {string} [streamingJob.transformation.query] Specifies the query that
   * will be run in the streaming job. You can learn more about the Stream
   * Analytics Query Language (SAQL) here:
   * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.transformation.name] Resource name
   *
   * @param {array} [streamingJob.outputs] A list of one or more outputs for the
   * streaming job. The name property for each output is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual output.
   *
   * @param {array} [streamingJob.functions] A list of one or more functions for
   * the streaming job. The name property for each function is required when
   * specifying this property in a PUT request. This property cannot be modify
   * via a PATCH operation. You must use the PATCH API available for the
   * individual transformation.
   *
   * @param {string} [streamingJob.location] Resource location. Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {object} [streamingJob.tags] Resource tags
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
   * value to always overwrite the current record set. Specify the last-seen ETag
   * value to prevent accidentally overwritting concurrent changes.
   *
   * @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 {StreamingJob} - 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 StreamingJob} 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(streamingJob, 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._update(streamingJob, resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(streamingJob, resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Deletes a streaming job.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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 streaming job.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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);
    }
  }

  /**
   * Gets details about the specified streaming job.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] The $expand OData query parameter. This is
   * a comma-separated list of additional streaming job properties to include in
   * the response, beyond the default set returned when this parameter is absent.
   * The default set is all streaming job properties other than 'inputs',
   * 'transformation', 'outputs', and 'functions'.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<StreamingJob>} - 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 details about the specified streaming job.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] The $expand OData query parameter. This is
   * a comma-separated list of additional streaming job properties to include in
   * the response, beyond the default set returned when this parameter is absent.
   * The default set is all streaming job properties other than 'inputs',
   * 'transformation', 'outputs', and 'functions'.
   *
   * @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 {StreamingJob} - 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 StreamingJob} 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);
    }
  }

  /**
   * Lists all of the streaming jobs in the specified resource group.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] The $expand OData query parameter. This is
   * a comma-separated list of additional streaming job properties to include in
   * the response, beyond the default set returned when this parameter is absent.
   * The default set is all streaming job properties other than 'inputs',
   * 'transformation', 'outputs', and 'functions'.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<StreamingJobListResult>} - 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 of the streaming jobs in the specified resource group.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] The $expand OData query parameter. This is
   * a comma-separated list of additional streaming job properties to include in
   * the response, beyond the default set returned when this parameter is absent.
   * The default set is all streaming job properties other than 'inputs',
   * 'transformation', 'outputs', and 'functions'.
   *
   * @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 {StreamingJobListResult} - 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 StreamingJobListResult} 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);
    }
  }

  /**
   * Lists all of the streaming jobs in the given subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] The $expand OData query parameter. This is
   * a comma-separated list of additional streaming job properties to include in
   * the response, beyond the default set returned when this parameter is absent.
   * The default set is all streaming job properties other than 'inputs',
   * 'transformation', 'outputs', and 'functions'.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<StreamingJobListResult>} - 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 of the streaming jobs in the given subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] The $expand OData query parameter. This is
   * a comma-separated list of additional streaming job properties to include in
   * the response, beyond the default set returned when this parameter is absent.
   * The default set is all streaming job properties other than 'inputs',
   * 'transformation', 'outputs', and 'functions'.
   *
   * @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 {StreamingJobListResult} - 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 StreamingJobListResult} 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);
    }
  }

  /**
   * Starts a streaming job. Once a job is started it will start processing input
   * events and produce output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.startJobParameters] Parameters applicable to a
   * start streaming job operation.
   *
   * @param {string} [options.startJobParameters.outputStartMode] Value may be
   * JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the
   * starting point of the output event stream should start whenever the job is
   * started, start at a custom user time stamp specified via the outputStartTime
   * property, or start from the last event output time. Possible values include:
   * 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [options.startJobParameters.outputStartTime] Value is either
   * an ISO-8601 formatted time stamp that indicates the starting point of the
   * output event stream, or null to indicate that the output event stream will
   * start whenever the streaming job is started. This property must have a value
   * if outputStartMode is set to CustomTime.
   *
   * @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.
   */
  startWithHttpOperationResponse(resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._start(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;
      });
    });
  }

  /**
   * Starts a streaming job. Once a job is started it will start processing input
   * events and produce output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.startJobParameters] Parameters applicable to a
   * start streaming job operation.
   *
   * @param {string} [options.startJobParameters.outputStartMode] Value may be
   * JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the
   * starting point of the output event stream should start whenever the job is
   * started, start at a custom user time stamp specified via the outputStartTime
   * property, or start from the last event output time. Possible values include:
   * 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [options.startJobParameters.outputStartTime] Value is either
   * an ISO-8601 formatted time stamp that indicates the starting point of the
   * output event stream, or null to indicate that the output event stream will
   * start whenever the streaming job is started. This property must have a value
   * if outputStartMode is set to CustomTime.
   *
   * @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.
   */
  start(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._start(resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._start(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Stops a running streaming job. This will cause a running streaming job to
   * stop processing input events and producing output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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.
   */
  stopWithHttpOperationResponse(resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._stop(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;
      });
    });
  }

  /**
   * Stops a running streaming job. This will cause a running streaming job to
   * stop processing input events and producing output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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.
   */
  stop(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._stop(resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._stop(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Creates a streaming job or replaces an already existing streaming job.
   *
   * @param {object} streamingJob The definition of the streaming job that will
   * be used to create a new streaming job or replace the existing one.
   *
   * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
   * Required on PUT (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
   * (CreateOrReplace) requests. Possible values include: 'Standard'
   *
   * @param {string} [streamingJob.outputStartMode] This property should only be
   * utilized when it is desired that the job be started immediately upon
   * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
   * indicate whether the starting point of the output event stream should start
   * whenever the job is started, start at a custom user time stamp specified via
   * the outputStartTime property, or start from the last event output time.
   * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
   * formatted time stamp that indicates the starting point of the output event
   * stream, or null to indicate that the output event stream will start whenever
   * the streaming job is started. This property must have a value if
   * outputStartMode is set to CustomTime.
   *
   * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
   * to apply to events that arrive out of order in the input event stream.
   * Possible values include: 'Adjust', 'Drop'
   *
   * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
   * apply to events that arrive at the output and cannot be written to the
   * external storage due to being malformed (missing column values, column
   * values of wrong type or size). Possible values include: 'Stop', 'Drop'
   *
   * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
   * tolerable delay in seconds where out-of-order events can be adjusted to be
   * back in order.
   *
   * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
   * maximum tolerable delay in seconds where events arriving late could be
   * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
   * used to specify wait indefinitely. If the property is absent, it is
   * interpreted to have a value of -1.
   *
   * @param {string} [streamingJob.dataLocale] The data locale of the stream
   * analytics job. Value should be the name of a supported .NET Culture from the
   * set
   * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
   * Defaults to 'en-US' if none specified.
   *
   * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
   * behaviors of the streaming job. Possible values include: '1.0'
   *
   * @param {array} [streamingJob.inputs] A list of one or more inputs to the
   * streaming job. The name property for each input is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual input.
   *
   * @param {object} [streamingJob.transformation] Indicates the query and the
   * number of streaming units to use for the streaming job. The name property of
   * the transformation is required when specifying this property in a PUT
   * request. This property cannot be modify via a PATCH operation. You must use
   * the PATCH API available for the individual tranformation.
   *
   * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
   * number of streaming units that the streaming job uses.
   *
   * @param {string} [streamingJob.transformation.query] Specifies the query that
   * will be run in the streaming job. You can learn more about the Stream
   * Analytics Query Language (SAQL) here:
   * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.transformation.name] Resource name
   *
   * @param {array} [streamingJob.outputs] A list of one or more outputs for the
   * streaming job. The name property for each output is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual output.
   *
   * @param {array} [streamingJob.functions] A list of one or more functions for
   * the streaming job. The name property for each function is required when
   * specifying this property in a PUT request. This property cannot be modify
   * via a PATCH operation. You must use the PATCH API available for the
   * individual transformation.
   *
   * @param {string} [streamingJob.location] Resource location. Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {object} [streamingJob.tags] Resource tags
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
   * value to always overwrite the current record set. Specify the last-seen ETag
   * value to prevent accidentally overwritting concurrent changes.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new streaming
   * job to be created, but to prevent updating an existing record set. Other
   * values will result in a 412 Pre-condition Failed response.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<StreamingJob>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrReplaceWithHttpOperationResponse(streamingJob, resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrReplace(streamingJob, 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;
      });
    });
  }

  /**
   * Creates a streaming job or replaces an already existing streaming job.
   *
   * @param {object} streamingJob The definition of the streaming job that will
   * be used to create a new streaming job or replace the existing one.
   *
   * @param {object} [streamingJob.sku] Describes the SKU of the streaming job.
   * Required on PUT (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.sku.name] The name of the SKU. Required on PUT
   * (CreateOrReplace) requests. Possible values include: 'Standard'
   *
   * @param {string} [streamingJob.outputStartMode] This property should only be
   * utilized when it is desired that the job be started immediately upon
   * creation. Value may be JobStartTime, CustomTime, or LastOutputEventTime to
   * indicate whether the starting point of the output event stream should start
   * whenever the job is started, start at a custom user time stamp specified via
   * the outputStartTime property, or start from the last event output time.
   * Possible values include: 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [streamingJob.outputStartTime] Value is either an ISO-8601
   * formatted time stamp that indicates the starting point of the output event
   * stream, or null to indicate that the output event stream will start whenever
   * the streaming job is started. This property must have a value if
   * outputStartMode is set to CustomTime.
   *
   * @param {string} [streamingJob.eventsOutOfOrderPolicy] Indicates the policy
   * to apply to events that arrive out of order in the input event stream.
   * Possible values include: 'Adjust', 'Drop'
   *
   * @param {string} [streamingJob.outputErrorPolicy] Indicates the policy to
   * apply to events that arrive at the output and cannot be written to the
   * external storage due to being malformed (missing column values, column
   * values of wrong type or size). Possible values include: 'Stop', 'Drop'
   *
   * @param {number} [streamingJob.eventsOutOfOrderMaxDelayInSeconds] The maximum
   * tolerable delay in seconds where out-of-order events can be adjusted to be
   * back in order.
   *
   * @param {number} [streamingJob.eventsLateArrivalMaxDelayInSeconds] The
   * maximum tolerable delay in seconds where events arriving late could be
   * included.  Supported range is -1 to 1814399 (20.23:59:59 days) and -1 is
   * used to specify wait indefinitely. If the property is absent, it is
   * interpreted to have a value of -1.
   *
   * @param {string} [streamingJob.dataLocale] The data locale of the stream
   * analytics job. Value should be the name of a supported .NET Culture from the
   * set
   * https://msdn.microsoft.com/en-us/library/system.globalization.culturetypes(v=vs.110).aspx.
   * Defaults to 'en-US' if none specified.
   *
   * @param {string} [streamingJob.compatibilityLevel] Controls certain runtime
   * behaviors of the streaming job. Possible values include: '1.0'
   *
   * @param {array} [streamingJob.inputs] A list of one or more inputs to the
   * streaming job. The name property for each input is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual input.
   *
   * @param {object} [streamingJob.transformation] Indicates the query and the
   * number of streaming units to use for the streaming job. The name property of
   * the transformation is required when specifying this property in a PUT
   * request. This property cannot be modify via a PATCH operation. You must use
   * the PATCH API available for the individual tranformation.
   *
   * @param {number} [streamingJob.transformation.streamingUnits] Specifies the
   * number of streaming units that the streaming job uses.
   *
   * @param {string} [streamingJob.transformation.query] Specifies the query that
   * will be run in the streaming job. You can learn more about the Stream
   * Analytics Query Language (SAQL) here:
   * https://msdn.microsoft.com/library/azure/dn834998 . Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {string} [streamingJob.transformation.name] Resource name
   *
   * @param {array} [streamingJob.outputs] A list of one or more outputs for the
   * streaming job. The name property for each output is required when specifying
   * this property in a PUT request. This property cannot be modify via a PATCH
   * operation. You must use the PATCH API available for the individual output.
   *
   * @param {array} [streamingJob.functions] A list of one or more functions for
   * the streaming job. The name property for each function is required when
   * specifying this property in a PUT request. This property cannot be modify
   * via a PATCH operation. You must use the PATCH API available for the
   * individual transformation.
   *
   * @param {string} [streamingJob.location] Resource location. Required on PUT
   * (CreateOrReplace) requests.
   *
   * @param {object} [streamingJob.tags] Resource tags
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] The ETag of the streaming job. Omit this
   * value to always overwrite the current record set. Specify the last-seen ETag
   * value to prevent accidentally overwritting concurrent changes.
   *
   * @param {string} [options.ifNoneMatch] Set to '*' to allow a new streaming
   * job to be created, but to prevent updating an existing record set. Other
   * values will result in a 412 Pre-condition Failed response.
   *
   * @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 {StreamingJob} - 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 StreamingJob} 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.
   */
  beginCreateOrReplace(streamingJob, 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._beginCreateOrReplace(streamingJob, resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrReplace(streamingJob, resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Deletes a streaming job.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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 streaming job.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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);
    }
  }

  /**
   * Starts a streaming job. Once a job is started it will start processing input
   * events and produce output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.startJobParameters] Parameters applicable to a
   * start streaming job operation.
   *
   * @param {string} [options.startJobParameters.outputStartMode] Value may be
   * JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the
   * starting point of the output event stream should start whenever the job is
   * started, start at a custom user time stamp specified via the outputStartTime
   * property, or start from the last event output time. Possible values include:
   * 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [options.startJobParameters.outputStartTime] Value is either
   * an ISO-8601 formatted time stamp that indicates the starting point of the
   * output event stream, or null to indicate that the output event stream will
   * start whenever the streaming job is started. This property must have a value
   * if outputStartMode is set to CustomTime.
   *
   * @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.
   */
  beginStartWithHttpOperationResponse(resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginStart(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;
      });
    });
  }

  /**
   * Starts a streaming job. Once a job is started it will start processing input
   * events and produce output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.startJobParameters] Parameters applicable to a
   * start streaming job operation.
   *
   * @param {string} [options.startJobParameters.outputStartMode] Value may be
   * JobStartTime, CustomTime, or LastOutputEventTime to indicate whether the
   * starting point of the output event stream should start whenever the job is
   * started, start at a custom user time stamp specified via the outputStartTime
   * property, or start from the last event output time. Possible values include:
   * 'JobStartTime', 'CustomTime', 'LastOutputEventTime'
   *
   * @param {date} [options.startJobParameters.outputStartTime] Value is either
   * an ISO-8601 formatted time stamp that indicates the starting point of the
   * output event stream, or null to indicate that the output event stream will
   * start whenever the streaming job is started. This property must have a value
   * if outputStartMode is set to CustomTime.
   *
   * @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.
   */
  beginStart(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._beginStart(resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginStart(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Stops a running streaming job. This will cause a running streaming job to
   * stop processing input events and producing output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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.
   */
  beginStopWithHttpOperationResponse(resourceGroupName, jobName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginStop(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;
      });
    });
  }

  /**
   * Stops a running streaming job. This will cause a running streaming job to
   * stop processing input events and producing output.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource. You can obtain this value from the Azure Resource
   * Manager API or the portal.
   *
   * @param {string} jobName The name of the streaming job.
   *
   * @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.
   */
  beginStop(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._beginStop(resourceGroupName, jobName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginStop(resourceGroupName, jobName, options, optionalCallback);
    }
  }

  /**
   * Lists all of the streaming jobs in the specified 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<StreamingJobListResult>} - 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 of the streaming jobs in the specified 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 {StreamingJobListResult} - 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 StreamingJobListResult} 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);
    }
  }

  /**
   * Lists all of the streaming jobs in the given 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<StreamingJobListResult>} - 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 of the streaming jobs in the given 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 {StreamingJobListResult} - 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 StreamingJobListResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = StreamingJobs;
