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;
  
  
  /**
   * Creates or updates a virtual network gateway in the specified resource
   * group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} parameters Parameters supplied to create or update virtual
   * network gateway operation.
   *
   * @param {array} [parameters.ipConfigurations] IP configurations for virtual
   * network gateway.
   *
   * @param {string} [parameters.gatewayType] The type of this virtual network
   * gateway. Possible values are: 'Vpn' and 'ExpressRoute'. Possible values
   * include: 'Vpn', 'ExpressRoute'
   *
   * @param {string} [parameters.vpnType] The type of this virtual network
   * gateway. Possible values are: 'PolicyBased' and 'RouteBased'. Possible
   * values include: 'PolicyBased', 'RouteBased'
   *
   * @param {boolean} [parameters.enableBgp] Whether BGP is enabled for this
   * virtual network gateway or not.
   *
   * @param {boolean} [parameters.activeActive] ActiveActive flag
   *
   * @param {object} [parameters.gatewayDefaultSite] The reference of the
   * LocalNetworkGateway resource which represents local network site having
   * default routes. Assign Null value in case of removing existing default site
   * setting.
   *
   * @param {string} [parameters.gatewayDefaultSite.id] Resource ID.
   *
   * @param {object} [parameters.sku] The reference of the
   * VirtualNetworkGatewaySku resource which represents the SKU selected for
   * Virtual network gateway.
   *
   * @param {string} [parameters.sku.name] Gateway SKU name. Possible values
   * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
   * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
   * 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {string} [parameters.sku.tier] Gateway SKU tier. Possible values
   * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
   * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
   * 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {number} [parameters.sku.capacity] The capacity.
   *
   * @param {object} [parameters.vpnClientConfiguration] The reference of the
   * VpnClientConfiguration resource which represents the P2S VpnClient
   * configurations.
   *
   * @param {object} [parameters.vpnClientConfiguration.vpnClientAddressPool] The
   * reference of the address space resource which represents Address space for
   * P2S VpnClient.
   *
   * @param {array} [parameters.vpnClientConfiguration.vpnClientRootCertificates]
   * VpnClientRootCertificate for virtual network gateway.
   *
   * @param {array}
   * [parameters.vpnClientConfiguration.vpnClientRevokedCertificates]
   * VpnClientRevokedCertificate for Virtual network gateway.
   *
   * @param {array} [parameters.vpnClientConfiguration.vpnClientProtocols]
   * VpnClientProtocols for Virtual network gateway.
   *
   * @param {array} [parameters.vpnClientConfiguration.vpnClientIpsecPolicies]
   * VpnClientIpsecPolicies for virtual network gateway P2S client.
   *
   * @param {string} [parameters.vpnClientConfiguration.radiusServerAddress] The
   * radius server address property of the VirtualNetworkGateway resource for vpn
   * client connection.
   *
   * @param {string} [parameters.vpnClientConfiguration.radiusServerSecret] The
   * radius secret property of the VirtualNetworkGateway resource for vpn client
   * connection.
   *
   * @param {object} [parameters.bgpSettings] Virtual network gateway's BGP
   * speaker settings.
   *
   * @param {number} [parameters.bgpSettings.asn] The BGP speaker's ASN.
   *
   * @param {string} [parameters.bgpSettings.bgpPeeringAddress] The BGP peering
   * address and BGP identifier of this BGP speaker.
   *
   * @param {number} [parameters.bgpSettings.peerWeight] The weight added to
   * routes learned from this BGP speaker.
   *
   * @param {object} [parameters.customRoutes] The reference of the address space
   * resource which represents the custom routes address space specified by the
   * the customer for virtual network gateway and VpnClient.
   *
   * @param {array} [parameters.customRoutes.addressPrefixes] A list of address
   * blocks reserved for this virtual network in CIDR notation.
   *
   * @param {string} [parameters.resourceGuid] The resource GUID property of the
   * VirtualNetworkGateway resource.
   *
   * @param {string} [parameters.etag] Gets a unique read-only string that
   * changes whenever the resource is updated.
   *
   * @param {string} [parameters.id] Resource ID.
   *
   * @param {string} [parameters.location] Resource location.
   *
   * @param {object} [parameters.tags] Resource tags.
   *
   * @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 VirtualNetworkGateway} 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, virtualNetworkGatewayName, 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, virtualNetworkGatewayName, 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['VirtualNetworkGateway']().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 specified virtual network gateway by resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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 VirtualNetworkGateway} 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, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['VirtualNetworkGateway']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  
  /**
   * Deletes the specified virtual network gateway.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
  
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
  
    // Send request
    this.beginDeleteMethod(resourceGroupName, virtualNetworkGatewayName, 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);
      });
    });
  }
  
  
  /**
   * Updates a virtual network gateway tags.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} parameters Parameters supplied to update virtual network
   * gateway tags.
   *
   * @param {object} [parameters.tags] Resource tags.
   *
   * @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 VirtualNetworkGateway} 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 _updateTags(resourceGroupName, virtualNetworkGatewayName, 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.beginUpdateTags(resourceGroupName, virtualNetworkGatewayName, 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['VirtualNetworkGateway']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
  
        return callback(null, result, httpRequest, response);
      });
    });
  }
  
  /**
   * Gets all virtual network gateways by resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @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 VirtualNetworkGatewayListResult} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _list(resourceGroupName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (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.Network/virtualNetworkGateways';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['VirtualNetworkGatewayListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets all the connections in a virtual network gateway.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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 VirtualNetworkGatewayListConnectionsResult}
   *                      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 _listConnections(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/connections';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['VirtualNetworkGatewayListConnectionsResult']().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);
    });
  }
  
  
  /**
   * Resets the primary of the virtual network gateway in the specified resource
   * group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.gatewayVip] Virtual network gateway vip address
   * supplied to the begin reset of the active-active feature enabled gateway.
   *
   * @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 VirtualNetworkGateway} 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 _reset(resourceGroupName, virtualNetworkGatewayName, 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.beginReset(resourceGroupName, virtualNetworkGatewayName, 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['VirtualNetworkGateway']().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);
      });
    });
  }
  
  
  /**
   * Resets the VPN client shared key of the virtual network gateway in the
   * specified resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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 _resetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, 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.beginResetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, 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);
      });
    });
  }
  
  /**
   * Generates VPN client package for P2S client of the virtual network gateway
   * in the specified resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} parameters Parameters supplied to the generate virtual
   * network gateway VPN client package operation.
   *
   * @param {string} [parameters.processorArchitecture] VPN client Processor
   * Architecture. Possible values are: 'AMD64' and 'X86'. Possible values
   * include: 'Amd64', 'X86'
   *
   * @param {string} [parameters.authenticationMethod] VPN client authentication
   * method. Possible values include: 'EAPTLS', 'EAPMSCHAPv2'
   *
   * @param {string} [parameters.radiusServerAuthCertificate] The public
   * certificate data for the radius server authentication certificate as a
   * Base-64 encoded string. Required only if external radius authentication has
   * been configured with EAPTLS authentication.
   *
   * @param {array} [parameters.clientRootCertificates] A list of client root
   * certificates public certificate data encoded as Base-64 strings. Optional
   * parameter for external radius based authentication with EAPTLS.
   *
   * @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.
   *
   *                      {string} [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 _generatevpnclientpackage(resourceGroupName, virtualNetworkGatewayName, 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.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VpnClientParameters']().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 !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = {
              required: false,
              serializedName: 'parsedResponse',
              type: {
                name: 'String'
              }
            };
            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);
    });
  }
  
  /**
   * Generates VPN profile for P2S client of the virtual network gateway in the
   * specified resource group. Used for IKEV2 and radius based authentication.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} parameters Parameters supplied to the generate virtual
   * network gateway VPN client package operation.
   *
   * @param {string} [parameters.processorArchitecture] VPN client Processor
   * Architecture. Possible values are: 'AMD64' and 'X86'. Possible values
   * include: 'Amd64', 'X86'
   *
   * @param {string} [parameters.authenticationMethod] VPN client authentication
   * method. Possible values include: 'EAPTLS', 'EAPMSCHAPv2'
   *
   * @param {string} [parameters.radiusServerAuthCertificate] The public
   * certificate data for the radius server authentication certificate as a
   * Base-64 encoded string. Required only if external radius authentication has
   * been configured with EAPTLS authentication.
   *
   * @param {array} [parameters.clientRootCertificates] A list of client root
   * certificates public certificate data encoded as Base-64 strings. Optional
   * parameter for external radius based authentication with EAPTLS.
   *
   * @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.
   *
   *                      {string} [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 _generateVpnProfile(resourceGroupName, virtualNetworkGatewayName, 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.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnprofile';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VpnClientParameters']().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 !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = {
              required: false,
              serializedName: 'parsedResponse',
              type: {
                name: 'String'
              }
            };
            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 pre-generated VPN profile for P2S client of the virtual network gateway
   * in the specified resource group. The profile needs to be generated first
   * using generateVpnProfile.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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.
   *
   *                      {string} [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 _getVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, 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.beginGetVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, 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 = {
              required: false,
              serializedName: 'parsedResponse',
              type: {
                name: 'String'
              }
            };
            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 GetBgpPeerStatus operation retrieves the status of all BGP peers.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.peer] The IP address of the peer to retrieve the
   * status of.
   *
   * @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 BgpPeerStatusListResult} 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 _getBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, 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.beginGetBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, 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['BgpPeerStatusListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
  
        return callback(null, result, httpRequest, response);
      });
    });
  }
  
  /**
   * Gets a xml format representation for supported vpn devices.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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.
   *
   *                      {string} [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 _supportedVpnDevices(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/supportedvpndevices';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = {
              required: false,
              serializedName: 'parsedResponse',
              type: {
                name: 'String'
              }
            };
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  
  /**
   * This operation retrieves a list of routes the virtual network gateway has
   * learned, including routes learned from BGP peers.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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 GatewayRouteListResult} 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 _getLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, 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.beginGetLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, 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['GatewayRouteListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
  
        return callback(null, result, httpRequest, response);
      });
    });
  }
  
  
  /**
   * This operation retrieves a list of routes the virtual network gateway is
   * advertising to the specified peer.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {string} peer The IP address of the peer
   *
   * @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 GatewayRouteListResult} 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 _getAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, 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.beginGetAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, 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['GatewayRouteListResult']().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 Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy
   * for P2S client of virtual network gateway in the specified resource group
   * through Network resource provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} vpnclientIpsecParams Parameters supplied to the Begin Set
   * vpnclient ipsec parameters of Virtual Network Gateway P2S client operation
   * through Network resource provider.
   *
   * @param {number} vpnclientIpsecParams.saLifeTimeSeconds The IPSec Security
   * Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for
   * P2S client.
   *
   * @param {number} vpnclientIpsecParams.saDataSizeKilobytes The IPSec Security
   * Association (also called Quick Mode or Phase 2 SA) payload size in KB for
   * P2S client..
   *
   * @param {string} vpnclientIpsecParams.ipsecEncryption The IPSec encryption
   * algorithm (IKE phase 1). Possible values include: 'None', 'DES', 'DES3',
   * 'AES128', 'AES192', 'AES256', 'GCMAES128', 'GCMAES192', 'GCMAES256'
   *
   * @param {string} vpnclientIpsecParams.ipsecIntegrity The IPSec integrity
   * algorithm (IKE phase 1). Possible values include: 'MD5', 'SHA1', 'SHA256',
   * 'GCMAES128', 'GCMAES192', 'GCMAES256'
   *
   * @param {string} vpnclientIpsecParams.ikeEncryption The IKE encryption
   * algorithm (IKE phase 2). Possible values include: 'DES', 'DES3', 'AES128',
   * 'AES192', 'AES256', 'GCMAES256', 'GCMAES128'
   *
   * @param {string} vpnclientIpsecParams.ikeIntegrity The IKE integrity
   * algorithm (IKE phase 2). Possible values include: 'MD5', 'SHA1', 'SHA256',
   * 'SHA384', 'GCMAES256', 'GCMAES128'
   *
   * @param {string} vpnclientIpsecParams.dhGroup The DH Group used in IKE Phase
   * 1 for initial SA. Possible values include: 'None', 'DHGroup1', 'DHGroup2',
   * 'DHGroup14', 'DHGroup2048', 'ECP256', 'ECP384', 'DHGroup24'
   *
   * @param {string} vpnclientIpsecParams.pfsGroup The Pfs Group used in IKE
   * Phase 2 for new child SA. Possible values include: 'None', 'PFS1', 'PFS2',
   * 'PFS2048', 'ECP256', 'ECP384', 'PFS24', 'PFS14', 'PFSMM'
   *
   * @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 VpnClientIPsecParameters} 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 _setVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, 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.beginSetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, 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['VpnClientIPsecParameters']().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 Get VpnclientIpsecParameters operation retrieves information about the
   * vpnclient ipsec policy for P2S client of virtual network gateway in the
   * specified resource group through Network resource provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The virtual network gateway 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 VpnClientIPsecParameters} 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 _getVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, 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.beginGetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, 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['VpnClientIPsecParameters']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
  
        return callback(null, result, httpRequest, response);
      });
    });
  }
  
  /**
   * Gets a xml format representation for vpn device configuration script.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection for which the configuration script is generated.
   *
   * @param {object} parameters Parameters supplied to the generate vpn device
   * script operation.
   *
   * @param {string} [parameters.vendor] The vendor for the vpn device.
   *
   * @param {string} [parameters.deviceFamily] The device family for the vpn
   * device.
   *
   * @param {string} [parameters.firmwareVersion] The firmware version for the
   * vpn device.
   *
   * @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.
   *
   *                      {string} [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 _vpnDeviceConfigurationScript(resourceGroupName, virtualNetworkGatewayConnectionName, 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.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayConnectionName === null || virtualNetworkGatewayConnectionName === undefined || typeof virtualNetworkGatewayConnectionName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayConnectionName 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.Network/connections/{virtualNetworkGatewayConnectionName}/vpndeviceconfigurationscript';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayConnectionName}', encodeURIComponent(virtualNetworkGatewayConnectionName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VpnDeviceScriptParameters']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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 = {
              required: false,
              serializedName: 'parsedResponse',
              type: {
                name: 'String'
              }
            };
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Creates or updates a virtual network gateway in the specified resource
   * group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} parameters Parameters supplied to create or update virtual
   * network gateway operation.
   *
   * @param {array} [parameters.ipConfigurations] IP configurations for virtual
   * network gateway.
   *
   * @param {string} [parameters.gatewayType] The type of this virtual network
   * gateway. Possible values are: 'Vpn' and 'ExpressRoute'. Possible values
   * include: 'Vpn', 'ExpressRoute'
   *
   * @param {string} [parameters.vpnType] The type of this virtual network
   * gateway. Possible values are: 'PolicyBased' and 'RouteBased'. Possible
   * values include: 'PolicyBased', 'RouteBased'
   *
   * @param {boolean} [parameters.enableBgp] Whether BGP is enabled for this
   * virtual network gateway or not.
   *
   * @param {boolean} [parameters.activeActive] ActiveActive flag
   *
   * @param {object} [parameters.gatewayDefaultSite] The reference of the
   * LocalNetworkGateway resource which represents local network site having
   * default routes. Assign Null value in case of removing existing default site
   * setting.
   *
   * @param {string} [parameters.gatewayDefaultSite.id] Resource ID.
   *
   * @param {object} [parameters.sku] The reference of the
   * VirtualNetworkGatewaySku resource which represents the SKU selected for
   * Virtual network gateway.
   *
   * @param {string} [parameters.sku.name] Gateway SKU name. Possible values
   * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
   * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
   * 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {string} [parameters.sku.tier] Gateway SKU tier. Possible values
   * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
   * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
   * 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {number} [parameters.sku.capacity] The capacity.
   *
   * @param {object} [parameters.vpnClientConfiguration] The reference of the
   * VpnClientConfiguration resource which represents the P2S VpnClient
   * configurations.
   *
   * @param {object} [parameters.vpnClientConfiguration.vpnClientAddressPool] The
   * reference of the address space resource which represents Address space for
   * P2S VpnClient.
   *
   * @param {array} [parameters.vpnClientConfiguration.vpnClientRootCertificates]
   * VpnClientRootCertificate for virtual network gateway.
   *
   * @param {array}
   * [parameters.vpnClientConfiguration.vpnClientRevokedCertificates]
   * VpnClientRevokedCertificate for Virtual network gateway.
   *
   * @param {array} [parameters.vpnClientConfiguration.vpnClientProtocols]
   * VpnClientProtocols for Virtual network gateway.
   *
   * @param {array} [parameters.vpnClientConfiguration.vpnClientIpsecPolicies]
   * VpnClientIpsecPolicies for virtual network gateway P2S client.
   *
   * @param {string} [parameters.vpnClientConfiguration.radiusServerAddress] The
   * radius server address property of the VirtualNetworkGateway resource for vpn
   * client connection.
   *
   * @param {string} [parameters.vpnClientConfiguration.radiusServerSecret] The
   * radius secret property of the VirtualNetworkGateway resource for vpn client
   * connection.
   *
   * @param {object} [parameters.bgpSettings] Virtual network gateway's BGP
   * speaker settings.
   *
   * @param {number} [parameters.bgpSettings.asn] The BGP speaker's ASN.
   *
   * @param {string} [parameters.bgpSettings.bgpPeeringAddress] The BGP peering
   * address and BGP identifier of this BGP speaker.
   *
   * @param {number} [parameters.bgpSettings.peerWeight] The weight added to
   * routes learned from this BGP speaker.
   *
   * @param {object} [parameters.customRoutes] The reference of the address space
   * resource which represents the custom routes address space specified by the
   * the customer for virtual network gateway and VpnClient.
   *
   * @param {array} [parameters.customRoutes.addressPrefixes] A list of address
   * blocks reserved for this virtual network in CIDR notation.
   *
   * @param {string} [parameters.resourceGuid] The resource GUID property of the
   * VirtualNetworkGateway resource.
   *
   * @param {string} [parameters.etag] Gets a unique read-only string that
   * changes whenever the resource is updated.
   *
   * @param {string} [parameters.id] Resource ID.
   *
   * @param {string} [parameters.location] Resource location.
   *
   * @param {object} [parameters.tags] Resource tags.
   *
   * @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 VirtualNetworkGateway} 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, virtualNetworkGatewayName, 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.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['VirtualNetworkGateway']().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['VirtualNetworkGateway']().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['VirtualNetworkGateway']().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 virtual network gateway.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _beginDeleteMethod(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202 && statusCode !== 204) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Updates a virtual network gateway tags.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} parameters Parameters supplied to update virtual network
   * gateway tags.
   *
   * @param {object} [parameters.tags] Resource tags.
   *
   * @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 VirtualNetworkGateway} 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 _beginUpdateTags(resourceGroupName, virtualNetworkGatewayName, 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.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = '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['TagsObject']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            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['VirtualNetworkGateway']().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);
    });
  }
  
  /**
   * Resets the primary of the virtual network gateway in the specified resource
   * group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.gatewayVip] Virtual network gateway vip address
   * supplied to the begin reset of the active-active feature enabled gateway.
   *
   * @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 VirtualNetworkGateway} 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 _beginReset(resourceGroupName, virtualNetworkGatewayName, 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 gatewayVip = (options && options.gatewayVip !== undefined) ? options.gatewayVip : undefined;
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName cannot be null or undefined and it must be of type string.');
      }
      if (gatewayVip !== null && gatewayVip !== undefined && typeof gatewayVip.valueOf() !== 'string') {
        throw new Error('gatewayVip 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    if (gatewayVip !== null && gatewayVip !== undefined) {
      queryParameters.push('gatewayVip=' + encodeURIComponent(gatewayVip));
    }
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['VirtualNetworkGateway']().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);
    });
  }
  
  /**
   * Resets the VPN client shared key of the virtual network gateway in the
   * specified resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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 _beginResetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/resetvpnclientsharedkey';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = '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);
    });
  }
  
  /**
   * Gets pre-generated VPN profile for P2S client of the virtual network gateway
   * in the specified resource group. The profile needs to be generated first
   * using generateVpnProfile.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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.
   *
   *                      {string} [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 _beginGetVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnprofilepackageurl';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = {
              required: false,
              serializedName: 'parsedResponse',
              type: {
                name: 'String'
              }
            };
            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 GetBgpPeerStatus operation retrieves the status of all BGP peers.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.peer] The IP address of the peer to retrieve the
   * status of.
   *
   * @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 BgpPeerStatusListResult} 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 _beginGetBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, 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 peer = (options && options.peer !== undefined) ? options.peer : undefined;
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName cannot be null or undefined and it must be of type string.');
      }
      if (peer !== null && peer !== undefined && typeof peer.valueOf() !== 'string') {
        throw new Error('peer 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    if (peer !== null && peer !== undefined) {
      queryParameters.push('peer=' + encodeURIComponent(peer));
    }
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['BgpPeerStatusListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * This operation retrieves a list of routes the virtual network gateway has
   * learned, including routes learned from BGP peers.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @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 GatewayRouteListResult} 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 _beginGetLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['GatewayRouteListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * This operation retrieves a list of routes the virtual network gateway is
   * advertising to the specified peer.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {string} peer The IP address of the peer
   *
   * @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 GatewayRouteListResult} 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 _beginGetAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName cannot be null or undefined and it must be of type string.');
      }
      if (peer === null || peer === undefined || typeof peer.valueOf() !== 'string') {
        throw new Error('peer 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('peer=' + encodeURIComponent(peer));
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['GatewayRouteListResult']().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 Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy
   * for P2S client of virtual network gateway in the specified resource group
   * through Network resource provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The name of the virtual network
   * gateway.
   *
   * @param {object} vpnclientIpsecParams Parameters supplied to the Begin Set
   * vpnclient ipsec parameters of Virtual Network Gateway P2S client operation
   * through Network resource provider.
   *
   * @param {number} vpnclientIpsecParams.saLifeTimeSeconds The IPSec Security
   * Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for
   * P2S client.
   *
   * @param {number} vpnclientIpsecParams.saDataSizeKilobytes The IPSec Security
   * Association (also called Quick Mode or Phase 2 SA) payload size in KB for
   * P2S client..
   *
   * @param {string} vpnclientIpsecParams.ipsecEncryption The IPSec encryption
   * algorithm (IKE phase 1). Possible values include: 'None', 'DES', 'DES3',
   * 'AES128', 'AES192', 'AES256', 'GCMAES128', 'GCMAES192', 'GCMAES256'
   *
   * @param {string} vpnclientIpsecParams.ipsecIntegrity The IPSec integrity
   * algorithm (IKE phase 1). Possible values include: 'MD5', 'SHA1', 'SHA256',
   * 'GCMAES128', 'GCMAES192', 'GCMAES256'
   *
   * @param {string} vpnclientIpsecParams.ikeEncryption The IKE encryption
   * algorithm (IKE phase 2). Possible values include: 'DES', 'DES3', 'AES128',
   * 'AES192', 'AES256', 'GCMAES256', 'GCMAES128'
   *
   * @param {string} vpnclientIpsecParams.ikeIntegrity The IKE integrity
   * algorithm (IKE phase 2). Possible values include: 'MD5', 'SHA1', 'SHA256',
   * 'SHA384', 'GCMAES256', 'GCMAES128'
   *
   * @param {string} vpnclientIpsecParams.dhGroup The DH Group used in IKE Phase
   * 1 for initial SA. Possible values include: 'None', 'DHGroup1', 'DHGroup2',
   * 'DHGroup14', 'DHGroup2048', 'ECP256', 'ECP384', 'DHGroup24'
   *
   * @param {string} vpnclientIpsecParams.pfsGroup The Pfs Group used in IKE
   * Phase 2 for new child SA. Possible values include: 'None', 'PFS1', 'PFS2',
   * 'PFS2048', 'ECP256', 'ECP384', 'PFS24', 'PFS14', 'PFSMM'
   *
   * @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 VpnClientIPsecParameters} 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 _beginSetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName cannot be null or undefined and it must be of type string.');
      }
      if (vpnclientIpsecParams === null || vpnclientIpsecParams === undefined) {
        throw new Error('vpnclientIpsecParams 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/setvpnclientipsecparameters';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = '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 (vpnclientIpsecParams !== null && vpnclientIpsecParams !== undefined) {
        let requestModelMapper = new client.models['VpnClientIPsecParameters']().mapper();
        requestModel = client.serialize(requestModelMapper, vpnclientIpsecParams, 'vpnclientIpsecParams');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(vpnclientIpsecParams, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['VpnClientIPsecParameters']().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 Get VpnclientIpsecParameters operation retrieves information about the
   * vpnclient ipsec policy for P2S client of virtual network gateway in the
   * specified resource group through Network resource provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayName The virtual network gateway 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 VpnClientIPsecParameters} 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 _beginGetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2019-02-01';
    // 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 (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined || typeof virtualNetworkGatewayName.valueOf() !== 'string') {
        throw new Error('virtualNetworkGatewayName 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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getvpnclientipsecparameters';
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{virtualNetworkGatewayName}', encodeURIComponent(virtualNetworkGatewayName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['VpnClientIPsecParameters']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets all virtual network gateways by 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 VirtualNetworkGatewayListResult} 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['VirtualNetworkGatewayListResult']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Gets all the connections in a virtual network gateway.
   *
   * @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 VirtualNetworkGatewayListConnectionsResult}
   *                      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 _listConnectionsNext(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['VirtualNetworkGatewayListConnectionsResult']().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 VirtualNetworkGateways. */
  class VirtualNetworkGateways {
    /**
     * Create a VirtualNetworkGateways.
     * @param {NetworkManagementClient} client Reference to the service client.
     */
    constructor(client) {
      this.client = client;
      this._createOrUpdate = _createOrUpdate;
      this._get = _get;
      this._deleteMethod = _deleteMethod;
      this._updateTags = _updateTags;
      this._list = _list;
      this._listConnections = _listConnections;
      this._reset = _reset;
      this._resetVpnClientSharedKey = _resetVpnClientSharedKey;
      this._generatevpnclientpackage = _generatevpnclientpackage;
      this._generateVpnProfile = _generateVpnProfile;
      this._getVpnProfilePackageUrl = _getVpnProfilePackageUrl;
      this._getBgpPeerStatus = _getBgpPeerStatus;
      this._supportedVpnDevices = _supportedVpnDevices;
      this._getLearnedRoutes = _getLearnedRoutes;
      this._getAdvertisedRoutes = _getAdvertisedRoutes;
      this._setVpnclientIpsecParameters = _setVpnclientIpsecParameters;
      this._getVpnclientIpsecParameters = _getVpnclientIpsecParameters;
      this._vpnDeviceConfigurationScript = _vpnDeviceConfigurationScript;
      this._beginCreateOrUpdate = _beginCreateOrUpdate;
      this._beginDeleteMethod = _beginDeleteMethod;
      this._beginUpdateTags = _beginUpdateTags;
      this._beginReset = _beginReset;
      this._beginResetVpnClientSharedKey = _beginResetVpnClientSharedKey;
      this._beginGetVpnProfilePackageUrl = _beginGetVpnProfilePackageUrl;
      this._beginGetBgpPeerStatus = _beginGetBgpPeerStatus;
      this._beginGetLearnedRoutes = _beginGetLearnedRoutes;
      this._beginGetAdvertisedRoutes = _beginGetAdvertisedRoutes;
      this._beginSetVpnclientIpsecParameters = _beginSetVpnclientIpsecParameters;
      this._beginGetVpnclientIpsecParameters = _beginGetVpnclientIpsecParameters;
      this._listNext = _listNext;
      this._listConnectionsNext = _listConnectionsNext;
    }
  
    /**
     * Creates or updates a virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to create or update virtual
     * network gateway operation.
     *
     * @param {array} [parameters.ipConfigurations] IP configurations for virtual
     * network gateway.
     *
     * @param {string} [parameters.gatewayType] The type of this virtual network
     * gateway. Possible values are: 'Vpn' and 'ExpressRoute'. Possible values
     * include: 'Vpn', 'ExpressRoute'
     *
     * @param {string} [parameters.vpnType] The type of this virtual network
     * gateway. Possible values are: 'PolicyBased' and 'RouteBased'. Possible
     * values include: 'PolicyBased', 'RouteBased'
     *
     * @param {boolean} [parameters.enableBgp] Whether BGP is enabled for this
     * virtual network gateway or not.
     *
     * @param {boolean} [parameters.activeActive] ActiveActive flag
     *
     * @param {object} [parameters.gatewayDefaultSite] The reference of the
     * LocalNetworkGateway resource which represents local network site having
     * default routes. Assign Null value in case of removing existing default site
     * setting.
     *
     * @param {string} [parameters.gatewayDefaultSite.id] Resource ID.
     *
     * @param {object} [parameters.sku] The reference of the
     * VirtualNetworkGatewaySku resource which represents the SKU selected for
     * Virtual network gateway.
     *
     * @param {string} [parameters.sku.name] Gateway SKU name. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {string} [parameters.sku.tier] Gateway SKU tier. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {number} [parameters.sku.capacity] The capacity.
     *
     * @param {object} [parameters.vpnClientConfiguration] The reference of the
     * VpnClientConfiguration resource which represents the P2S VpnClient
     * configurations.
     *
     * @param {object} [parameters.vpnClientConfiguration.vpnClientAddressPool] The
     * reference of the address space resource which represents Address space for
     * P2S VpnClient.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientRootCertificates]
     * VpnClientRootCertificate for virtual network gateway.
     *
     * @param {array}
     * [parameters.vpnClientConfiguration.vpnClientRevokedCertificates]
     * VpnClientRevokedCertificate for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientProtocols]
     * VpnClientProtocols for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientIpsecPolicies]
     * VpnClientIpsecPolicies for virtual network gateway P2S client.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerAddress] The
     * radius server address property of the VirtualNetworkGateway resource for vpn
     * client connection.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerSecret] The
     * radius secret property of the VirtualNetworkGateway resource for vpn client
     * connection.
     *
     * @param {object} [parameters.bgpSettings] Virtual network gateway's BGP
     * speaker settings.
     *
     * @param {number} [parameters.bgpSettings.asn] The BGP speaker's ASN.
     *
     * @param {string} [parameters.bgpSettings.bgpPeeringAddress] The BGP peering
     * address and BGP identifier of this BGP speaker.
     *
     * @param {number} [parameters.bgpSettings.peerWeight] The weight added to
     * routes learned from this BGP speaker.
     *
     * @param {object} [parameters.customRoutes] The reference of the address space
     * resource which represents the custom routes address space specified by the
     * the customer for virtual network gateway and VpnClient.
     *
     * @param {array} [parameters.customRoutes.addressPrefixes] A list of address
     * blocks reserved for this virtual network in CIDR notation.
     *
     * @param {string} [parameters.resourceGuid] The resource GUID property of the
     * VirtualNetworkGateway resource.
     *
     * @param {string} [parameters.etag] Gets a unique read-only string that
     * changes whenever the resource is updated.
     *
     * @param {string} [parameters.id] Resource ID.
     *
     * @param {string} [parameters.location] Resource location.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    createOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._createOrUpdate(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Creates or updates a virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to create or update virtual
     * network gateway operation.
     *
     * @param {array} [parameters.ipConfigurations] IP configurations for virtual
     * network gateway.
     *
     * @param {string} [parameters.gatewayType] The type of this virtual network
     * gateway. Possible values are: 'Vpn' and 'ExpressRoute'. Possible values
     * include: 'Vpn', 'ExpressRoute'
     *
     * @param {string} [parameters.vpnType] The type of this virtual network
     * gateway. Possible values are: 'PolicyBased' and 'RouteBased'. Possible
     * values include: 'PolicyBased', 'RouteBased'
     *
     * @param {boolean} [parameters.enableBgp] Whether BGP is enabled for this
     * virtual network gateway or not.
     *
     * @param {boolean} [parameters.activeActive] ActiveActive flag
     *
     * @param {object} [parameters.gatewayDefaultSite] The reference of the
     * LocalNetworkGateway resource which represents local network site having
     * default routes. Assign Null value in case of removing existing default site
     * setting.
     *
     * @param {string} [parameters.gatewayDefaultSite.id] Resource ID.
     *
     * @param {object} [parameters.sku] The reference of the
     * VirtualNetworkGatewaySku resource which represents the SKU selected for
     * Virtual network gateway.
     *
     * @param {string} [parameters.sku.name] Gateway SKU name. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {string} [parameters.sku.tier] Gateway SKU tier. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {number} [parameters.sku.capacity] The capacity.
     *
     * @param {object} [parameters.vpnClientConfiguration] The reference of the
     * VpnClientConfiguration resource which represents the P2S VpnClient
     * configurations.
     *
     * @param {object} [parameters.vpnClientConfiguration.vpnClientAddressPool] The
     * reference of the address space resource which represents Address space for
     * P2S VpnClient.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientRootCertificates]
     * VpnClientRootCertificate for virtual network gateway.
     *
     * @param {array}
     * [parameters.vpnClientConfiguration.vpnClientRevokedCertificates]
     * VpnClientRevokedCertificate for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientProtocols]
     * VpnClientProtocols for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientIpsecPolicies]
     * VpnClientIpsecPolicies for virtual network gateway P2S client.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerAddress] The
     * radius server address property of the VirtualNetworkGateway resource for vpn
     * client connection.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerSecret] The
     * radius secret property of the VirtualNetworkGateway resource for vpn client
     * connection.
     *
     * @param {object} [parameters.bgpSettings] Virtual network gateway's BGP
     * speaker settings.
     *
     * @param {number} [parameters.bgpSettings.asn] The BGP speaker's ASN.
     *
     * @param {string} [parameters.bgpSettings.bgpPeeringAddress] The BGP peering
     * address and BGP identifier of this BGP speaker.
     *
     * @param {number} [parameters.bgpSettings.peerWeight] The weight added to
     * routes learned from this BGP speaker.
     *
     * @param {object} [parameters.customRoutes] The reference of the address space
     * resource which represents the custom routes address space specified by the
     * the customer for virtual network gateway and VpnClient.
     *
     * @param {array} [parameters.customRoutes.addressPrefixes] A list of address
     * blocks reserved for this virtual network in CIDR notation.
     *
     * @param {string} [parameters.resourceGuid] The resource GUID property of the
     * VirtualNetworkGateway resource.
     *
     * @param {string} [parameters.etag] Gets a unique read-only string that
     * changes whenever the resource is updated.
     *
     * @param {string} [parameters.id] Resource ID.
     *
     * @param {string} [parameters.location] Resource location.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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, virtualNetworkGatewayName, 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, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._createOrUpdate(resourceGroupName, virtualNetworkGatewayName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Gets the specified virtual network gateway by resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, virtualNetworkGatewayName, 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 virtual network gateway by resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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, virtualNetworkGatewayName, 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, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._get(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Deletes the specified virtual network gateway.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, virtualNetworkGatewayName, 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 virtual network gateway.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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, virtualNetworkGatewayName, 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, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._deleteMethod(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Updates a virtual network gateway tags.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to update virtual network
     * gateway tags.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    updateTagsWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._updateTags(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Updates a virtual network gateway tags.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to update virtual network
     * gateway tags.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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.
     */
    updateTags(resourceGroupName, virtualNetworkGatewayName, 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._updateTags(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._updateTags(resourceGroupName, virtualNetworkGatewayName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Gets all virtual network gateways by resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @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<VirtualNetworkGatewayListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listWithHttpOperationResponse(resourceGroupName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._list(resourceGroupName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets all virtual network gateways by resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @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 {VirtualNetworkGatewayListResult} - 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 VirtualNetworkGatewayListResult} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    list(resourceGroupName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._list(resourceGroupName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._list(resourceGroupName, options, optionalCallback);
      }
    }
  
    /**
     * Gets all the connections in a virtual network gateway.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<VirtualNetworkGatewayListConnectionsResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listConnectionsWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listConnections(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets all the connections in a virtual network gateway.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {VirtualNetworkGatewayListConnectionsResult} - 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 VirtualNetworkGatewayListConnectionsResult}
     *                      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.
     */
    listConnections(resourceGroupName, virtualNetworkGatewayName, 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._listConnections(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listConnections(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Resets the primary of the virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.gatewayVip] Virtual network gateway vip address
     * supplied to the begin reset of the active-active feature enabled gateway.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    resetWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._reset(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Resets the primary of the virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.gatewayVip] Virtual network gateway vip address
     * supplied to the begin reset of the active-active feature enabled gateway.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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.
     */
    reset(resourceGroupName, virtualNetworkGatewayName, 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._reset(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._reset(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Resets the VPN client shared key of the virtual network gateway in the
     * specified resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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.
     */
    resetVpnClientSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._resetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Resets the VPN client shared key of the virtual network gateway in the
     * specified resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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.
     */
    resetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, 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._resetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._resetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Generates VPN client package for P2S client of the virtual network gateway
     * in the specified resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to the generate virtual
     * network gateway VPN client package operation.
     *
     * @param {string} [parameters.processorArchitecture] VPN client Processor
     * Architecture. Possible values are: 'AMD64' and 'X86'. Possible values
     * include: 'Amd64', 'X86'
     *
     * @param {string} [parameters.authenticationMethod] VPN client authentication
     * method. Possible values include: 'EAPTLS', 'EAPMSCHAPv2'
     *
     * @param {string} [parameters.radiusServerAuthCertificate] The public
     * certificate data for the radius server authentication certificate as a
     * Base-64 encoded string. Required only if external radius authentication has
     * been configured with EAPTLS authentication.
     *
     * @param {array} [parameters.clientRootCertificates] A list of client root
     * certificates public certificate data encoded as Base-64 strings. Optional
     * parameter for external radius based authentication with EAPTLS.
     *
     * @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<String>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    generatevpnclientpackageWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._generatevpnclientpackage(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Generates VPN client package for P2S client of the virtual network gateway
     * in the specified resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to the generate virtual
     * network gateway VPN client package operation.
     *
     * @param {string} [parameters.processorArchitecture] VPN client Processor
     * Architecture. Possible values are: 'AMD64' and 'X86'. Possible values
     * include: 'Amd64', 'X86'
     *
     * @param {string} [parameters.authenticationMethod] VPN client authentication
     * method. Possible values include: 'EAPTLS', 'EAPMSCHAPv2'
     *
     * @param {string} [parameters.radiusServerAuthCertificate] The public
     * certificate data for the radius server authentication certificate as a
     * Base-64 encoded string. Required only if external radius authentication has
     * been configured with EAPTLS authentication.
     *
     * @param {array} [parameters.clientRootCertificates] A list of client root
     * certificates public certificate data encoded as Base-64 strings. Optional
     * parameter for external radius based authentication with EAPTLS.
     *
     * @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 {String} - 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.
     *
     *                      {string} [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.
     */
    generatevpnclientpackage(resourceGroupName, virtualNetworkGatewayName, 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._generatevpnclientpackage(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._generatevpnclientpackage(resourceGroupName, virtualNetworkGatewayName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Generates VPN profile for P2S client of the virtual network gateway in the
     * specified resource group. Used for IKEV2 and radius based authentication.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to the generate virtual
     * network gateway VPN client package operation.
     *
     * @param {string} [parameters.processorArchitecture] VPN client Processor
     * Architecture. Possible values are: 'AMD64' and 'X86'. Possible values
     * include: 'Amd64', 'X86'
     *
     * @param {string} [parameters.authenticationMethod] VPN client authentication
     * method. Possible values include: 'EAPTLS', 'EAPMSCHAPv2'
     *
     * @param {string} [parameters.radiusServerAuthCertificate] The public
     * certificate data for the radius server authentication certificate as a
     * Base-64 encoded string. Required only if external radius authentication has
     * been configured with EAPTLS authentication.
     *
     * @param {array} [parameters.clientRootCertificates] A list of client root
     * certificates public certificate data encoded as Base-64 strings. Optional
     * parameter for external radius based authentication with EAPTLS.
     *
     * @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<String>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    generateVpnProfileWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._generateVpnProfile(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Generates VPN profile for P2S client of the virtual network gateway in the
     * specified resource group. Used for IKEV2 and radius based authentication.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to the generate virtual
     * network gateway VPN client package operation.
     *
     * @param {string} [parameters.processorArchitecture] VPN client Processor
     * Architecture. Possible values are: 'AMD64' and 'X86'. Possible values
     * include: 'Amd64', 'X86'
     *
     * @param {string} [parameters.authenticationMethod] VPN client authentication
     * method. Possible values include: 'EAPTLS', 'EAPMSCHAPv2'
     *
     * @param {string} [parameters.radiusServerAuthCertificate] The public
     * certificate data for the radius server authentication certificate as a
     * Base-64 encoded string. Required only if external radius authentication has
     * been configured with EAPTLS authentication.
     *
     * @param {array} [parameters.clientRootCertificates] A list of client root
     * certificates public certificate data encoded as Base-64 strings. Optional
     * parameter for external radius based authentication with EAPTLS.
     *
     * @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 {String} - 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.
     *
     *                      {string} [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.
     */
    generateVpnProfile(resourceGroupName, virtualNetworkGatewayName, 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._generateVpnProfile(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._generateVpnProfile(resourceGroupName, virtualNetworkGatewayName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Gets pre-generated VPN profile for P2S client of the virtual network gateway
     * in the specified resource group. The profile needs to be generated first
     * using generateVpnProfile.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<String>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getVpnProfilePackageUrlWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets pre-generated VPN profile for P2S client of the virtual network gateway
     * in the specified resource group. The profile needs to be generated first
     * using generateVpnProfile.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {String} - 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.
     *
     *                      {string} [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.
     */
    getVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, 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._getVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * The GetBgpPeerStatus operation retrieves the status of all BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.peer] The IP address of the peer to retrieve the
     * status of.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<BgpPeerStatusListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getBgpPeerStatusWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The GetBgpPeerStatus operation retrieves the status of all BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.peer] The IP address of the peer to retrieve the
     * status of.
     *
     * @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 {BgpPeerStatusListResult} - 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 BgpPeerStatusListResult} 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.
     */
    getBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, 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._getBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Gets a xml format representation for supported vpn devices.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<String>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    supportedVpnDevicesWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._supportedVpnDevices(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets a xml format representation for supported vpn devices.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {String} - 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.
     *
     *                      {string} [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.
     */
    supportedVpnDevices(resourceGroupName, virtualNetworkGatewayName, 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._supportedVpnDevices(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._supportedVpnDevices(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway has
     * learned, including routes learned from BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<GatewayRouteListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getLearnedRoutesWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway has
     * learned, including routes learned from BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {GatewayRouteListResult} - 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 GatewayRouteListResult} 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.
     */
    getLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, 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._getLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway is
     * advertising to the specified peer.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {string} peer The IP address of the peer
     *
     * @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<GatewayRouteListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getAdvertisedRoutesWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, peer, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway is
     * advertising to the specified peer.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {string} peer The IP address of the peer
     *
     * @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 {GatewayRouteListResult} - 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 GatewayRouteListResult} 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.
     */
    getAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, 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._getAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, optionalCallback);
      }
    }
  
    /**
     * The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy
     * for P2S client of virtual network gateway in the specified resource group
     * through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} vpnclientIpsecParams Parameters supplied to the Begin Set
     * vpnclient ipsec parameters of Virtual Network Gateway P2S client operation
     * through Network resource provider.
     *
     * @param {number} vpnclientIpsecParams.saLifeTimeSeconds The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for
     * P2S client.
     *
     * @param {number} vpnclientIpsecParams.saDataSizeKilobytes The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) payload size in KB for
     * P2S client..
     *
     * @param {string} vpnclientIpsecParams.ipsecEncryption The IPSec encryption
     * algorithm (IKE phase 1). Possible values include: 'None', 'DES', 'DES3',
     * 'AES128', 'AES192', 'AES256', 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ipsecIntegrity The IPSec integrity
     * algorithm (IKE phase 1). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ikeEncryption The IKE encryption
     * algorithm (IKE phase 2). Possible values include: 'DES', 'DES3', 'AES128',
     * 'AES192', 'AES256', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.ikeIntegrity The IKE integrity
     * algorithm (IKE phase 2). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'SHA384', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.dhGroup The DH Group used in IKE Phase
     * 1 for initial SA. Possible values include: 'None', 'DHGroup1', 'DHGroup2',
     * 'DHGroup14', 'DHGroup2048', 'ECP256', 'ECP384', 'DHGroup24'
     *
     * @param {string} vpnclientIpsecParams.pfsGroup The Pfs Group used in IKE
     * Phase 2 for new child SA. Possible values include: 'None', 'PFS1', 'PFS2',
     * 'PFS2048', 'ECP256', 'ECP384', 'PFS24', 'PFS14', 'PFSMM'
     *
     * @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<VpnClientIPsecParameters>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    setVpnclientIpsecParametersWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._setVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy
     * for P2S client of virtual network gateway in the specified resource group
     * through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} vpnclientIpsecParams Parameters supplied to the Begin Set
     * vpnclient ipsec parameters of Virtual Network Gateway P2S client operation
     * through Network resource provider.
     *
     * @param {number} vpnclientIpsecParams.saLifeTimeSeconds The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for
     * P2S client.
     *
     * @param {number} vpnclientIpsecParams.saDataSizeKilobytes The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) payload size in KB for
     * P2S client..
     *
     * @param {string} vpnclientIpsecParams.ipsecEncryption The IPSec encryption
     * algorithm (IKE phase 1). Possible values include: 'None', 'DES', 'DES3',
     * 'AES128', 'AES192', 'AES256', 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ipsecIntegrity The IPSec integrity
     * algorithm (IKE phase 1). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ikeEncryption The IKE encryption
     * algorithm (IKE phase 2). Possible values include: 'DES', 'DES3', 'AES128',
     * 'AES192', 'AES256', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.ikeIntegrity The IKE integrity
     * algorithm (IKE phase 2). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'SHA384', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.dhGroup The DH Group used in IKE Phase
     * 1 for initial SA. Possible values include: 'None', 'DHGroup1', 'DHGroup2',
     * 'DHGroup14', 'DHGroup2048', 'ECP256', 'ECP384', 'DHGroup24'
     *
     * @param {string} vpnclientIpsecParams.pfsGroup The Pfs Group used in IKE
     * Phase 2 for new child SA. Possible values include: 'None', 'PFS1', 'PFS2',
     * 'PFS2048', 'ECP256', 'ECP384', 'PFS24', 'PFS14', 'PFSMM'
     *
     * @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 {VpnClientIPsecParameters} - 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 VpnClientIPsecParameters} 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.
     */
    setVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, 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._setVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._setVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, optionalCallback);
      }
    }
  
    /**
     * The Get VpnclientIpsecParameters operation retrieves information about the
     * vpnclient ipsec policy for P2S client of virtual network gateway in the
     * specified resource group through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The virtual network gateway 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<VpnClientIPsecParameters>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getVpnclientIpsecParametersWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._getVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The Get VpnclientIpsecParameters operation retrieves information about the
     * vpnclient ipsec policy for P2S client of virtual network gateway in the
     * specified resource group through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The virtual network gateway 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 {VpnClientIPsecParameters} - 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 VpnClientIPsecParameters} 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.
     */
    getVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, 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._getVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._getVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Gets a xml format representation for vpn device configuration script.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
     * network gateway connection for which the configuration script is generated.
     *
     * @param {object} parameters Parameters supplied to the generate vpn device
     * script operation.
     *
     * @param {string} [parameters.vendor] The vendor for the vpn device.
     *
     * @param {string} [parameters.deviceFamily] The device family for the vpn
     * device.
     *
     * @param {string} [parameters.firmwareVersion] The firmware version for the
     * vpn device.
     *
     * @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<String>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    vpnDeviceConfigurationScriptWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._vpnDeviceConfigurationScript(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets a xml format representation for vpn device configuration script.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
     * network gateway connection for which the configuration script is generated.
     *
     * @param {object} parameters Parameters supplied to the generate vpn device
     * script operation.
     *
     * @param {string} [parameters.vendor] The vendor for the vpn device.
     *
     * @param {string} [parameters.deviceFamily] The device family for the vpn
     * device.
     *
     * @param {string} [parameters.firmwareVersion] The firmware version for the
     * vpn device.
     *
     * @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 {String} - 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.
     *
     *                      {string} [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.
     */
    vpnDeviceConfigurationScript(resourceGroupName, virtualNetworkGatewayConnectionName, 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._vpnDeviceConfigurationScript(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._vpnDeviceConfigurationScript(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Creates or updates a virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to create or update virtual
     * network gateway operation.
     *
     * @param {array} [parameters.ipConfigurations] IP configurations for virtual
     * network gateway.
     *
     * @param {string} [parameters.gatewayType] The type of this virtual network
     * gateway. Possible values are: 'Vpn' and 'ExpressRoute'. Possible values
     * include: 'Vpn', 'ExpressRoute'
     *
     * @param {string} [parameters.vpnType] The type of this virtual network
     * gateway. Possible values are: 'PolicyBased' and 'RouteBased'. Possible
     * values include: 'PolicyBased', 'RouteBased'
     *
     * @param {boolean} [parameters.enableBgp] Whether BGP is enabled for this
     * virtual network gateway or not.
     *
     * @param {boolean} [parameters.activeActive] ActiveActive flag
     *
     * @param {object} [parameters.gatewayDefaultSite] The reference of the
     * LocalNetworkGateway resource which represents local network site having
     * default routes. Assign Null value in case of removing existing default site
     * setting.
     *
     * @param {string} [parameters.gatewayDefaultSite.id] Resource ID.
     *
     * @param {object} [parameters.sku] The reference of the
     * VirtualNetworkGatewaySku resource which represents the SKU selected for
     * Virtual network gateway.
     *
     * @param {string} [parameters.sku.name] Gateway SKU name. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {string} [parameters.sku.tier] Gateway SKU tier. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {number} [parameters.sku.capacity] The capacity.
     *
     * @param {object} [parameters.vpnClientConfiguration] The reference of the
     * VpnClientConfiguration resource which represents the P2S VpnClient
     * configurations.
     *
     * @param {object} [parameters.vpnClientConfiguration.vpnClientAddressPool] The
     * reference of the address space resource which represents Address space for
     * P2S VpnClient.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientRootCertificates]
     * VpnClientRootCertificate for virtual network gateway.
     *
     * @param {array}
     * [parameters.vpnClientConfiguration.vpnClientRevokedCertificates]
     * VpnClientRevokedCertificate for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientProtocols]
     * VpnClientProtocols for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientIpsecPolicies]
     * VpnClientIpsecPolicies for virtual network gateway P2S client.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerAddress] The
     * radius server address property of the VirtualNetworkGateway resource for vpn
     * client connection.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerSecret] The
     * radius secret property of the VirtualNetworkGateway resource for vpn client
     * connection.
     *
     * @param {object} [parameters.bgpSettings] Virtual network gateway's BGP
     * speaker settings.
     *
     * @param {number} [parameters.bgpSettings.asn] The BGP speaker's ASN.
     *
     * @param {string} [parameters.bgpSettings.bgpPeeringAddress] The BGP peering
     * address and BGP identifier of this BGP speaker.
     *
     * @param {number} [parameters.bgpSettings.peerWeight] The weight added to
     * routes learned from this BGP speaker.
     *
     * @param {object} [parameters.customRoutes] The reference of the address space
     * resource which represents the custom routes address space specified by the
     * the customer for virtual network gateway and VpnClient.
     *
     * @param {array} [parameters.customRoutes.addressPrefixes] A list of address
     * blocks reserved for this virtual network in CIDR notation.
     *
     * @param {string} [parameters.resourceGuid] The resource GUID property of the
     * VirtualNetworkGateway resource.
     *
     * @param {string} [parameters.etag] Gets a unique read-only string that
     * changes whenever the resource is updated.
     *
     * @param {string} [parameters.id] Resource ID.
     *
     * @param {string} [parameters.location] Resource location.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginCreateOrUpdate(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Creates or updates a virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to create or update virtual
     * network gateway operation.
     *
     * @param {array} [parameters.ipConfigurations] IP configurations for virtual
     * network gateway.
     *
     * @param {string} [parameters.gatewayType] The type of this virtual network
     * gateway. Possible values are: 'Vpn' and 'ExpressRoute'. Possible values
     * include: 'Vpn', 'ExpressRoute'
     *
     * @param {string} [parameters.vpnType] The type of this virtual network
     * gateway. Possible values are: 'PolicyBased' and 'RouteBased'. Possible
     * values include: 'PolicyBased', 'RouteBased'
     *
     * @param {boolean} [parameters.enableBgp] Whether BGP is enabled for this
     * virtual network gateway or not.
     *
     * @param {boolean} [parameters.activeActive] ActiveActive flag
     *
     * @param {object} [parameters.gatewayDefaultSite] The reference of the
     * LocalNetworkGateway resource which represents local network site having
     * default routes. Assign Null value in case of removing existing default site
     * setting.
     *
     * @param {string} [parameters.gatewayDefaultSite.id] Resource ID.
     *
     * @param {object} [parameters.sku] The reference of the
     * VirtualNetworkGatewaySku resource which represents the SKU selected for
     * Virtual network gateway.
     *
     * @param {string} [parameters.sku.name] Gateway SKU name. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {string} [parameters.sku.tier] Gateway SKU tier. Possible values
     * include: 'Basic', 'HighPerformance', 'Standard', 'UltraPerformance',
     * 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ', 'VpnGw3AZ', 'ErGw1AZ',
     * 'ErGw2AZ', 'ErGw3AZ'
     *
     * @param {number} [parameters.sku.capacity] The capacity.
     *
     * @param {object} [parameters.vpnClientConfiguration] The reference of the
     * VpnClientConfiguration resource which represents the P2S VpnClient
     * configurations.
     *
     * @param {object} [parameters.vpnClientConfiguration.vpnClientAddressPool] The
     * reference of the address space resource which represents Address space for
     * P2S VpnClient.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientRootCertificates]
     * VpnClientRootCertificate for virtual network gateway.
     *
     * @param {array}
     * [parameters.vpnClientConfiguration.vpnClientRevokedCertificates]
     * VpnClientRevokedCertificate for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientProtocols]
     * VpnClientProtocols for Virtual network gateway.
     *
     * @param {array} [parameters.vpnClientConfiguration.vpnClientIpsecPolicies]
     * VpnClientIpsecPolicies for virtual network gateway P2S client.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerAddress] The
     * radius server address property of the VirtualNetworkGateway resource for vpn
     * client connection.
     *
     * @param {string} [parameters.vpnClientConfiguration.radiusServerSecret] The
     * radius secret property of the VirtualNetworkGateway resource for vpn client
     * connection.
     *
     * @param {object} [parameters.bgpSettings] Virtual network gateway's BGP
     * speaker settings.
     *
     * @param {number} [parameters.bgpSettings.asn] The BGP speaker's ASN.
     *
     * @param {string} [parameters.bgpSettings.bgpPeeringAddress] The BGP peering
     * address and BGP identifier of this BGP speaker.
     *
     * @param {number} [parameters.bgpSettings.peerWeight] The weight added to
     * routes learned from this BGP speaker.
     *
     * @param {object} [parameters.customRoutes] The reference of the address space
     * resource which represents the custom routes address space specified by the
     * the customer for virtual network gateway and VpnClient.
     *
     * @param {array} [parameters.customRoutes.addressPrefixes] A list of address
     * blocks reserved for this virtual network in CIDR notation.
     *
     * @param {string} [parameters.resourceGuid] The resource GUID property of the
     * VirtualNetworkGateway resource.
     *
     * @param {string} [parameters.etag] Gets a unique read-only string that
     * changes whenever the resource is updated.
     *
     * @param {string} [parameters.id] Resource ID.
     *
     * @param {string} [parameters.location] Resource location.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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, virtualNetworkGatewayName, 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, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginCreateOrUpdate(resourceGroupName, virtualNetworkGatewayName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Deletes the specified virtual network gateway.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<null>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginDeleteMethodWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(resourceGroupName, virtualNetworkGatewayName, 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 virtual network gateway.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {null} - The deserialized result object.
     *
     *                      @reject {Error} - The error object.
     *
     * {function} optionalCallback(err, result, request, response)
     *
     *                      {Error}  err        - The Error object if an error occurred, null otherwise.
     *
     *                      {null} [result]   - The deserialized result object if an error did not occur.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    beginDeleteMethod(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._beginDeleteMethod(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginDeleteMethod(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Updates a virtual network gateway tags.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to update virtual network
     * gateway tags.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginUpdateTagsWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginUpdateTags(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Updates a virtual network gateway tags.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} parameters Parameters supplied to update virtual network
     * gateway tags.
     *
     * @param {object} [parameters.tags] Resource tags.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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.
     */
    beginUpdateTags(resourceGroupName, virtualNetworkGatewayName, 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._beginUpdateTags(resourceGroupName, virtualNetworkGatewayName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginUpdateTags(resourceGroupName, virtualNetworkGatewayName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Resets the primary of the virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.gatewayVip] Virtual network gateway vip address
     * supplied to the begin reset of the active-active feature enabled gateway.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<VirtualNetworkGateway>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginResetWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginReset(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Resets the primary of the virtual network gateway in the specified resource
     * group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.gatewayVip] Virtual network gateway vip address
     * supplied to the begin reset of the active-active feature enabled gateway.
     *
     * @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 {VirtualNetworkGateway} - 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 VirtualNetworkGateway} 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.
     */
    beginReset(resourceGroupName, virtualNetworkGatewayName, 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._beginReset(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginReset(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Resets the VPN client shared key of the virtual network gateway in the
     * specified resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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.
     */
    beginResetVpnClientSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginResetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Resets the VPN client shared key of the virtual network gateway in the
     * specified resource group.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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.
     */
    beginResetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, 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._beginResetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginResetVpnClientSharedKey(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Gets pre-generated VPN profile for P2S client of the virtual network gateway
     * in the specified resource group. The profile needs to be generated first
     * using generateVpnProfile.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<String>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginGetVpnProfilePackageUrlWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginGetVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets pre-generated VPN profile for P2S client of the virtual network gateway
     * in the specified resource group. The profile needs to be generated first
     * using generateVpnProfile.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {String} - 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.
     *
     *                      {string} [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.
     */
    beginGetVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, 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._beginGetVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginGetVpnProfilePackageUrl(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * The GetBgpPeerStatus operation retrieves the status of all BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.peer] The IP address of the peer to retrieve the
     * status of.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<BgpPeerStatusListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginGetBgpPeerStatusWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginGetBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The GetBgpPeerStatus operation retrieves the status of all BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.peer] The IP address of the peer to retrieve the
     * status of.
     *
     * @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 {BgpPeerStatusListResult} - 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 BgpPeerStatusListResult} 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.
     */
    beginGetBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, 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._beginGetBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginGetBgpPeerStatus(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway has
     * learned, including routes learned from BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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<GatewayRouteListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginGetLearnedRoutesWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginGetLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway has
     * learned, including routes learned from BGP peers.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @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 {GatewayRouteListResult} - 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 GatewayRouteListResult} 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.
     */
    beginGetLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, 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._beginGetLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginGetLearnedRoutes(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway is
     * advertising to the specified peer.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {string} peer The IP address of the peer
     *
     * @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<GatewayRouteListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginGetAdvertisedRoutesWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, peer, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginGetAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * This operation retrieves a list of routes the virtual network gateway is
     * advertising to the specified peer.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {string} peer The IP address of the peer
     *
     * @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 {GatewayRouteListResult} - 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 GatewayRouteListResult} 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.
     */
    beginGetAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, 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._beginGetAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginGetAdvertisedRoutes(resourceGroupName, virtualNetworkGatewayName, peer, options, optionalCallback);
      }
    }
  
    /**
     * The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy
     * for P2S client of virtual network gateway in the specified resource group
     * through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} vpnclientIpsecParams Parameters supplied to the Begin Set
     * vpnclient ipsec parameters of Virtual Network Gateway P2S client operation
     * through Network resource provider.
     *
     * @param {number} vpnclientIpsecParams.saLifeTimeSeconds The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for
     * P2S client.
     *
     * @param {number} vpnclientIpsecParams.saDataSizeKilobytes The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) payload size in KB for
     * P2S client..
     *
     * @param {string} vpnclientIpsecParams.ipsecEncryption The IPSec encryption
     * algorithm (IKE phase 1). Possible values include: 'None', 'DES', 'DES3',
     * 'AES128', 'AES192', 'AES256', 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ipsecIntegrity The IPSec integrity
     * algorithm (IKE phase 1). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ikeEncryption The IKE encryption
     * algorithm (IKE phase 2). Possible values include: 'DES', 'DES3', 'AES128',
     * 'AES192', 'AES256', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.ikeIntegrity The IKE integrity
     * algorithm (IKE phase 2). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'SHA384', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.dhGroup The DH Group used in IKE Phase
     * 1 for initial SA. Possible values include: 'None', 'DHGroup1', 'DHGroup2',
     * 'DHGroup14', 'DHGroup2048', 'ECP256', 'ECP384', 'DHGroup24'
     *
     * @param {string} vpnclientIpsecParams.pfsGroup The Pfs Group used in IKE
     * Phase 2 for new child SA. Possible values include: 'None', 'PFS1', 'PFS2',
     * 'PFS2048', 'ECP256', 'ECP384', 'PFS24', 'PFS14', 'PFSMM'
     *
     * @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<VpnClientIPsecParameters>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginSetVpnclientIpsecParametersWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginSetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy
     * for P2S client of virtual network gateway in the specified resource group
     * through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The name of the virtual network
     * gateway.
     *
     * @param {object} vpnclientIpsecParams Parameters supplied to the Begin Set
     * vpnclient ipsec parameters of Virtual Network Gateway P2S client operation
     * through Network resource provider.
     *
     * @param {number} vpnclientIpsecParams.saLifeTimeSeconds The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) lifetime in seconds for
     * P2S client.
     *
     * @param {number} vpnclientIpsecParams.saDataSizeKilobytes The IPSec Security
     * Association (also called Quick Mode or Phase 2 SA) payload size in KB for
     * P2S client..
     *
     * @param {string} vpnclientIpsecParams.ipsecEncryption The IPSec encryption
     * algorithm (IKE phase 1). Possible values include: 'None', 'DES', 'DES3',
     * 'AES128', 'AES192', 'AES256', 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ipsecIntegrity The IPSec integrity
     * algorithm (IKE phase 1). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'GCMAES128', 'GCMAES192', 'GCMAES256'
     *
     * @param {string} vpnclientIpsecParams.ikeEncryption The IKE encryption
     * algorithm (IKE phase 2). Possible values include: 'DES', 'DES3', 'AES128',
     * 'AES192', 'AES256', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.ikeIntegrity The IKE integrity
     * algorithm (IKE phase 2). Possible values include: 'MD5', 'SHA1', 'SHA256',
     * 'SHA384', 'GCMAES256', 'GCMAES128'
     *
     * @param {string} vpnclientIpsecParams.dhGroup The DH Group used in IKE Phase
     * 1 for initial SA. Possible values include: 'None', 'DHGroup1', 'DHGroup2',
     * 'DHGroup14', 'DHGroup2048', 'ECP256', 'ECP384', 'DHGroup24'
     *
     * @param {string} vpnclientIpsecParams.pfsGroup The Pfs Group used in IKE
     * Phase 2 for new child SA. Possible values include: 'None', 'PFS1', 'PFS2',
     * 'PFS2048', 'ECP256', 'ECP384', 'PFS24', 'PFS14', 'PFSMM'
     *
     * @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 {VpnClientIPsecParameters} - 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 VpnClientIPsecParameters} 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.
     */
    beginSetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, 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._beginSetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginSetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, vpnclientIpsecParams, options, optionalCallback);
      }
    }
  
    /**
     * The Get VpnclientIpsecParameters operation retrieves information about the
     * vpnclient ipsec policy for P2S client of virtual network gateway in the
     * specified resource group through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The virtual network gateway 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<VpnClientIPsecParameters>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginGetVpnclientIpsecParametersWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginGetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * The Get VpnclientIpsecParameters operation retrieves information about the
     * vpnclient ipsec policy for P2S client of virtual network gateway in the
     * specified resource group through Network resource provider.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} virtualNetworkGatewayName The virtual network gateway 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 {VpnClientIPsecParameters} - 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 VpnClientIPsecParameters} 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.
     */
    beginGetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, 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._beginGetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginGetVpnclientIpsecParameters(resourceGroupName, virtualNetworkGatewayName, options, optionalCallback);
      }
    }
  
    /**
     * Gets all virtual network gateways by 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<VirtualNetworkGatewayListResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets all virtual network gateways by 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 {VirtualNetworkGatewayListResult} - 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 VirtualNetworkGatewayListResult} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    listNext(nextPageLink, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._listNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listNext(nextPageLink, options, optionalCallback);
      }
    }
  
    /**
     * Gets all the connections in a virtual network gateway.
     *
     * @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<VirtualNetworkGatewayListConnectionsResult>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listConnectionsNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listConnectionsNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Gets all the connections in a virtual network gateway.
     *
     * @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 {VirtualNetworkGatewayListConnectionsResult} - 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 VirtualNetworkGatewayListConnectionsResult}
     *                      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.
     */
    listConnectionsNext(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._listConnectionsNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listConnectionsNext(nextPageLink, options, optionalCallback);
      }
    }
  
  }
  
  module.exports = VirtualNetworkGateways;
  