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

'use strict';

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

/**
 * Lists integration runtimes.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @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 IntegrationRuntimeListResponse} 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 _listByFactory(resourceGroupName, factoryName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Creates or updates an integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @param {object} integrationRuntime Integration runtime resource definition.
 *
 * @param {object} integrationRuntime.properties Integration runtime
 * properties.
 *
 * @param {string} [integrationRuntime.properties.description] Integration
 * runtime description.
 *
 * @param {string} integrationRuntime.properties.type Polymorphic Discriminator
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifMatch] ETag of the integration runtime entity.
 * Should only be specified for update, for which it should match existing
 * entity or can be * for unconditional update.
 *
 * @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 IntegrationRuntimeResource} 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 _createOrUpdate(resourceGroupName, factoryName, integrationRuntimeName, integrationRuntime, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let ifMatch = (options && options.ifMatch !== undefined) ? options.ifMatch : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (ifMatch !== null && ifMatch !== undefined && typeof ifMatch.valueOf() !== 'string') {
      throw new Error('ifMatch must be of type string.');
    }
    if (integrationRuntime === null || integrationRuntime === undefined) {
      throw new Error('integrationRuntime cannot be null or undefined.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 (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 (integrationRuntime !== null && integrationRuntime !== undefined) {
      let requestModelMapper = new client.models['IntegrationRuntimeResource']().mapper();
      requestModel = client.serialize(requestModelMapper, integrationRuntime, 'integrationRuntime');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(integrationRuntime, 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['IntegrationRuntimeResource']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Gets an integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.ifNoneMatch] ETag of the integration runtime
 * entity. Should only be specified for get. If the ETag matches the existing
 * entity tag, or if * was provided, then no content will be returned.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link IntegrationRuntimeResource} 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, factoryName, integrationRuntimeName, 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 ifNoneMatch = (options && options.ifNoneMatch !== undefined) ? options.ifNoneMatch : undefined;
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (ifNoneMatch !== null && ifNoneMatch !== undefined && typeof ifNoneMatch.valueOf() !== 'string') {
      throw new Error('ifNoneMatch 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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (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];
      }
    }
  }
  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 !== 304) {
      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['IntegrationRuntimeResource']().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 integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @param {object} updateIntegrationRuntimeRequest The parameters for updating
 * an integration runtime.
 *
 * @param {string} [updateIntegrationRuntimeRequest.autoUpdate] Enables or
 * disables the auto-update feature of the self-hosted integration runtime. See
 * https://go.microsoft.com/fwlink/?linkid=854189. Possible values include:
 * 'On', 'Off'
 *
 * @param {string} [updateIntegrationRuntimeRequest.updateDelayOffset] The time
 * offset (in hours) in the day, e.g., PT03H is 3 hours. The integration
 * runtime auto update will happen on that time.
 *
 * @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 IntegrationRuntimeResource} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _update(resourceGroupName, factoryName, integrationRuntimeName, updateIntegrationRuntimeRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (updateIntegrationRuntimeRequest === null || updateIntegrationRuntimeRequest === undefined) {
      throw new Error('updateIntegrationRuntimeRequest cannot be null or undefined.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 (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 (updateIntegrationRuntimeRequest !== null && updateIntegrationRuntimeRequest !== undefined) {
      let requestModelMapper = new client.models['UpdateIntegrationRuntimeRequest']().mapper();
      requestModel = client.serialize(requestModelMapper, updateIntegrationRuntimeRequest, 'updateIntegrationRuntimeRequest');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(updateIntegrationRuntimeRequest, 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['IntegrationRuntimeResource']().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 an integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 !== 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);
  });
}

/**
 * Gets detailed status information for an integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 IntegrationRuntimeStatusResponse} 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 _getStatus(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/getStatus';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Gets the on-premises integration runtime connection information for
 * encrypting the on-premises data source credentials.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 IntegrationRuntimeConnectionInfo} 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 _getConnectionInfo(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * Regenerates the authentication key for an integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @param {object} regenerateKeyParameters The parameters for regenerating
 * integration runtime authentication key.
 *
 * @param {string} [regenerateKeyParameters.keyName] The name of the
 * authentication key to regenerate. Possible values include: 'authKey1',
 * 'authKey2'
 *
 * @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 IntegrationRuntimeAuthKeys} 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 _regenerateAuthKey(resourceGroupName, factoryName, integrationRuntimeName, regenerateKeyParameters, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (regenerateKeyParameters === null || regenerateKeyParameters === undefined) {
      throw new Error('regenerateKeyParameters cannot be null or undefined.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 (regenerateKeyParameters !== null && regenerateKeyParameters !== undefined) {
      let requestModelMapper = new client.models['IntegrationRuntimeRegenerateKeyParameters']().mapper();
      requestModel = client.serialize(requestModelMapper, regenerateKeyParameters, 'regenerateKeyParameters');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(regenerateKeyParameters, 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['IntegrationRuntimeAuthKeys']().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);
  });
}

/**
 * Retrieves the authentication keys for an integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 IntegrationRuntimeAuthKeys} 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 _listAuthKeys(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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


/**
 * Stops a ManagedReserved type integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, 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);
    });
  });
}

/**
 * Force the integration runtime to synchronize credentials across integration
 * runtime nodes, and this will override the credentials across all worker
 * nodes with those available on the dispatcher node. If you already have the
 * latest credential backup file, you should manually import it (preferred) on
 * any self-hosted integration runtime node than using this API directly.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 _syncCredentials(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Get the integration runtime monitoring data, which includes the monitor data
 * for all the nodes under this integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 IntegrationRuntimeMonitoringData} 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 _getMonitoringData(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/monitoringData';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * Upgrade self-hosted integration runtime to latest version if availably.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 _upgrade(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/upgrade';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Remove all linked integration runtimes under specific data factory in a
 * self-hosted integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @param {object} linkedIntegrationRuntimeRequest The data factory name for
 * the linked integration runtime.
 *
 * @param {string} linkedIntegrationRuntimeRequest.linkedFactoryName The data
 * factory name for linked integration runtime.
 *
 * @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 _removeLinks(resourceGroupName, factoryName, integrationRuntimeName, linkedIntegrationRuntimeRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (linkedIntegrationRuntimeRequest === null || linkedIntegrationRuntimeRequest === undefined) {
      throw new Error('linkedIntegrationRuntimeRequest cannot be null or undefined.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/removeLinks';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 (linkedIntegrationRuntimeRequest !== null && linkedIntegrationRuntimeRequest !== undefined) {
      let requestModelMapper = new client.models['LinkedIntegrationRuntimeRequest']().mapper();
      requestModel = client.serialize(requestModelMapper, linkedIntegrationRuntimeRequest, 'linkedIntegrationRuntimeRequest');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(linkedIntegrationRuntimeRequest, 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;

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

/**
 * Create a linked integration runtime entry in a shared integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @param {object} createLinkedIntegrationRuntimeRequest The linked integration
 * runtime properties.
 *
 * @param {string} [createLinkedIntegrationRuntimeRequest.name] The name of the
 * linked integration runtime.
 *
 * @param {string} [createLinkedIntegrationRuntimeRequest.subscriptionId] The
 * ID of the subscription that the linked integration runtime belongs to.
 *
 * @param {string} [createLinkedIntegrationRuntimeRequest.dataFactoryName] The
 * name of the data factory that the linked integration runtime belongs to.
 *
 * @param {string} [createLinkedIntegrationRuntimeRequest.dataFactoryLocation]
 * The location of the data factory that the linked integration runtime belongs
 * to.
 *
 * @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 IntegrationRuntimeStatusResponse} 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 _createLinkedIntegrationRuntime(resourceGroupName, factoryName, integrationRuntimeName, createLinkedIntegrationRuntimeRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (createLinkedIntegrationRuntimeRequest === null || createLinkedIntegrationRuntimeRequest === undefined) {
      throw new Error('createLinkedIntegrationRuntimeRequest cannot be null or undefined.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/linkedIntegrationRuntime';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 (createLinkedIntegrationRuntimeRequest !== null && createLinkedIntegrationRuntimeRequest !== undefined) {
      let requestModelMapper = new client.models['CreateLinkedIntegrationRuntimeRequest']().mapper();
      requestModel = client.serialize(requestModelMapper, createLinkedIntegrationRuntimeRequest, 'createLinkedIntegrationRuntimeRequest');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(createLinkedIntegrationRuntimeRequest, 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['IntegrationRuntimeStatusResponse']().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 ManagedReserved type integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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 IntegrationRuntimeStatusResponse} 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 _beginStart(resourceGroupName, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/start';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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;
    // 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['IntegrationRuntimeStatusResponse']().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);
  });
}

/**
 * Stops a ManagedReserved type integration runtime.
 *
 * @param {string} resourceGroupName The resource group name.
 *
 * @param {string} factoryName The factory name.
 *
 * @param {string} integrationRuntimeName The integration runtime name.
 *
 * @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, factoryName, integrationRuntimeName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (factoryName === null || factoryName === undefined || typeof factoryName.valueOf() !== 'string') {
      throw new Error('factoryName cannot be null or undefined and it must be of type string.');
    }
    if (factoryName !== null && factoryName !== undefined) {
      if (factoryName.length > 63)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MaxLength": 63');
      }
      if (factoryName.length < 3)
      {
        throw new Error('"factoryName" should satisfy the constraint - "MinLength": 3');
      }
      if (factoryName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"factoryName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (integrationRuntimeName === null || integrationRuntimeName === undefined || typeof integrationRuntimeName.valueOf() !== 'string') {
      throw new Error('integrationRuntimeName cannot be null or undefined and it must be of type string.');
    }
    if (integrationRuntimeName !== null && integrationRuntimeName !== undefined) {
      if (integrationRuntimeName.length > 63)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MaxLength": 63');
      }
      if (integrationRuntimeName.length < 3)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "MinLength": 3');
      }
      if (integrationRuntimeName.match(/^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/) === null)
      {
        throw new Error('"integrationRuntimeName" should satisfy the constraint - "Pattern": /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.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.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/stop';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{factoryName}', encodeURIComponent(factoryName));
  requestUrl = requestUrl.replace('{integrationRuntimeName}', encodeURIComponent(integrationRuntimeName));
  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 integration runtimes.
 *
 * @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 IntegrationRuntimeListResponse} 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 _listByFactoryNext(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['IntegrationRuntimeListResponse']().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 IntegrationRuntimes. */
