/*
 * 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 connection in the specified
 * resource group.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @param {object} parameters Parameters supplied to the create or update
 * virtual network gateway connection operation.
 *
 * @param {string} [parameters.authorizationKey] The authorizationKey.
 *
 * @param {object} parameters.virtualNetworkGateway1 The reference to virtual
 * network gateway resource.
 *
 * @param {object} [parameters.virtualNetworkGateway2] The reference to virtual
 * network gateway resource.
 *
 * @param {array} [parameters.virtualNetworkGateway2.ipConfigurations] IP
 * configurations for virtual network gateway.
 *
 * @param {string} [parameters.virtualNetworkGateway2.gatewayType] The type of
 * this virtual network gateway. Possible values are: 'Vpn' and 'ExpressRoute'.
 * Possible values include: 'Vpn', 'ExpressRoute'
 *
 * @param {string} [parameters.virtualNetworkGateway2.vpnType] The type of this
 * virtual network gateway. Possible values are: 'PolicyBased' and
 * 'RouteBased'. Possible values include: 'PolicyBased', 'RouteBased'
 *
 * @param {boolean} [parameters.virtualNetworkGateway2.enableBgp] Whether BGP
 * is enabled for this virtual network gateway or not.
 *
 * @param {boolean} [parameters.virtualNetworkGateway2.activeActive]
 * ActiveActive flag
 *
 * @param {object} [parameters.virtualNetworkGateway2.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 {object} [parameters.virtualNetworkGateway2.sku] The reference of the
 * VirtualNetworkGatewaySku resource which represents the SKU selected for
 * Virtual network gateway.
 *
 * @param {string} [parameters.virtualNetworkGateway2.sku.name] Gateway SKU
 * name. Possible values include: 'Basic', 'HighPerformance', 'Standard',
 * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
 * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
 *
 * @param {string} [parameters.virtualNetworkGateway2.sku.tier] Gateway SKU
 * tier. Possible values include: 'Basic', 'HighPerformance', 'Standard',
 * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
 * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
 *
 * @param {number} [parameters.virtualNetworkGateway2.sku.capacity] The
 * capacity.
 *
 * @param {object} [parameters.virtualNetworkGateway2.vpnClientConfiguration]
 * The reference of the VpnClientConfiguration resource which represents the
 * P2S VpnClient configurations.
 *
 * @param {object}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientAddressPool]
 * The reference of the address space resource which represents Address space
 * for P2S VpnClient.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRootCertificates]
 * VpnClientRootCertificate for virtual network gateway.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRevokedCertificates]
 * VpnClientRevokedCertificate for Virtual network gateway.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientProtocols]
 * VpnClientProtocols for Virtual network gateway.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientIpsecPolicies]
 * VpnClientIpsecPolicies for virtual network gateway P2S client.
 *
 * @param {string}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerAddress]
 * The radius server address property of the VirtualNetworkGateway resource for
 * vpn client connection.
 *
 * @param {string}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerSecret]
 * The radius secret property of the VirtualNetworkGateway resource for vpn
 * client connection.
 *
 * @param {object} [parameters.virtualNetworkGateway2.bgpSettings] Virtual
 * network gateway's BGP speaker settings.
 *
 * @param {object} [parameters.virtualNetworkGateway2.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 {string} [parameters.virtualNetworkGateway2.resourceGuid] The
 * resource GUID property of the VirtualNetworkGateway resource.
 *
 * @param {string} [parameters.virtualNetworkGateway2.etag] Gets a unique
 * read-only string that changes whenever the resource is updated.
 *
 * @param {string} [parameters.virtualNetworkGateway2.id] Resource ID.
 *
 * @param {string} [parameters.virtualNetworkGateway2.location] Resource
 * location.
 *
 * @param {object} [parameters.virtualNetworkGateway2.tags] Resource tags.
 *
 * @param {object} [parameters.localNetworkGateway2] The reference to local
 * network gateway resource.
 *
 * @param {object} [parameters.localNetworkGateway2.localNetworkAddressSpace]
 * Local network site address space.
 *
 * @param {array}
 * [parameters.localNetworkGateway2.localNetworkAddressSpace.addressPrefixes] A
 * list of address blocks reserved for this virtual network in CIDR notation.
 *
 * @param {string} [parameters.localNetworkGateway2.gatewayIpAddress] IP
 * address of local network gateway.
 *
 * @param {object} [parameters.localNetworkGateway2.bgpSettings] Local network
 * gateway's BGP speaker settings.
 *
 * @param {number} [parameters.localNetworkGateway2.bgpSettings.asn] The BGP
 * speaker's ASN.
 *
 * @param {string}
 * [parameters.localNetworkGateway2.bgpSettings.bgpPeeringAddress] The BGP
 * peering address and BGP identifier of this BGP speaker.
 *
 * @param {number} [parameters.localNetworkGateway2.bgpSettings.peerWeight] The
 * weight added to routes learned from this BGP speaker.
 *
 * @param {string} [parameters.localNetworkGateway2.resourceGuid] The resource
 * GUID property of the LocalNetworkGateway resource.
 *
 * @param {string} [parameters.localNetworkGateway2.etag] A unique read-only
 * string that changes whenever the resource is updated.
 *
 * @param {string} [parameters.localNetworkGateway2.id] Resource ID.
 *
 * @param {string} [parameters.localNetworkGateway2.location] Resource
 * location.
 *
 * @param {object} [parameters.localNetworkGateway2.tags] Resource tags.
 *
 * @param {string} parameters.connectionType Gateway connection type. Possible
 * values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient'
 *
 * @param {string} [parameters.connectionProtocol] Connection protocol used for
 * this connection. Possible values include: 'IKEv2', 'IKEv1'
 *
 * @param {number} [parameters.routingWeight] The routing weight.
 *
 * @param {string} [parameters.sharedKey] The IPSec shared key.
 *
 * @param {object} [parameters.peer] The reference to peerings resource.
 *
 * @param {string} [parameters.peer.id] Resource ID.
 *
 * @param {boolean} [parameters.enableBgp] EnableBgp flag
 *
 * @param {boolean} [parameters.usePolicyBasedTrafficSelectors] Enable
 * policy-based traffic selectors.
 *
 * @param {array} [parameters.ipsecPolicies] The IPSec Policies to be
 * considered by this connection.
 *
 * @param {string} [parameters.resourceGuid] The resource GUID property of the
 * VirtualNetworkGatewayConnection resource.
 *
 * @param {boolean} [parameters.expressRouteGatewayBypass] Bypass ExpressRoute
 * Gateway for data forwarding
 *
 * @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 VirtualNetworkGatewayConnection} 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, 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.');
  }

  // Send request
  this.beginCreateOrUpdate(resourceGroupName, virtualNetworkGatewayConnectionName, 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['VirtualNetworkGatewayConnection']().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 connection by resource group.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @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 VirtualNetworkGatewayConnection} 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, virtualNetworkGatewayConnectionName, 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 (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}';
  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 = '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['VirtualNetworkGatewayConnection']().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 connection.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @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, virtualNetworkGatewayConnectionName, 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, virtualNetworkGatewayConnectionName, 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 connection tags.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @param {object} parameters Parameters supplied to update virtual network
 * gateway connection 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 VirtualNetworkGatewayConnection} 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, 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.');
  }

  // Send request
  this.beginUpdateTags(resourceGroupName, virtualNetworkGatewayConnectionName, 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['VirtualNetworkGatewayConnection']().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 Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual
 * network gateway connection shared key for passed virtual network gateway
 * connection in the specified resource group through Network resource
 * provider.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The virtual network
 * gateway connection name.
 *
 * @param {object} parameters Parameters supplied to the Begin Set Virtual
 * Network Gateway connection Shared key operation throughNetwork resource
 * provider.
 *
 * @param {string} parameters.value The virtual network connection shared key
 * value.
 *
 * @param {string} [parameters.id] Resource ID.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link ConnectionSharedKey} 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 _setSharedKey(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.');
  }

  // Send request
  this.beginSetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, 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['ConnectionSharedKey']().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 VirtualNetworkGatewayConnectionSharedKey operation retrieves
 * information about the specified virtual network gateway connection shared
 * key through Network resource provider.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The virtual network
 * gateway connection shared key 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 ConnectionSharedKey} 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 _getSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, 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 (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}/sharedkey';
  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 = '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['ConnectionSharedKey']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * The List VirtualNetworkGatewayConnections operation retrieves all the
 * virtual network gateways connections created.
 *
 * @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 VirtualNetworkGatewayConnectionListResult}
 *                      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/connections';
  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['VirtualNetworkGatewayConnectionListResult']().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 VirtualNetworkGatewayConnectionResetSharedKey operation resets the
 * virtual network gateway connection shared key for passed virtual network
 * gateway connection in the specified resource group through Network resource
 * provider.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The virtual network
 * gateway connection reset shared key Name.
 *
 * @param {object} parameters Parameters supplied to the begin reset virtual
 * network gateway connection shared key operation through network resource
 * provider.
 *
 * @param {number} parameters.keyLength The virtual network connection reset
 * shared key length, should between 1 and 128.
 *
 * @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 ConnectionResetSharedKey} 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 _resetSharedKey(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.');
  }

  // Send request
  this.beginResetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, 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['ConnectionResetSharedKey']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }

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

/**
 * Creates or updates a virtual network gateway connection in the specified
 * resource group.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @param {object} parameters Parameters supplied to the create or update
 * virtual network gateway connection operation.
 *
 * @param {string} [parameters.authorizationKey] The authorizationKey.
 *
 * @param {object} parameters.virtualNetworkGateway1 The reference to virtual
 * network gateway resource.
 *
 * @param {object} [parameters.virtualNetworkGateway2] The reference to virtual
 * network gateway resource.
 *
 * @param {array} [parameters.virtualNetworkGateway2.ipConfigurations] IP
 * configurations for virtual network gateway.
 *
 * @param {string} [parameters.virtualNetworkGateway2.gatewayType] The type of
 * this virtual network gateway. Possible values are: 'Vpn' and 'ExpressRoute'.
 * Possible values include: 'Vpn', 'ExpressRoute'
 *
 * @param {string} [parameters.virtualNetworkGateway2.vpnType] The type of this
 * virtual network gateway. Possible values are: 'PolicyBased' and
 * 'RouteBased'. Possible values include: 'PolicyBased', 'RouteBased'
 *
 * @param {boolean} [parameters.virtualNetworkGateway2.enableBgp] Whether BGP
 * is enabled for this virtual network gateway or not.
 *
 * @param {boolean} [parameters.virtualNetworkGateway2.activeActive]
 * ActiveActive flag
 *
 * @param {object} [parameters.virtualNetworkGateway2.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 {object} [parameters.virtualNetworkGateway2.sku] The reference of the
 * VirtualNetworkGatewaySku resource which represents the SKU selected for
 * Virtual network gateway.
 *
 * @param {string} [parameters.virtualNetworkGateway2.sku.name] Gateway SKU
 * name. Possible values include: 'Basic', 'HighPerformance', 'Standard',
 * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
 * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
 *
 * @param {string} [parameters.virtualNetworkGateway2.sku.tier] Gateway SKU
 * tier. Possible values include: 'Basic', 'HighPerformance', 'Standard',
 * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
 * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
 *
 * @param {number} [parameters.virtualNetworkGateway2.sku.capacity] The
 * capacity.
 *
 * @param {object} [parameters.virtualNetworkGateway2.vpnClientConfiguration]
 * The reference of the VpnClientConfiguration resource which represents the
 * P2S VpnClient configurations.
 *
 * @param {object}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientAddressPool]
 * The reference of the address space resource which represents Address space
 * for P2S VpnClient.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRootCertificates]
 * VpnClientRootCertificate for virtual network gateway.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRevokedCertificates]
 * VpnClientRevokedCertificate for Virtual network gateway.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientProtocols]
 * VpnClientProtocols for Virtual network gateway.
 *
 * @param {array}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientIpsecPolicies]
 * VpnClientIpsecPolicies for virtual network gateway P2S client.
 *
 * @param {string}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerAddress]
 * The radius server address property of the VirtualNetworkGateway resource for
 * vpn client connection.
 *
 * @param {string}
 * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerSecret]
 * The radius secret property of the VirtualNetworkGateway resource for vpn
 * client connection.
 *
 * @param {object} [parameters.virtualNetworkGateway2.bgpSettings] Virtual
 * network gateway's BGP speaker settings.
 *
 * @param {object} [parameters.virtualNetworkGateway2.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 {string} [parameters.virtualNetworkGateway2.resourceGuid] The
 * resource GUID property of the VirtualNetworkGateway resource.
 *
 * @param {string} [parameters.virtualNetworkGateway2.etag] Gets a unique
 * read-only string that changes whenever the resource is updated.
 *
 * @param {string} [parameters.virtualNetworkGateway2.id] Resource ID.
 *
 * @param {string} [parameters.virtualNetworkGateway2.location] Resource
 * location.
 *
 * @param {object} [parameters.virtualNetworkGateway2.tags] Resource tags.
 *
 * @param {object} [parameters.localNetworkGateway2] The reference to local
 * network gateway resource.
 *
 * @param {object} [parameters.localNetworkGateway2.localNetworkAddressSpace]
 * Local network site address space.
 *
 * @param {array}
 * [parameters.localNetworkGateway2.localNetworkAddressSpace.addressPrefixes] A
 * list of address blocks reserved for this virtual network in CIDR notation.
 *
 * @param {string} [parameters.localNetworkGateway2.gatewayIpAddress] IP
 * address of local network gateway.
 *
 * @param {object} [parameters.localNetworkGateway2.bgpSettings] Local network
 * gateway's BGP speaker settings.
 *
 * @param {number} [parameters.localNetworkGateway2.bgpSettings.asn] The BGP
 * speaker's ASN.
 *
 * @param {string}
 * [parameters.localNetworkGateway2.bgpSettings.bgpPeeringAddress] The BGP
 * peering address and BGP identifier of this BGP speaker.
 *
 * @param {number} [parameters.localNetworkGateway2.bgpSettings.peerWeight] The
 * weight added to routes learned from this BGP speaker.
 *
 * @param {string} [parameters.localNetworkGateway2.resourceGuid] The resource
 * GUID property of the LocalNetworkGateway resource.
 *
 * @param {string} [parameters.localNetworkGateway2.etag] A unique read-only
 * string that changes whenever the resource is updated.
 *
 * @param {string} [parameters.localNetworkGateway2.id] Resource ID.
 *
 * @param {string} [parameters.localNetworkGateway2.location] Resource
 * location.
 *
 * @param {object} [parameters.localNetworkGateway2.tags] Resource tags.
 *
 * @param {string} parameters.connectionType Gateway connection type. Possible
 * values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient'
 *
 * @param {string} [parameters.connectionProtocol] Connection protocol used for
 * this connection. Possible values include: 'IKEv2', 'IKEv1'
 *
 * @param {number} [parameters.routingWeight] The routing weight.
 *
 * @param {string} [parameters.sharedKey] The IPSec shared key.
 *
 * @param {object} [parameters.peer] The reference to peerings resource.
 *
 * @param {string} [parameters.peer.id] Resource ID.
 *
 * @param {boolean} [parameters.enableBgp] EnableBgp flag
 *
 * @param {boolean} [parameters.usePolicyBasedTrafficSelectors] Enable
 * policy-based traffic selectors.
 *
 * @param {array} [parameters.ipsecPolicies] The IPSec Policies to be
 * considered by this connection.
 *
 * @param {string} [parameters.resourceGuid] The resource GUID property of the
 * VirtualNetworkGatewayConnection resource.
 *
 * @param {boolean} [parameters.expressRouteGatewayBypass] Bypass ExpressRoute
 * Gateway for data forwarding
 *
 * @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 VirtualNetworkGatewayConnection} 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, 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}';
  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 = '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['VirtualNetworkGatewayConnection']().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['VirtualNetworkGatewayConnection']().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['VirtualNetworkGatewayConnection']().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 connection.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @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, virtualNetworkGatewayConnectionName, 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 (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}';
  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 = '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 connection tags.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
 * network gateway connection.
 *
 * @param {object} parameters Parameters supplied to update virtual network
 * gateway connection 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 VirtualNetworkGatewayConnection} 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, 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}';
  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 = '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['VirtualNetworkGatewayConnection']().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 Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual
 * network gateway connection shared key for passed virtual network gateway
 * connection in the specified resource group through Network resource
 * provider.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The virtual network
 * gateway connection name.
 *
 * @param {object} parameters Parameters supplied to the Begin Set Virtual
 * Network Gateway connection Shared key operation throughNetwork resource
 * provider.
 *
 * @param {string} parameters.value The virtual network connection shared key
 * value.
 *
 * @param {string} [parameters.id] Resource ID.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link ConnectionSharedKey} 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 _beginSetSharedKey(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}/sharedkey';
  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 = '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['ConnectionSharedKey']().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['ConnectionSharedKey']().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['ConnectionSharedKey']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError1.request = msRest.stripRequest(httpRequest);
        deserializationError1.response = msRest.stripResponse(response);
        return callback(deserializationError1);
      }
    }

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

/**
 * The VirtualNetworkGatewayConnectionResetSharedKey operation resets the
 * virtual network gateway connection shared key for passed virtual network
 * gateway connection in the specified resource group through Network resource
 * provider.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} virtualNetworkGatewayConnectionName The virtual network
 * gateway connection reset shared key Name.
 *
 * @param {object} parameters Parameters supplied to the begin reset virtual
 * network gateway connection shared key operation through network resource
 * provider.
 *
 * @param {number} parameters.keyLength The virtual network connection reset
 * shared key length, should between 1 and 128.
 *
 * @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 ConnectionResetSharedKey} 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 _beginResetSharedKey(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}/sharedkey/reset';
  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['ConnectionResetSharedKey']().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 = new client.models['ConnectionResetSharedKey']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * The List VirtualNetworkGatewayConnections operation retrieves all the
 * virtual network gateways connections created.
 *
 * @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 VirtualNetworkGatewayConnectionListResult}
 *                      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['VirtualNetworkGatewayConnectionListResult']().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 VirtualNetworkGatewayConnections. */
