/*
 * 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;

/**
 * @summary Gets the list of Replication protected items.
 *
 * Gets the list of ASR replication protected items in the protection
 * container.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container 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 ReplicationProtectedItemCollection} 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 _listByReplicationProtectionContainers(fabricName, protectionContainerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * @summary Gets the details of a Replication protected item.
 *
 * Gets the details of an ASR replication protected item.
 *
 * @param {string} fabricName Fabric unique name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item 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 ReplicationProtectedItem} 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(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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


/**
 * @summary Enables protection.
 *
 * The operation to create an ASR replication protected item (Enable
 * replication).
 *
 * @param {string} fabricName Name of the fabric.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName A name for the replication
 * protected item.
 *
 * @param {object} input Enable Protection Input.
 *
 * @param {object} [input.properties] Enable protection input properties.
 *
 * @param {string} [input.properties.policyId] The Policy Id.
 *
 * @param {string} [input.properties.protectableItemId] The protectable item
 * Id.
 *
 * @param {object} [input.properties.providerSpecificDetails] The
 * ReplicationProviderInput. For HyperVReplicaAzure provider, it will be
 * AzureEnableProtectionInput object. For San provider, it will be
 * SanEnableProtectionInput object. For HyperVReplicaAzure provider, it can be
 * null.
 *
 * @param {string} input.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _create(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginCreate(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Purges protection.
 *
 * The operation to delete or purge a replication protected item. This
 * operation will force delete the replication protected item. Use the remove
 * operation on replication protected item to perform a clean disable
 * replication for the item.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item 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 _purge(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginPurge(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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


/**
 * @summary Updates protection.
 *
 * The operation to update the recovery settings of an ASR replication
 * protected item.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} updateProtectionInput Update protection input.
 *
 * @param {object} [updateProtectionInput.properties] Update replication
 * protected item properties.
 *
 * @param {string} [updateProtectionInput.properties.recoveryAzureVMName]
 * Target azure VM name given by the user.
 *
 * @param {string} [updateProtectionInput.properties.recoveryAzureVMSize]
 * Target Azure Vm size.
 *
 * @param {string}
 * [updateProtectionInput.properties.selectedRecoveryAzureNetworkId] Target
 * Azure Network Id.
 *
 * @param {string} [updateProtectionInput.properties.selectedSourceNicId] The
 * selected source nic Id which will be used as the primary nic during
 * failover.
 *
 * @param {string} [updateProtectionInput.properties.enableRdpOnTargetOption]
 * The selected option to enable RDP\SSH on target vm after failover. String
 * value of {SrsDataContract.EnableRDPOnTargetOption} enum.
 *
 * @param {array} [updateProtectionInput.properties.vmNics] The list of vm nic
 * details.
 *
 * @param {string} [updateProtectionInput.properties.licenseType] License type.
 * Possible values include: 'NotSpecified', 'NoLicenseType', 'WindowsServer'
 *
 * @param {string} [updateProtectionInput.properties.recoveryAvailabilitySetId]
 * The target availability set id.
 *
 * @param {object} [updateProtectionInput.properties.providerSpecificDetails]
 * The provider specific input to update replication protected item.
 *
 * @param {string}
 * updateProtectionInput.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _update(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginUpdate(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Change or apply recovery point.
 *
 * The operation to change the recovery point of a failed over replication
 * protected item.
 *
 * @param {string} fabricName The ARM fabric name.
 *
 * @param {string} protectionContainerName The protection container name.
 *
 * @param {string} replicatedProtectedItemName The replicated protected item's
 * name.
 *
 * @param {object} applyRecoveryPointInput The ApplyRecoveryPointInput.
 *
 * @param {object} [applyRecoveryPointInput.properties] The input properties to
 * apply recovery point.
 *
 * @param {string} [applyRecoveryPointInput.properties.recoveryPointId] The
 * recovery point Id.
 *
 * @param {object} [applyRecoveryPointInput.properties.providerSpecificDetails]
 * Provider specific input for applying recovery point.
 *
 * @param {string}
 * applyRecoveryPointInput.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _applyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginApplyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Execute commit failover
 *
 * Operation to commit the failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item 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 ReplicationProtectedItem} 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 _failoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginFailoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Execute planned failover
 *
 * Operation to initiate a planned failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} failoverInput Disable protection input.
 *
 * @param {object} [failoverInput.properties] Planned failover input properties
 *
 * @param {string} [failoverInput.properties.failoverDirection] Failover
 * direction.
 *
 * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
 * specific settings
 *
 * @param {string}
 * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
 * Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _plannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginPlannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Disables protection.
 *
 * The operation to disable replication on a replication protected item. This
 * will also remove the item.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} disableProtectionInput Disable protection input.
 *
 * @param {object} [disableProtectionInput.properties] Disable protection input
 * properties.
 *
 * @param {string} [disableProtectionInput.properties.disableProtectionReason]
 * Disable protection reason. It can have values
 * NotSpecified/MigrationComplete. Possible values include: 'NotSpecified',
 * 'MigrationComplete'
 *
 * @param {object} [disableProtectionInput.properties.replicationProviderInput]
 * Replication provider specific input.
 *
 * @param {string}
 * disableProtectionInput.properties.replicationProviderInput.instanceType
 * Polymorphic Discriminator
 *
 * @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(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginDeleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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


/**
 * @summary Resynchronize or repair replication.
 *
 * The operation to start resynchronize/repair replication for a replication
 * protected item requiring resynchronization.
 *
 * @param {string} fabricName The name of the fabric.
 *
 * @param {string} protectionContainerName The name of the container.
 *
 * @param {string} replicatedProtectedItemName The name of the replication
 * protected item.
 *
 * @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 ReplicationProtectedItem} 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 _repairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginRepairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Execute Reverse Replication\Reprotect
 *
 * Operation to reprotect or reverse replicate a failed over replication
 * protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} rrInput Disable protection input.
 *
 * @param {object} [rrInput.properties] Reverse replication properties
 *
 * @param {string} [rrInput.properties.failoverDirection] Failover direction.
 *
 * @param {object} [rrInput.properties.providerSpecificDetails] Provider
 * specific reverse replication input.
 *
 * @param {string} rrInput.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _reprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginReprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Execute test failover
 *
 * Operation to perform a test failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} failoverInput Test failover input.
 *
 * @param {object} [failoverInput.properties] Planned failover input properties
 *
 * @param {string} [failoverInput.properties.failoverDirection] Failover
 * direction.
 *
 * @param {string} [failoverInput.properties.networkType] Network type to be
 * used for test failover.
 *
 * @param {string} [failoverInput.properties.networkId] The id of the network
 * to be used for test failover
 *
 * @param {string} [failoverInput.properties.skipTestFailoverCleanup] A value
 * indicating whether the test failover cleanup is to be skipped.
 *
 * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
 * specific settings
 *
 * @param {string}
 * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
 * Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _testFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginTestFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Execute test failover cleanup.
 *
 * Operation to clean up the test failover of a replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} cleanupInput Test failover cleanup input.
 *
 * @param {object} cleanupInput.properties Test failover cleanup input
 * properties.
 *
 * @param {string} [cleanupInput.properties.comments] Test failover cleanup
 * comments.
 *
 * @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 ReplicationProtectedItem} 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 _testFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginTestFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Execute unplanned failover
 *
 * Operation to initiate a failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} failoverInput Disable protection input.
 *
 * @param {object} [failoverInput.properties] Planned failover input properties
 *
 * @param {string} [failoverInput.properties.failoverDirection] Failover
 * direction.
 *
 * @param {string} [failoverInput.properties.sourceSiteOperations] Source site
 * operations status
 *
 * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
 * specific settings
 *
 * @param {string}
 * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
 * Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _unplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginUnplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}


/**
 * @summary Update the mobility service on a protected item.
 *
 * The operation to update(push update) the installed mobility service software
 * on a replication protected item to the latest available version.
 *
 * @param {string} fabricName The name of the fabric containing the protected
 * item.
 *
 * @param {string} protectionContainerName The name of the container containing
 * the protected item.
 *
 * @param {string} replicationProtectedItemName The name of the protected item
 * on which the agent is to be updated.
 *
 * @param {object} updateMobilityServiceRequest Request to update the mobility
 * service on the protected item.
 *
 * @param {object} [updateMobilityServiceRequest.properties] The properties of
 * the update mobility service request.
 *
 * @param {string} [updateMobilityServiceRequest.properties.runAsAccountId] The
 * CS run as account Id.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link ReplicationProtectedItem} 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 _updateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginUpdateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
    });
  });
}

/**
 * @summary Gets the list of replication protected items.
 *
 * Gets the list of ASR replication protected items in the vault.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.skipToken] The pagination token. Possible values:
 * "FabricId" or "FabricId_CloudId" or null
 *
 * @param {string} [options.filter] OData filter options.
 *
 * @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 ReplicationProtectedItemCollection} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _list(options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let skipToken = (options && options.skipToken !== undefined) ? options.skipToken : undefined;
  let filter = (options && options.filter !== undefined) ? options.filter : undefined;
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (skipToken !== null && skipToken !== undefined && typeof skipToken.valueOf() !== 'string') {
      throw new Error('skipToken must be of type string.');
    }
    if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
      throw new Error('filter 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.RecoveryServices/vaults/{resourceName}/replicationProtectedItems';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (skipToken !== null && skipToken !== undefined) {
    queryParameters.push('skipToken=' + encodeURIComponent(skipToken));
  }
  if (filter !== null && filter !== undefined) {
    queryParameters.push('$filter=' + encodeURIComponent(filter));
  }
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * @summary Enables protection.
 *
 * The operation to create an ASR replication protected item (Enable
 * replication).
 *
 * @param {string} fabricName Name of the fabric.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName A name for the replication
 * protected item.
 *
 * @param {object} input Enable Protection Input.
 *
 * @param {object} [input.properties] Enable protection input properties.
 *
 * @param {string} [input.properties.policyId] The Policy Id.
 *
 * @param {string} [input.properties.protectableItemId] The protectable item
 * Id.
 *
 * @param {object} [input.properties.providerSpecificDetails] The
 * ReplicationProviderInput. For HyperVReplicaAzure provider, it will be
 * AzureEnableProtectionInput object. For San provider, it will be
 * SanEnableProtectionInput object. For HyperVReplicaAzure provider, it can be
 * null.
 *
 * @param {string} input.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginCreate(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (input === null || input === undefined) {
      throw new Error('input 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (input !== null && input !== undefined) {
      let requestModelMapper = new client.models['EnableProtectionInput']().mapper();
      requestModel = client.serialize(requestModelMapper, input, 'input');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(input, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Purges protection.
 *
 * The operation to delete or purge a replication protected item. This
 * operation will force delete the replication protected item. Use the remove
 * operation on replication protected item to perform a clean disable
 * replication for the item.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item 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 _beginPurge(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * @summary Updates protection.
 *
 * The operation to update the recovery settings of an ASR replication
 * protected item.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} updateProtectionInput Update protection input.
 *
 * @param {object} [updateProtectionInput.properties] Update replication
 * protected item properties.
 *
 * @param {string} [updateProtectionInput.properties.recoveryAzureVMName]
 * Target azure VM name given by the user.
 *
 * @param {string} [updateProtectionInput.properties.recoveryAzureVMSize]
 * Target Azure Vm size.
 *
 * @param {string}
 * [updateProtectionInput.properties.selectedRecoveryAzureNetworkId] Target
 * Azure Network Id.
 *
 * @param {string} [updateProtectionInput.properties.selectedSourceNicId] The
 * selected source nic Id which will be used as the primary nic during
 * failover.
 *
 * @param {string} [updateProtectionInput.properties.enableRdpOnTargetOption]
 * The selected option to enable RDP\SSH on target vm after failover. String
 * value of {SrsDataContract.EnableRDPOnTargetOption} enum.
 *
 * @param {array} [updateProtectionInput.properties.vmNics] The list of vm nic
 * details.
 *
 * @param {string} [updateProtectionInput.properties.licenseType] License type.
 * Possible values include: 'NotSpecified', 'NoLicenseType', 'WindowsServer'
 *
 * @param {string} [updateProtectionInput.properties.recoveryAvailabilitySetId]
 * The target availability set id.
 *
 * @param {object} [updateProtectionInput.properties.providerSpecificDetails]
 * The provider specific input to update replication protected item.
 *
 * @param {string}
 * updateProtectionInput.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginUpdate(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (updateProtectionInput === null || updateProtectionInput === undefined) {
      throw new Error('updateProtectionInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * @summary Change or apply recovery point.
 *
 * The operation to change the recovery point of a failed over replication
 * protected item.
 *
 * @param {string} fabricName The ARM fabric name.
 *
 * @param {string} protectionContainerName The protection container name.
 *
 * @param {string} replicatedProtectedItemName The replicated protected item's
 * name.
 *
 * @param {object} applyRecoveryPointInput The ApplyRecoveryPointInput.
 *
 * @param {object} [applyRecoveryPointInput.properties] The input properties to
 * apply recovery point.
 *
 * @param {string} [applyRecoveryPointInput.properties.recoveryPointId] The
 * recovery point Id.
 *
 * @param {object} [applyRecoveryPointInput.properties.providerSpecificDetails]
 * Provider specific input for applying recovery point.
 *
 * @param {string}
 * applyRecoveryPointInput.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _beginApplyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (applyRecoveryPointInput === null || applyRecoveryPointInput === undefined) {
      throw new Error('applyRecoveryPointInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/applyRecoveryPoint';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (applyRecoveryPointInput !== null && applyRecoveryPointInput !== undefined) {
      let requestModelMapper = new client.models['ApplyRecoveryPointInput']().mapper();
      requestModel = client.serialize(requestModelMapper, applyRecoveryPointInput, 'applyRecoveryPointInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(applyRecoveryPointInput, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Execute commit failover
 *
 * Operation to commit the failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item 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 ReplicationProtectedItem} 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 _beginFailoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/failoverCommit';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * @summary Execute planned failover
 *
 * Operation to initiate a planned failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} failoverInput Disable protection input.
 *
 * @param {object} [failoverInput.properties] Planned failover input properties
 *
 * @param {string} [failoverInput.properties.failoverDirection] Failover
 * direction.
 *
 * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
 * specific settings
 *
 * @param {string}
 * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
 * Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _beginPlannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (failoverInput === null || failoverInput === undefined) {
      throw new Error('failoverInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/plannedFailover';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (failoverInput !== null && failoverInput !== undefined) {
      let requestModelMapper = new client.models['PlannedFailoverInput']().mapper();
      requestModel = client.serialize(requestModelMapper, failoverInput, 'failoverInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(failoverInput, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Disables protection.
 *
 * The operation to disable replication on a replication protected item. This
 * will also remove the item.
 *
 * @param {string} fabricName Fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} disableProtectionInput Disable protection input.
 *
 * @param {object} [disableProtectionInput.properties] Disable protection input
 * properties.
 *
 * @param {string} [disableProtectionInput.properties.disableProtectionReason]
 * Disable protection reason. It can have values
 * NotSpecified/MigrationComplete. Possible values include: 'NotSpecified',
 * 'MigrationComplete'
 *
 * @param {object} [disableProtectionInput.properties.replicationProviderInput]
 * Replication provider specific input.
 *
 * @param {string}
 * disableProtectionInput.properties.replicationProviderInput.instanceType
 * Polymorphic Discriminator
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDeleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (disableProtectionInput === null || disableProtectionInput === undefined) {
      throw new Error('disableProtectionInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/remove';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (disableProtectionInput !== null && disableProtectionInput !== undefined) {
      let requestModelMapper = new client.models['DisableProtectionInput']().mapper();
      requestModel = client.serialize(requestModelMapper, disableProtectionInput, 'disableProtectionInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(disableProtectionInput, 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 !== 202 && statusCode !== 204) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

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

/**
 * @summary Resynchronize or repair replication.
 *
 * The operation to start resynchronize/repair replication for a replication
 * protected item requiring resynchronization.
 *
 * @param {string} fabricName The name of the fabric.
 *
 * @param {string} protectionContainerName The name of the container.
 *
 * @param {string} replicatedProtectedItemName The name of the replication
 * protected item.
 *
 * @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 ReplicationProtectedItem} 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 _beginRepairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/repairReplication';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * @summary Execute Reverse Replication\Reprotect
 *
 * Operation to reprotect or reverse replicate a failed over replication
 * protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} rrInput Disable protection input.
 *
 * @param {object} [rrInput.properties] Reverse replication properties
 *
 * @param {string} [rrInput.properties.failoverDirection] Failover direction.
 *
 * @param {object} [rrInput.properties.providerSpecificDetails] Provider
 * specific reverse replication input.
 *
 * @param {string} rrInput.properties.providerSpecificDetails.instanceType
 * Polymorphic Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _beginReprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (rrInput === null || rrInput === undefined) {
      throw new Error('rrInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/reProtect';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (rrInput !== null && rrInput !== undefined) {
      let requestModelMapper = new client.models['ReverseReplicationInput']().mapper();
      requestModel = client.serialize(requestModelMapper, rrInput, 'rrInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(rrInput, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Execute test failover
 *
 * Operation to perform a test failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} failoverInput Test failover input.
 *
 * @param {object} [failoverInput.properties] Planned failover input properties
 *
 * @param {string} [failoverInput.properties.failoverDirection] Failover
 * direction.
 *
 * @param {string} [failoverInput.properties.networkType] Network type to be
 * used for test failover.
 *
 * @param {string} [failoverInput.properties.networkId] The id of the network
 * to be used for test failover
 *
 * @param {string} [failoverInput.properties.skipTestFailoverCleanup] A value
 * indicating whether the test failover cleanup is to be skipped.
 *
 * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
 * specific settings
 *
 * @param {string}
 * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
 * Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _beginTestFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (failoverInput === null || failoverInput === undefined) {
      throw new Error('failoverInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailover';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (failoverInput !== null && failoverInput !== undefined) {
      let requestModelMapper = new client.models['TestFailoverInput']().mapper();
      requestModel = client.serialize(requestModelMapper, failoverInput, 'failoverInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(failoverInput, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Execute test failover cleanup.
 *
 * Operation to clean up the test failover of a replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} cleanupInput Test failover cleanup input.
 *
 * @param {object} cleanupInput.properties Test failover cleanup input
 * properties.
 *
 * @param {string} [cleanupInput.properties.comments] Test failover cleanup
 * comments.
 *
 * @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 ReplicationProtectedItem} 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 _beginTestFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (cleanupInput === null || cleanupInput === undefined) {
      throw new Error('cleanupInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailoverCleanup';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (cleanupInput !== null && cleanupInput !== undefined) {
      let requestModelMapper = new client.models['TestFailoverCleanupInput']().mapper();
      requestModel = client.serialize(requestModelMapper, cleanupInput, 'cleanupInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(cleanupInput, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Execute unplanned failover
 *
 * Operation to initiate a failover of the replication protected item.
 *
 * @param {string} fabricName Unique fabric name.
 *
 * @param {string} protectionContainerName Protection container name.
 *
 * @param {string} replicatedProtectedItemName Replication protected item name.
 *
 * @param {object} failoverInput Disable protection input.
 *
 * @param {object} [failoverInput.properties] Planned failover input properties
 *
 * @param {string} [failoverInput.properties.failoverDirection] Failover
 * direction.
 *
 * @param {string} [failoverInput.properties.sourceSiteOperations] Source site
 * operations status
 *
 * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
 * specific settings
 *
 * @param {string}
 * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
 * Discriminator
 *
 * @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 ReplicationProtectedItem} 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 _beginUnplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicatedProtectedItemName === null || replicatedProtectedItemName === undefined || typeof replicatedProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicatedProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (failoverInput === null || failoverInput === undefined) {
      throw new Error('failoverInput 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/unplannedFailover';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicatedProtectedItemName}', encodeURIComponent(replicatedProtectedItemName));
  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 (failoverInput !== null && failoverInput !== undefined) {
      let requestModelMapper = new client.models['UnplannedFailoverInput']().mapper();
      requestModel = client.serialize(requestModelMapper, failoverInput, 'failoverInput');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(failoverInput, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Update the mobility service on a protected item.
 *
 * The operation to update(push update) the installed mobility service software
 * on a replication protected item to the latest available version.
 *
 * @param {string} fabricName The name of the fabric containing the protected
 * item.
 *
 * @param {string} protectionContainerName The name of the container containing
 * the protected item.
 *
 * @param {string} replicationProtectedItemName The name of the protected item
 * on which the agent is to be updated.
 *
 * @param {object} updateMobilityServiceRequest Request to update the mobility
 * service on the protected item.
 *
 * @param {object} [updateMobilityServiceRequest.properties] The properties of
 * the update mobility service request.
 *
 * @param {string} [updateMobilityServiceRequest.properties.runAsAccountId] The
 * CS run as account Id.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link ReplicationProtectedItem} 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 _beginUpdateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceName === null || this.client.resourceName === undefined || typeof this.client.resourceName.valueOf() !== 'string') {
      throw new Error('this.client.resourceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.resourceGroupName === null || this.client.resourceGroupName === undefined || typeof this.client.resourceGroupName.valueOf() !== 'string') {
      throw new Error('this.client.resourceGroupName 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 (fabricName === null || fabricName === undefined || typeof fabricName.valueOf() !== 'string') {
      throw new Error('fabricName cannot be null or undefined and it must be of type string.');
    }
    if (protectionContainerName === null || protectionContainerName === undefined || typeof protectionContainerName.valueOf() !== 'string') {
      throw new Error('protectionContainerName cannot be null or undefined and it must be of type string.');
    }
    if (replicationProtectedItemName === null || replicationProtectedItemName === undefined || typeof replicationProtectedItemName.valueOf() !== 'string') {
      throw new Error('replicationProtectedItemName cannot be null or undefined and it must be of type string.');
    }
    if (updateMobilityServiceRequest === null || updateMobilityServiceRequest === undefined) {
      throw new Error('updateMobilityServiceRequest 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.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicationProtectedItemName}/updateMobilityService';
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(this.client.resourceName));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(this.client.resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{fabricName}', encodeURIComponent(fabricName));
  requestUrl = requestUrl.replace('{protectionContainerName}', encodeURIComponent(protectionContainerName));
  requestUrl = requestUrl.replace('{replicationProtectedItemName}', encodeURIComponent(replicationProtectedItemName));
  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 (updateMobilityServiceRequest !== null && updateMobilityServiceRequest !== undefined) {
      let requestModelMapper = new client.models['UpdateMobilityServiceRequest']().mapper();
      requestModel = client.serialize(requestModelMapper, updateMobilityServiceRequest, 'updateMobilityServiceRequest');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(updateMobilityServiceRequest, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItem']().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);
  });
}

/**
 * @summary Gets the list of Replication protected items.
 *
 * Gets the list of ASR replication protected items in the protection
 * container.
 *
 * @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 ReplicationProtectedItemCollection} 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 _listByReplicationProtectionContainersNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

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

/**
 * @summary Gets the list of replication protected items.
 *
 * Gets the list of ASR replication protected items in the vault.
 *
 * @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 ReplicationProtectedItemCollection} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _listNext(nextPageLink, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['ReplicationProtectedItemCollection']().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 ReplicationProtectedItems. */
