text: /*
   * 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;
  
  /**
   * Check the give namespace name availability.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {object} parameters Parameters to check availability of the given
   * namespace name
   *
   * @param {string} parameters.name The Name to check the namespce name
   * availability and The namespace name can contain only letters, numbers, and
   * hyphens. The namespace must start with a letter, and it must end with a
   * letter or number.
   *
   * @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 CheckNameAvailabilityResult} 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 _checkNameAvailabilityMethod(resourceGroupName, namespaceName, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (parameters === null || parameters === undefined) {
        throw new Error('parameters 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.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/CheckNameAvailability';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['CheckNameAvailability']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        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['CheckNameAvailabilityResult']().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 all Alias(Disaster Recovery configurations)
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace 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 ArmDisasterRecoveryListResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _list(resourceGroupName, namespaceName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['ArmDisasterRecoveryListResult']().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 a new Alias(Disaster Recovery configuration)
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration name
   *
   * @param {object} parameters Parameters required to create an Alias(Disaster
   * Recovery configuration)
   *
   * @param {string} [parameters.partnerNamespace] ARM Id of the
   * Primary/Secondary eventhub namespace name, which is part of GEO DR pairning
   *
   * @param {string} [parameters.alternateName] Primary/Secondary eventhub
   * namespace name, which is part of GEO DR pairning
   *
   * @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 ArmDisasterRecovery} 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, namespaceName, alias, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (parameters === null || parameters === undefined) {
        throw new Error('parameters cannot be null or undefined.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['ArmDisasterRecovery']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['ArmDisasterRecovery']().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 Alias(Disaster Recovery configuration)
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration 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, namespaceName, alias, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        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);
    });
  }
  
  /**
   * Retrieves Alias(Disaster Recovery configuration) for primary or secondary
   * namespace
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration 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 ArmDisasterRecovery} 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, namespaceName, alias, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['ArmDisasterRecovery']().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);
    });
  }
  
  /**
   * This operation disables the Disaster Recovery and stops replicating changes
   * from primary to secondary namespaces
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration 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 _breakPairing(resourceGroupName, namespaceName, alias, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/breakPairing';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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);
    });
  }
  
  /**
   * envokes GEO DR failover and reconfigure the alias to point to the secondary
   * namespace
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration 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 _failOver(resourceGroupName, namespaceName, alias, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/failover';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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);
    });
  }
  
  /**
   * Gets the authorization rules for a namespace.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration 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 SBAuthorizationRuleListResult} 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 _listAuthorizationRules(resourceGroupName, namespaceName, alias, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['SBAuthorizationRuleListResult']().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 authorization rule for a namespace by rule name.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration name
   *
   * @param {string} authorizationRuleName The authorizationrule 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 SBAuthorizationRule} 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 _getAuthorizationRule(resourceGroupName, namespaceName, alias, authorizationRuleName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (authorizationRuleName === null || authorizationRuleName === undefined || typeof authorizationRuleName.valueOf() !== 'string') {
        throw new Error('authorizationRuleName cannot be null or undefined and it must be of type string.');
      }
      if (authorizationRuleName !== null && authorizationRuleName !== undefined) {
        if (authorizationRuleName.length > 50)
        {
          throw new Error('"authorizationRuleName" should satisfy the constraint - "MaxLength": 50');
        }
        if (authorizationRuleName.length < 1)
        {
          throw new Error('"authorizationRuleName" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{authorizationRuleName}', encodeURIComponent(authorizationRuleName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['SBAuthorizationRule']().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 primary and secondary connection strings for the namespace.
   *
   * @param {string} resourceGroupName Name of the Resource group within the
   * Azure subscription.
   *
   * @param {string} namespaceName The namespace name
   *
   * @param {string} alias The Disaster Recovery configuration name
   *
   * @param {string} authorizationRuleName The authorizationrule 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 AccessKeys} 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 _listKeys(resourceGroupName, namespaceName, alias, authorizationRuleName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (resourceGroupName !== null && resourceGroupName !== undefined) {
        if (resourceGroupName.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 (namespaceName === null || namespaceName === undefined || typeof namespaceName.valueOf() !== 'string') {
        throw new Error('namespaceName cannot be null or undefined and it must be of type string.');
      }
      if (namespaceName !== null && namespaceName !== undefined) {
        if (namespaceName.length > 50)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MaxLength": 50');
        }
        if (namespaceName.length < 6)
        {
          throw new Error('"namespaceName" should satisfy the constraint - "MinLength": 6');
        }
      }
      if (alias === null || alias === undefined || typeof alias.valueOf() !== 'string') {
        throw new Error('alias cannot be null or undefined and it must be of type string.');
      }
      if (alias !== null && alias !== undefined) {
        if (alias.length > 50)
        {
          throw new Error('"alias" should satisfy the constraint - "MaxLength": 50');
        }
        if (alias.length < 1)
        {
          throw new Error('"alias" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (authorizationRuleName === null || authorizationRuleName === undefined || typeof authorizationRuleName.valueOf() !== 'string') {
        throw new Error('authorizationRuleName cannot be null or undefined and it must be of type string.');
      }
      if (authorizationRuleName !== null && authorizationRuleName !== undefined) {
        if (authorizationRuleName.length > 50)
        {
          throw new Error('"authorizationRuleName" should satisfy the constraint - "MaxLength": 50');
        }
        if (authorizationRuleName.length < 1)
        {
          throw new Error('"authorizationRuleName" should satisfy the constraint - "MinLength": 1');
        }
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/disasterRecoveryConfigs/{alias}/AuthorizationRules/{authorizationRuleName}/listKeys';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{namespaceName}', encodeURIComponent(namespaceName));
    requestUrl = requestUrl.replace('{alias}', encodeURIComponent(alias));
    requestUrl = requestUrl.replace('{authorizationRuleName}', encodeURIComponent(authorizationRuleName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['AccessKeys']().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 all Alias(Disaster Recovery configurations)
   *
   * @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 ArmDisasterRecoveryListResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _listNext(nextPageLink, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
        throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let requestUrl = '{nextLink}';
    requestUrl = requestUrl.replace('{nextLink}', nextPageLink);
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['ArmDisasterRecoveryListResult']().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 authorization rules for a namespace.
   *
   * @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 SBAuthorizationRuleListResult} 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 _listAuthorizationRulesNext(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['SBAuthorizationRuleListResult']().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 DisasterRecoveryConfigs. */
  class DisasterRecoveryConfigs {
    /**
     * Create a DisasterRecoveryConfigs.
     * @param {ServiceBusManagementClient} client Reference to the service client.
     */
    constructor(client) {
      this.client = client;
      this._checkNameAvailabilityMethod = _checkNameAvailabilityMethod;
      this._list = _list;
      this._createOrUpdate = _createOrUpdate;
      this._deleteMethod = _deleteMethod;
      this._get = _get;
      this._breakPairing = _breakPairing;
      this._failOver = _failOver;
      this._listAuthorizationRules = _listAuthorizationRules;
      this._getAuthorizationRule = _getAuthorizationRule;
      this._listKeys = _listKeys;
      this._listNext = _listNext;
      this._listAuthorizationRulesNext = _listAuthorizationRulesNext;
    }
  
    /**
     * Check the give namespace name availability.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {object} parameters Parameters to check availability of the given
     * namespace name
     *
     * @param {string} parameters.name The Name to check the namespce name
     * availability and The namespace name can contain only letters, numbers, and
     * hyphens. The namespace must start with a letter, and it must end with a
     * letter or number.
     *
     * @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<CheckNameAvailabilityResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    checkNameAvailabilityMethodWithHttpOperationResponse(resourceGroupName, namespaceName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._checkNameAvailabilityMethod(resourceGroupName, namespaceName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Check the give namespace name availability.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {object} parameters Parameters to check availability of the given
     * namespace name
     *
     * @param {string} parameters.name The Name to check the namespce name
     * availability and The namespace name can contain only letters, numbers, and
     * hyphens. The namespace must start with a letter, and it must end with a
     * letter or number.
     *
     * @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 {CheckNameAvailabilityResult} - 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 CheckNameAvailabilityResult} 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.
     */
    checkNameAvailabilityMethod(resourceGroupName, namespaceName, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._checkNameAvailabilityMethod(resourceGroupName, namespaceName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._checkNameAvailabilityMethod(resourceGroupName, namespaceName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Gets all Alias(Disaster Recovery configurations)
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace 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<ArmDisasterRecoveryListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listWithHttpOperationResponse(resourceGroupName, namespaceName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._list(resourceGroupName, namespaceName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets all Alias(Disaster Recovery configurations)
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace 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 {ArmDisasterRecoveryListResult} - 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 ArmDisasterRecoveryListResult} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    list(resourceGroupName, namespaceName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._list(resourceGroupName, namespaceName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._list(resourceGroupName, namespaceName, options, optionalCallback);
      }
    }
  
    /**
     * Creates or updates a new Alias(Disaster Recovery configuration)
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration name
     *
     * @param {object} parameters Parameters required to create an Alias(Disaster
     * Recovery configuration)
     *
     * @param {string} [parameters.partnerNamespace] ARM Id of the
     * Primary/Secondary eventhub namespace name, which is part of GEO DR pairning
     *
     * @param {string} [parameters.alternateName] Primary/Secondary eventhub
     * namespace name, which is part of GEO DR pairning
     *
     * @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<ArmDisasterRecovery>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    createOrUpdateWithHttpOperationResponse(resourceGroupName, namespaceName, alias, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._createOrUpdate(resourceGroupName, namespaceName, alias, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Creates or updates a new Alias(Disaster Recovery configuration)
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration name
     *
     * @param {object} parameters Parameters required to create an Alias(Disaster
     * Recovery configuration)
     *
     * @param {string} [parameters.partnerNamespace] ARM Id of the
     * Primary/Secondary eventhub namespace name, which is part of GEO DR pairning
     *
     * @param {string} [parameters.alternateName] Primary/Secondary eventhub
     * namespace name, which is part of GEO DR pairning
     *
     * @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 {ArmDisasterRecovery} - 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 ArmDisasterRecovery} 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, namespaceName, alias, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._createOrUpdate(resourceGroupName, namespaceName, alias, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._createOrUpdate(resourceGroupName, namespaceName, alias, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Deletes an Alias(Disaster Recovery configuration)
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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, namespaceName, alias, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, namespaceName, alias, 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 Alias(Disaster Recovery configuration)
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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, namespaceName, alias, 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, namespaceName, alias, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._deleteMethod(resourceGroupName, namespaceName, alias, options, optionalCallback);
      }
    }
  
    /**
     * Retrieves Alias(Disaster Recovery configuration) for primary or secondary
     * namespace
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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<ArmDisasterRecovery>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getWithHttpOperationResponse(resourceGroupName, namespaceName, alias, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, namespaceName, alias, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Retrieves Alias(Disaster Recovery configuration) for primary or secondary
     * namespace
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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 {ArmDisasterRecovery} - 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 ArmDisasterRecovery} 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, namespaceName, alias, 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, namespaceName, alias, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._get(resourceGroupName, namespaceName, alias, options, optionalCallback);
      }
    }
  
    /**
     * This operation disables the Disaster Recovery and stops replicating changes
     * from primary to secondary namespaces
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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.
     */
    breakPairingWithHttpOperationResponse(resourceGroupName, namespaceName, alias, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._breakPairing(resourceGroupName, namespaceName, alias, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * This operation disables the Disaster Recovery and stops replicating changes
     * from primary to secondary namespaces
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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.
     */
    breakPairing(resourceGroupName, namespaceName, alias, 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._breakPairing(resourceGroupName, namespaceName, alias, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._breakPairing(resourceGroupName, namespaceName, alias, options, optionalCallback);
      }
    }
  
    /**
     * envokes GEO DR failover and reconfigure the alias to point to the secondary
     * namespace
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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.
     */
    failOverWithHttpOperationResponse(resourceGroupName, namespaceName, alias, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._failOver(resourceGroupName, namespaceName, alias, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * envokes GEO DR failover and reconfigure the alias to point to the secondary
     * namespace
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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.
     */
    failOver(resourceGroupName, namespaceName, alias, 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._failOver(resourceGroupName, namespaceName, alias, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._failOver(resourceGroupName, namespaceName, alias, options, optionalCallback);
      }
    }
  
    /**
     * Gets the authorization rules for a namespace.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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<SBAuthorizationRuleListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listAuthorizationRulesWithHttpOperationResponse(resourceGroupName, namespaceName, alias, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listAuthorizationRules(resourceGroupName, namespaceName, alias, 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 authorization rules for a namespace.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration 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 {SBAuthorizationRuleListResult} - 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 SBAuthorizationRuleListResult} 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.
     */
    listAuthorizationRules(resourceGroupName, namespaceName, alias, 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._listAuthorizationRules(resourceGroupName, namespaceName, alias, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listAuthorizationRules(resourceGroupName, namespaceName, alias, options, optionalCallback);
      }
    }
  
    /**
     * Gets an authorization rule for a namespace by rule name.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration name
     *
     * @param {string} authorizationRuleName The authorizationrule 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<SBAuthorizationRule>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getAuthorizationRuleWithHttpOperationResponse(resourceGroupName, namespaceName, alias, authorizationRuleName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getAuthorizationRule(resourceGroupName, namespaceName, alias, authorizationRuleName, 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 authorization rule for a namespace by rule name.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration name
     *
     * @param {string} authorizationRuleName The authorizationrule 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 {SBAuthorizationRule} - 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 SBAuthorizationRule} 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.
     */
    getAuthorizationRule(resourceGroupName, namespaceName, alias, authorizationRuleName, 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._getAuthorizationRule(resourceGroupName, namespaceName, alias, authorizationRuleName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getAuthorizationRule(resourceGroupName, namespaceName, alias, authorizationRuleName, options, optionalCallback);
      }
    }
  
    /**
     * Gets the primary and secondary connection strings for the namespace.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration name
     *
     * @param {string} authorizationRuleName The authorizationrule 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<AccessKeys>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listKeysWithHttpOperationResponse(resourceGroupName, namespaceName, alias, authorizationRuleName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listKeys(resourceGroupName, namespaceName, alias, authorizationRuleName, 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 primary and secondary connection strings for the namespace.
     *
     * @param {string} resourceGroupName Name of the Resource group within the
     * Azure subscription.
     *
     * @param {string} namespaceName The namespace name
     *
     * @param {string} alias The Disaster Recovery configuration name
     *
     * @param {string} authorizationRuleName The authorizationrule 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 {AccessKeys} - 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 AccessKeys} 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.
     */
    listKeys(resourceGroupName, namespaceName, alias, authorizationRuleName, 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._listKeys(resourceGroupName, namespaceName, alias, authorizationRuleName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listKeys(resourceGroupName, namespaceName, alias, authorizationRuleName, options, optionalCallback);
      }
    }
  
    /**
     * Gets all Alias(Disaster Recovery configurations)
     *
     * @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<ArmDisasterRecoveryListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets all Alias(Disaster Recovery configurations)
     *
     * @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 {ArmDisasterRecoveryListResult} - 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 ArmDisasterRecoveryListResult} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    listNext(nextPageLink, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._listNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listNext(nextPageLink, options, optionalCallback);
      }
    }
  
    /**
     * Gets the authorization rules for a namespace.
     *
     * @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<SBAuthorizationRuleListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listAuthorizationRulesNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listAuthorizationRulesNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets the authorization rules for a namespace.
     *
     * @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 {SBAuthorizationRuleListResult} - 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 SBAuthorizationRuleListResult} 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.
     */
    listAuthorizationRulesNext(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._listAuthorizationRulesNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listAuthorizationRulesNext(nextPageLink, options, optionalCallback);
      }
    }
  
  }
  
  module.exports = DisasterRecoveryConfigs;
  