text: /*
   * Copyright (c) Microsoft Corporation. All rights reserved.
   * Licensed under the MIT License. See License.txt in the project root for
   * license information.
   *
   * Code generated by Microsoft (R) AutoRest Code Generator.
   * Changes may cause incorrect behavior and will be lost if the code is
   * regenerated.
   */
  
  'use strict';
  
  const msRest = require('ms-rest');
  const msRestAzure = require('ms-rest-azure');
  const WebResource = msRest.WebResource;
  
  
  /**
   * Create or update a key vault in the specified subscription.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the server belongs.
   *
   * @param {string} vaultName Name of the vault
   *
   * @param {object} parameters Parameters to create or update the vault
   *
   * @param {string} parameters.location The supported Azure location where the
   * key vault should be created.
   *
   * @param {object} [parameters.tags] The tags that will be assigned to the key
   * vault.
   *
   * @param {object} parameters.properties Properties of the vault
   *
   * @param {uuid} parameters.properties.tenantId The Azure Active Directory
   * tenant ID that should be used for authenticating requests to the key vault.
   *
   * @param {object} parameters.properties.sku SKU details
   *
   * @param {string} parameters.properties.sku.name SKU name to specify whether
   * the key vault is a standard vault or a premium vault. Possible values
   * include: 'standard', 'premium'
   *
   * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
   * identities that have access to the key vault. All identities in the array
   * must use the same tenant ID as the key vault's tenant ID.
   *
   * @param {string} [parameters.properties.vaultUri] The URI of the vault for
   * performing operations on keys and secrets.
   *
   * @param {boolean} [parameters.properties.enabledForDeployment] Property to
   * specify whether Azure Virtual Machines are permitted to retrieve
   * certificates stored as secrets from the key vault.
   *
   * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
   * to specify whether Azure Disk Encryption is permitted to retrieve secrets
   * from the vault and unwrap keys.
   *
   * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
   * Property to specify whether Azure Resource Manager is permitted to retrieve
   * secrets from the key vault.
   *
   * @param {boolean} [parameters.properties.enableSoftDelete] Property to
   * specify whether the 'soft delete' functionality is enabled for this key
   * vault. It does not accept false value.
   *
   * @param {string} [parameters.properties.createMode] The vault's create mode
   * to indicate whether the vault need to be recovered or not. Possible values
   * include: 'recover', 'default'
   *
   * @param {boolean} [parameters.properties.enablePurgeProtection] Property
   * specifying whether protection against purge is enabled for this vault.
   * Setting this property to true activates protection against purge for this
   * vault and its content - only the Key Vault service may initiate a hard,
   * irrecoverable deletion. The setting is effective only if soft delete is also
   * enabled. Enabling this functionality is irreversible - that is, the property
   * does not accept false as its value.
   *
   * @param {object} [parameters.properties.networkAcls] A collection of rules
   * governing the accessibility of the vault from specific network locations.
   *
   * @param {string} [parameters.properties.networkAcls.bypass] Tells what
   * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
   * not specified the default is 'AzureServices'. Possible values include:
   * 'AzureServices', 'None'
   *
   * @param {string} [parameters.properties.networkAcls.defaultAction] The
   * default action when no rule from ipRules and from virtualNetworkRules match.
   * This is only used after the bypass property has been evaluated. Possible
   * values include: 'Allow', 'Deny'
   *
   * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
   * address rules.
   *
   * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
   * list of virtual network rules.
   *
   * @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 Vault} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _createOrUpdate(resourceGroupName, vaultName, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
  
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
  
    // Send request
    this.beginCreateOrUpdate(resourceGroupName, vaultName, parameters, 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['Vault']().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);
      });
    });
  }
  
  /**
   * Update a key vault in the specified subscription.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the server belongs.
   *
   * @param {string} vaultName Name of the vault
   *
   * @param {object} parameters Parameters to patch the vault
   *
   * @param {object} [parameters.tags] The tags that will be assigned to the key
   * vault.
   *
   * @param {object} [parameters.properties] Properties of the vault
   *
   * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory
   * tenant ID that should be used for authenticating requests to the key vault.
   *
   * @param {object} [parameters.properties.sku] SKU details
   *
   * @param {string} parameters.properties.sku.name SKU name to specify whether
   * the key vault is a standard vault or a premium vault. Possible values
   * include: 'standard', 'premium'
   *
   * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
   * identities that have access to the key vault. All identities in the array
   * must use the same tenant ID as the key vault's tenant ID.
   *
   * @param {boolean} [parameters.properties.enabledForDeployment] Property to
   * specify whether Azure Virtual Machines are permitted to retrieve
   * certificates stored as secrets from the key vault.
   *
   * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
   * to specify whether Azure Disk Encryption is permitted to retrieve secrets
   * from the vault and unwrap keys.
   *
   * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
   * Property to specify whether Azure Resource Manager is permitted to retrieve
   * secrets from the key vault.
   *
   * @param {boolean} [parameters.properties.enableSoftDelete] Property to
   * specify whether the 'soft delete' functionality is enabled for this key
   * vault. It does not accept false value.
   *
   * @param {string} [parameters.properties.createMode] The vault's create mode
   * to indicate whether the vault need to be recovered or not. Possible values
   * include: 'recover', 'default'
   *
   * @param {boolean} [parameters.properties.enablePurgeProtection] Property
   * specifying whether protection against purge is enabled for this vault.
   * Setting this property to true activates protection against purge for this
   * vault and its content - only the Key Vault service may initiate a hard,
   * irrecoverable deletion. The setting is effective only if soft delete is also
   * enabled. Enabling this functionality is irreversible - that is, the property
   * does not accept false as its value.
   *
   * @param {object} [parameters.properties.networkAcls] A collection of rules
   * governing the accessibility of the vault from specific network locations.
   *
   * @param {string} [parameters.properties.networkAcls.bypass] Tells what
   * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
   * not specified the default is 'AzureServices'. Possible values include:
   * 'AzureServices', 'None'
   *
   * @param {string} [parameters.properties.networkAcls.defaultAction] The
   * default action when no rule from ipRules and from virtualNetworkRules match.
   * This is only used after the bypass property has been evaluated. Possible
   * values include: 'Allow', 'Deny'
   *
   * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
   * address rules.
   *
   * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
   * list of virtual network rules.
   *
   * @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 Vault} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _update(resourceGroupName, vaultName, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    if (parameters === null || parameters === undefined)
    {
      parameters = {};
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName !== null && vaultName !== undefined) {
        if (vaultName.match(/^[a-zA-Z0-9-]{3,24}$/) === null)
        {
          throw new Error('"vaultName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9-]{3,24}$/');
        }
      }
      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 (parameters === null || parameters === undefined) {
        throw new Error('parameters cannot be null or undefined.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = '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 (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VaultPatchParameters']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['Vault']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
      // Deserialize Response
      if (statusCode === 201) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['Vault']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError1.request = msRest.stripRequest(httpRequest);
          deserializationError1.response = msRest.stripResponse(response);
          return callback(deserializationError1);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Deletes the specified Azure key vault.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the vault belongs.
   *
   * @param {string} vaultName The name of the vault to delete
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _deleteMethod(resourceGroupName, vaultName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets the specified Azure key vault.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the vault belongs.
   *
   * @param {string} vaultName The name of the vault.
   *
   * @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 Vault} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _get(resourceGroupName, vaultName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['Vault']().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);
    });
  }
  
  /**
   * Update access policies in a key vault in the specified subscription.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the vault belongs.
   *
   * @param {string} vaultName Name of the vault
   *
   * @param {string} operationKind Name of the operation. Possible values
   * include: 'add', 'replace', 'remove'
   *
   * @param {object} parameters Access policy to merge into the vault
   *
   * @param {object} parameters.properties Properties of the access policy
   *
   * @param {array} parameters.properties.accessPolicies An array of 0 to 16
   * identities that have access to the key vault. All identities in the array
   * must use the same tenant ID as the key vault's tenant 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 VaultAccessPolicyParameters} 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 _updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName !== null && vaultName !== undefined) {
        if (vaultName.match(/^[a-zA-Z0-9-]{3,24}$/) === null)
        {
          throw new Error('"vaultName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9-]{3,24}$/');
        }
      }
      if (operationKind) {
        let allowedValues = [ 'add', 'replace', 'remove' ];
        if (!allowedValues.some( function(item) { return item === operationKind; })) {
          throw new Error(operationKind + ' is not a valid value. The valid values are: ' + allowedValues);
        }
      } else {
        throw new Error('operationKind cannot be null or undefined.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (parameters === null || parameters === undefined) {
        throw new Error('parameters cannot be null or undefined.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/accessPolicies/{operationKind}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{operationKind}', encodeURIComponent(operationKind));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VaultAccessPolicyParameters']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['VaultAccessPolicyParameters']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
      // Deserialize Response
      if (statusCode === 201) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['VaultAccessPolicyParameters']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError1.request = msRest.stripRequest(httpRequest);
          deserializationError1.response = msRest.stripResponse(response);
          return callback(deserializationError1);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * The List operation gets information about the vaults associated with the
   * subscription and within the specified resource group.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the vault belongs.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.top] Maximum number of results to return.
   *
   * @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 VaultListResult} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _listByResourceGroup(resourceGroupName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let top = (options && options.top !== undefined) ? options.top : undefined;
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (top !== null && top !== undefined && typeof top !== 'number') {
        throw new Error('top must be of type number.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    if (top !== null && top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(top.toString()));
    }
    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['VaultListResult']().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);
    });
  }
  
  /**
   * The List operation gets information about the vaults associated with the
   * subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.top] Maximum number of results to return.
   *
   * @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 VaultListResult} 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 _listBySubscription(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 top = (options && options.top !== undefined) ? options.top : undefined;
    // Validate
    try {
      if (top !== null && top !== undefined && typeof top !== 'number') {
        throw new Error('top must be of type number.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/vaults';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    if (top !== null && top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(top.toString()));
    }
    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['VaultListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets information about the deleted vaults in a subscription.
   *
   * @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 DeletedVaultListResult} 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 _listDeleted(options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['DeletedVaultListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets the deleted Azure key vault.
   *
   * @param {string} vaultName The name of the vault.
   *
   * @param {string} location The location of the deleted vault.
   *
   * @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 DeletedVault} 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 _getDeleted(vaultName, location, 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 (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (location === null || location === undefined || typeof location.valueOf() !== 'string') {
        throw new Error('location cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}';
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{location}', encodeURIComponent(location));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['DeletedVault']().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);
    });
  }
  
  
  /**
   * Permanently deletes the specified vault. aka Purges the deleted Azure key
   * vault.
   *
   * @param {string} vaultName The name of the soft-deleted vault.
   *
   * @param {string} location The location of the soft-deleted vault.
   *
   * @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 _purgeDeleted(vaultName, location, 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.beginPurgeDeleted(vaultName, location, 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);
      });
    });
  }
  
  /**
   * The List operation gets information about the vaults associated with the
   * subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.top] Maximum number of results to return.
   *
   * @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 ResourceListResult} 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 top = (options && options.top !== undefined) ? options.top : undefined;
    let filter = 'resourceType eq \'Microsoft.KeyVault/vaults\'';
    let apiVersion = '2015-11-01';
    // Validate
    try {
      if (top !== null && top !== undefined && typeof top !== 'number') {
        throw new Error('top must be of type number.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resources';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('$filter=' + encodeURIComponent(filter));
    if (top !== null && top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(top.toString()));
    }
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['ResourceListResult']().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);
    });
  }
  
  /**
   * Checks that the vault name is valid and is not already in use.
   *
   * @param {object} vaultName The name of the vault.
   *
   * @param {string} vaultName.name The vault 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 CheckNameAvailabilityResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _checkNameAvailability(vaultName, 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.');
    }
    if (vaultName === null || vaultName === undefined)
    {
      vaultName = {};
    }
    // Validate
    try {
      if (vaultName === null || vaultName === undefined) {
        throw new Error('vaultName cannot be null or undefined.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/checkNameAvailability';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (vaultName !== null && vaultName !== undefined) {
        let requestModelMapper = new client.models['VaultCheckNameAvailabilityParameters']().mapper();
        requestModel = client.serialize(requestModelMapper, vaultName, 'vaultName');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(vaultName, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['CheckNameAvailabilityResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Create or update a key vault in the specified subscription.
   *
   * @param {string} resourceGroupName The name of the Resource Group to which
   * the server belongs.
   *
   * @param {string} vaultName Name of the vault
   *
   * @param {object} parameters Parameters to create or update the vault
   *
   * @param {string} parameters.location The supported Azure location where the
   * key vault should be created.
   *
   * @param {object} [parameters.tags] The tags that will be assigned to the key
   * vault.
   *
   * @param {object} parameters.properties Properties of the vault
   *
   * @param {uuid} parameters.properties.tenantId The Azure Active Directory
   * tenant ID that should be used for authenticating requests to the key vault.
   *
   * @param {object} parameters.properties.sku SKU details
   *
   * @param {string} parameters.properties.sku.name SKU name to specify whether
   * the key vault is a standard vault or a premium vault. Possible values
   * include: 'standard', 'premium'
   *
   * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
   * identities that have access to the key vault. All identities in the array
   * must use the same tenant ID as the key vault's tenant ID.
   *
   * @param {string} [parameters.properties.vaultUri] The URI of the vault for
   * performing operations on keys and secrets.
   *
   * @param {boolean} [parameters.properties.enabledForDeployment] Property to
   * specify whether Azure Virtual Machines are permitted to retrieve
   * certificates stored as secrets from the key vault.
   *
   * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
   * to specify whether Azure Disk Encryption is permitted to retrieve secrets
   * from the vault and unwrap keys.
   *
   * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
   * Property to specify whether Azure Resource Manager is permitted to retrieve
   * secrets from the key vault.
   *
   * @param {boolean} [parameters.properties.enableSoftDelete] Property to
   * specify whether the 'soft delete' functionality is enabled for this key
   * vault. It does not accept false value.
   *
   * @param {string} [parameters.properties.createMode] The vault's create mode
   * to indicate whether the vault need to be recovered or not. Possible values
   * include: 'recover', 'default'
   *
   * @param {boolean} [parameters.properties.enablePurgeProtection] Property
   * specifying whether protection against purge is enabled for this vault.
   * Setting this property to true activates protection against purge for this
   * vault and its content - only the Key Vault service may initiate a hard,
   * irrecoverable deletion. The setting is effective only if soft delete is also
   * enabled. Enabling this functionality is irreversible - that is, the property
   * does not accept false as its value.
   *
   * @param {object} [parameters.properties.networkAcls] A collection of rules
   * governing the accessibility of the vault from specific network locations.
   *
   * @param {string} [parameters.properties.networkAcls.bypass] Tells what
   * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
   * not specified the default is 'AzureServices'. Possible values include:
   * 'AzureServices', 'None'
   *
   * @param {string} [parameters.properties.networkAcls.defaultAction] The
   * default action when no rule from ipRules and from virtualNetworkRules match.
   * This is only used after the bypass property has been evaluated. Possible
   * values include: 'Allow', 'Deny'
   *
   * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
   * address rules.
   *
   * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
   * list of virtual network rules.
   *
   * @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 Vault} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _beginCreateOrUpdate(resourceGroupName, vaultName, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    if (parameters === null || parameters === undefined)
    {
      parameters = {};
    }
    // Validate
    try {
      if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
        throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (vaultName !== null && vaultName !== undefined) {
        if (vaultName.match(/^[a-zA-Z0-9-]{3,24}$/) === null)
        {
          throw new Error('"vaultName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9-]{3,24}$/');
        }
      }
      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 (parameters === null || parameters === undefined) {
        throw new Error('parameters cannot be null or undefined.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VaultCreateOrUpdateParameters']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['Vault']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
      // Deserialize Response
      if (statusCode === 201) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['Vault']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError1.request = msRest.stripRequest(httpRequest);
          deserializationError1.response = msRest.stripResponse(response);
          return callback(deserializationError1);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Permanently deletes the specified vault. aka Purges the deleted Azure key
   * vault.
   *
   * @param {string} vaultName The name of the soft-deleted vault.
   *
   * @param {string} location The location of the soft-deleted vault.
   *
   * @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 _beginPurgeDeleted(vaultName, location, 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 (vaultName === null || vaultName === undefined || typeof vaultName.valueOf() !== 'string') {
        throw new Error('vaultName cannot be null or undefined and it must be of type string.');
      }
      if (location === null || location === undefined || typeof location.valueOf() !== 'string') {
        throw new Error('location cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge';
    requestUrl = requestUrl.replace('{vaultName}', encodeURIComponent(vaultName));
    requestUrl = requestUrl.replace('{location}', encodeURIComponent(location));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * The List operation gets information about the vaults associated with the
   * subscription and within the specified resource group.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link VaultListResult} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _listByResourceGroupNext(nextPageLink, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
        throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let requestUrl = '{nextLink}';
    requestUrl = requestUrl.replace('{nextLink}', nextPageLink);
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['VaultListResult']().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);
    });
  }
  
  /**
   * The List operation gets information about the vaults associated with the
   * subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link VaultListResult} 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 _listBySubscriptionNext(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['VaultListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets information about the deleted vaults in a subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link DeletedVaultListResult} 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 _listDeletedNext(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['DeletedVaultListResult']().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);
    });
  }
  
  /**
   * The List operation gets information about the vaults associated with the
   * subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link ResourceListResult} 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['ResourceListResult']().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 Vaults. */
  class Vaults {
    /**
     * Create a Vaults.
     * @param {KeyVaultManagementClient} client Reference to the service client.
     */
    constructor(client) {
      this.client = client;
      this._createOrUpdate = _createOrUpdate;
      this._update = _update;
      this._deleteMethod = _deleteMethod;
      this._get = _get;
      this._updateAccessPolicy = _updateAccessPolicy;
      this._listByResourceGroup = _listByResourceGroup;
      this._listBySubscription = _listBySubscription;
      this._listDeleted = _listDeleted;
      this._getDeleted = _getDeleted;
      this._purgeDeleted = _purgeDeleted;
      this._list = _list;
      this._checkNameAvailability = _checkNameAvailability;
      this._beginCreateOrUpdate = _beginCreateOrUpdate;
      this._beginPurgeDeleted = _beginPurgeDeleted;
      this._listByResourceGroupNext = _listByResourceGroupNext;
      this._listBySubscriptionNext = _listBySubscriptionNext;
      this._listDeletedNext = _listDeletedNext;
      this._listNext = _listNext;
    }
  
    /**
     * Create or update a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the server belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {object} parameters Parameters to create or update the vault
     *
     * @param {string} parameters.location The supported Azure location where the
     * key vault should be created.
     *
     * @param {object} [parameters.tags] The tags that will be assigned to the key
     * vault.
     *
     * @param {object} parameters.properties Properties of the vault
     *
     * @param {uuid} parameters.properties.tenantId The Azure Active Directory
     * tenant ID that should be used for authenticating requests to the key vault.
     *
     * @param {object} parameters.properties.sku SKU details
     *
     * @param {string} parameters.properties.sku.name SKU name to specify whether
     * the key vault is a standard vault or a premium vault. Possible values
     * include: 'standard', 'premium'
     *
     * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant ID.
     *
     * @param {string} [parameters.properties.vaultUri] The URI of the vault for
     * performing operations on keys and secrets.
     *
     * @param {boolean} [parameters.properties.enabledForDeployment] Property to
     * specify whether Azure Virtual Machines are permitted to retrieve
     * certificates stored as secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
     * to specify whether Azure Disk Encryption is permitted to retrieve secrets
     * from the vault and unwrap keys.
     *
     * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
     * Property to specify whether Azure Resource Manager is permitted to retrieve
     * secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enableSoftDelete] Property to
     * specify whether the 'soft delete' functionality is enabled for this key
     * vault. It does not accept false value.
     *
     * @param {string} [parameters.properties.createMode] The vault's create mode
     * to indicate whether the vault need to be recovered or not. Possible values
     * include: 'recover', 'default'
     *
     * @param {boolean} [parameters.properties.enablePurgeProtection] Property
     * specifying whether protection against purge is enabled for this vault.
     * Setting this property to true activates protection against purge for this
     * vault and its content - only the Key Vault service may initiate a hard,
     * irrecoverable deletion. The setting is effective only if soft delete is also
     * enabled. Enabling this functionality is irreversible - that is, the property
     * does not accept false as its value.
     *
     * @param {object} [parameters.properties.networkAcls] A collection of rules
     * governing the accessibility of the vault from specific network locations.
     *
     * @param {string} [parameters.properties.networkAcls.bypass] Tells what
     * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
     * not specified the default is 'AzureServices'. Possible values include:
     * 'AzureServices', 'None'
     *
     * @param {string} [parameters.properties.networkAcls.defaultAction] The
     * default action when no rule from ipRules and from virtualNetworkRules match.
     * This is only used after the bypass property has been evaluated. Possible
     * values include: 'Allow', 'Deny'
     *
     * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
     * address rules.
     *
     * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
     * list of virtual network rules.
     *
     * @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<Vault>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    createOrUpdateWithHttpOperationResponse(resourceGroupName, vaultName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._createOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Create or update a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the server belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {object} parameters Parameters to create or update the vault
     *
     * @param {string} parameters.location The supported Azure location where the
     * key vault should be created.
     *
     * @param {object} [parameters.tags] The tags that will be assigned to the key
     * vault.
     *
     * @param {object} parameters.properties Properties of the vault
     *
     * @param {uuid} parameters.properties.tenantId The Azure Active Directory
     * tenant ID that should be used for authenticating requests to the key vault.
     *
     * @param {object} parameters.properties.sku SKU details
     *
     * @param {string} parameters.properties.sku.name SKU name to specify whether
     * the key vault is a standard vault or a premium vault. Possible values
     * include: 'standard', 'premium'
     *
     * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant ID.
     *
     * @param {string} [parameters.properties.vaultUri] The URI of the vault for
     * performing operations on keys and secrets.
     *
     * @param {boolean} [parameters.properties.enabledForDeployment] Property to
     * specify whether Azure Virtual Machines are permitted to retrieve
     * certificates stored as secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
     * to specify whether Azure Disk Encryption is permitted to retrieve secrets
     * from the vault and unwrap keys.
     *
     * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
     * Property to specify whether Azure Resource Manager is permitted to retrieve
     * secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enableSoftDelete] Property to
     * specify whether the 'soft delete' functionality is enabled for this key
     * vault. It does not accept false value.
     *
     * @param {string} [parameters.properties.createMode] The vault's create mode
     * to indicate whether the vault need to be recovered or not. Possible values
     * include: 'recover', 'default'
     *
     * @param {boolean} [parameters.properties.enablePurgeProtection] Property
     * specifying whether protection against purge is enabled for this vault.
     * Setting this property to true activates protection against purge for this
     * vault and its content - only the Key Vault service may initiate a hard,
     * irrecoverable deletion. The setting is effective only if soft delete is also
     * enabled. Enabling this functionality is irreversible - that is, the property
     * does not accept false as its value.
     *
     * @param {object} [parameters.properties.networkAcls] A collection of rules
     * governing the accessibility of the vault from specific network locations.
     *
     * @param {string} [parameters.properties.networkAcls.bypass] Tells what
     * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
     * not specified the default is 'AzureServices'. Possible values include:
     * 'AzureServices', 'None'
     *
     * @param {string} [parameters.properties.networkAcls.defaultAction] The
     * default action when no rule from ipRules and from virtualNetworkRules match.
     * This is only used after the bypass property has been evaluated. Possible
     * values include: 'Allow', 'Deny'
     *
     * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
     * address rules.
     *
     * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
     * list of virtual network rules.
     *
     * @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 {Vault} - 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 Vault} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    createOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._createOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._createOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Update a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the server belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {object} parameters Parameters to patch the vault
     *
     * @param {object} [parameters.tags] The tags that will be assigned to the key
     * vault.
     *
     * @param {object} [parameters.properties] Properties of the vault
     *
     * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory
     * tenant ID that should be used for authenticating requests to the key vault.
     *
     * @param {object} [parameters.properties.sku] SKU details
     *
     * @param {string} parameters.properties.sku.name SKU name to specify whether
     * the key vault is a standard vault or a premium vault. Possible values
     * include: 'standard', 'premium'
     *
     * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant ID.
     *
     * @param {boolean} [parameters.properties.enabledForDeployment] Property to
     * specify whether Azure Virtual Machines are permitted to retrieve
     * certificates stored as secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
     * to specify whether Azure Disk Encryption is permitted to retrieve secrets
     * from the vault and unwrap keys.
     *
     * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
     * Property to specify whether Azure Resource Manager is permitted to retrieve
     * secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enableSoftDelete] Property to
     * specify whether the 'soft delete' functionality is enabled for this key
     * vault. It does not accept false value.
     *
     * @param {string} [parameters.properties.createMode] The vault's create mode
     * to indicate whether the vault need to be recovered or not. Possible values
     * include: 'recover', 'default'
     *
     * @param {boolean} [parameters.properties.enablePurgeProtection] Property
     * specifying whether protection against purge is enabled for this vault.
     * Setting this property to true activates protection against purge for this
     * vault and its content - only the Key Vault service may initiate a hard,
     * irrecoverable deletion. The setting is effective only if soft delete is also
     * enabled. Enabling this functionality is irreversible - that is, the property
     * does not accept false as its value.
     *
     * @param {object} [parameters.properties.networkAcls] A collection of rules
     * governing the accessibility of the vault from specific network locations.
     *
     * @param {string} [parameters.properties.networkAcls.bypass] Tells what
     * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
     * not specified the default is 'AzureServices'. Possible values include:
     * 'AzureServices', 'None'
     *
     * @param {string} [parameters.properties.networkAcls.defaultAction] The
     * default action when no rule from ipRules and from virtualNetworkRules match.
     * This is only used after the bypass property has been evaluated. Possible
     * values include: 'Allow', 'Deny'
     *
     * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
     * address rules.
     *
     * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
     * list of virtual network rules.
     *
     * @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<Vault>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    updateWithHttpOperationResponse(resourceGroupName, vaultName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._update(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Update a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the server belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {object} parameters Parameters to patch the vault
     *
     * @param {object} [parameters.tags] The tags that will be assigned to the key
     * vault.
     *
     * @param {object} [parameters.properties] Properties of the vault
     *
     * @param {uuid} [parameters.properties.tenantId] The Azure Active Directory
     * tenant ID that should be used for authenticating requests to the key vault.
     *
     * @param {object} [parameters.properties.sku] SKU details
     *
     * @param {string} parameters.properties.sku.name SKU name to specify whether
     * the key vault is a standard vault or a premium vault. Possible values
     * include: 'standard', 'premium'
     *
     * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant ID.
     *
     * @param {boolean} [parameters.properties.enabledForDeployment] Property to
     * specify whether Azure Virtual Machines are permitted to retrieve
     * certificates stored as secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
     * to specify whether Azure Disk Encryption is permitted to retrieve secrets
     * from the vault and unwrap keys.
     *
     * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
     * Property to specify whether Azure Resource Manager is permitted to retrieve
     * secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enableSoftDelete] Property to
     * specify whether the 'soft delete' functionality is enabled for this key
     * vault. It does not accept false value.
     *
     * @param {string} [parameters.properties.createMode] The vault's create mode
     * to indicate whether the vault need to be recovered or not. Possible values
     * include: 'recover', 'default'
     *
     * @param {boolean} [parameters.properties.enablePurgeProtection] Property
     * specifying whether protection against purge is enabled for this vault.
     * Setting this property to true activates protection against purge for this
     * vault and its content - only the Key Vault service may initiate a hard,
     * irrecoverable deletion. The setting is effective only if soft delete is also
     * enabled. Enabling this functionality is irreversible - that is, the property
     * does not accept false as its value.
     *
     * @param {object} [parameters.properties.networkAcls] A collection of rules
     * governing the accessibility of the vault from specific network locations.
     *
     * @param {string} [parameters.properties.networkAcls.bypass] Tells what
     * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
     * not specified the default is 'AzureServices'. Possible values include:
     * 'AzureServices', 'None'
     *
     * @param {string} [parameters.properties.networkAcls.defaultAction] The
     * default action when no rule from ipRules and from virtualNetworkRules match.
     * This is only used after the bypass property has been evaluated. Possible
     * values include: 'Allow', 'Deny'
     *
     * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
     * address rules.
     *
     * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
     * list of virtual network rules.
     *
     * @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 {Vault} - 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 Vault} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    update(resourceGroupName, vaultName, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._update(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._update(resourceGroupName, vaultName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Deletes the specified Azure key vault.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {string} vaultName The name of the vault to delete
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<null>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    deleteMethodWithHttpOperationResponse(resourceGroupName, vaultName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, vaultName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Deletes the specified Azure key vault.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {string} vaultName The name of the vault to delete
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {null} - The deserialized result object.
     *
     *                      @reject {Error} - The error object.
     *
     * {function} optionalCallback(err, result, request, response)
     *
     *                      {Error}  err        - The Error object if an error occurred, null otherwise.
     *
     *                      {null} [result]   - The deserialized result object if an error did not occur.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    deleteMethod(resourceGroupName, vaultName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._deleteMethod(resourceGroupName, vaultName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._deleteMethod(resourceGroupName, vaultName, options, optionalCallback);
      }
    }
  
    /**
     * Gets the specified Azure key vault.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {string} vaultName The name of the vault.
     *
     * @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<Vault>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getWithHttpOperationResponse(resourceGroupName, vaultName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, vaultName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets the specified Azure key vault.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {string} vaultName The name of the vault.
     *
     * @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 {Vault} - 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 Vault} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    get(resourceGroupName, vaultName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._get(resourceGroupName, vaultName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._get(resourceGroupName, vaultName, options, optionalCallback);
      }
    }
  
    /**
     * Update access policies in a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {string} operationKind Name of the operation. Possible values
     * include: 'add', 'replace', 'remove'
     *
     * @param {object} parameters Access policy to merge into the vault
     *
     * @param {object} parameters.properties Properties of the access policy
     *
     * @param {array} parameters.properties.accessPolicies An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant 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<VaultAccessPolicyParameters>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    updateAccessPolicyWithHttpOperationResponse(resourceGroupName, vaultName, operationKind, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Update access policies in a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {string} operationKind Name of the operation. Possible values
     * include: 'add', 'replace', 'remove'
     *
     * @param {object} parameters Access policy to merge into the vault
     *
     * @param {object} parameters.properties Properties of the access policy
     *
     * @param {array} parameters.properties.accessPolicies An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant 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 {VaultAccessPolicyParameters} - 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 VaultAccessPolicyParameters} 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.
     */
    updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._updateAccessPolicy(resourceGroupName, vaultName, operationKind, parameters, options, optionalCallback);
      }
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription and within the specified resource group.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {number} [options.top] Maximum number of results to return.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<VaultListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription and within the specified resource group.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the vault belongs.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {number} [options.top] Maximum number of results to return.
     *
     * @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 {VaultListResult} - 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 VaultListResult} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    listByResourceGroup(resourceGroupName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listByResourceGroup(resourceGroupName, options, optionalCallback);
      }
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {number} [options.top] Maximum number of results to return.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<VaultListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listBySubscriptionWithHttpOperationResponse(options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listBySubscription(options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {number} [options.top] Maximum number of results to return.
     *
     * @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 {VaultListResult} - 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 VaultListResult} 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.
     */
    listBySubscription(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._listBySubscription(options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listBySubscription(options, optionalCallback);
      }
    }
  
    /**
     * Gets information about the deleted vaults in a subscription.
     *
     * @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<DeletedVaultListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listDeletedWithHttpOperationResponse(options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listDeleted(options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets information about the deleted vaults in a subscription.
     *
     * @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 {DeletedVaultListResult} - 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 DeletedVaultListResult} 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.
     */
    listDeleted(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._listDeleted(options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listDeleted(options, optionalCallback);
      }
    }
  
    /**
     * Gets the deleted Azure key vault.
     *
     * @param {string} vaultName The name of the vault.
     *
     * @param {string} location The location of the deleted vault.
     *
     * @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<DeletedVault>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getDeletedWithHttpOperationResponse(vaultName, location, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getDeleted(vaultName, location, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets the deleted Azure key vault.
     *
     * @param {string} vaultName The name of the vault.
     *
     * @param {string} location The location of the deleted vault.
     *
     * @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 {DeletedVault} - 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 DeletedVault} 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.
     */
    getDeleted(vaultName, location, 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._getDeleted(vaultName, location, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getDeleted(vaultName, location, options, optionalCallback);
      }
    }
  
    /**
     * Permanently deletes the specified vault. aka Purges the deleted Azure key
     * vault.
     *
     * @param {string} vaultName The name of the soft-deleted vault.
     *
     * @param {string} location The location of the soft-deleted vault.
     *
     * @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.
     */
    purgeDeletedWithHttpOperationResponse(vaultName, location, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._purgeDeleted(vaultName, location, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Permanently deletes the specified vault. aka Purges the deleted Azure key
     * vault.
     *
     * @param {string} vaultName The name of the soft-deleted vault.
     *
     * @param {string} location The location of the soft-deleted vault.
     *
     * @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.
     */
    purgeDeleted(vaultName, location, 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._purgeDeleted(vaultName, location, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._purgeDeleted(vaultName, location, options, optionalCallback);
      }
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {number} [options.top] Maximum number of results to return.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<ResourceListResult>} - 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;
        });
      });
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {number} [options.top] Maximum number of results to return.
     *
     * @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 {ResourceListResult} - 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 ResourceListResult} 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);
      }
    }
  
    /**
     * Checks that the vault name is valid and is not already in use.
     *
     * @param {object} vaultName The name of the vault.
     *
     * @param {string} vaultName.name The vault 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<CheckNameAvailabilityResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    checkNameAvailabilityWithHttpOperationResponse(vaultName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._checkNameAvailability(vaultName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Checks that the vault name is valid and is not already in use.
     *
     * @param {object} vaultName The name of the vault.
     *
     * @param {string} vaultName.name The vault 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 {CheckNameAvailabilityResult} - The deserialized result object.
     *
     *                      @reject {Error} - The error object.
     *
     * {function} optionalCallback(err, result, request, response)
     *
     *                      {Error}  err        - The Error object if an error occurred, null otherwise.
     *
     *                      {object} [result]   - The deserialized result object if an error did not occur.
     *                      See {@link CheckNameAvailabilityResult} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    checkNameAvailability(vaultName, 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._checkNameAvailability(vaultName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._checkNameAvailability(vaultName, options, optionalCallback);
      }
    }
  
    /**
     * Create or update a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the server belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {object} parameters Parameters to create or update the vault
     *
     * @param {string} parameters.location The supported Azure location where the
     * key vault should be created.
     *
     * @param {object} [parameters.tags] The tags that will be assigned to the key
     * vault.
     *
     * @param {object} parameters.properties Properties of the vault
     *
     * @param {uuid} parameters.properties.tenantId The Azure Active Directory
     * tenant ID that should be used for authenticating requests to the key vault.
     *
     * @param {object} parameters.properties.sku SKU details
     *
     * @param {string} parameters.properties.sku.name SKU name to specify whether
     * the key vault is a standard vault or a premium vault. Possible values
     * include: 'standard', 'premium'
     *
     * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant ID.
     *
     * @param {string} [parameters.properties.vaultUri] The URI of the vault for
     * performing operations on keys and secrets.
     *
     * @param {boolean} [parameters.properties.enabledForDeployment] Property to
     * specify whether Azure Virtual Machines are permitted to retrieve
     * certificates stored as secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
     * to specify whether Azure Disk Encryption is permitted to retrieve secrets
     * from the vault and unwrap keys.
     *
     * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
     * Property to specify whether Azure Resource Manager is permitted to retrieve
     * secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enableSoftDelete] Property to
     * specify whether the 'soft delete' functionality is enabled for this key
     * vault. It does not accept false value.
     *
     * @param {string} [parameters.properties.createMode] The vault's create mode
     * to indicate whether the vault need to be recovered or not. Possible values
     * include: 'recover', 'default'
     *
     * @param {boolean} [parameters.properties.enablePurgeProtection] Property
     * specifying whether protection against purge is enabled for this vault.
     * Setting this property to true activates protection against purge for this
     * vault and its content - only the Key Vault service may initiate a hard,
     * irrecoverable deletion. The setting is effective only if soft delete is also
     * enabled. Enabling this functionality is irreversible - that is, the property
     * does not accept false as its value.
     *
     * @param {object} [parameters.properties.networkAcls] A collection of rules
     * governing the accessibility of the vault from specific network locations.
     *
     * @param {string} [parameters.properties.networkAcls.bypass] Tells what
     * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
     * not specified the default is 'AzureServices'. Possible values include:
     * 'AzureServices', 'None'
     *
     * @param {string} [parameters.properties.networkAcls.defaultAction] The
     * default action when no rule from ipRules and from virtualNetworkRules match.
     * This is only used after the bypass property has been evaluated. Possible
     * values include: 'Allow', 'Deny'
     *
     * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
     * address rules.
     *
     * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
     * list of virtual network rules.
     *
     * @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<Vault>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, vaultName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginCreateOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Create or update a key vault in the specified subscription.
     *
     * @param {string} resourceGroupName The name of the Resource Group to which
     * the server belongs.
     *
     * @param {string} vaultName Name of the vault
     *
     * @param {object} parameters Parameters to create or update the vault
     *
     * @param {string} parameters.location The supported Azure location where the
     * key vault should be created.
     *
     * @param {object} [parameters.tags] The tags that will be assigned to the key
     * vault.
     *
     * @param {object} parameters.properties Properties of the vault
     *
     * @param {uuid} parameters.properties.tenantId The Azure Active Directory
     * tenant ID that should be used for authenticating requests to the key vault.
     *
     * @param {object} parameters.properties.sku SKU details
     *
     * @param {string} parameters.properties.sku.name SKU name to specify whether
     * the key vault is a standard vault or a premium vault. Possible values
     * include: 'standard', 'premium'
     *
     * @param {array} [parameters.properties.accessPolicies] An array of 0 to 16
     * identities that have access to the key vault. All identities in the array
     * must use the same tenant ID as the key vault's tenant ID.
     *
     * @param {string} [parameters.properties.vaultUri] The URI of the vault for
     * performing operations on keys and secrets.
     *
     * @param {boolean} [parameters.properties.enabledForDeployment] Property to
     * specify whether Azure Virtual Machines are permitted to retrieve
     * certificates stored as secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enabledForDiskEncryption] Property
     * to specify whether Azure Disk Encryption is permitted to retrieve secrets
     * from the vault and unwrap keys.
     *
     * @param {boolean} [parameters.properties.enabledForTemplateDeployment]
     * Property to specify whether Azure Resource Manager is permitted to retrieve
     * secrets from the key vault.
     *
     * @param {boolean} [parameters.properties.enableSoftDelete] Property to
     * specify whether the 'soft delete' functionality is enabled for this key
     * vault. It does not accept false value.
     *
     * @param {string} [parameters.properties.createMode] The vault's create mode
     * to indicate whether the vault need to be recovered or not. Possible values
     * include: 'recover', 'default'
     *
     * @param {boolean} [parameters.properties.enablePurgeProtection] Property
     * specifying whether protection against purge is enabled for this vault.
     * Setting this property to true activates protection against purge for this
     * vault and its content - only the Key Vault service may initiate a hard,
     * irrecoverable deletion. The setting is effective only if soft delete is also
     * enabled. Enabling this functionality is irreversible - that is, the property
     * does not accept false as its value.
     *
     * @param {object} [parameters.properties.networkAcls] A collection of rules
     * governing the accessibility of the vault from specific network locations.
     *
     * @param {string} [parameters.properties.networkAcls.bypass] Tells what
     * traffic can bypass network rules. This can be 'AzureServices' or 'None'.  If
     * not specified the default is 'AzureServices'. Possible values include:
     * 'AzureServices', 'None'
     *
     * @param {string} [parameters.properties.networkAcls.defaultAction] The
     * default action when no rule from ipRules and from virtualNetworkRules match.
     * This is only used after the bypass property has been evaluated. Possible
     * values include: 'Allow', 'Deny'
     *
     * @param {array} [parameters.properties.networkAcls.ipRules] The list of IP
     * address rules.
     *
     * @param {array} [parameters.properties.networkAcls.virtualNetworkRules] The
     * list of virtual network rules.
     *
     * @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 {Vault} - 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 Vault} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    beginCreateOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._beginCreateOrUpdate(resourceGroupName, vaultName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginCreateOrUpdate(resourceGroupName, vaultName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Permanently deletes the specified vault. aka Purges the deleted Azure key
     * vault.
     *
     * @param {string} vaultName The name of the soft-deleted vault.
     *
     * @param {string} location The location of the soft-deleted vault.
     *
     * @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.
     */
    beginPurgeDeletedWithHttpOperationResponse(vaultName, location, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginPurgeDeleted(vaultName, location, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Permanently deletes the specified vault. aka Purges the deleted Azure key
     * vault.
     *
     * @param {string} vaultName The name of the soft-deleted vault.
     *
     * @param {string} location The location of the soft-deleted vault.
     *
     * @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.
     */
    beginPurgeDeleted(vaultName, location, 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._beginPurgeDeleted(vaultName, location, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginPurgeDeleted(vaultName, location, options, optionalCallback);
      }
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription and within the specified resource group.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<VaultListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription and within the specified resource group.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {VaultListResult} - 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 VaultListResult} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    listByResourceGroupNext(nextPageLink, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listByResourceGroupNext(nextPageLink, options, optionalCallback);
      }
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<VaultListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listBySubscriptionNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {VaultListResult} - 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 VaultListResult} 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.
     */
    listBySubscriptionNext(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._listBySubscriptionNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listBySubscriptionNext(nextPageLink, options, optionalCallback);
      }
    }
  
    /**
     * Gets information about the deleted vaults in a subscription.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<DeletedVaultListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listDeletedNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listDeletedNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets information about the deleted vaults in a subscription.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {DeletedVaultListResult} - 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 DeletedVaultListResult} 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.
     */
    listDeletedNext(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._listDeletedNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listDeletedNext(nextPageLink, options, optionalCallback);
      }
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<ResourceListResult>} - 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;
        });
      });
    }
  
    /**
     * The List operation gets information about the vaults associated with the
     * subscription.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {ResourceListResult} - 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 ResourceListResult} 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 = Vaults;
  