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

'use strict';

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

/**
 * Lists all of the HealthProbeSettings within a Front Door.
 *
 * @param {string} resourceGroupName Name of the Resource group within the
 * Azure subscription.
 *
 * @param {string} frontDoorName Name of the Front Door which is globally
 * unique.
 *
 * @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 HealthProbeSettingsListResult} 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 _listByFrontDoor(resourceGroupName, frontDoorName, 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 apiVersion = '2018-08-01';
  // 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 > 80)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 80');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/');
      }
    }
    if (frontDoorName === null || frontDoorName === undefined || typeof frontDoorName.valueOf() !== 'string') {
      throw new Error('frontDoorName cannot be null or undefined and it must be of type string.');
    }
    if (frontDoorName !== null && frontDoorName !== undefined) {
      if (frontDoorName.length > 64)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MaxLength": 64');
      }
      if (frontDoorName.length < 5)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MinLength": 5');
      }
      if (frontDoorName.match(/^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/');
      }
    }
    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.Network/frontDoors/{frontDoorName}/healthProbeSettings';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{frontDoorName}', encodeURIComponent(frontDoorName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['ErrorResponse']().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['HealthProbeSettingsListResult']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Gets a HealthProbeSettings with the specified Rule name within the specified
 * Front Door.
 *
 * @param {string} resourceGroupName Name of the Resource group within the
 * Azure subscription.
 *
 * @param {string} frontDoorName Name of the Front Door which is globally
 * unique.
 *
 * @param {string} healthProbeSettingsName Name of the health probe settings
 * which is unique within the Front Door.
 *
 * @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 HealthProbeSettingsModel} 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, frontDoorName, healthProbeSettingsName, 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 apiVersion = '2018-08-01';
  // 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 > 80)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 80');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/');
      }
    }
    if (frontDoorName === null || frontDoorName === undefined || typeof frontDoorName.valueOf() !== 'string') {
      throw new Error('frontDoorName cannot be null or undefined and it must be of type string.');
    }
    if (frontDoorName !== null && frontDoorName !== undefined) {
      if (frontDoorName.length > 64)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MaxLength": 64');
      }
      if (frontDoorName.length < 5)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MinLength": 5');
      }
      if (frontDoorName.match(/^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/');
      }
    }
    if (healthProbeSettingsName === null || healthProbeSettingsName === undefined || typeof healthProbeSettingsName.valueOf() !== 'string') {
      throw new Error('healthProbeSettingsName cannot be null or undefined and it must be of type string.');
    }
    if (healthProbeSettingsName !== null && healthProbeSettingsName !== undefined) {
      if (healthProbeSettingsName.length > 90)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "MaxLength": 90');
      }
      if (healthProbeSettingsName.length < 1)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "MinLength": 1');
      }
      if (healthProbeSettingsName.match(/^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$/');
      }
    }
    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.Network/frontDoors/{frontDoorName}/healthProbeSettings/{healthProbeSettingsName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{frontDoorName}', encodeURIComponent(frontDoorName));
  requestUrl = requestUrl.replace('{healthProbeSettingsName}', encodeURIComponent(healthProbeSettingsName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['ErrorResponse']().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['HealthProbeSettingsModel']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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


/**
 * Creates a new HealthProbeSettings with the specified Rule name within the
 * specified Front Door.
 *
 * @param {string} resourceGroupName Name of the Resource group within the
 * Azure subscription.
 *
 * @param {string} frontDoorName Name of the Front Door which is globally
 * unique.
 *
 * @param {string} healthProbeSettingsName Name of the health probe settings
 * which is unique within the Front Door.
 *
 * @param {object} healthProbeSettingsParameters HealthProbeSettings properties
 * needed to create a new Front Door.
 *
 * @param {string} [healthProbeSettingsParameters.path] The path to use for the
 * health probe. Default is /
 *
 * @param {string} [healthProbeSettingsParameters.protocol] Protocol scheme to
 * use for this probe. Possible values include: 'Http', 'Https'
 *
 * @param {number} [healthProbeSettingsParameters.intervalInSeconds] The number
 * of seconds between health probes.
 *
 * @param {string} [healthProbeSettingsParameters.resourceState] Resource
 * status. Possible values include: 'Creating', 'Enabling', 'Enabled',
 * 'Disabling', 'Disabled', 'Deleting'
 *
 * @param {string} [healthProbeSettingsParameters.name] Resource name.
 *
 * @param {string} [healthProbeSettingsParameters.id] Resource ID.
 *
 * @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 HealthProbeSettingsModel} 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, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, 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.beginCreateOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, 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['HealthProbeSettingsModel']().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 existing HealthProbeSettings with the specified parameters.
 *
 * @param {string} resourceGroupName Name of the Resource group within the
 * Azure subscription.
 *
 * @param {string} frontDoorName Name of the Front Door which is globally
 * unique.
 *
 * @param {string} healthProbeSettingsName Name of the health probe settings
 * which is unique within the Front Door.
 *
 * @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, frontDoorName, healthProbeSettingsName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

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

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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

/**
 * Creates a new HealthProbeSettings with the specified Rule name within the
 * specified Front Door.
 *
 * @param {string} resourceGroupName Name of the Resource group within the
 * Azure subscription.
 *
 * @param {string} frontDoorName Name of the Front Door which is globally
 * unique.
 *
 * @param {string} healthProbeSettingsName Name of the health probe settings
 * which is unique within the Front Door.
 *
 * @param {object} healthProbeSettingsParameters HealthProbeSettings properties
 * needed to create a new Front Door.
 *
 * @param {string} [healthProbeSettingsParameters.path] The path to use for the
 * health probe. Default is /
 *
 * @param {string} [healthProbeSettingsParameters.protocol] Protocol scheme to
 * use for this probe. Possible values include: 'Http', 'Https'
 *
 * @param {number} [healthProbeSettingsParameters.intervalInSeconds] The number
 * of seconds between health probes.
 *
 * @param {string} [healthProbeSettingsParameters.resourceState] Resource
 * status. Possible values include: 'Creating', 'Enabling', 'Enabled',
 * 'Disabling', 'Disabled', 'Deleting'
 *
 * @param {string} [healthProbeSettingsParameters.name] Resource name.
 *
 * @param {string} [healthProbeSettingsParameters.id] Resource ID.
 *
 * @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 HealthProbeSettingsModel} 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 _beginCreateOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, 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 apiVersion = '2018-08-01';
  // 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 > 80)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 80');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/');
      }
    }
    if (frontDoorName === null || frontDoorName === undefined || typeof frontDoorName.valueOf() !== 'string') {
      throw new Error('frontDoorName cannot be null or undefined and it must be of type string.');
    }
    if (frontDoorName !== null && frontDoorName !== undefined) {
      if (frontDoorName.length > 64)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MaxLength": 64');
      }
      if (frontDoorName.length < 5)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MinLength": 5');
      }
      if (frontDoorName.match(/^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/');
      }
    }
    if (healthProbeSettingsName === null || healthProbeSettingsName === undefined || typeof healthProbeSettingsName.valueOf() !== 'string') {
      throw new Error('healthProbeSettingsName cannot be null or undefined and it must be of type string.');
    }
    if (healthProbeSettingsName !== null && healthProbeSettingsName !== undefined) {
      if (healthProbeSettingsName.length > 90)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "MaxLength": 90');
      }
      if (healthProbeSettingsName.length < 1)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "MinLength": 1');
      }
      if (healthProbeSettingsName.match(/^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$/');
      }
    }
    if (healthProbeSettingsParameters === null || healthProbeSettingsParameters === undefined) {
      throw new Error('healthProbeSettingsParameters 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.Network/frontDoors/{frontDoorName}/healthProbeSettings/{healthProbeSettingsName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{frontDoorName}', encodeURIComponent(frontDoorName));
  requestUrl = requestUrl.replace('{healthProbeSettingsName}', encodeURIComponent(healthProbeSettingsName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Deletes an existing HealthProbeSettings with the specified parameters.
 *
 * @param {string} resourceGroupName Name of the Resource group within the
 * Azure subscription.
 *
 * @param {string} frontDoorName Name of the Front Door which is globally
 * unique.
 *
 * @param {string} healthProbeSettingsName Name of the health probe settings
 * which is unique within the Front Door.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDeleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, 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 apiVersion = '2018-08-01';
  // 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 > 80)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 80');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9_\-\(\)\.]*[^\.]$/');
      }
    }
    if (frontDoorName === null || frontDoorName === undefined || typeof frontDoorName.valueOf() !== 'string') {
      throw new Error('frontDoorName cannot be null or undefined and it must be of type string.');
    }
    if (frontDoorName !== null && frontDoorName !== undefined) {
      if (frontDoorName.length > 64)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MaxLength": 64');
      }
      if (frontDoorName.length < 5)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "MinLength": 5');
      }
      if (frontDoorName.match(/^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"frontDoorName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$/');
      }
    }
    if (healthProbeSettingsName === null || healthProbeSettingsName === undefined || typeof healthProbeSettingsName.valueOf() !== 'string') {
      throw new Error('healthProbeSettingsName cannot be null or undefined and it must be of type string.');
    }
    if (healthProbeSettingsName !== null && healthProbeSettingsName !== undefined) {
      if (healthProbeSettingsName.length > 90)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "MaxLength": 90');
      }
      if (healthProbeSettingsName.length < 1)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "MinLength": 1');
      }
      if (healthProbeSettingsName.match(/^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$/) === null)
      {
        throw new Error('"healthProbeSettingsName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$/');
      }
    }
    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.Network/frontDoors/{frontDoorName}/healthProbeSettings/{healthProbeSettingsName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{frontDoorName}', encodeURIComponent(frontDoorName));
  requestUrl = requestUrl.replace('{healthProbeSettingsName}', encodeURIComponent(healthProbeSettingsName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Lists all of the HealthProbeSettings within a Front Door.
 *
 * @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 HealthProbeSettingsListResult} 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 _listByFrontDoorNext(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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['ErrorResponse']().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['HealthProbeSettingsListResult']().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 HealthProbeSettings. */