class ReplicationProtectedItems {
  /**
   * Create a ReplicationProtectedItems.
   * @param {SiteRecoveryManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listByReplicationProtectionContainers = _listByReplicationProtectionContainers;
    this._get = _get;
    this._create = _create;
    this._purge = _purge;
    this._update = _update;
    this._applyRecoveryPoint = _applyRecoveryPoint;
    this._failoverCommit = _failoverCommit;
    this._plannedFailover = _plannedFailover;
    this._deleteMethod = _deleteMethod;
    this._repairReplication = _repairReplication;
    this._reprotect = _reprotect;
    this._testFailover = _testFailover;
    this._testFailoverCleanup = _testFailoverCleanup;
    this._unplannedFailover = _unplannedFailover;
    this._updateMobilityService = _updateMobilityService;
    this._list = _list;
    this._beginCreate = _beginCreate;
    this._beginPurge = _beginPurge;
    this._beginUpdate = _beginUpdate;
    this._beginApplyRecoveryPoint = _beginApplyRecoveryPoint;
    this._beginFailoverCommit = _beginFailoverCommit;
    this._beginPlannedFailover = _beginPlannedFailover;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginRepairReplication = _beginRepairReplication;
    this._beginReprotect = _beginReprotect;
    this._beginTestFailover = _beginTestFailover;
    this._beginTestFailoverCleanup = _beginTestFailoverCleanup;
    this._beginUnplannedFailover = _beginUnplannedFailover;
    this._beginUpdateMobilityService = _beginUpdateMobilityService;
    this._listByReplicationProtectionContainersNext = _listByReplicationProtectionContainersNext;
    this._listNext = _listNext;
  }

  /**
   * @summary Gets the list of Replication protected items.
   *
   * Gets the list of ASR replication protected items in the protection
   * container.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container 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<ReplicationProtectedItemCollection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByReplicationProtectionContainersWithHttpOperationResponse(fabricName, protectionContainerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByReplicationProtectionContainers(fabricName, protectionContainerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Gets the list of Replication protected items.
   *
   * Gets the list of ASR replication protected items in the protection
   * container.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container 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 {ReplicationProtectedItemCollection} - 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 ReplicationProtectedItemCollection} 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.
   */
  listByReplicationProtectionContainers(fabricName, protectionContainerName, 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._listByReplicationProtectionContainers(fabricName, protectionContainerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByReplicationProtectionContainers(fabricName, protectionContainerName, options, optionalCallback);
    }
  }

