UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

1,201 lines (1,054 loc) 829 kB
/* jshint latedef:false */ /* jshint forin:false */ /* jshint noempty:false */ // // Copyright (c) Microsoft and contributors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // // Warning: This code was generated by a tool. // // Changes to this file may cause incorrect behavior and will be lost if the // code is regenerated. 'use strict'; var util = require('util'); var azureCommon = require('azure-common'); var Service = azureCommon.Service; var WebResource = azureCommon.WebResource; var NetworkResourceProviderClient = ( /** @lends NetworkResourceProviderClient */ function() { /** * @class * The Windows Azure Network management API provides a RESTful set of web * services that interact with Windows Azure Networks service to manage your * network resrources. The API has entities that capture the relationship * between an end user and the Windows Azure Networks service. * Initializes a new instance of the NetworkResourceProviderClient class. * @constructor * * @param {SubscriptionCloudCredentials} credentials Gets subscription * credentials which uniquely identify Microsoft Azure subscription. The * subscription ID forms part of the URI for every service call. * * @param {string} [credentials.subscriptionId] * * @param {string} [baseUri] Gets the URI used as the base for all cloud * service requests. * * @param {Array} filters */ function NetworkResourceProviderClient(credentials, baseUri, filters) { if (credentials === null || credentials === undefined) { throw new Error('credentials cannot be null.'); } NetworkResourceProviderClient['super_'].call(this, credentials, filters); this.credentials = credentials; this.baseUri = baseUri; if (this.baseUri === null || this.baseUri === undefined) { this.baseUri = 'https://management.azure.com/'; } if (this.apiVersion === null || this.apiVersion === undefined) { this.apiVersion = '2015-05-01-preview'; } if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) { this.longRunningOperationInitialTimeout = -1; } if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) { this.longRunningOperationRetryTimeout = -1; } /** * Provides an instance of the [GatewayOperations](-GatewayOperations.html) * object. * @type {object} */ this.gateways = new GatewayOperations(this); /** * Provides an instance of the * [LoadBalancerOperations](-LoadBalancerOperations.html) object. * @type {object} */ this.loadBalancers = new LoadBalancerOperations(this); /** * Provides an instance of the * [NetworkInterfaceOperations](-NetworkInterfaceOperations.html) object. * @type {object} */ this.networkInterfaces = new NetworkInterfaceOperations(this); /** * Provides an instance of the * [NetworkSecurityGroupOperations](-NetworkSecurityGroupOperations.html) * object. * @type {object} */ this.networkSecurityGroups = new NetworkSecurityGroupOperations(this); /** * Provides an instance of the * [PublicIpAddressOperations](-PublicIpAddressOperations.html) object. * @type {object} */ this.publicIpAddresses = new PublicIpAddressOperations(this); /** * Provides an instance of the * [SecurityRuleOperations](-SecurityRuleOperations.html) object. * @type {object} */ this.securityRules = new SecurityRuleOperations(this); /** * Provides an instance of the [SubnetOperations](-SubnetOperations.html) * object. * @type {object} */ this.subnets = new SubnetOperations(this); /** * Provides an instance of the [UsageOperations](-UsageOperations.html) * object. * @type {object} */ this.usages = new UsageOperations(this); /** * Provides an instance of the * [VirtualNetworkOperations](-VirtualNetworkOperations.html) object. * @type {object} */ this.virtualNetworks = new VirtualNetworkOperations(this); } util.inherits(NetworkResourceProviderClient, Service); /** * Checks whether a domain name in the cloudapp.net zone is available for use. * * @param {string} location The location of the domain name * * @param {string} domainNameLabel The domain name to be verified. It must * conform to the following regular expression: * ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. * * @param {function} callback * * @returns {Stream} The response stream. */ NetworkResourceProviderClient.prototype.checkDnsNameAvailability = function(location, domainNameLabel, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (location === null || location === undefined) { return callback(new Error('location cannot be null.')); } if (domainNameLabel === null || domainNameLabel === undefined) { return callback(new Error('domainNameLabel cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/subscriptions/'; if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.credentials.subscriptionId); } url2 = url2 + '/providers/'; url2 = url2 + 'Microsoft.Network'; url2 = url2 + '/locations/'; url2 = url2 + encodeURIComponent(location); url2 = url2 + '/CheckDnsNameAvailability'; var queryParameters = []; queryParameters.push('domainNameLabel=' + encodeURIComponent(domainNameLabel)); queryParameters.push('api-version=2015-05-01-preview'); if (queryParameters.length > 0) { url2 = url2 + '?' + queryParameters.join('&'); } var baseUrl = this.baseUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.length - 1] === '/') { baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); } if (url2[0] === '/') { url2 = url2.substring(1); } url2 = baseUrl + '/' + url2; url2 = url2.replace(' ', '%20'); // Create HTTP transport objects var httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/json'; // Send Request return this.pipeline(httpRequest, function (err, response, body) { if (err !== null && err !== undefined) { return callback(err); } var statusCode = response.statusCode; if (statusCode !== 200) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response if (statusCode === 200) { var responseContent = body; result = {}; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var availableValue = responseDoc['available']; if (availableValue !== null && availableValue !== undefined) { var availableInstance = availableValue; result.dnsNameAvailability = availableInstance; } } } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * The Get Operation Status operation returns the status of the specified * operation. After calling an asynchronous operation, you can call Get * Operation Status to determine whether the operation has succeeded, * failed, or is still in progress. * * @param {string} azureAsyncOperation Location value returned by the Begin * operation. * * @param {function} callback * * @returns {Stream} The response stream. */ NetworkResourceProviderClient.prototype.getLongRunningOperationStatus = function(azureAsyncOperation, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (azureAsyncOperation === null || azureAsyncOperation === undefined) { return callback(new Error('azureAsyncOperation cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + azureAsyncOperation; url2 = url2.replace(' ', '%20'); // Create HTTP transport objects var httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['x-ms-version'] = '2015-05-01-preview'; // Send Request return this.pipeline(httpRequest, function (err, response, body) { if (err !== null && err !== undefined) { return callback(err); } var statusCode = response.statusCode; if (statusCode !== 200 && statusCode !== 202) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response if (statusCode === 200 || statusCode === 202) { var responseContent = body; result = {}; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var statusValue = responseDoc['status']; if (statusValue !== null && statusValue !== undefined) { var statusInstance = statusValue; result.status = statusInstance; } var errorValue = responseDoc['error']; if (errorValue !== null && errorValue !== undefined) { var errorInstance = { details: [] }; result.error = errorInstance; var codeValue = errorValue['code']; if (codeValue !== null && codeValue !== undefined) { var codeInstance = codeValue; errorInstance.code = codeInstance; } var messageValue = errorValue['message']; if (messageValue !== null && messageValue !== undefined) { var messageInstance = messageValue; errorInstance.message = messageInstance; } var targetValue = errorValue['target']; if (targetValue !== null && targetValue !== undefined) { var targetInstance = targetValue; errorInstance.target = targetInstance; } var detailsArray = errorValue['details']; if (detailsArray !== null && detailsArray !== undefined) { for (var loweredIndex1 = 0; loweredIndex1 < detailsArray.length; loweredIndex1 = loweredIndex1 + 1) { var detailsValue = detailsArray[loweredIndex1]; var errorDetailsInstance = {}; errorInstance.details.push(errorDetailsInstance); var codeValue2 = detailsValue['code']; if (codeValue2 !== null && codeValue2 !== undefined) { var codeInstance2 = codeValue2; errorDetailsInstance.code = codeInstance2; } var targetValue2 = detailsValue['target']; if (targetValue2 !== null && targetValue2 !== undefined) { var targetInstance2 = targetValue2; errorDetailsInstance.target = targetInstance2; } var messageValue2 = detailsValue['message']; if (messageValue2 !== null && messageValue2 !== undefined) { var messageInstance2 = messageValue2; errorDetailsInstance.message = messageInstance2; } } } var innerErrorValue = errorValue['innerError']; if (innerErrorValue !== null && innerErrorValue !== undefined) { var innerErrorInstance = innerErrorValue; errorInstance.innerError = innerErrorInstance; } } } } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; return NetworkResourceProviderClient; })(); exports.NetworkResourceProviderClient = NetworkResourceProviderClient; var GatewayOperations = ( /** @lends GatewayOperations */ function() { /** * @class * The Network Resource Provider API includes operations for managing the * Virtual network Gateway for your subscription. * __NOTE__: An instance of this class is automatically created for an * instance of the [NetworkResourceProviderClient] {@link * NetworkResourceProviderClient~NetworkResourceProviderClient}. * See [gateways] {@link * NetworkResourceProviderClient~NetworkResourceProviderClient#gateways}. * Initializes a new instance of the GatewayOperations class. * @constructor * * @param {NetworkResourceProviderClient} client Reference to the service * client. */ function GatewayOperations(client) { this.client = client; } /** * The Put LocalNetworkGateway operation creates/updates a local network * gateway in the specified resource group through NRP. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} localNetworkGatewayName The name of the local network * gateway. * * @param {LocalNetworkGateway} parameters Parameters supplied to the Begin * Create or update Local Network Gateway operation through NRP. * * @param {string} [parameters.gatewayIpAddress] IP address of local network * gateway. * * @param {AddressSpace} [parameters.localNetworkSiteAddressSpace] Local * network site Address space * * @param {IEnumerable} * [parameters.localNetworkSiteAddressSpace.addressPrefixes] Gets or sets * List of address blocks reserved for this virtual network in CIDR notation * * @param {string} [parameters.provisioningState] Gets or sets Provisioning * state of the LocalNetworkGateway resource Updating/Deleting/Failed * * @param {string} [parameters.etag] Gets a unique read-only string that * changes whenever the resource is updated * * @param {string} [parameters.id] Gets or sets the ID of the resource. * * @param {string} [parameters.name] Gets or sets the name of the resource. * * @param {string} [parameters.type] Gets or sets the type of the resource. * * @param {string} parameters.location Gets or sets the location of the * resource. * * @param {object} [parameters.tags] Gets or sets the tags attached to the * resource. * * @param {function} callback * * @returns {Stream} The response stream. */ GatewayOperations.prototype.beginCreateOrUpdatingLocalNetworkGateway = function(resourceGroupName, localNetworkGatewayName, parameters, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (resourceGroupName === null || resourceGroupName === undefined) { return callback(new Error('resourceGroupName cannot be null.')); } if (localNetworkGatewayName === null || localNetworkGatewayName === undefined) { return callback(new Error('localNetworkGatewayName cannot be null.')); } if (parameters === null || parameters === undefined) { return callback(new Error('parameters cannot be null.')); } if (parameters.location === null || parameters.location === undefined) { return callback(new Error('parameters.location cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/subscriptions/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/resourceGroups/'; url2 = url2 + encodeURIComponent(resourceGroupName); url2 = url2 + '/providers/microsoft.network/localNetworkGateways/'; url2 = url2 + encodeURIComponent(localNetworkGatewayName); var queryParameters = []; queryParameters.push('api-version=2015-05-01-preview'); if (queryParameters.length > 0) { url2 = url2 + '?' + queryParameters.join('&'); } var baseUrl = this.client.baseUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.length - 1] === '/') { baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); } if (url2[0] === '/') { url2 = url2.substring(1); } url2 = baseUrl + '/' + url2; url2 = url2.replace(' ', '%20'); // Create HTTP transport objects var httpRequest = new WebResource(); httpRequest.method = 'PUT'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/json'; // Serialize Request var requestContent = null; var requestDoc = null; var localNetworkGatewayJsonFormatValue = {}; requestDoc = localNetworkGatewayJsonFormatValue; var propertiesValue = {}; localNetworkGatewayJsonFormatValue['properties'] = propertiesValue; if (parameters.gatewayIpAddress !== null && parameters.gatewayIpAddress !== undefined) { propertiesValue['gatewayIpAddress'] = parameters.gatewayIpAddress; } if (parameters.localNetworkSiteAddressSpace !== null && parameters.localNetworkSiteAddressSpace !== undefined) { var localNetworkSiteAddressSpaceValue = {}; propertiesValue['localNetworkSiteAddressSpace'] = localNetworkSiteAddressSpaceValue; if (parameters.localNetworkSiteAddressSpace.addressPrefixes !== null && parameters.localNetworkSiteAddressSpace.addressPrefixes !== undefined) { var addressPrefixesArray = []; for (var loweredIndex1 = 0; loweredIndex1 < parameters.localNetworkSiteAddressSpace.addressPrefixes.length; loweredIndex1 = loweredIndex1 + 1) { var addressPrefixesItem = parameters.localNetworkSiteAddressSpace.addressPrefixes[loweredIndex1]; addressPrefixesArray.push(addressPrefixesItem); } localNetworkSiteAddressSpaceValue['addressPrefixes'] = addressPrefixesArray; } } if (parameters.provisioningState !== null && parameters.provisioningState !== undefined) { propertiesValue['provisioningState'] = parameters.provisioningState; } if (parameters.etag !== null && parameters.etag !== undefined) { localNetworkGatewayJsonFormatValue['etag'] = parameters.etag; } if (parameters.id !== null && parameters.id !== undefined) { localNetworkGatewayJsonFormatValue['id'] = parameters.id; } if (parameters.name !== null && parameters.name !== undefined) { localNetworkGatewayJsonFormatValue['name'] = parameters.name; } if (parameters.type !== null && parameters.type !== undefined) { localNetworkGatewayJsonFormatValue['type'] = parameters.type; } localNetworkGatewayJsonFormatValue['location'] = parameters.location; if (parameters.tags !== null && parameters.tags !== undefined) { var tagsDictionary = {}; for (var tagsKey in parameters.tags) { var tagsValue = parameters.tags[tagsKey]; tagsDictionary[tagsKey] = tagsValue; } localNetworkGatewayJsonFormatValue['tags'] = tagsDictionary; } requestContent = JSON.stringify(requestDoc); httpRequest.body = requestContent; httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8'); // Send Request return this.client.pipeline(httpRequest, function (err, response, body) { if (err !== null && err !== undefined) { return callback(err); } var statusCode = response.statusCode; if (statusCode !== 200 && statusCode !== 201) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response if (statusCode === 200 || statusCode === 201) { var responseContent = body; result = {}; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var localNetworkGatewayInstance = { tags: {} }; result.localNetworkGateway = localNetworkGatewayInstance; var propertiesValue2 = responseDoc['properties']; if (propertiesValue2 !== null && propertiesValue2 !== undefined) { var gatewayIpAddressValue = propertiesValue2['gatewayIpAddress']; if (gatewayIpAddressValue !== null && gatewayIpAddressValue !== undefined) { var gatewayIpAddressInstance = gatewayIpAddressValue; localNetworkGatewayInstance.gatewayIpAddress = gatewayIpAddressInstance; } var localNetworkSiteAddressSpaceValue2 = propertiesValue2['localNetworkSiteAddressSpace']; if (localNetworkSiteAddressSpaceValue2 !== null && localNetworkSiteAddressSpaceValue2 !== undefined) { var localNetworkSiteAddressSpaceInstance = { addressPrefixes: [] }; localNetworkGatewayInstance.localNetworkSiteAddressSpace = localNetworkSiteAddressSpaceInstance; var addressPrefixesArray2 = localNetworkSiteAddressSpaceValue2['addressPrefixes']; if (addressPrefixesArray2 !== null && addressPrefixesArray2 !== undefined) { for (var loweredIndex2 = 0; loweredIndex2 < addressPrefixesArray2.length; loweredIndex2 = loweredIndex2 + 1) { var addressPrefixesValue = addressPrefixesArray2[loweredIndex2]; localNetworkSiteAddressSpaceInstance.addressPrefixes.push(addressPrefixesValue); } } } var provisioningStateValue = propertiesValue2['provisioningState']; if (provisioningStateValue !== null && provisioningStateValue !== undefined) { var provisioningStateInstance = provisioningStateValue; localNetworkGatewayInstance.provisioningState = provisioningStateInstance; } } var etagValue = responseDoc['etag']; if (etagValue !== null && etagValue !== undefined) { var etagInstance = etagValue; localNetworkGatewayInstance.etag = etagInstance; } var idValue = responseDoc['id']; if (idValue !== null && idValue !== undefined) { var idInstance = idValue; localNetworkGatewayInstance.id = idInstance; } var nameValue = responseDoc['name']; if (nameValue !== null && nameValue !== undefined) { var nameInstance = nameValue; localNetworkGatewayInstance.name = nameInstance; } var typeValue = responseDoc['type']; if (typeValue !== null && typeValue !== undefined) { var typeInstance = typeValue; localNetworkGatewayInstance.type = typeInstance; } var locationValue = responseDoc['location']; if (locationValue !== null && locationValue !== undefined) { var locationInstance = locationValue; localNetworkGatewayInstance.location = locationInstance; } var tagsSequenceElement = responseDoc['tags']; if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { for (var property in tagsSequenceElement) { var tagsKey2 = property; var tagsValue2 = tagsSequenceElement[property]; localNetworkGatewayInstance.tags[tagsKey2] = tagsValue2; } } var errorValue = responseDoc['error']; if (errorValue !== null && errorValue !== undefined) { var errorInstance = { details: [] }; result.error = errorInstance; var codeValue = errorValue['code']; if (codeValue !== null && codeValue !== undefined) { var codeInstance = codeValue; errorInstance.code = codeInstance; } var messageValue = errorValue['message']; if (messageValue !== null && messageValue !== undefined) { var messageInstance = messageValue; errorInstance.message = messageInstance; } var targetValue = errorValue['target']; if (targetValue !== null && targetValue !== undefined) { var targetInstance = targetValue; errorInstance.target = targetInstance; } var detailsArray = errorValue['details']; if (detailsArray !== null && detailsArray !== undefined) { for (var loweredIndex3 = 0; loweredIndex3 < detailsArray.length; loweredIndex3 = loweredIndex3 + 1) { var detailsValue = detailsArray[loweredIndex3]; var errorDetailsInstance = {}; errorInstance.details.push(errorDetailsInstance); var codeValue2 = detailsValue['code']; if (codeValue2 !== null && codeValue2 !== undefined) { var codeInstance2 = codeValue2; errorDetailsInstance.code = codeInstance2; } var targetValue2 = detailsValue['target']; if (targetValue2 !== null && targetValue2 !== undefined) { var targetInstance2 = targetValue2; errorDetailsInstance.target = targetInstance2; } var messageValue2 = detailsValue['message']; if (messageValue2 !== null && messageValue2 !== undefined) { var messageInstance2 = messageValue2; errorDetailsInstance.message = messageInstance2; } } } var innerErrorValue = errorValue['innerError']; if (innerErrorValue !== null && innerErrorValue !== undefined) { var innerErrorInstance = innerErrorValue; errorInstance.innerError = innerErrorInstance; } } } } result.statusCode = statusCode; result.azureAsyncOperation = response.headers['azure-asyncoperation']; result.retryAfter = parseInt(response.headers['retry-after'], 10); result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * The Put VirtualNetworkGateway operation creates/updates a virtual network * gateway in the specified resource group through NRP. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} virtualNetworkGatewayName The name of the virtual network * gateway. * * @param {VirtualNetworkGateway} parameters Parameters supplied to the Begin * Create or update Virtual Network Gateway operation through NRP. * * @param {IEnumerable} [parameters.ipConfigurations] IpConfigurations for * Virtual network gateway. * * @param {string} [parameters.gatewaySize] The size of this virtual network * gateway. * * @param {string} [parameters.gatewayType] The size of this virtual network * gateway. * * @param {boolean} [parameters.enableBgp] EnableBgp Flag * * @param {string} [parameters.provisioningState] Gets or sets Provisioning * state of the VirtualNetworkGateway resource Updating/Deleting/Failed * * @param {string} [parameters.etag] Gets a unique read-only string that * changes whenever the resource is updated * * @param {string} [parameters.id] Gets or sets the ID of the resource. * * @param {string} [parameters.name] Gets or sets the name of the resource. * * @param {string} [parameters.type] Gets or sets the type of the resource. * * @param {string} parameters.location Gets or sets the location of the * resource. * * @param {object} [parameters.tags] Gets or sets the tags attached to the * resource. * * @param {function} callback * * @returns {Stream} The response stream. */ GatewayOperations.prototype.beginCreateOrUpdatingVirtualNetworkGateway = function(resourceGroupName, virtualNetworkGatewayName, parameters, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (resourceGroupName === null || resourceGroupName === undefined) { return callback(new Error('resourceGroupName cannot be null.')); } if (virtualNetworkGatewayName === null || virtualNetworkGatewayName === undefined) { return callback(new Error('virtualNetworkGatewayName cannot be null.')); } if (parameters === null || parameters === undefined) { return callback(new Error('parameters cannot be null.')); } if (parameters.location === null || parameters.location === undefined) { return callback(new Error('parameters.location cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/subscriptions/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/resourceGroups/'; url2 = url2 + encodeURIComponent(resourceGroupName); url2 = url2 + '/providers/microsoft.network/virtualnetworkgateways/'; url2 = url2 + encodeURIComponent(virtualNetworkGatewayName); var queryParameters = []; queryParameters.push('api-version=2015-05-01-preview'); if (queryParameters.length > 0) { url2 = url2 + '?' + queryParameters.join('&'); } var baseUrl = this.client.baseUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.length - 1] === '/') { baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0); } if (url2[0] === '/') { url2 = url2.substring(1); } url2 = baseUrl + '/' + url2; url2 = url2.replace(' ', '%20'); // Create HTTP transport objects var httpRequest = new WebResource(); httpRequest.method = 'PUT'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/json'; // Serialize Request var requestContent = null; var requestDoc = null; var virtualNetworkGatewayJsonFormatValue = {}; requestDoc = virtualNetworkGatewayJsonFormatValue; var propertiesValue = {}; virtualNetworkGatewayJsonFormatValue['properties'] = propertiesValue; if (parameters.ipConfigurations !== null && parameters.ipConfigurations !== undefined) { var ipConfigurationsArray = []; for (var loweredIndex1 = 0; loweredIndex1 < parameters.ipConfigurations.length; loweredIndex1 = loweredIndex1 + 1) { var ipConfigurationsItem = parameters.ipConfigurations[loweredIndex1]; var virtualNetworkGatewayIpConfigurationJsonFormatValue = {}; ipConfigurationsArray.push(virtualNetworkGatewayIpConfigurationJsonFormatValue); var propertiesValue2 = {}; virtualNetworkGatewayIpConfigurationJsonFormatValue['properties'] = propertiesValue2; if (ipConfigurationsItem.privateIpAddress !== null && ipConfigurationsItem.privateIpAddress !== undefined) { propertiesValue2['privateIPAddress'] = ipConfigurationsItem.privateIpAddress; } if (ipConfigurationsItem.privateIpAllocationMethod !== null && ipConfigurationsItem.privateIpAllocationMethod !== undefined) { propertiesValue2['privateIPAllocationMethod'] = ipConfigurationsItem.privateIpAllocationMethod; } if (ipConfigurationsItem.subnet !== null && ipConfigurationsItem.subnet !== undefined) { var subnetValue = {}; propertiesValue2['subnet'] = subnetValue; if (ipConfigurationsItem.subnet.id !== null && ipConfigurationsItem.subnet.id !== undefined) { subnetValue['id'] = ipConfigurationsItem.subnet.id; } } if (ipConfigurationsItem.publicIpAddress !== null && ipConfigurationsItem.publicIpAddress !== undefined) { var publicIPAddressValue = {}; propertiesValue2['publicIPAddress'] = publicIPAddressValue; if (ipConfigurationsItem.publicIpAddress.id !== null && ipConfigurationsItem.publicIpAddress.id !== undefined) { publicIPAddressValue['id'] = ipConfigurationsItem.publicIpAddress.id; } } if (ipConfigurationsItem.provisioningState !== null && ipConfigurationsItem.provisioningState !== undefined) { propertiesValue2['provisioningState'] = ipConfigurationsItem.provisioningState; } if (ipConfigurationsItem.name !== null && ipConfigurationsItem.name !== undefined) { virtualNetworkGatewayIpConfigurationJsonFormatValue['name'] = ipConfigurationsItem.name; } if (ipConfigurationsItem.etag !== null && ipConfigurationsItem.etag !== undefined) { virtualNetworkGatewayIpConfigurationJsonFormatValue['etag'] = ipConfigurationsItem.etag; } if (ipConfigurationsItem.id !== null && ipConfigurationsItem.id !== undefined) { virtualNetworkGatewayIpConfigurationJsonFormatValue['id'] = ipConfigurationsItem.id; } } propertiesValue['ipConfigurations'] = ipConfigurationsArray; } if (parameters.gatewaySize !== null && parameters.gatewaySize !== undefined) { propertiesValue['gatewaySize'] = parameters.gatewaySize; } if (parameters.gatewayType !== null && parameters.gatewayType !== undefined) { propertiesValue['gatewayType'] = parameters.gatewayType; } if (parameters.enableBgp !== null && parameters.enableBgp !== undefined) { propertiesValue['enableBgp'] = parameters.enableBgp; } if (parameters.provisioningState !== null && parameters.provisioningState !== undefined) { propertiesValue['provisioningState'] = parameters.provisioningState; } if (parameters.etag !== null && parameters.etag !== undefined) { virtualNetworkGatewayJsonFormatValue['etag'] = parameters.etag; } if (parameters.id !== null && parameters.id !== undefined) { virtualNetworkGatewayJsonFormatValue['id'] = parameters.id; } if (parameters.name !== null && parameters.name !== undefined) { virtualNetworkGatewayJsonFormatValue['name'] = parameters.name; } if (parameters.type !== null && parameters.type !== undefined) { virtualNetworkGatewayJsonFormatValue['type'] = parameters.type; } virtualNetworkGatewayJsonFormatValue['location'] = parameters.location; if (parameters.tags !== null && parameters.tags !== undefined) { var tagsDictionary = {}; for (var tagsKey in parameters.tags) { var tagsValue = parameters.tags[tagsKey]; tagsDictionary[tagsKey] = tagsValue; } virtualNetworkGatewayJsonFormatValue['tags'] = tagsDictionary; } requestContent = JSON.stringify(requestDoc); httpRequest.body = requestContent; httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8'); // Send Request return this.client.pipeline(httpRequest, function (err, response, body) { if (err !== null && err !== undefined) { return callback(err); } var statusCode = response.statusCode; if (statusCode !== 200 && statusCode !== 201) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response if (statusCode === 200 || statusCode === 201) { var responseContent = body; result = {}; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var virtualNetworkGatewayInstance = { ipConfigurations: [], tags: {} }; result.virtualNetworkGateway = virtualNetworkGatewayInstance; var propertiesValue3 = responseDoc['properties']; if (propertiesValue3 !== null && propertiesValue3 !== undefined) { var ipConfigurationsArray2 = propertiesValue3['ipConfigurations']; if (ipConfigurationsArray2 !== null && ipConfigurationsArray2 !== undefined) { for (var loweredIndex2 = 0; loweredIndex2 < ipConfigurationsArray2.length; loweredIndex2 = loweredIndex2 + 1) { var ipConfigurationsValue = ipConfigurationsArray2[loweredIndex2]; var virtualNetworkGatewayIpConfigurationJsonFormatInstance = {}; virtualNetworkGatewayInstance.ipConfigurations.push(virtualNetworkGatewayIpConfigurationJsonFormatInstance); var propertiesValue4 = ipConfigurationsValue['properties']; if (propertiesValue4 !== null && propertiesValue4 !== undefined) { var privateIPAddressValue = propertiesValue4['privateIPAddress']; if (privateIPAddressValue !== null && privateIPAddressValue !== undefined) { var privateIPAddressInstance = privateIPAddressValue; virtualNetworkGatewayIpConfigurationJsonFormatInstance.privateIpAddress = privateIPAddressInstance; } var privateIPAllocationMethodValue = propertiesValue4['privateIPAllocationMethod']; if (privateIPAllocationMethodValue !== null && privateIPAllocationMethodValue !== undefined) { var privateIPAllocationMethodInstance = privateIPAllocationMethodValue; virtualNetworkGatewayIpConfigurationJsonFormatInstance.privateIpAllocationMethod = privateIPAllocationMethodInstance; } var subnetValue2 = propertiesValue4['subnet']; if (subnetValue2 !== null && subnetValue2 !== undefined) { var subnetInstance = {}; virtualNetworkGatewayIpConfigurationJsonFormatInstance.subnet = subnetInstance; var idValue = subnetValue2['id']; if (idValue !== null && idValue !== undefined) { var idInstance = idValue; subnetInstance.id = idInstance; } } var publicIPAddressValue2 = propertiesValue4['publicIPAddress']; if (publicIPAddressValue2 !== null && publicIPAddressValue2 !== undefined) { var publicIPAddressInstance = {}; virtualNetworkGatewayIpConfigurationJsonFormatInstance.publicIpAddress = publicIPAddressInstance; var idValue2 = publicIPAddressValue2['id']; if (idValue2 !== null && idValue2 !== undefined) { var idInstance2 = idValue2; publicIPAddressInstance.id = idInstance2; } } var provisioningStateValue = propertiesValue4['provisioningState']; if (provisioningStateValue !== null && provisioningStateValue !== undefined) { var provisioningStateInstance = provisioningStateValue; virtualNetworkGatewayIpConfigurationJsonFormatInstance.provisioningState = provisioningStateInstance; } } var nameValue = ipConfigurationsValue['name']; if (nameValue !== null && nameValue !== undefined) { var nameInstance = nameValue; virtualNetworkGatewayIpConfigurationJsonFormatInstance.name = nameInstance; } var etagValue = ipConfigurationsValue['etag']; if (etagValue !== null && etagValue !== undefined) { var etagInstance = etagValue; virtualNetworkGatewayIpConfigurationJsonFormatInstance.etag = etagInstance; } var idValue3 = ipConfigurationsValue['id']; if (idValue3 !== null && idValue3 !== undefined) { var idInstance3 = idValue3; virtualNetworkGatewayIpConfigurationJsonFormatInstance.id = idInstance3; } } } var gatewaySizeValue = propertiesValue3['gatewaySize']; if (gatewaySizeValue !== null && gatewaySizeValue !== undefined) { var gatewaySizeInstance = gatewaySizeValue; virtualNetworkGatewayInstance.gatewaySize = gatewaySizeInstance; } var gatewayTypeValue = propertiesValue3['gatewayType']; if (gatewayTypeValue !== null && gatewayTypeValue !== undefined) { var gatewayTypeInstance = gatewayTypeValue; virtualNetworkGatewayInstance.gatewayType = gatewayTypeInstance; } var enableBgpValue = propertiesValue3['enableBgp']; if (enableBgpValue !== null && enableBgpValue !== undefined) { var enableBgpInstance = enableBgpValue; virtualNetworkGatewayInstance.enableBgp = enableBgpInstance; } var provisioningStateValue2 = propertiesValue3['provisioningState']; if (provisioningStateValue2 !== null && provisioningStateValue2 !== undefined) { var provisioningStateInstance2 = provisioningStateValue2; virtualNetworkGatewayInstance.provisioningState = provisioningStateInstance2; } } var etagValue2 = responseDoc['etag']; if (etagValue2 !== null && etagValue2 !== undefined) { var etagInstance2 = etagValue2; virtualNetworkGatewayInstance.etag = etagInstance2; } var idValue4 = responseDoc['id']; if (idValue4 !== null && idValue4 !== undefined) { var idInstance4 = idValue4; virtualNetworkGatewayInstance.id = idInstance4; } var nameValue2 = responseDoc['name']; if (nameValue2 !== null && nameValue2 !== undefined) { var nameInstance2 = nameValue2; virtualNetworkGatewayInstance.name = nameInstance2; } var typeValue = responseDoc['type']; if (typeValue !== null && typeValue !== undefined) { var typeInstance = typeValue; virtualNetworkGatewayInstance.type = typeInstance; } var locationValue = responseDoc['location']; if (locationValue !== null && locationValue !== undefined) { var locationInstance = locationValue; virtualNetworkGatewayInstance.location = locationInstance; } var tagsSequenceElement = responseDoc['tags']; if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { for (var property in tagsSequenceElement) { var tagsKey2 = property; var tagsValue2 = tagsSequenceElement[property]; virtualNetworkGatewayInstance.tags[tagsKey2] = tagsValue2; } } var errorValue = responseDoc['error']; if (errorValue !== null && errorValue !== undefined) { var errorInstance = { details: [] }; result.error = errorInstance; var codeValue = errorValue['code']; if (codeValue !== null && codeValue !== undefined) { var codeInstance = codeValue; errorInstance.code = codeInstance; } var messageValue = errorValue['message']; if (messageValue !== null && messageValue !== undefined) { var messageInstance = messageValue; errorInstance.message = messageInstance; } var targetValue = errorValue['target']; if (targetValue !== null && targetValue !== undefined) { var targetInstance = targetValue; errorInstance.target = targetInstance; } var detailsArray = errorValue['details']; if (detailsArray !== null && detailsArray !== undefined) { for (var loweredIndex3 = 0; loweredIndex3 < detailsArray.length; loweredIndex3 = loweredIndex3 + 1) { var detailsValue = detailsArray[loweredIndex3]; var errorDetailsInstance = {}; errorInstance.details.push(errorDetailsInstance); var codeValue2 = detailsValue['code']; if (codeValue2 !== null && codeValue2 !== undefined) { var codeInstance2 = codeValue2; errorDetailsInstance.code = codeInstance2; } var targetValue2 = detailsValue['target']; if (targetValue2 !== null && targetValue2 !== undefined) { var targetInstance2 = targetValue2; errorDetailsInstance.target = targetInstance2; } var messageValue2 = detailsValue['message']; if (messageValue2 !== null && messageValue2 !== undefined) { var messageInstance2 = messageValue2; errorDetailsInstance.message = messageInstance2; } } } var innerErrorValue = errorValue['innerError']; if (innerErrorValue !== null && innerErrorValue !== undefined) { var innerErrorInstance = innerErrorValue; errorInstance.innerError = innerErrorInstance; } } } } result.statusCode = statusCode; result.azureAsyncOperation = response.headers['azure-asyncoperation']; result.retryAfter = parseInt(response.headers['retry-after'], 10); result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * The Put VirtualNetworkGatewayConnection operation creates/updates a * virtual network gateway connection in the specified resource group * through NRP. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} virtualNetworkGatewayConnectionName The name of the * virtual network gateway conenction. * * @param {VirtualNetworkGatewayConnection} parameters Parameters supplied to * the Begin Create or update Virtual Network Gateway connection operation * through NRP. * * @param {VirtualNetworkGateway} [parameters.virtualNetworkGateway1] * * @param {IEnumerable} [parameters.virtualNetworkGateway1.ipConfigurations] * IpConfigurations for Virtual network gateway. * * @param {string} [parameters.virtualNetworkGateway1.gatewaySize] The size * of this virtual network gateway. * * @param {string} [parameters.virtualNetworkGateway1.gatewayType] The size * of this virtual network gateway. * * @param {boolean} [parameters.virtualNetworkGateway1.enableBgp] EnableBgp * Flag * * @param {string} [parameters.virtualNetworkGateway1.provisioningState] Gets * or sets Provisioning state of the VirtualNetworkGateway resource * Updating/Deleting/Failed * * @param {string} [parameters.virtualNetworkGateway1.etag] Gets a unique * read-only string that changes whenever the resource is updated * * @param {string} [parameters.virtualNetworkGateway1.id] Gets or sets the ID * of the resource. * * @param {string} [parameters.virtualNetworkGateway1.