class IntegrationRuntimes {
  /**
   * Create a IntegrationRuntimes.
   * @param {DataFactoryManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listByFactory = _listByFactory;
    this._createOrUpdate = _createOrUpdate;
    this._get = _get;
    this._update = _update;
    this._deleteMethod = _deleteMethod;
    this._getStatus = _getStatus;
    this._getConnectionInfo = _getConnectionInfo;
    this._regenerateAuthKey = _regenerateAuthKey;
    this._listAuthKeys = _listAuthKeys;
    this._start = _start;
    this._stop = _stop;
    this._syncCredentials = _syncCredentials;
    this._getMonitoringData = _getMonitoringData;
    this._upgrade = _upgrade;
    this._removeLinks = _removeLinks;
    this._createLinkedIntegrationRuntime = _createLinkedIntegrationRuntime;
    this._beginStart = _beginStart;
    this._beginStop = _beginStop;
    this._listByFactoryNext = _listByFactoryNext;
  }

  /**
   * Lists integration runtimes.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @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<IntegrationRuntimeListResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByFactoryWithHttpOperationResponse(resourceGroupName, factoryName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByFactory(resourceGroupName, factoryName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists integration runtimes.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @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 {IntegrationRuntimeListResponse} - 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 IntegrationRuntimeListResponse} 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.
   */
  listByFactory(resourceGroupName, factoryName, 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._listByFactory(resourceGroupName, factoryName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByFactory(resourceGroupName, factoryName, options, optionalCallback);
    }
  }