class HealthProbeSettings {
  /**
   * Create a HealthProbeSettings.
   * @param {FrontDoorManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listByFrontDoor = _listByFrontDoor;
    this._get = _get;
    this._createOrUpdate = _createOrUpdate;
    this._deleteMethod = _deleteMethod;
    this._beginCreateOrUpdate = _beginCreateOrUpdate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._listByFrontDoorNext = _listByFrontDoorNext;
  }

  /**
   * Lists all of the HealthProbeSettings within a Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @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<HealthProbeSettingsListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByFrontDoorWithHttpOperationResponse(resourceGroupName, frontDoorName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByFrontDoor(resourceGroupName, frontDoorName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all of the HealthProbeSettings within a Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @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 {HealthProbeSettingsListResult} - 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 HealthProbeSettingsListResult} 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.
   */
  listByFrontDoor(resourceGroupName, frontDoorName, 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._listByFrontDoor(resourceGroupName, frontDoorName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByFrontDoor(resourceGroupName, frontDoorName, options, optionalCallback);
    }
  }

  /**
   * Gets a HealthProbeSettings with the specified Rule name within the specified
   * Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @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<HealthProbeSettingsModel>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, frontDoorName, healthProbeSettingsName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, frontDoorName, healthProbeSettingsName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a HealthProbeSettings with the specified Rule name within the specified
   * Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @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 {HealthProbeSettingsModel} - 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 HealthProbeSettingsModel} 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, frontDoorName, healthProbeSettingsName, 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, frontDoorName, healthProbeSettingsName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, frontDoorName, healthProbeSettingsName, options, optionalCallback);
    }
  }

  /**
   * Creates a new HealthProbeSettings with the specified Rule name within the
   * specified Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @param {object} healthProbeSettingsParameters HealthProbeSettings properties
   * needed to create a new Front Door.
   *
   * @param {string} [healthProbeSettingsParameters.path] The path to use for the
   * health probe. Default is /
   *
   * @param {string} [healthProbeSettingsParameters.protocol] Protocol scheme to
   * use for this probe. Possible values include: 'Http', 'Https'
   *
   * @param {number} [healthProbeSettingsParameters.intervalInSeconds] The number
   * of seconds between health probes.
   *
   * @param {string} [healthProbeSettingsParameters.resourceState] Resource
   * status. Possible values include: 'Creating', 'Enabling', 'Enabled',
   * 'Disabling', 'Disabled', 'Deleting'
   *
   * @param {string} [healthProbeSettingsParameters.name] Resource name.
   *
   * @param {string} [healthProbeSettingsParameters.id] Resource ID.
   *
   * @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<HealthProbeSettingsModel>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a new HealthProbeSettings with the specified Rule name within the
   * specified Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @param {object} healthProbeSettingsParameters HealthProbeSettings properties
   * needed to create a new Front Door.
   *
   * @param {string} [healthProbeSettingsParameters.path] The path to use for the
   * health probe. Default is /
   *
   * @param {string} [healthProbeSettingsParameters.protocol] Protocol scheme to
   * use for this probe. Possible values include: 'Http', 'Https'
   *
   * @param {number} [healthProbeSettingsParameters.intervalInSeconds] The number
   * of seconds between health probes.
   *
   * @param {string} [healthProbeSettingsParameters.resourceState] Resource
   * status. Possible values include: 'Creating', 'Enabling', 'Enabled',
   * 'Disabling', 'Disabled', 'Deleting'
   *
   * @param {string} [healthProbeSettingsParameters.name] Resource name.
   *
   * @param {string} [healthProbeSettingsParameters.id] Resource ID.
   *
   * @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 {HealthProbeSettingsModel} - 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 HealthProbeSettingsModel} 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, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, 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, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options, optionalCallback);
    }
  }

  /**
   * Deletes an existing HealthProbeSettings with the specified parameters.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @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, frontDoorName, healthProbeSettingsName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, 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 existing HealthProbeSettings with the specified parameters.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @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, frontDoorName, healthProbeSettingsName, 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, frontDoorName, healthProbeSettingsName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, options, optionalCallback);
    }
  }

  /**
   * Creates a new HealthProbeSettings with the specified Rule name within the
   * specified Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @param {object} healthProbeSettingsParameters HealthProbeSettings properties
   * needed to create a new Front Door.
   *
   * @param {string} [healthProbeSettingsParameters.path] The path to use for the
   * health probe. Default is /
   *
   * @param {string} [healthProbeSettingsParameters.protocol] Protocol scheme to
   * use for this probe. Possible values include: 'Http', 'Https'
   *
   * @param {number} [healthProbeSettingsParameters.intervalInSeconds] The number
   * of seconds between health probes.
   *
   * @param {string} [healthProbeSettingsParameters.resourceState] Resource
   * status. Possible values include: 'Creating', 'Enabling', 'Enabled',
   * 'Disabling', 'Disabled', 'Deleting'
   *
   * @param {string} [healthProbeSettingsParameters.name] Resource name.
   *
   * @param {string} [healthProbeSettingsParameters.id] Resource ID.
   *
   * @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<HealthProbeSettingsModel>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a new HealthProbeSettings with the specified Rule name within the
   * specified Front Door.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @param {object} healthProbeSettingsParameters HealthProbeSettings properties
   * needed to create a new Front Door.
   *
   * @param {string} [healthProbeSettingsParameters.path] The path to use for the
   * health probe. Default is /
   *
   * @param {string} [healthProbeSettingsParameters.protocol] Protocol scheme to
   * use for this probe. Possible values include: 'Http', 'Https'
   *
   * @param {number} [healthProbeSettingsParameters.intervalInSeconds] The number
   * of seconds between health probes.
   *
   * @param {string} [healthProbeSettingsParameters.resourceState] Resource
   * status. Possible values include: 'Creating', 'Enabling', 'Enabled',
   * 'Disabling', 'Disabled', 'Deleting'
   *
   * @param {string} [healthProbeSettingsParameters.name] Resource name.
   *
   * @param {string} [healthProbeSettingsParameters.id] Resource ID.
   *
   * @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 {HealthProbeSettingsModel} - 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 HealthProbeSettingsModel} 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.
   */
  beginCreateOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, 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._beginCreateOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdate(resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters, options, optionalCallback);
    }
  }

  /**
   * Deletes an existing HealthProbeSettings with the specified parameters.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(resourceGroupName, frontDoorName, healthProbeSettingsName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, 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 existing HealthProbeSettings with the specified parameters.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} frontDoorName Name of the Front Door which is globally
   * unique.
   *
   * @param {string} healthProbeSettingsName Name of the health probe settings
   * which is unique within the Front Door.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, frontDoorName, healthProbeSettingsName, options, optionalCallback);
    }
  }

  /**
   * Lists all of the HealthProbeSettings within a Front Door.
   *
   * @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<HealthProbeSettingsListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByFrontDoorNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByFrontDoorNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Lists all of the HealthProbeSettings within a Front Door.
   *
   * @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 {HealthProbeSettingsListResult} - 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 HealthProbeSettingsListResult} 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.
   */
  listByFrontDoorNext(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._listByFrontDoorNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByFrontDoorNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = HealthProbeSettings;