class VirtualNetworkGatewayConnections {
  /**
   * Create a VirtualNetworkGatewayConnections.
   * @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._setSharedKey = _setSharedKey;
    this._getSharedKey = _getSharedKey;
    this._list = _list;
    this._resetSharedKey = _resetSharedKey;
    this._beginCreateOrUpdate = _beginCreateOrUpdate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginUpdateTags = _beginUpdateTags;
    this._beginSetSharedKey = _beginSetSharedKey;
    this._beginResetSharedKey = _beginResetSharedKey;
    this._listNext = _listNext;
  }

  /**
   * Creates or updates a virtual network gateway connection in the specified
   * resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to the create or update
   * virtual network gateway connection operation.
   *
   * @param {string} [parameters.authorizationKey] The authorizationKey.
   *
   * @param {object} parameters.virtualNetworkGateway1 The reference to virtual
   * network gateway resource.
   *
   * @param {object} [parameters.virtualNetworkGateway2] The reference to virtual
   * network gateway resource.
   *
   * @param {array} [parameters.virtualNetworkGateway2.ipConfigurations] IP
   * configurations for virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.gatewayType] The type of
   * this virtual network gateway. Possible values are: 'Vpn' and 'ExpressRoute'.
   * Possible values include: 'Vpn', 'ExpressRoute'
   *
   * @param {string} [parameters.virtualNetworkGateway2.vpnType] The type of this
   * virtual network gateway. Possible values are: 'PolicyBased' and
   * 'RouteBased'. Possible values include: 'PolicyBased', 'RouteBased'
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.enableBgp] Whether BGP
   * is enabled for this virtual network gateway or not.
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.activeActive]
   * ActiveActive flag
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {object} [parameters.virtualNetworkGateway2.sku] The reference of the
   * VirtualNetworkGatewaySku resource which represents the SKU selected for
   * Virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.name] Gateway SKU
   * name. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.tier] Gateway SKU
   * tier. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {number} [parameters.virtualNetworkGateway2.sku.capacity] The
   * capacity.
   *
   * @param {object} [parameters.virtualNetworkGateway2.vpnClientConfiguration]
   * The reference of the VpnClientConfiguration resource which represents the
   * P2S VpnClient configurations.
   *
   * @param {object}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientAddressPool]
   * The reference of the address space resource which represents Address space
   * for P2S VpnClient.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRootCertificates]
   * VpnClientRootCertificate for virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRevokedCertificates]
   * VpnClientRevokedCertificate for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientProtocols]
   * VpnClientProtocols for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientIpsecPolicies]
   * VpnClientIpsecPolicies for virtual network gateway P2S client.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerAddress]
   * The radius server address property of the VirtualNetworkGateway resource for
   * vpn client connection.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerSecret]
   * The radius secret property of the VirtualNetworkGateway resource for vpn
   * client connection.
   *
   * @param {object} [parameters.virtualNetworkGateway2.bgpSettings] Virtual
   * network gateway's BGP speaker settings.
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {string} [parameters.virtualNetworkGateway2.resourceGuid] The
   * resource GUID property of the VirtualNetworkGateway resource.
   *
   * @param {string} [parameters.virtualNetworkGateway2.etag] Gets a unique
   * read-only string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.virtualNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.virtualNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.virtualNetworkGateway2.tags] Resource tags.
   *
   * @param {object} [parameters.localNetworkGateway2] The reference to local
   * network gateway resource.
   *
   * @param {object} [parameters.localNetworkGateway2.localNetworkAddressSpace]
   * Local network site address space.
   *
   * @param {array}
   * [parameters.localNetworkGateway2.localNetworkAddressSpace.addressPrefixes] A
   * list of address blocks reserved for this virtual network in CIDR notation.
   *
   * @param {string} [parameters.localNetworkGateway2.gatewayIpAddress] IP
   * address of local network gateway.
   *
   * @param {object} [parameters.localNetworkGateway2.bgpSettings] Local network
   * gateway's BGP speaker settings.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.asn] The BGP
   * speaker's ASN.
   *
   * @param {string}
   * [parameters.localNetworkGateway2.bgpSettings.bgpPeeringAddress] The BGP
   * peering address and BGP identifier of this BGP speaker.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.peerWeight] The
   * weight added to routes learned from this BGP speaker.
   *
   * @param {string} [parameters.localNetworkGateway2.resourceGuid] The resource
   * GUID property of the LocalNetworkGateway resource.
   *
   * @param {string} [parameters.localNetworkGateway2.etag] A unique read-only
   * string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.localNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.localNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.localNetworkGateway2.tags] Resource tags.
   *
   * @param {string} parameters.connectionType Gateway connection type. Possible
   * values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient'
   *
   * @param {string} [parameters.connectionProtocol] Connection protocol used for
   * this connection. Possible values include: 'IKEv2', 'IKEv1'
   *
   * @param {number} [parameters.routingWeight] The routing weight.
   *
   * @param {string} [parameters.sharedKey] The IPSec shared key.
   *
   * @param {object} [parameters.peer] The reference to peerings resource.
   *
   * @param {string} [parameters.peer.id] Resource ID.
   *
   * @param {boolean} [parameters.enableBgp] EnableBgp flag
   *
   * @param {boolean} [parameters.usePolicyBasedTrafficSelectors] Enable
   * policy-based traffic selectors.
   *
   * @param {array} [parameters.ipsecPolicies] The IPSec Policies to be
   * considered by this connection.
   *
   * @param {string} [parameters.resourceGuid] The resource GUID property of the
   * VirtualNetworkGatewayConnection resource.
   *
   * @param {boolean} [parameters.expressRouteGatewayBypass] Bypass ExpressRoute
   * Gateway for data forwarding
   *
   * @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<VirtualNetworkGatewayConnection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(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;
      });
    });
  }

  /**
   * Creates or updates a virtual network gateway connection in the specified
   * resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to the create or update
   * virtual network gateway connection operation.
   *
   * @param {string} [parameters.authorizationKey] The authorizationKey.
   *
   * @param {object} parameters.virtualNetworkGateway1 The reference to virtual
   * network gateway resource.
   *
   * @param {object} [parameters.virtualNetworkGateway2] The reference to virtual
   * network gateway resource.
   *
   * @param {array} [parameters.virtualNetworkGateway2.ipConfigurations] IP
   * configurations for virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.gatewayType] The type of
   * this virtual network gateway. Possible values are: 'Vpn' and 'ExpressRoute'.
   * Possible values include: 'Vpn', 'ExpressRoute'
   *
   * @param {string} [parameters.virtualNetworkGateway2.vpnType] The type of this
   * virtual network gateway. Possible values are: 'PolicyBased' and
   * 'RouteBased'. Possible values include: 'PolicyBased', 'RouteBased'
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.enableBgp] Whether BGP
   * is enabled for this virtual network gateway or not.
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.activeActive]
   * ActiveActive flag
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {object} [parameters.virtualNetworkGateway2.sku] The reference of the
   * VirtualNetworkGatewaySku resource which represents the SKU selected for
   * Virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.name] Gateway SKU
   * name. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.tier] Gateway SKU
   * tier. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {number} [parameters.virtualNetworkGateway2.sku.capacity] The
   * capacity.
   *
   * @param {object} [parameters.virtualNetworkGateway2.vpnClientConfiguration]
   * The reference of the VpnClientConfiguration resource which represents the
   * P2S VpnClient configurations.
   *
   * @param {object}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientAddressPool]
   * The reference of the address space resource which represents Address space
   * for P2S VpnClient.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRootCertificates]
   * VpnClientRootCertificate for virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRevokedCertificates]
   * VpnClientRevokedCertificate for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientProtocols]
   * VpnClientProtocols for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientIpsecPolicies]
   * VpnClientIpsecPolicies for virtual network gateway P2S client.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerAddress]
   * The radius server address property of the VirtualNetworkGateway resource for
   * vpn client connection.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerSecret]
   * The radius secret property of the VirtualNetworkGateway resource for vpn
   * client connection.
   *
   * @param {object} [parameters.virtualNetworkGateway2.bgpSettings] Virtual
   * network gateway's BGP speaker settings.
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {string} [parameters.virtualNetworkGateway2.resourceGuid] The
   * resource GUID property of the VirtualNetworkGateway resource.
   *
   * @param {string} [parameters.virtualNetworkGateway2.etag] Gets a unique
   * read-only string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.virtualNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.virtualNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.virtualNetworkGateway2.tags] Resource tags.
   *
   * @param {object} [parameters.localNetworkGateway2] The reference to local
   * network gateway resource.
   *
   * @param {object} [parameters.localNetworkGateway2.localNetworkAddressSpace]
   * Local network site address space.
   *
   * @param {array}
   * [parameters.localNetworkGateway2.localNetworkAddressSpace.addressPrefixes] A
   * list of address blocks reserved for this virtual network in CIDR notation.
   *
   * @param {string} [parameters.localNetworkGateway2.gatewayIpAddress] IP
   * address of local network gateway.
   *
   * @param {object} [parameters.localNetworkGateway2.bgpSettings] Local network
   * gateway's BGP speaker settings.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.asn] The BGP
   * speaker's ASN.
   *
   * @param {string}
   * [parameters.localNetworkGateway2.bgpSettings.bgpPeeringAddress] The BGP
   * peering address and BGP identifier of this BGP speaker.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.peerWeight] The
   * weight added to routes learned from this BGP speaker.
   *
   * @param {string} [parameters.localNetworkGateway2.resourceGuid] The resource
   * GUID property of the LocalNetworkGateway resource.
   *
   * @param {string} [parameters.localNetworkGateway2.etag] A unique read-only
   * string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.localNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.localNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.localNetworkGateway2.tags] Resource tags.
   *
   * @param {string} parameters.connectionType Gateway connection type. Possible
   * values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient'
   *
   * @param {string} [parameters.connectionProtocol] Connection protocol used for
   * this connection. Possible values include: 'IKEv2', 'IKEv1'
   *
   * @param {number} [parameters.routingWeight] The routing weight.
   *
   * @param {string} [parameters.sharedKey] The IPSec shared key.
   *
   * @param {object} [parameters.peer] The reference to peerings resource.
   *
   * @param {string} [parameters.peer.id] Resource ID.
   *
   * @param {boolean} [parameters.enableBgp] EnableBgp flag
   *
   * @param {boolean} [parameters.usePolicyBasedTrafficSelectors] Enable
   * policy-based traffic selectors.
   *
   * @param {array} [parameters.ipsecPolicies] The IPSec Policies to be
   * considered by this connection.
   *
   * @param {string} [parameters.resourceGuid] The resource GUID property of the
   * VirtualNetworkGatewayConnection resource.
   *
   * @param {boolean} [parameters.expressRouteGatewayBypass] Bypass ExpressRoute
   * Gateway for data forwarding
   *
   * @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 {VirtualNetworkGatewayConnection} - 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 VirtualNetworkGatewayConnection} 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, 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._createOrUpdate(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * Gets the specified virtual network gateway connection by resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @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<VirtualNetworkGatewayConnection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, virtualNetworkGatewayConnectionName, 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 connection by resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @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 {VirtualNetworkGatewayConnection} - 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 VirtualNetworkGatewayConnection} 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, virtualNetworkGatewayConnectionName, 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, virtualNetworkGatewayConnectionName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, virtualNetworkGatewayConnectionName, options, optionalCallback);
    }
  }

  /**
   * Deletes the specified virtual network Gateway connection.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @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, virtualNetworkGatewayConnectionName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, virtualNetworkGatewayConnectionName, 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 connection.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @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, virtualNetworkGatewayConnectionName, 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, virtualNetworkGatewayConnectionName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, virtualNetworkGatewayConnectionName, options, optionalCallback);
    }
  }

  /**
   * Updates a virtual network gateway connection tags.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to update virtual network
   * gateway connection 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<VirtualNetworkGatewayConnection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateTagsWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._updateTags(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;
      });
    });
  }

  /**
   * Updates a virtual network gateway connection tags.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to update virtual network
   * gateway connection 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 {VirtualNetworkGatewayConnection} - 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 VirtualNetworkGatewayConnection} 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, 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._updateTags(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._updateTags(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual
   * network gateway connection shared key for passed virtual network gateway
   * connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection name.
   *
   * @param {object} parameters Parameters supplied to the Begin Set Virtual
   * Network Gateway connection Shared key operation throughNetwork resource
   * provider.
   *
   * @param {string} parameters.value The virtual network connection shared key
   * value.
   *
   * @param {string} [parameters.id] Resource ID.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ConnectionSharedKey>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  setSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._setSharedKey(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;
      });
    });
  }

  /**
   * The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual
   * network gateway connection shared key for passed virtual network gateway
   * connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection name.
   *
   * @param {object} parameters Parameters supplied to the Begin Set Virtual
   * Network Gateway connection Shared key operation throughNetwork resource
   * provider.
   *
   * @param {string} parameters.value The virtual network connection shared key
   * value.
   *
   * @param {string} [parameters.id] Resource ID.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {ConnectionSharedKey} - 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 ConnectionSharedKey} 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.
   */
  setSharedKey(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._setSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._setSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves
   * information about the specified virtual network gateway connection shared
   * key through Network resource provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection shared key 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<ConnectionSharedKey>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, 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 VirtualNetworkGatewayConnectionSharedKey operation retrieves
   * information about the specified virtual network gateway connection shared
   * key through Network resource provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection shared key 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 {ConnectionSharedKey} - 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 ConnectionSharedKey} 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.
   */
  getSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, 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._getSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, options, optionalCallback);
    }
  }

  /**
   * The List VirtualNetworkGatewayConnections operation retrieves all the
   * virtual network gateways connections created.
   *
   * @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<VirtualNetworkGatewayConnectionListResult>} - 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;
      });
    });
  }

  /**
   * The List VirtualNetworkGatewayConnections operation retrieves all the
   * virtual network gateways connections created.
   *
   * @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 {VirtualNetworkGatewayConnectionListResult} - 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 VirtualNetworkGatewayConnectionListResult}
   *                      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);
    }
  }

  /**
   * The VirtualNetworkGatewayConnectionResetSharedKey operation resets the
   * virtual network gateway connection shared key for passed virtual network
   * gateway connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection reset shared key Name.
   *
   * @param {object} parameters Parameters supplied to the begin reset virtual
   * network gateway connection shared key operation through network resource
   * provider.
   *
   * @param {number} parameters.keyLength The virtual network connection reset
   * shared key length, should between 1 and 128.
   *
   * @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<ConnectionResetSharedKey>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  resetSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._resetSharedKey(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;
      });
    });
  }

  /**
   * The VirtualNetworkGatewayConnectionResetSharedKey operation resets the
   * virtual network gateway connection shared key for passed virtual network
   * gateway connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection reset shared key Name.
   *
   * @param {object} parameters Parameters supplied to the begin reset virtual
   * network gateway connection shared key operation through network resource
   * provider.
   *
   * @param {number} parameters.keyLength The virtual network connection reset
   * shared key length, should between 1 and 128.
   *
   * @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 {ConnectionResetSharedKey} - 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 ConnectionResetSharedKey} 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.
   */
  resetSharedKey(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._resetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._resetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * Creates or updates a virtual network gateway connection in the specified
   * resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to the create or update
   * virtual network gateway connection operation.
   *
   * @param {string} [parameters.authorizationKey] The authorizationKey.
   *
   * @param {object} parameters.virtualNetworkGateway1 The reference to virtual
   * network gateway resource.
   *
   * @param {object} [parameters.virtualNetworkGateway2] The reference to virtual
   * network gateway resource.
   *
   * @param {array} [parameters.virtualNetworkGateway2.ipConfigurations] IP
   * configurations for virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.gatewayType] The type of
   * this virtual network gateway. Possible values are: 'Vpn' and 'ExpressRoute'.
   * Possible values include: 'Vpn', 'ExpressRoute'
   *
   * @param {string} [parameters.virtualNetworkGateway2.vpnType] The type of this
   * virtual network gateway. Possible values are: 'PolicyBased' and
   * 'RouteBased'. Possible values include: 'PolicyBased', 'RouteBased'
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.enableBgp] Whether BGP
   * is enabled for this virtual network gateway or not.
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.activeActive]
   * ActiveActive flag
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {object} [parameters.virtualNetworkGateway2.sku] The reference of the
   * VirtualNetworkGatewaySku resource which represents the SKU selected for
   * Virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.name] Gateway SKU
   * name. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.tier] Gateway SKU
   * tier. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {number} [parameters.virtualNetworkGateway2.sku.capacity] The
   * capacity.
   *
   * @param {object} [parameters.virtualNetworkGateway2.vpnClientConfiguration]
   * The reference of the VpnClientConfiguration resource which represents the
   * P2S VpnClient configurations.
   *
   * @param {object}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientAddressPool]
   * The reference of the address space resource which represents Address space
   * for P2S VpnClient.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRootCertificates]
   * VpnClientRootCertificate for virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRevokedCertificates]
   * VpnClientRevokedCertificate for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientProtocols]
   * VpnClientProtocols for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientIpsecPolicies]
   * VpnClientIpsecPolicies for virtual network gateway P2S client.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerAddress]
   * The radius server address property of the VirtualNetworkGateway resource for
   * vpn client connection.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerSecret]
   * The radius secret property of the VirtualNetworkGateway resource for vpn
   * client connection.
   *
   * @param {object} [parameters.virtualNetworkGateway2.bgpSettings] Virtual
   * network gateway's BGP speaker settings.
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {string} [parameters.virtualNetworkGateway2.resourceGuid] The
   * resource GUID property of the VirtualNetworkGateway resource.
   *
   * @param {string} [parameters.virtualNetworkGateway2.etag] Gets a unique
   * read-only string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.virtualNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.virtualNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.virtualNetworkGateway2.tags] Resource tags.
   *
   * @param {object} [parameters.localNetworkGateway2] The reference to local
   * network gateway resource.
   *
   * @param {object} [parameters.localNetworkGateway2.localNetworkAddressSpace]
   * Local network site address space.
   *
   * @param {array}
   * [parameters.localNetworkGateway2.localNetworkAddressSpace.addressPrefixes] A
   * list of address blocks reserved for this virtual network in CIDR notation.
   *
   * @param {string} [parameters.localNetworkGateway2.gatewayIpAddress] IP
   * address of local network gateway.
   *
   * @param {object} [parameters.localNetworkGateway2.bgpSettings] Local network
   * gateway's BGP speaker settings.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.asn] The BGP
   * speaker's ASN.
   *
   * @param {string}
   * [parameters.localNetworkGateway2.bgpSettings.bgpPeeringAddress] The BGP
   * peering address and BGP identifier of this BGP speaker.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.peerWeight] The
   * weight added to routes learned from this BGP speaker.
   *
   * @param {string} [parameters.localNetworkGateway2.resourceGuid] The resource
   * GUID property of the LocalNetworkGateway resource.
   *
   * @param {string} [parameters.localNetworkGateway2.etag] A unique read-only
   * string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.localNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.localNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.localNetworkGateway2.tags] Resource tags.
   *
   * @param {string} parameters.connectionType Gateway connection type. Possible
   * values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient'
   *
   * @param {string} [parameters.connectionProtocol] Connection protocol used for
   * this connection. Possible values include: 'IKEv2', 'IKEv1'
   *
   * @param {number} [parameters.routingWeight] The routing weight.
   *
   * @param {string} [parameters.sharedKey] The IPSec shared key.
   *
   * @param {object} [parameters.peer] The reference to peerings resource.
   *
   * @param {string} [parameters.peer.id] Resource ID.
   *
   * @param {boolean} [parameters.enableBgp] EnableBgp flag
   *
   * @param {boolean} [parameters.usePolicyBasedTrafficSelectors] Enable
   * policy-based traffic selectors.
   *
   * @param {array} [parameters.ipsecPolicies] The IPSec Policies to be
   * considered by this connection.
   *
   * @param {string} [parameters.resourceGuid] The resource GUID property of the
   * VirtualNetworkGatewayConnection resource.
   *
   * @param {boolean} [parameters.expressRouteGatewayBypass] Bypass ExpressRoute
   * Gateway for data forwarding
   *
   * @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<VirtualNetworkGatewayConnection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdate(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;
      });
    });
  }

  /**
   * Creates or updates a virtual network gateway connection in the specified
   * resource group.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to the create or update
   * virtual network gateway connection operation.
   *
   * @param {string} [parameters.authorizationKey] The authorizationKey.
   *
   * @param {object} parameters.virtualNetworkGateway1 The reference to virtual
   * network gateway resource.
   *
   * @param {object} [parameters.virtualNetworkGateway2] The reference to virtual
   * network gateway resource.
   *
   * @param {array} [parameters.virtualNetworkGateway2.ipConfigurations] IP
   * configurations for virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.gatewayType] The type of
   * this virtual network gateway. Possible values are: 'Vpn' and 'ExpressRoute'.
   * Possible values include: 'Vpn', 'ExpressRoute'
   *
   * @param {string} [parameters.virtualNetworkGateway2.vpnType] The type of this
   * virtual network gateway. Possible values are: 'PolicyBased' and
   * 'RouteBased'. Possible values include: 'PolicyBased', 'RouteBased'
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.enableBgp] Whether BGP
   * is enabled for this virtual network gateway or not.
   *
   * @param {boolean} [parameters.virtualNetworkGateway2.activeActive]
   * ActiveActive flag
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {object} [parameters.virtualNetworkGateway2.sku] The reference of the
   * VirtualNetworkGatewaySku resource which represents the SKU selected for
   * Virtual network gateway.
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.name] Gateway SKU
   * name. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {string} [parameters.virtualNetworkGateway2.sku.tier] Gateway SKU
   * tier. Possible values include: 'Basic', 'HighPerformance', 'Standard',
   * 'UltraPerformance', 'VpnGw1', 'VpnGw2', 'VpnGw3', 'VpnGw1AZ', 'VpnGw2AZ',
   * 'VpnGw3AZ', 'ErGw1AZ', 'ErGw2AZ', 'ErGw3AZ'
   *
   * @param {number} [parameters.virtualNetworkGateway2.sku.capacity] The
   * capacity.
   *
   * @param {object} [parameters.virtualNetworkGateway2.vpnClientConfiguration]
   * The reference of the VpnClientConfiguration resource which represents the
   * P2S VpnClient configurations.
   *
   * @param {object}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientAddressPool]
   * The reference of the address space resource which represents Address space
   * for P2S VpnClient.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRootCertificates]
   * VpnClientRootCertificate for virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientRevokedCertificates]
   * VpnClientRevokedCertificate for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientProtocols]
   * VpnClientProtocols for Virtual network gateway.
   *
   * @param {array}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.vpnClientIpsecPolicies]
   * VpnClientIpsecPolicies for virtual network gateway P2S client.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerAddress]
   * The radius server address property of the VirtualNetworkGateway resource for
   * vpn client connection.
   *
   * @param {string}
   * [parameters.virtualNetworkGateway2.vpnClientConfiguration.radiusServerSecret]
   * The radius secret property of the VirtualNetworkGateway resource for vpn
   * client connection.
   *
   * @param {object} [parameters.virtualNetworkGateway2.bgpSettings] Virtual
   * network gateway's BGP speaker settings.
   *
   * @param {object} [parameters.virtualNetworkGateway2.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 {string} [parameters.virtualNetworkGateway2.resourceGuid] The
   * resource GUID property of the VirtualNetworkGateway resource.
   *
   * @param {string} [parameters.virtualNetworkGateway2.etag] Gets a unique
   * read-only string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.virtualNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.virtualNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.virtualNetworkGateway2.tags] Resource tags.
   *
   * @param {object} [parameters.localNetworkGateway2] The reference to local
   * network gateway resource.
   *
   * @param {object} [parameters.localNetworkGateway2.localNetworkAddressSpace]
   * Local network site address space.
   *
   * @param {array}
   * [parameters.localNetworkGateway2.localNetworkAddressSpace.addressPrefixes] A
   * list of address blocks reserved for this virtual network in CIDR notation.
   *
   * @param {string} [parameters.localNetworkGateway2.gatewayIpAddress] IP
   * address of local network gateway.
   *
   * @param {object} [parameters.localNetworkGateway2.bgpSettings] Local network
   * gateway's BGP speaker settings.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.asn] The BGP
   * speaker's ASN.
   *
   * @param {string}
   * [parameters.localNetworkGateway2.bgpSettings.bgpPeeringAddress] The BGP
   * peering address and BGP identifier of this BGP speaker.
   *
   * @param {number} [parameters.localNetworkGateway2.bgpSettings.peerWeight] The
   * weight added to routes learned from this BGP speaker.
   *
   * @param {string} [parameters.localNetworkGateway2.resourceGuid] The resource
   * GUID property of the LocalNetworkGateway resource.
   *
   * @param {string} [parameters.localNetworkGateway2.etag] A unique read-only
   * string that changes whenever the resource is updated.
   *
   * @param {string} [parameters.localNetworkGateway2.id] Resource ID.
   *
   * @param {string} [parameters.localNetworkGateway2.location] Resource
   * location.
   *
   * @param {object} [parameters.localNetworkGateway2.tags] Resource tags.
   *
   * @param {string} parameters.connectionType Gateway connection type. Possible
   * values include: 'IPsec', 'Vnet2Vnet', 'ExpressRoute', 'VPNClient'
   *
   * @param {string} [parameters.connectionProtocol] Connection protocol used for
   * this connection. Possible values include: 'IKEv2', 'IKEv1'
   *
   * @param {number} [parameters.routingWeight] The routing weight.
   *
   * @param {string} [parameters.sharedKey] The IPSec shared key.
   *
   * @param {object} [parameters.peer] The reference to peerings resource.
   *
   * @param {string} [parameters.peer.id] Resource ID.
   *
   * @param {boolean} [parameters.enableBgp] EnableBgp flag
   *
   * @param {boolean} [parameters.usePolicyBasedTrafficSelectors] Enable
   * policy-based traffic selectors.
   *
   * @param {array} [parameters.ipsecPolicies] The IPSec Policies to be
   * considered by this connection.
   *
   * @param {string} [parameters.resourceGuid] The resource GUID property of the
   * VirtualNetworkGatewayConnection resource.
   *
   * @param {boolean} [parameters.expressRouteGatewayBypass] Bypass ExpressRoute
   * Gateway for data forwarding
   *
   * @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 {VirtualNetworkGatewayConnection} - 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 VirtualNetworkGatewayConnection} 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, 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._beginCreateOrUpdate(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdate(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes the specified virtual network Gateway connection.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @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, virtualNetworkGatewayConnectionName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, virtualNetworkGatewayConnectionName, 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 connection.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @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, virtualNetworkGatewayConnectionName, 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, virtualNetworkGatewayConnectionName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, virtualNetworkGatewayConnectionName, options, optionalCallback);
    }
  }

  /**
   * Updates a virtual network gateway connection tags.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to update virtual network
   * gateway connection 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<VirtualNetworkGatewayConnection>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateTagsWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdateTags(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;
      });
    });
  }

  /**
   * Updates a virtual network gateway connection tags.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The name of the virtual
   * network gateway connection.
   *
   * @param {object} parameters Parameters supplied to update virtual network
   * gateway connection 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 {VirtualNetworkGatewayConnection} - 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 VirtualNetworkGatewayConnection} 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, 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._beginUpdateTags(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdateTags(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual
   * network gateway connection shared key for passed virtual network gateway
   * connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection name.
   *
   * @param {object} parameters Parameters supplied to the Begin Set Virtual
   * Network Gateway connection Shared key operation throughNetwork resource
   * provider.
   *
   * @param {string} parameters.value The virtual network connection shared key
   * value.
   *
   * @param {string} [parameters.id] Resource ID.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ConnectionSharedKey>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginSetSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginSetSharedKey(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;
      });
    });
  }

  /**
   * The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual
   * network gateway connection shared key for passed virtual network gateway
   * connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection name.
   *
   * @param {object} parameters Parameters supplied to the Begin Set Virtual
   * Network Gateway connection Shared key operation throughNetwork resource
   * provider.
   *
   * @param {string} parameters.value The virtual network connection shared key
   * value.
   *
   * @param {string} [parameters.id] Resource ID.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {ConnectionSharedKey} - 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 ConnectionSharedKey} 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.
   */
  beginSetSharedKey(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._beginSetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginSetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * The VirtualNetworkGatewayConnectionResetSharedKey operation resets the
   * virtual network gateway connection shared key for passed virtual network
   * gateway connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection reset shared key Name.
   *
   * @param {object} parameters Parameters supplied to the begin reset virtual
   * network gateway connection shared key operation through network resource
   * provider.
   *
   * @param {number} parameters.keyLength The virtual network connection reset
   * shared key length, should between 1 and 128.
   *
   * @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<ConnectionResetSharedKey>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginResetSharedKeyWithHttpOperationResponse(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginResetSharedKey(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;
      });
    });
  }

  /**
   * The VirtualNetworkGatewayConnectionResetSharedKey operation resets the
   * virtual network gateway connection shared key for passed virtual network
   * gateway connection in the specified resource group through Network resource
   * provider.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} virtualNetworkGatewayConnectionName The virtual network
   * gateway connection reset shared key Name.
   *
   * @param {object} parameters Parameters supplied to the begin reset virtual
   * network gateway connection shared key operation through network resource
   * provider.
   *
   * @param {number} parameters.keyLength The virtual network connection reset
   * shared key length, should between 1 and 128.
   *
   * @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 {ConnectionResetSharedKey} - 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 ConnectionResetSharedKey} 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.
   */
  beginResetSharedKey(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._beginResetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginResetSharedKey(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, options, optionalCallback);
    }
  }

  /**
   * The List VirtualNetworkGatewayConnections operation retrieves all the
   * virtual network gateways connections created.
   *
   * @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<VirtualNetworkGatewayConnectionListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * The List VirtualNetworkGatewayConnections operation retrieves all the
   * virtual network gateways connections created.
   *
   * @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 {VirtualNetworkGatewayConnectionListResult} - 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 VirtualNetworkGatewayConnectionListResult}
   *                      for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  listNext(nextPageLink, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = VirtualNetworkGatewayConnections;