  /**
   * Creates or updates an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} integrationRuntime Integration runtime resource definition.
   *
   * @param {object} integrationRuntime.properties Integration runtime
   * properties.
   *
   * @param {string} [integrationRuntime.properties.description] Integration
   * runtime description.
   *
   * @param {string} integrationRuntime.properties.type Polymorphic Discriminator
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] ETag of the integration runtime entity.
   * Should only be specified for update, for which it should match existing
   * entity or can be * for unconditional update.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<IntegrationRuntimeResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, integrationRuntime, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(resourceGroupName, factoryName, integrationRuntimeName, integrationRuntime, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} integrationRuntime Integration runtime resource definition.
   *
   * @param {object} integrationRuntime.properties Integration runtime
   * properties.
   *
   * @param {string} [integrationRuntime.properties.description] Integration
   * runtime description.
   *
   * @param {string} integrationRuntime.properties.type Polymorphic Discriminator
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifMatch] ETag of the integration runtime entity.
   * Should only be specified for update, for which it should match existing
   * entity or can be * for unconditional update.
   *
   * @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 {IntegrationRuntimeResource} - 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 IntegrationRuntimeResource} 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.
   */
  createOrUpdate(resourceGroupName, factoryName, integrationRuntimeName, integrationRuntime, 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._createOrUpdate(resourceGroupName, factoryName, integrationRuntimeName, integrationRuntime, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, factoryName, integrationRuntimeName, integrationRuntime, options, optionalCallback);
    }
  }

  /**
   * Gets an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifNoneMatch] ETag of the integration runtime
   * entity. Should only be specified for get. If the ETag matches the existing
   * entity tag, or if * was provided, then no content will be returned.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<IntegrationRuntimeResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.ifNoneMatch] ETag of the integration runtime
   * entity. Should only be specified for get. If the ETag matches the existing
   * entity tag, or if * was provided, then no content will be returned.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {IntegrationRuntimeResource} - 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 IntegrationRuntimeResource} 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, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Updates an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} updateIntegrationRuntimeRequest The parameters for updating
   * an integration runtime.
   *
   * @param {string} [updateIntegrationRuntimeRequest.autoUpdate] Enables or
   * disables the auto-update feature of the self-hosted integration runtime. See
   * https://go.microsoft.com/fwlink/?linkid=854189. Possible values include:
   * 'On', 'Off'
   *
   * @param {string} [updateIntegrationRuntimeRequest.updateDelayOffset] The time
   * offset (in hours) in the day, e.g., PT03H is 3 hours. The integration
   * runtime auto update will happen on that time.
   *
   * @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<IntegrationRuntimeResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, updateIntegrationRuntimeRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, factoryName, integrationRuntimeName, updateIntegrationRuntimeRequest, 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 integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} updateIntegrationRuntimeRequest The parameters for updating
   * an integration runtime.
   *
   * @param {string} [updateIntegrationRuntimeRequest.autoUpdate] Enables or
   * disables the auto-update feature of the self-hosted integration runtime. See
   * https://go.microsoft.com/fwlink/?linkid=854189. Possible values include:
   * 'On', 'Off'
   *
   * @param {string} [updateIntegrationRuntimeRequest.updateDelayOffset] The time
   * offset (in hours) in the day, e.g., PT03H is 3 hours. The integration
   * runtime auto update will happen on that time.
   *
   * @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 {IntegrationRuntimeResource} - 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 IntegrationRuntimeResource} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  update(resourceGroupName, factoryName, integrationRuntimeName, updateIntegrationRuntimeRequest, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._update(resourceGroupName, factoryName, integrationRuntimeName, updateIntegrationRuntimeRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, factoryName, integrationRuntimeName, updateIntegrationRuntimeRequest, options, optionalCallback);
    }
  }

  /**
   * Deletes an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Gets detailed status information for an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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<IntegrationRuntimeStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getStatusWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getStatus(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets detailed status information for an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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 {IntegrationRuntimeStatusResponse} - 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 IntegrationRuntimeStatusResponse} 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.
   */
  getStatus(resourceGroupName, factoryName, integrationRuntimeName, 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._getStatus(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getStatus(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Gets the on-premises integration runtime connection information for
   * encrypting the on-premises data source credentials.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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<IntegrationRuntimeConnectionInfo>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getConnectionInfoWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getConnectionInfo(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets the on-premises integration runtime connection information for
   * encrypting the on-premises data source credentials.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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 {IntegrationRuntimeConnectionInfo} - 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 IntegrationRuntimeConnectionInfo} 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.
   */
  getConnectionInfo(resourceGroupName, factoryName, integrationRuntimeName, 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._getConnectionInfo(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getConnectionInfo(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Regenerates the authentication key for an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} regenerateKeyParameters The parameters for regenerating
   * integration runtime authentication key.
   *
   * @param {string} [regenerateKeyParameters.keyName] The name of the
   * authentication key to regenerate. Possible values include: 'authKey1',
   * 'authKey2'
   *
   * @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<IntegrationRuntimeAuthKeys>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  regenerateAuthKeyWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, regenerateKeyParameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._regenerateAuthKey(resourceGroupName, factoryName, integrationRuntimeName, regenerateKeyParameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Regenerates the authentication key for an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} regenerateKeyParameters The parameters for regenerating
   * integration runtime authentication key.
   *
   * @param {string} [regenerateKeyParameters.keyName] The name of the
   * authentication key to regenerate. Possible values include: 'authKey1',
   * 'authKey2'
   *
   * @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 {IntegrationRuntimeAuthKeys} - 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 IntegrationRuntimeAuthKeys} 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.
   */
  regenerateAuthKey(resourceGroupName, factoryName, integrationRuntimeName, regenerateKeyParameters, 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._regenerateAuthKey(resourceGroupName, factoryName, integrationRuntimeName, regenerateKeyParameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._regenerateAuthKey(resourceGroupName, factoryName, integrationRuntimeName, regenerateKeyParameters, options, optionalCallback);
    }
  }

  /**
   * Retrieves the authentication keys for an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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<IntegrationRuntimeAuthKeys>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listAuthKeysWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listAuthKeys(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Retrieves the authentication keys for an integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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 {IntegrationRuntimeAuthKeys} - 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 IntegrationRuntimeAuthKeys} 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.
   */
  listAuthKeys(resourceGroupName, factoryName, integrationRuntimeName, 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._listAuthKeys(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listAuthKeys(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Starts a ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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<IntegrationRuntimeStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  startWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._start(resourceGroupName, factoryName, integrationRuntimeName, 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 ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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 {IntegrationRuntimeStatusResponse} - 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 IntegrationRuntimeStatusResponse} 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.
   */
  start(resourceGroupName, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._start(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Stops a ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._stop(resourceGroupName, factoryName, integrationRuntimeName, 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 ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._stop(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Force the integration runtime to synchronize credentials across integration
   * runtime nodes, and this will override the credentials across all worker
   * nodes with those available on the dispatcher node. If you already have the
   * latest credential backup file, you should manually import it (preferred) on
   * any self-hosted integration runtime node than using this API directly.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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.
   */
  syncCredentialsWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._syncCredentials(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Force the integration runtime to synchronize credentials across integration
   * runtime nodes, and this will override the credentials across all worker
   * nodes with those available on the dispatcher node. If you already have the
   * latest credential backup file, you should manually import it (preferred) on
   * any self-hosted integration runtime node than using this API directly.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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.
   */
  syncCredentials(resourceGroupName, factoryName, integrationRuntimeName, 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._syncCredentials(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._syncCredentials(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Get the integration runtime monitoring data, which includes the monitor data
   * for all the nodes under this integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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<IntegrationRuntimeMonitoringData>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getMonitoringDataWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getMonitoringData(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get the integration runtime monitoring data, which includes the monitor data
   * for all the nodes under this integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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 {IntegrationRuntimeMonitoringData} - 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 IntegrationRuntimeMonitoringData} 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.
   */
  getMonitoringData(resourceGroupName, factoryName, integrationRuntimeName, 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._getMonitoringData(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getMonitoringData(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Upgrade self-hosted integration runtime to latest version if availably.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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.
   */
  upgradeWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._upgrade(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Upgrade self-hosted integration runtime to latest version if availably.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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.
   */
  upgrade(resourceGroupName, factoryName, integrationRuntimeName, 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._upgrade(resourceGroupName, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._upgrade(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Remove all linked integration runtimes under specific data factory in a
   * self-hosted integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} linkedIntegrationRuntimeRequest The data factory name for
   * the linked integration runtime.
   *
   * @param {string} linkedIntegrationRuntimeRequest.linkedFactoryName The data
   * factory name for linked integration runtime.
   *
   * @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.
   */
  removeLinksWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, linkedIntegrationRuntimeRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._removeLinks(resourceGroupName, factoryName, integrationRuntimeName, linkedIntegrationRuntimeRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Remove all linked integration runtimes under specific data factory in a
   * self-hosted integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} linkedIntegrationRuntimeRequest The data factory name for
   * the linked integration runtime.
   *
   * @param {string} linkedIntegrationRuntimeRequest.linkedFactoryName The data
   * factory name for linked integration runtime.
   *
   * @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.
   */
  removeLinks(resourceGroupName, factoryName, integrationRuntimeName, linkedIntegrationRuntimeRequest, 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._removeLinks(resourceGroupName, factoryName, integrationRuntimeName, linkedIntegrationRuntimeRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._removeLinks(resourceGroupName, factoryName, integrationRuntimeName, linkedIntegrationRuntimeRequest, options, optionalCallback);
    }
  }

  /**
   * Create a linked integration runtime entry in a shared integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} createLinkedIntegrationRuntimeRequest The linked integration
   * runtime properties.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.name] The name of the
   * linked integration runtime.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.subscriptionId] The
   * ID of the subscription that the linked integration runtime belongs to.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.dataFactoryName] The
   * name of the data factory that the linked integration runtime belongs to.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.dataFactoryLocation]
   * The location of the data factory that the linked integration runtime belongs
   * to.
   *
   * @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<IntegrationRuntimeStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createLinkedIntegrationRuntimeWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, createLinkedIntegrationRuntimeRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createLinkedIntegrationRuntime(resourceGroupName, factoryName, integrationRuntimeName, createLinkedIntegrationRuntimeRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Create a linked integration runtime entry in a shared integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @param {object} createLinkedIntegrationRuntimeRequest The linked integration
   * runtime properties.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.name] The name of the
   * linked integration runtime.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.subscriptionId] The
   * ID of the subscription that the linked integration runtime belongs to.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.dataFactoryName] The
   * name of the data factory that the linked integration runtime belongs to.
   *
   * @param {string} [createLinkedIntegrationRuntimeRequest.dataFactoryLocation]
   * The location of the data factory that the linked integration runtime belongs
   * to.
   *
   * @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 {IntegrationRuntimeStatusResponse} - 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 IntegrationRuntimeStatusResponse} 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.
   */
  createLinkedIntegrationRuntime(resourceGroupName, factoryName, integrationRuntimeName, createLinkedIntegrationRuntimeRequest, 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._createLinkedIntegrationRuntime(resourceGroupName, factoryName, integrationRuntimeName, createLinkedIntegrationRuntimeRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createLinkedIntegrationRuntime(resourceGroupName, factoryName, integrationRuntimeName, createLinkedIntegrationRuntimeRequest, options, optionalCallback);
    }
  }

  /**
   * Starts a ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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<IntegrationRuntimeStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginStartWithHttpOperationResponse(resourceGroupName, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginStart(resourceGroupName, factoryName, integrationRuntimeName, 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 ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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 {IntegrationRuntimeStatusResponse} - 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 IntegrationRuntimeStatusResponse} 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.
   */
  beginStart(resourceGroupName, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginStart(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Stops a ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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, factoryName, integrationRuntimeName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginStop(resourceGroupName, factoryName, integrationRuntimeName, 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 ManagedReserved type integration runtime.
   *
   * @param {string} resourceGroupName The resource group name.
   *
   * @param {string} factoryName The factory name.
   *
   * @param {string} integrationRuntimeName The integration runtime name.
   *
   * @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, factoryName, integrationRuntimeName, 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, factoryName, integrationRuntimeName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginStop(resourceGroupName, factoryName, integrationRuntimeName, options, optionalCallback);
    }
  }

  /**
   * Lists integration runtimes.
   *
   * @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<IntegrationRuntimeListResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByFactoryNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByFactoryNext(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 integration runtimes.
   *
   * @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 {IntegrationRuntimeListResponse} - 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 IntegrationRuntimeListResponse} 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.
   */
  listByFactoryNext(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._listByFactoryNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByFactoryNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = IntegrationRuntimes;