  /**
   * @summary Gets the details of a Replication protected item.
   *
   * Gets the details of an ASR replication protected item.
   *
   * @param {string} fabricName Fabric unique name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Gets the details of a Replication protected item.
   *
   * Gets the details of an ASR replication protected item.
   *
   * @param {string} fabricName Fabric unique name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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(fabricName, protectionContainerName, replicatedProtectedItemName, 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(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Enables protection.
   *
   * The operation to create an ASR replication protected item (Enable
   * replication).
   *
   * @param {string} fabricName Name of the fabric.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName A name for the replication
   * protected item.
   *
   * @param {object} input Enable Protection Input.
   *
   * @param {object} [input.properties] Enable protection input properties.
   *
   * @param {string} [input.properties.policyId] The Policy Id.
   *
   * @param {string} [input.properties.protectableItemId] The protectable item
   * Id.
   *
   * @param {object} [input.properties.providerSpecificDetails] The
   * ReplicationProviderInput. For HyperVReplicaAzure provider, it will be
   * AzureEnableProtectionInput object. For San provider, it will be
   * SanEnableProtectionInput object. For HyperVReplicaAzure provider, it can be
   * null.
   *
   * @param {string} input.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, input, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Enables protection.
   *
   * The operation to create an ASR replication protected item (Enable
   * replication).
   *
   * @param {string} fabricName Name of the fabric.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName A name for the replication
   * protected item.
   *
   * @param {object} input Enable Protection Input.
   *
   * @param {object} [input.properties] Enable protection input properties.
   *
   * @param {string} [input.properties.policyId] The Policy Id.
   *
   * @param {string} [input.properties.protectableItemId] The protectable item
   * Id.
   *
   * @param {object} [input.properties.providerSpecificDetails] The
   * ReplicationProviderInput. For HyperVReplicaAzure provider, it will be
   * AzureEnableProtectionInput object. For San provider, it will be
   * SanEnableProtectionInput object. For HyperVReplicaAzure provider, it can be
   * null.
   *
   * @param {string} input.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  create(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._create(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, optionalCallback);
    }
  }

  /**
   * @summary Purges protection.
   *
   * The operation to delete or purge a replication protected item. This
   * operation will force delete the replication protected item. Use the remove
   * operation on replication protected item to perform a clean disable
   * replication for the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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.
   */
  purgeWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._purge(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Purges protection.
   *
   * The operation to delete or purge a replication protected item. This
   * operation will force delete the replication protected item. Use the remove
   * operation on replication protected item to perform a clean disable
   * replication for the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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.
   */
  purge(fabricName, protectionContainerName, replicatedProtectedItemName, 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._purge(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._purge(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Updates protection.
   *
   * The operation to update the recovery settings of an ASR replication
   * protected item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} updateProtectionInput Update protection input.
   *
   * @param {object} [updateProtectionInput.properties] Update replication
   * protected item properties.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMName]
   * Target azure VM name given by the user.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMSize]
   * Target Azure Vm size.
   *
   * @param {string}
   * [updateProtectionInput.properties.selectedRecoveryAzureNetworkId] Target
   * Azure Network Id.
   *
   * @param {string} [updateProtectionInput.properties.selectedSourceNicId] The
   * selected source nic Id which will be used as the primary nic during
   * failover.
   *
   * @param {string} [updateProtectionInput.properties.enableRdpOnTargetOption]
   * The selected option to enable RDP\SSH on target vm after failover. String
   * value of {SrsDataContract.EnableRDPOnTargetOption} enum.
   *
   * @param {array} [updateProtectionInput.properties.vmNics] The list of vm nic
   * details.
   *
   * @param {string} [updateProtectionInput.properties.licenseType] License type.
   * Possible values include: 'NotSpecified', 'NoLicenseType', 'WindowsServer'
   *
   * @param {string} [updateProtectionInput.properties.recoveryAvailabilitySetId]
   * The target availability set id.
   *
   * @param {object} [updateProtectionInput.properties.providerSpecificDetails]
   * The provider specific input to update replication protected item.
   *
   * @param {string}
   * updateProtectionInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Updates protection.
   *
   * The operation to update the recovery settings of an ASR replication
   * protected item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} updateProtectionInput Update protection input.
   *
   * @param {object} [updateProtectionInput.properties] Update replication
   * protected item properties.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMName]
   * Target azure VM name given by the user.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMSize]
   * Target Azure Vm size.
   *
   * @param {string}
   * [updateProtectionInput.properties.selectedRecoveryAzureNetworkId] Target
   * Azure Network Id.
   *
   * @param {string} [updateProtectionInput.properties.selectedSourceNicId] The
   * selected source nic Id which will be used as the primary nic during
   * failover.
   *
   * @param {string} [updateProtectionInput.properties.enableRdpOnTargetOption]
   * The selected option to enable RDP\SSH on target vm after failover. String
   * value of {SrsDataContract.EnableRDPOnTargetOption} enum.
   *
   * @param {array} [updateProtectionInput.properties.vmNics] The list of vm nic
   * details.
   *
   * @param {string} [updateProtectionInput.properties.licenseType] License type.
   * Possible values include: 'NotSpecified', 'NoLicenseType', 'WindowsServer'
   *
   * @param {string} [updateProtectionInput.properties.recoveryAvailabilitySetId]
   * The target availability set id.
   *
   * @param {object} [updateProtectionInput.properties.providerSpecificDetails]
   * The provider specific input to update replication protected item.
   *
   * @param {string}
   * updateProtectionInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  update(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._update(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, optionalCallback);
    }
  }

  /**
   * @summary Change or apply recovery point.
   *
   * The operation to change the recovery point of a failed over replication
   * protected item.
   *
   * @param {string} fabricName The ARM fabric name.
   *
   * @param {string} protectionContainerName The protection container name.
   *
   * @param {string} replicatedProtectedItemName The replicated protected item's
   * name.
   *
   * @param {object} applyRecoveryPointInput The ApplyRecoveryPointInput.
   *
   * @param {object} [applyRecoveryPointInput.properties] The input properties to
   * apply recovery point.
   *
   * @param {string} [applyRecoveryPointInput.properties.recoveryPointId] The
   * recovery point Id.
   *
   * @param {object} [applyRecoveryPointInput.properties.providerSpecificDetails]
   * Provider specific input for applying recovery point.
   *
   * @param {string}
   * applyRecoveryPointInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  applyRecoveryPointWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._applyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Change or apply recovery point.
   *
   * The operation to change the recovery point of a failed over replication
   * protected item.
   *
   * @param {string} fabricName The ARM fabric name.
   *
   * @param {string} protectionContainerName The protection container name.
   *
   * @param {string} replicatedProtectedItemName The replicated protected item's
   * name.
   *
   * @param {object} applyRecoveryPointInput The ApplyRecoveryPointInput.
   *
   * @param {object} [applyRecoveryPointInput.properties] The input properties to
   * apply recovery point.
   *
   * @param {string} [applyRecoveryPointInput.properties.recoveryPointId] The
   * recovery point Id.
   *
   * @param {object} [applyRecoveryPointInput.properties.providerSpecificDetails]
   * Provider specific input for applying recovery point.
   *
   * @param {string}
   * applyRecoveryPointInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  applyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, 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._applyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._applyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute commit failover
   *
   * Operation to commit the failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  failoverCommitWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._failoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute commit failover
   *
   * Operation to commit the failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  failoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, 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._failoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._failoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Execute planned failover
   *
   * Operation to initiate a planned failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  plannedFailoverWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._plannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute planned failover
   *
   * Operation to initiate a planned failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  plannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, 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._plannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._plannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, optionalCallback);
    }
  }

  /**
   * @summary Disables protection.
   *
   * The operation to disable replication on a replication protected item. This
   * will also remove the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} disableProtectionInput Disable protection input.
   *
   * @param {object} [disableProtectionInput.properties] Disable protection input
   * properties.
   *
   * @param {string} [disableProtectionInput.properties.disableProtectionReason]
   * Disable protection reason. It can have values
   * NotSpecified/MigrationComplete. Possible values include: 'NotSpecified',
   * 'MigrationComplete'
   *
   * @param {object} [disableProtectionInput.properties.replicationProviderInput]
   * Replication provider specific input.
   *
   * @param {string}
   * disableProtectionInput.properties.replicationProviderInput.instanceType
   * Polymorphic Discriminator
   *
   * @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(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Disables protection.
   *
   * The operation to disable replication on a replication protected item. This
   * will also remove the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} disableProtectionInput Disable protection input.
   *
   * @param {object} [disableProtectionInput.properties] Disable protection input
   * properties.
   *
   * @param {string} [disableProtectionInput.properties.disableProtectionReason]
   * Disable protection reason. It can have values
   * NotSpecified/MigrationComplete. Possible values include: 'NotSpecified',
   * 'MigrationComplete'
   *
   * @param {object} [disableProtectionInput.properties.replicationProviderInput]
   * Replication provider specific input.
   *
   * @param {string}
   * disableProtectionInput.properties.replicationProviderInput.instanceType
   * Polymorphic Discriminator
   *
   * @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(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, 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(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, optionalCallback);
    }
  }

  /**
   * @summary Resynchronize or repair replication.
   *
   * The operation to start resynchronize/repair replication for a replication
   * protected item requiring resynchronization.
   *
   * @param {string} fabricName The name of the fabric.
   *
   * @param {string} protectionContainerName The name of the container.
   *
   * @param {string} replicatedProtectedItemName The name of the replication
   * protected item.
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  repairReplicationWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._repairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Resynchronize or repair replication.
   *
   * The operation to start resynchronize/repair replication for a replication
   * protected item requiring resynchronization.
   *
   * @param {string} fabricName The name of the fabric.
   *
   * @param {string} protectionContainerName The name of the container.
   *
   * @param {string} replicatedProtectedItemName The name of the replication
   * protected item.
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  repairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, 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._repairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._repairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Execute Reverse Replication\Reprotect
   *
   * Operation to reprotect or reverse replicate a failed over replication
   * protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} rrInput Disable protection input.
   *
   * @param {object} [rrInput.properties] Reverse replication properties
   *
   * @param {string} [rrInput.properties.failoverDirection] Failover direction.
   *
   * @param {object} [rrInput.properties.providerSpecificDetails] Provider
   * specific reverse replication input.
   *
   * @param {string} rrInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  reprotectWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._reprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute Reverse Replication\Reprotect
   *
   * Operation to reprotect or reverse replicate a failed over replication
   * protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} rrInput Disable protection input.
   *
   * @param {object} [rrInput.properties] Reverse replication properties
   *
   * @param {string} [rrInput.properties.failoverDirection] Failover direction.
   *
   * @param {object} [rrInput.properties.providerSpecificDetails] Provider
   * specific reverse replication input.
   *
   * @param {string} rrInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  reprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, 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._reprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._reprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute test failover
   *
   * Operation to perform a test failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Test failover input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.networkType] Network type to be
   * used for test failover.
   *
   * @param {string} [failoverInput.properties.networkId] The id of the network
   * to be used for test failover
   *
   * @param {string} [failoverInput.properties.skipTestFailoverCleanup] A value
   * indicating whether the test failover cleanup is to be skipped.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  testFailoverWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._testFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute test failover
   *
   * Operation to perform a test failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Test failover input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.networkType] Network type to be
   * used for test failover.
   *
   * @param {string} [failoverInput.properties.networkId] The id of the network
   * to be used for test failover
   *
   * @param {string} [failoverInput.properties.skipTestFailoverCleanup] A value
   * indicating whether the test failover cleanup is to be skipped.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  testFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, 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._testFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._testFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute test failover cleanup.
   *
   * Operation to clean up the test failover of a replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} cleanupInput Test failover cleanup input.
   *
   * @param {object} cleanupInput.properties Test failover cleanup input
   * properties.
   *
   * @param {string} [cleanupInput.properties.comments] Test failover cleanup
   * comments.
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  testFailoverCleanupWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._testFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute test failover cleanup.
   *
   * Operation to clean up the test failover of a replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} cleanupInput Test failover cleanup input.
   *
   * @param {object} cleanupInput.properties Test failover cleanup input
   * properties.
   *
   * @param {string} [cleanupInput.properties.comments] Test failover cleanup
   * comments.
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  testFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, 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._testFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._testFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute unplanned failover
   *
   * Operation to initiate a failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.sourceSiteOperations] Source site
   * operations status
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  unplannedFailoverWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._unplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute unplanned failover
   *
   * Operation to initiate a failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.sourceSiteOperations] Source site
   * operations status
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  unplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, 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._unplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._unplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, optionalCallback);
    }
  }

  /**
   * @summary Update the mobility service on a protected item.
   *
   * The operation to update(push update) the installed mobility service software
   * on a replication protected item to the latest available version.
   *
   * @param {string} fabricName The name of the fabric containing the protected
   * item.
   *
   * @param {string} protectionContainerName The name of the container containing
   * the protected item.
   *
   * @param {string} replicationProtectedItemName The name of the protected item
   * on which the agent is to be updated.
   *
   * @param {object} updateMobilityServiceRequest Request to update the mobility
   * service on the protected item.
   *
   * @param {object} [updateMobilityServiceRequest.properties] The properties of
   * the update mobility service request.
   *
   * @param {string} [updateMobilityServiceRequest.properties.runAsAccountId] The
   * CS run as account Id.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateMobilityServiceWithHttpOperationResponse(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._updateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Update the mobility service on a protected item.
   *
   * The operation to update(push update) the installed mobility service software
   * on a replication protected item to the latest available version.
   *
   * @param {string} fabricName The name of the fabric containing the protected
   * item.
   *
   * @param {string} protectionContainerName The name of the container containing
   * the protected item.
   *
   * @param {string} replicationProtectedItemName The name of the protected item
   * on which the agent is to be updated.
   *
   * @param {object} updateMobilityServiceRequest Request to update the mobility
   * service on the protected item.
   *
   * @param {object} [updateMobilityServiceRequest.properties] The properties of
   * the update mobility service request.
   *
   * @param {string} [updateMobilityServiceRequest.properties.runAsAccountId] The
   * CS run as account Id.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  updateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, 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._updateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._updateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, optionalCallback);
    }
  }

  /**
   * @summary Gets the list of replication protected items.
   *
   * Gets the list of ASR replication protected items in the vault.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.skipToken] The pagination token. Possible values:
   * "FabricId" or "FabricId_CloudId" or null
   *
   * @param {string} [options.filter] OData filter options.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ReplicationProtectedItemCollection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listWithHttpOperationResponse(options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._list(options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Gets the list of replication protected items.
   *
   * Gets the list of ASR replication protected items in the vault.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.skipToken] The pagination token. Possible values:
   * "FabricId" or "FabricId_CloudId" or null
   *
   * @param {string} [options.filter] OData filter options.
   *
   * @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 {ReplicationProtectedItemCollection} - 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 ReplicationProtectedItemCollection} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  list(options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._list(options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._list(options, optionalCallback);
    }
  }

  /**
   * @summary Enables protection.
   *
   * The operation to create an ASR replication protected item (Enable
   * replication).
   *
   * @param {string} fabricName Name of the fabric.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName A name for the replication
   * protected item.
   *
   * @param {object} input Enable Protection Input.
   *
   * @param {object} [input.properties] Enable protection input properties.
   *
   * @param {string} [input.properties.policyId] The Policy Id.
   *
   * @param {string} [input.properties.protectableItemId] The protectable item
   * Id.
   *
   * @param {object} [input.properties.providerSpecificDetails] The
   * ReplicationProviderInput. For HyperVReplicaAzure provider, it will be
   * AzureEnableProtectionInput object. For San provider, it will be
   * SanEnableProtectionInput object. For HyperVReplicaAzure provider, it can be
   * null.
   *
   * @param {string} input.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, input, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreate(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Enables protection.
   *
   * The operation to create an ASR replication protected item (Enable
   * replication).
   *
   * @param {string} fabricName Name of the fabric.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName A name for the replication
   * protected item.
   *
   * @param {object} input Enable Protection Input.
   *
   * @param {object} [input.properties] Enable protection input properties.
   *
   * @param {string} [input.properties.policyId] The Policy Id.
   *
   * @param {string} [input.properties.protectableItemId] The protectable item
   * Id.
   *
   * @param {object} [input.properties.providerSpecificDetails] The
   * ReplicationProviderInput. For HyperVReplicaAzure provider, it will be
   * AzureEnableProtectionInput object. For San provider, it will be
   * SanEnableProtectionInput object. For HyperVReplicaAzure provider, it can be
   * null.
   *
   * @param {string} input.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginCreate(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginCreate(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreate(fabricName, protectionContainerName, replicatedProtectedItemName, input, options, optionalCallback);
    }
  }

  /**
   * @summary Purges protection.
   *
   * The operation to delete or purge a replication protected item. This
   * operation will force delete the replication protected item. Use the remove
   * operation on replication protected item to perform a clean disable
   * replication for the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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.
   */
  beginPurgeWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginPurge(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Purges protection.
   *
   * The operation to delete or purge a replication protected item. This
   * operation will force delete the replication protected item. Use the remove
   * operation on replication protected item to perform a clean disable
   * replication for the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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.
   */
  beginPurge(fabricName, protectionContainerName, replicatedProtectedItemName, 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._beginPurge(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginPurge(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Updates protection.
   *
   * The operation to update the recovery settings of an ASR replication
   * protected item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} updateProtectionInput Update protection input.
   *
   * @param {object} [updateProtectionInput.properties] Update replication
   * protected item properties.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMName]
   * Target azure VM name given by the user.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMSize]
   * Target Azure Vm size.
   *
   * @param {string}
   * [updateProtectionInput.properties.selectedRecoveryAzureNetworkId] Target
   * Azure Network Id.
   *
   * @param {string} [updateProtectionInput.properties.selectedSourceNicId] The
   * selected source nic Id which will be used as the primary nic during
   * failover.
   *
   * @param {string} [updateProtectionInput.properties.enableRdpOnTargetOption]
   * The selected option to enable RDP\SSH on target vm after failover. String
   * value of {SrsDataContract.EnableRDPOnTargetOption} enum.
   *
   * @param {array} [updateProtectionInput.properties.vmNics] The list of vm nic
   * details.
   *
   * @param {string} [updateProtectionInput.properties.licenseType] License type.
   * Possible values include: 'NotSpecified', 'NoLicenseType', 'WindowsServer'
   *
   * @param {string} [updateProtectionInput.properties.recoveryAvailabilitySetId]
   * The target availability set id.
   *
   * @param {object} [updateProtectionInput.properties.providerSpecificDetails]
   * The provider specific input to update replication protected item.
   *
   * @param {string}
   * updateProtectionInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdate(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Updates protection.
   *
   * The operation to update the recovery settings of an ASR replication
   * protected item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} updateProtectionInput Update protection input.
   *
   * @param {object} [updateProtectionInput.properties] Update replication
   * protected item properties.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMName]
   * Target azure VM name given by the user.
   *
   * @param {string} [updateProtectionInput.properties.recoveryAzureVMSize]
   * Target Azure Vm size.
   *
   * @param {string}
   * [updateProtectionInput.properties.selectedRecoveryAzureNetworkId] Target
   * Azure Network Id.
   *
   * @param {string} [updateProtectionInput.properties.selectedSourceNicId] The
   * selected source nic Id which will be used as the primary nic during
   * failover.
   *
   * @param {string} [updateProtectionInput.properties.enableRdpOnTargetOption]
   * The selected option to enable RDP\SSH on target vm after failover. String
   * value of {SrsDataContract.EnableRDPOnTargetOption} enum.
   *
   * @param {array} [updateProtectionInput.properties.vmNics] The list of vm nic
   * details.
   *
   * @param {string} [updateProtectionInput.properties.licenseType] License type.
   * Possible values include: 'NotSpecified', 'NoLicenseType', 'WindowsServer'
   *
   * @param {string} [updateProtectionInput.properties.recoveryAvailabilitySetId]
   * The target availability set id.
   *
   * @param {object} [updateProtectionInput.properties.providerSpecificDetails]
   * The provider specific input to update replication protected item.
   *
   * @param {string}
   * updateProtectionInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginUpdate(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginUpdate(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdate(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, options, optionalCallback);
    }
  }

  /**
   * @summary Change or apply recovery point.
   *
   * The operation to change the recovery point of a failed over replication
   * protected item.
   *
   * @param {string} fabricName The ARM fabric name.
   *
   * @param {string} protectionContainerName The protection container name.
   *
   * @param {string} replicatedProtectedItemName The replicated protected item's
   * name.
   *
   * @param {object} applyRecoveryPointInput The ApplyRecoveryPointInput.
   *
   * @param {object} [applyRecoveryPointInput.properties] The input properties to
   * apply recovery point.
   *
   * @param {string} [applyRecoveryPointInput.properties.recoveryPointId] The
   * recovery point Id.
   *
   * @param {object} [applyRecoveryPointInput.properties.providerSpecificDetails]
   * Provider specific input for applying recovery point.
   *
   * @param {string}
   * applyRecoveryPointInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginApplyRecoveryPointWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginApplyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Change or apply recovery point.
   *
   * The operation to change the recovery point of a failed over replication
   * protected item.
   *
   * @param {string} fabricName The ARM fabric name.
   *
   * @param {string} protectionContainerName The protection container name.
   *
   * @param {string} replicatedProtectedItemName The replicated protected item's
   * name.
   *
   * @param {object} applyRecoveryPointInput The ApplyRecoveryPointInput.
   *
   * @param {object} [applyRecoveryPointInput.properties] The input properties to
   * apply recovery point.
   *
   * @param {string} [applyRecoveryPointInput.properties.recoveryPointId] The
   * recovery point Id.
   *
   * @param {object} [applyRecoveryPointInput.properties.providerSpecificDetails]
   * Provider specific input for applying recovery point.
   *
   * @param {string}
   * applyRecoveryPointInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginApplyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, 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._beginApplyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginApplyRecoveryPoint(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute commit failover
   *
   * Operation to commit the failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginFailoverCommitWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginFailoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute commit failover
   *
   * Operation to commit the failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item 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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginFailoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, 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._beginFailoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginFailoverCommit(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Execute planned failover
   *
   * Operation to initiate a planned failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginPlannedFailoverWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginPlannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute planned failover
   *
   * Operation to initiate a planned failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginPlannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, 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._beginPlannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginPlannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, optionalCallback);
    }
  }

  /**
   * @summary Disables protection.
   *
   * The operation to disable replication on a replication protected item. This
   * will also remove the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} disableProtectionInput Disable protection input.
   *
   * @param {object} [disableProtectionInput.properties] Disable protection input
   * properties.
   *
   * @param {string} [disableProtectionInput.properties.disableProtectionReason]
   * Disable protection reason. It can have values
   * NotSpecified/MigrationComplete. Possible values include: 'NotSpecified',
   * 'MigrationComplete'
   *
   * @param {object} [disableProtectionInput.properties.replicationProviderInput]
   * Replication provider specific input.
   *
   * @param {string}
   * disableProtectionInput.properties.replicationProviderInput.instanceType
   * Polymorphic Discriminator
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Disables protection.
   *
   * The operation to disable replication on a replication protected item. This
   * will also remove the item.
   *
   * @param {string} fabricName Fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} disableProtectionInput Disable protection input.
   *
   * @param {object} [disableProtectionInput.properties] Disable protection input
   * properties.
   *
   * @param {string} [disableProtectionInput.properties.disableProtectionReason]
   * Disable protection reason. It can have values
   * NotSpecified/MigrationComplete. Possible values include: 'NotSpecified',
   * 'MigrationComplete'
   *
   * @param {object} [disableProtectionInput.properties.replicationProviderInput]
   * Replication provider specific input.
   *
   * @param {string}
   * disableProtectionInput.properties.replicationProviderInput.instanceType
   * Polymorphic Discriminator
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, options, optionalCallback);
    }
  }

  /**
   * @summary Resynchronize or repair replication.
   *
   * The operation to start resynchronize/repair replication for a replication
   * protected item requiring resynchronization.
   *
   * @param {string} fabricName The name of the fabric.
   *
   * @param {string} protectionContainerName The name of the container.
   *
   * @param {string} replicatedProtectedItemName The name of the replication
   * protected item.
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginRepairReplicationWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginRepairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Resynchronize or repair replication.
   *
   * The operation to start resynchronize/repair replication for a replication
   * protected item requiring resynchronization.
   *
   * @param {string} fabricName The name of the fabric.
   *
   * @param {string} protectionContainerName The name of the container.
   *
   * @param {string} replicatedProtectedItemName The name of the replication
   * protected item.
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginRepairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, 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._beginRepairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginRepairReplication(fabricName, protectionContainerName, replicatedProtectedItemName, options, optionalCallback);
    }
  }

  /**
   * @summary Execute Reverse Replication\Reprotect
   *
   * Operation to reprotect or reverse replicate a failed over replication
   * protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} rrInput Disable protection input.
   *
   * @param {object} [rrInput.properties] Reverse replication properties
   *
   * @param {string} [rrInput.properties.failoverDirection] Failover direction.
   *
   * @param {object} [rrInput.properties.providerSpecificDetails] Provider
   * specific reverse replication input.
   *
   * @param {string} rrInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginReprotectWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginReprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute Reverse Replication\Reprotect
   *
   * Operation to reprotect or reverse replicate a failed over replication
   * protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} rrInput Disable protection input.
   *
   * @param {object} [rrInput.properties] Reverse replication properties
   *
   * @param {string} [rrInput.properties.failoverDirection] Failover direction.
   *
   * @param {object} [rrInput.properties.providerSpecificDetails] Provider
   * specific reverse replication input.
   *
   * @param {string} rrInput.properties.providerSpecificDetails.instanceType
   * Polymorphic Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginReprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, 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._beginReprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginReprotect(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute test failover
   *
   * Operation to perform a test failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Test failover input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.networkType] Network type to be
   * used for test failover.
   *
   * @param {string} [failoverInput.properties.networkId] The id of the network
   * to be used for test failover
   *
   * @param {string} [failoverInput.properties.skipTestFailoverCleanup] A value
   * indicating whether the test failover cleanup is to be skipped.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginTestFailoverWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginTestFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute test failover
   *
   * Operation to perform a test failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Test failover input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.networkType] Network type to be
   * used for test failover.
   *
   * @param {string} [failoverInput.properties.networkId] The id of the network
   * to be used for test failover
   *
   * @param {string} [failoverInput.properties.skipTestFailoverCleanup] A value
   * indicating whether the test failover cleanup is to be skipped.
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginTestFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, 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._beginTestFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginTestFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute test failover cleanup.
   *
   * Operation to clean up the test failover of a replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} cleanupInput Test failover cleanup input.
   *
   * @param {object} cleanupInput.properties Test failover cleanup input
   * properties.
   *
   * @param {string} [cleanupInput.properties.comments] Test failover cleanup
   * comments.
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginTestFailoverCleanupWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginTestFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute test failover cleanup.
   *
   * Operation to clean up the test failover of a replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} cleanupInput Test failover cleanup input.
   *
   * @param {object} cleanupInput.properties Test failover cleanup input
   * properties.
   *
   * @param {string} [cleanupInput.properties.comments] Test failover cleanup
   * comments.
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginTestFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, 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._beginTestFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginTestFailoverCleanup(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, options, optionalCallback);
    }
  }

  /**
   * @summary Execute unplanned failover
   *
   * Operation to initiate a failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.sourceSiteOperations] Source site
   * operations status
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUnplannedFailoverWithHttpOperationResponse(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUnplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Execute unplanned failover
   *
   * Operation to initiate a failover of the replication protected item.
   *
   * @param {string} fabricName Unique fabric name.
   *
   * @param {string} protectionContainerName Protection container name.
   *
   * @param {string} replicatedProtectedItemName Replication protected item name.
   *
   * @param {object} failoverInput Disable protection input.
   *
   * @param {object} [failoverInput.properties] Planned failover input properties
   *
   * @param {string} [failoverInput.properties.failoverDirection] Failover
   * direction.
   *
   * @param {string} [failoverInput.properties.sourceSiteOperations] Source site
   * operations status
   *
   * @param {object} [failoverInput.properties.providerSpecificDetails] Provider
   * specific settings
   *
   * @param {string}
   * failoverInput.properties.providerSpecificDetails.instanceType Polymorphic
   * Discriminator
   *
   * @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 {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginUnplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, 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._beginUnplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUnplannedFailover(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, options, optionalCallback);
    }
  }

  /**
   * @summary Update the mobility service on a protected item.
   *
   * The operation to update(push update) the installed mobility service software
   * on a replication protected item to the latest available version.
   *
   * @param {string} fabricName The name of the fabric containing the protected
   * item.
   *
   * @param {string} protectionContainerName The name of the container containing
   * the protected item.
   *
   * @param {string} replicationProtectedItemName The name of the protected item
   * on which the agent is to be updated.
   *
   * @param {object} updateMobilityServiceRequest Request to update the mobility
   * service on the protected item.
   *
   * @param {object} [updateMobilityServiceRequest.properties] The properties of
   * the update mobility service request.
   *
   * @param {string} [updateMobilityServiceRequest.properties.runAsAccountId] The
   * CS run as account Id.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ReplicationProtectedItem>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateMobilityServiceWithHttpOperationResponse(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Update the mobility service on a protected item.
   *
   * The operation to update(push update) the installed mobility service software
   * on a replication protected item to the latest available version.
   *
   * @param {string} fabricName The name of the fabric containing the protected
   * item.
   *
   * @param {string} protectionContainerName The name of the container containing
   * the protected item.
   *
   * @param {string} replicationProtectedItemName The name of the protected item
   * on which the agent is to be updated.
   *
   * @param {object} updateMobilityServiceRequest Request to update the mobility
   * service on the protected item.
   *
   * @param {object} [updateMobilityServiceRequest.properties] The properties of
   * the update mobility service request.
   *
   * @param {string} [updateMobilityServiceRequest.properties.runAsAccountId] The
   * CS run as account Id.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {ReplicationProtectedItem} - 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 ReplicationProtectedItem} 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.
   */
  beginUpdateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, 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._beginUpdateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdateMobilityService(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, options, optionalCallback);
    }
  }

  /**
   * @summary Gets the list of Replication protected items.
   *
   * Gets the list of ASR replication protected items in the protection
   * container.
   *
   * @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<ReplicationProtectedItemCollection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByReplicationProtectionContainersNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByReplicationProtectionContainersNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Gets the list of Replication protected items.
   *
   * Gets the list of ASR replication protected items in the protection
   * container.
   *
   * @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 {ReplicationProtectedItemCollection} - 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 ReplicationProtectedItemCollection} 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.
   */
  listByReplicationProtectionContainersNext(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._listByReplicationProtectionContainersNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByReplicationProtectionContainersNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * @summary Gets the list of replication protected items.
   *
   * Gets the list of ASR replication protected items in the vault.
   *
   * @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<ReplicationProtectedItemCollection>} - 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;
      });
    });
  }

  /**
   * @summary Gets the list of replication protected items.
   *
   * Gets the list of ASR replication protected items in the vault.
   *
   * @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 {ReplicationProtectedItemCollection} - 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 ReplicationProtectedItemCollection} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = ReplicationProtectedItems;
