UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

1,155 lines (1,001 loc) 66.9 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 TrafficManagerManagementClient = ( /** @lends TrafficManagerManagementClient */ function() { /** * @class * The Windows Azure Traffic Manager management API provides a RESTful set of * web services that interact with Windows Azure Traffic Manager service for * creating, updating, listing, and deleting Traffic Manager profiles and * definitions. (see * http://msdn.microsoft.com/en-us/library/windowsazure/dn166981.aspx for * more information) * Initializes a new instance of the TrafficManagerManagementClient 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 TrafficManagerManagementClient(credentials, baseUri, filters) { if (credentials === null || credentials === undefined) { throw new Error('credentials cannot be null.'); } TrafficManagerManagementClient['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-04-28-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 [ProfileOperations](-ProfileOperations.html) * object. * @type {object} */ this.profiles = new ProfileOperations(this); } util.inherits(TrafficManagerManagementClient, Service); return TrafficManagerManagementClient; })(); exports.TrafficManagerManagementClient = TrafficManagerManagementClient; var ProfileOperations = ( /** @lends ProfileOperations */ function() { /** * @class * Operations for managing WATMv2 profiles. * __NOTE__: An instance of this class is automatically created for an * instance of the [TrafficManagerManagementClient] {@link * TrafficManagerManagementClient~TrafficManagerManagementClient}. * See [profiles] {@link * TrafficManagerManagementClient~TrafficManagerManagementClient#profiles}. * Initializes a new instance of the ProfileOperations class. * @constructor * * @param {TrafficManagerManagementClient} client Reference to the service * client. */ function ProfileOperations(client) { this.client = client; } /** * Create or update a WATMv2 profile within a resource group. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} profileName The name of the zone without a terminating dot. * * @param {ProfileCreateOrUpdateParameters} parameters Parameters supplied to * the CreateOrUpdate operation. * * @param {Profile} parameters.profile Gets or sets information about the * Profile being created or updated. * * @param {ProfileProperties} [parameters.profile.properties] Gets or sets * the properties of the profile. * * @param {string} [parameters.profile.properties.profileStatus] Gets or sets * the status of the profile. * * @param {string} [parameters.profile.properties.trafficRoutingMethod] Gets * or sets the load balancing method of the profile. * * @param {DnsConfig} [parameters.profile.properties.dnsConfig] Gets or sets * the dns config of the profile. * * @param {string} [parameters.profile.properties.dnsConfig.relativeName] * Gets or sets the relative name of the dns config. * * @param {string} [parameters.profile.properties.dnsConfig.fqdn] Gets or * sets the fqdn of the dns config. * * @param {number} [parameters.profile.properties.dnsConfig.ttl] Gets or sets * the ttl of the dns config. * * @param {MonitorConfig} [parameters.profile.properties.monitorConfig] Gets * or sets the monitor config of the profile. * * @param {string} * [parameters.profile.properties.monitorConfig.profileMonitorStatus] Gets * or sets the profile monitor status of the monitor config. * * @param {string} [parameters.profile.properties.monitorConfig.protocol] * Gets or sets the protocol of the monitor config. * * @param {number} [parameters.profile.properties.monitorConfig.port] Gets or * sets the port of the monitor config. * * @param {string} [parameters.profile.properties.monitorConfig.path] Gets or * sets the path of the monitor config. * * @param {array} [parameters.profile.properties.endpoints] Gets or sets the * list of endpoints in a profile. * * @param {string} [parameters.profile.id] Gets or sets the ID of the * resource. * * @param {string} [parameters.profile.name] Gets or sets the name of the * resource. * * @param {string} [parameters.profile.type] Gets or sets the type of the * resource. * * @param {string} parameters.profile.location Gets or sets the location of * the resource. * * @param {object} [parameters.profile.tags] Gets or sets the tags attached * to the resource. * * @param {function} callback * * @returns {Stream} The response stream. */ ProfileOperations.prototype.createOrUpdate = function(resourceGroupName, profileName, 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 (profileName === null || profileName === undefined) { return callback(new Error('profileName cannot be null.')); } if (parameters === null || parameters === undefined) { return callback(new Error('parameters cannot be null.')); } if (parameters.profile === null || parameters.profile === undefined) { return callback(new Error('parameters.profile cannot be null.')); } if (parameters.profile.location === null || parameters.profile.location === undefined) { return callback(new Error('parameters.profile.location cannot be null.')); } if (parameters.profile.properties !== null && parameters.profile.properties !== undefined) { if (parameters.profile.properties.dnsConfig === null || parameters.profile.properties.dnsConfig === undefined) { return callback(new Error('parameters.profile.properties.dnsConfig cannot be null.')); } if (parameters.profile.properties.dnsConfig.relativeName === null || parameters.profile.properties.dnsConfig.relativeName === undefined) { return callback(new Error('parameters.profile.properties.dnsConfig.relativeName cannot be null.')); } if (parameters.profile.properties.dnsConfig.ttl === null || parameters.profile.properties.dnsConfig.ttl === undefined) { return callback(new Error('parameters.profile.properties.dnsConfig.ttl cannot be null.')); } if (parameters.profile.properties.endpoints !== null && parameters.profile.properties.endpoints !== undefined) { for (var loweredIndex1 = 0; loweredIndex1 < parameters.profile.properties.endpoints.length; loweredIndex1 = loweredIndex1 + 1) { var endpointsParameterItem = parameters.profile.properties.endpoints[loweredIndex1]; if (endpointsParameterItem.properties === null || endpointsParameterItem.properties === undefined) { return callback(new Error('parameters.profile.properties.endpoints.properties cannot be null.')); } if (endpointsParameterItem.properties.endpointStatus === null || endpointsParameterItem.properties.endpointStatus === undefined) { return callback(new Error('parameters.profile.properties.endpoints.properties.endpointStatus cannot be null.')); } if (endpointsParameterItem.properties.target === null || endpointsParameterItem.properties.target === undefined) { return callback(new Error('parameters.profile.properties.endpoints.properties.target cannot be null.')); } } } if (parameters.profile.properties.monitorConfig === null || parameters.profile.properties.monitorConfig === undefined) { return callback(new Error('parameters.profile.properties.monitorConfig cannot be null.')); } if (parameters.profile.properties.monitorConfig.path === null || parameters.profile.properties.monitorConfig.path === undefined) { return callback(new Error('parameters.profile.properties.monitorConfig.path cannot be null.')); } if (parameters.profile.properties.monitorConfig.port === null || parameters.profile.properties.monitorConfig.port === undefined) { return callback(new Error('parameters.profile.properties.monitorConfig.port cannot be null.')); } if (parameters.profile.properties.monitorConfig.protocol === null || parameters.profile.properties.monitorConfig.protocol === undefined) { return callback(new Error('parameters.profile.properties.monitorConfig.protocol cannot be null.')); } if (parameters.profile.properties.trafficRoutingMethod === null || parameters.profile.properties.trafficRoutingMethod === undefined) { return callback(new Error('parameters.profile.properties.trafficRoutingMethod 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/'; url2 = url2 + 'microsoft.network'; url2 = url2 + '/trafficmanagerprofiles/'; url2 = url2 + encodeURIComponent(profileName); var queryParameters = []; queryParameters.push('api-version=2015-04-28-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; charset=utf-8'; // Serialize Request var requestContent = null; var requestDoc = null; var profileCreateOrUpdateParametersValue = {}; requestDoc = profileCreateOrUpdateParametersValue; if (parameters.profile.properties !== null && parameters.profile.properties !== undefined) { var propertiesValue = {}; profileCreateOrUpdateParametersValue['properties'] = propertiesValue; if (parameters.profile.properties.profileStatus !== null && parameters.profile.properties.profileStatus !== undefined) { propertiesValue['profileStatus'] = parameters.profile.properties.profileStatus; } propertiesValue['trafficRoutingMethod'] = parameters.profile.properties.trafficRoutingMethod; var dnsConfigValue = {}; propertiesValue['dnsConfig'] = dnsConfigValue; dnsConfigValue['relativeName'] = parameters.profile.properties.dnsConfig.relativeName; if (parameters.profile.properties.dnsConfig.fqdn !== null && parameters.profile.properties.dnsConfig.fqdn !== undefined) { dnsConfigValue['fqdn'] = parameters.profile.properties.dnsConfig.fqdn; } dnsConfigValue['ttl'] = parameters.profile.properties.dnsConfig.ttl; var monitorConfigValue = {}; propertiesValue['monitorConfig'] = monitorConfigValue; if (parameters.profile.properties.monitorConfig.profileMonitorStatus !== null && parameters.profile.properties.monitorConfig.profileMonitorStatus !== undefined) { monitorConfigValue['profileMonitorStatus'] = parameters.profile.properties.monitorConfig.profileMonitorStatus; } monitorConfigValue['protocol'] = parameters.profile.properties.monitorConfig.protocol; monitorConfigValue['port'] = parameters.profile.properties.monitorConfig.port; monitorConfigValue['path'] = parameters.profile.properties.monitorConfig.path; if (parameters.profile.properties.endpoints !== null && parameters.profile.properties.endpoints !== undefined) { var endpointsArray = []; for (var loweredIndex2 = 0; loweredIndex2 < parameters.profile.properties.endpoints.length; loweredIndex2 = loweredIndex2 + 1) { var endpointsItem = parameters.profile.properties.endpoints[loweredIndex2]; var endpointValue = {}; endpointsArray.push(endpointValue); if (endpointsItem.id !== null && endpointsItem.id !== undefined) { endpointValue['id'] = endpointsItem.id; } if (endpointsItem.name !== null && endpointsItem.name !== undefined) { endpointValue['name'] = endpointsItem.name; } if (endpointsItem.type !== null && endpointsItem.type !== undefined) { endpointValue['type'] = endpointsItem.type; } var propertiesValue2 = {}; endpointValue['properties'] = propertiesValue2; if (endpointsItem.properties.targetResourceId !== null && endpointsItem.properties.targetResourceId !== undefined) { propertiesValue2['targetResourceId'] = endpointsItem.properties.targetResourceId; } propertiesValue2['target'] = endpointsItem.properties.target; propertiesValue2['endpointStatus'] = endpointsItem.properties.endpointStatus; if (endpointsItem.properties.weight !== null && endpointsItem.properties.weight !== undefined) { propertiesValue2['weight'] = endpointsItem.properties.weight; } if (endpointsItem.properties.priority !== null && endpointsItem.properties.priority !== undefined) { propertiesValue2['priority'] = endpointsItem.properties.priority; } if (endpointsItem.properties.endpointLocation !== null && endpointsItem.properties.endpointLocation !== undefined) { propertiesValue2['endpointLocation'] = endpointsItem.properties.endpointLocation; } if (endpointsItem.properties.endpointMonitorStatus !== null && endpointsItem.properties.endpointMonitorStatus !== undefined) { propertiesValue2['endpointMonitorStatus'] = endpointsItem.properties.endpointMonitorStatus; } } propertiesValue['endpoints'] = endpointsArray; } } if (parameters.profile.id !== null && parameters.profile.id !== undefined) { profileCreateOrUpdateParametersValue['id'] = parameters.profile.id; } if (parameters.profile.name !== null && parameters.profile.name !== undefined) { profileCreateOrUpdateParametersValue['name'] = parameters.profile.name; } if (parameters.profile.type !== null && parameters.profile.type !== undefined) { profileCreateOrUpdateParametersValue['type'] = parameters.profile.type; } profileCreateOrUpdateParametersValue['location'] = parameters.profile.location; if (parameters.profile.tags !== null && parameters.profile.tags !== undefined) { var tagsDictionary = {}; for (var tagsKey in parameters.profile.tags) { var tagsValue = parameters.profile.tags[tagsKey]; tagsDictionary[tagsKey] = tagsValue; } profileCreateOrUpdateParametersValue['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 >= 400) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response var responseContent = body; result = {}; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var profileInstance = { tags: {} }; result.profile = profileInstance; var propertiesValue3 = responseDoc['properties']; if (propertiesValue3 !== null && propertiesValue3 !== undefined) { var propertiesInstance = { endpoints: [] }; profileInstance.properties = propertiesInstance; var profileStatusValue = propertiesValue3['profileStatus']; if (profileStatusValue !== null && profileStatusValue !== undefined) { var profileStatusInstance = profileStatusValue; propertiesInstance.profileStatus = profileStatusInstance; } var trafficRoutingMethodValue = propertiesValue3['trafficRoutingMethod']; if (trafficRoutingMethodValue !== null && trafficRoutingMethodValue !== undefined) { var trafficRoutingMethodInstance = trafficRoutingMethodValue; propertiesInstance.trafficRoutingMethod = trafficRoutingMethodInstance; } var dnsConfigValue2 = propertiesValue3['dnsConfig']; if (dnsConfigValue2 !== null && dnsConfigValue2 !== undefined) { var dnsConfigInstance = {}; propertiesInstance.dnsConfig = dnsConfigInstance; var relativeNameValue = dnsConfigValue2['relativeName']; if (relativeNameValue !== null && relativeNameValue !== undefined) { var relativeNameInstance = relativeNameValue; dnsConfigInstance.relativeName = relativeNameInstance; } var fqdnValue = dnsConfigValue2['fqdn']; if (fqdnValue !== null && fqdnValue !== undefined) { var fqdnInstance = fqdnValue; dnsConfigInstance.fqdn = fqdnInstance; } var ttlValue = dnsConfigValue2['ttl']; if (ttlValue !== null && ttlValue !== undefined) { var ttlInstance = ttlValue; dnsConfigInstance.ttl = ttlInstance; } } var monitorConfigValue2 = propertiesValue3['monitorConfig']; if (monitorConfigValue2 !== null && monitorConfigValue2 !== undefined) { var monitorConfigInstance = {}; propertiesInstance.monitorConfig = monitorConfigInstance; var profileMonitorStatusValue = monitorConfigValue2['profileMonitorStatus']; if (profileMonitorStatusValue !== null && profileMonitorStatusValue !== undefined) { var profileMonitorStatusInstance = profileMonitorStatusValue; monitorConfigInstance.profileMonitorStatus = profileMonitorStatusInstance; } var protocolValue = monitorConfigValue2['protocol']; if (protocolValue !== null && protocolValue !== undefined) { var protocolInstance = protocolValue; monitorConfigInstance.protocol = protocolInstance; } var portValue = monitorConfigValue2['port']; if (portValue !== null && portValue !== undefined) { var portInstance = portValue; monitorConfigInstance.port = portInstance; } var pathValue = monitorConfigValue2['path']; if (pathValue !== null && pathValue !== undefined) { var pathInstance = pathValue; monitorConfigInstance.path = pathInstance; } } var endpointsArray2 = propertiesValue3['endpoints']; if (endpointsArray2 !== null && endpointsArray2 !== undefined) { propertiesInstance.endpoints = []; for (var loweredIndex3 = 0; loweredIndex3 < endpointsArray2.length; loweredIndex3 = loweredIndex3 + 1) { var endpointsValue = endpointsArray2[loweredIndex3]; var endpointInstance = {}; propertiesInstance.endpoints.push(endpointInstance); var idValue = endpointsValue['id']; if (idValue !== null && idValue !== undefined) { var idInstance = idValue; endpointInstance.id = idInstance; } var nameValue = endpointsValue['name']; if (nameValue !== null && nameValue !== undefined) { var nameInstance = nameValue; endpointInstance.name = nameInstance; } var typeValue = endpointsValue['type']; if (typeValue !== null && typeValue !== undefined) { var typeInstance = typeValue; endpointInstance.type = typeInstance; } var propertiesValue4 = endpointsValue['properties']; if (propertiesValue4 !== null && propertiesValue4 !== undefined) { var propertiesInstance2 = {}; endpointInstance.properties = propertiesInstance2; var targetResourceIdValue = propertiesValue4['targetResourceId']; if (targetResourceIdValue !== null && targetResourceIdValue !== undefined) { var targetResourceIdInstance = targetResourceIdValue; propertiesInstance2.targetResourceId = targetResourceIdInstance; } var targetValue = propertiesValue4['target']; if (targetValue !== null && targetValue !== undefined) { var targetInstance = targetValue; propertiesInstance2.target = targetInstance; } var endpointStatusValue = propertiesValue4['endpointStatus']; if (endpointStatusValue !== null && endpointStatusValue !== undefined) { var endpointStatusInstance = endpointStatusValue; propertiesInstance2.endpointStatus = endpointStatusInstance; } var weightValue = propertiesValue4['weight']; if (weightValue !== null && weightValue !== undefined) { var weightInstance = weightValue; propertiesInstance2.weight = weightInstance; } var priorityValue = propertiesValue4['priority']; if (priorityValue !== null && priorityValue !== undefined) { var priorityInstance = priorityValue; propertiesInstance2.priority = priorityInstance; } var endpointLocationValue = propertiesValue4['endpointLocation']; if (endpointLocationValue !== null && endpointLocationValue !== undefined) { var endpointLocationInstance = endpointLocationValue; propertiesInstance2.endpointLocation = endpointLocationInstance; } var endpointMonitorStatusValue = propertiesValue4['endpointMonitorStatus']; if (endpointMonitorStatusValue !== null && endpointMonitorStatusValue !== undefined) { var endpointMonitorStatusInstance = endpointMonitorStatusValue; propertiesInstance2.endpointMonitorStatus = endpointMonitorStatusInstance; } } } } } var idValue2 = responseDoc['id']; if (idValue2 !== null && idValue2 !== undefined) { var idInstance2 = idValue2; profileInstance.id = idInstance2; } var nameValue2 = responseDoc['name']; if (nameValue2 !== null && nameValue2 !== undefined) { var nameInstance2 = nameValue2; profileInstance.name = nameInstance2; } var typeValue2 = responseDoc['type']; if (typeValue2 !== null && typeValue2 !== undefined) { var typeInstance2 = typeValue2; profileInstance.type = typeInstance2; } var locationValue = responseDoc['location']; if (locationValue !== null && locationValue !== undefined) { var locationInstance = locationValue; profileInstance.location = locationInstance; } var tagsSequenceElement = responseDoc['tags']; if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { for (var property in tagsSequenceElement) { var tagsKey2 = property; var tagsValue2 = tagsSequenceElement[property]; profileInstance.tags[tagsKey2] = tagsValue2; } } } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * Deletes a WATMv2 profile within a resource group. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} profileName The name of the zone without a terminating dot. * * @param {function} callback * * @returns {Stream} The response stream. */ ProfileOperations.prototype.deleteMethod = function(resourceGroupName, profileName, 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 (profileName === null || profileName === undefined) { return callback(new Error('profileName 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/'; url2 = url2 + 'microsoft.network'; url2 = url2 + '/trafficmanagerprofiles/'; url2 = url2 + encodeURIComponent(profileName); var queryParameters = []; queryParameters.push('api-version=2015-04-28-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 = 'DELETE'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; // 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 >= 400) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response result = {}; result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * Gets a WATMv2 profile within a resource group. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} profileName The name of the zone without a terminating dot. * * @param {function} callback * * @returns {Stream} The response stream. */ ProfileOperations.prototype.get = function(resourceGroupName, profileName, 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 (profileName === null || profileName === undefined) { return callback(new Error('profileName 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/'; url2 = url2 + 'microsoft.network'; url2 = url2 + '/trafficmanagerprofiles/'; url2 = url2 + encodeURIComponent(profileName); var queryParameters = []; queryParameters.push('api-version=2015-04-28-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 = 'GET'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; // 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 >= 400) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response var responseContent = body; result = {}; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var profileInstance = { tags: {} }; result.profile = profileInstance; var propertiesValue = responseDoc['properties']; if (propertiesValue !== null && propertiesValue !== undefined) { var propertiesInstance = { endpoints: [] }; profileInstance.properties = propertiesInstance; var profileStatusValue = propertiesValue['profileStatus']; if (profileStatusValue !== null && profileStatusValue !== undefined) { var profileStatusInstance = profileStatusValue; propertiesInstance.profileStatus = profileStatusInstance; } var trafficRoutingMethodValue = propertiesValue['trafficRoutingMethod']; if (trafficRoutingMethodValue !== null && trafficRoutingMethodValue !== undefined) { var trafficRoutingMethodInstance = trafficRoutingMethodValue; propertiesInstance.trafficRoutingMethod = trafficRoutingMethodInstance; } var dnsConfigValue = propertiesValue['dnsConfig']; if (dnsConfigValue !== null && dnsConfigValue !== undefined) { var dnsConfigInstance = {}; propertiesInstance.dnsConfig = dnsConfigInstance; var relativeNameValue = dnsConfigValue['relativeName']; if (relativeNameValue !== null && relativeNameValue !== undefined) { var relativeNameInstance = relativeNameValue; dnsConfigInstance.relativeName = relativeNameInstance; } var fqdnValue = dnsConfigValue['fqdn']; if (fqdnValue !== null && fqdnValue !== undefined) { var fqdnInstance = fqdnValue; dnsConfigInstance.fqdn = fqdnInstance; } var ttlValue = dnsConfigValue['ttl']; if (ttlValue !== null && ttlValue !== undefined) { var ttlInstance = ttlValue; dnsConfigInstance.ttl = ttlInstance; } } var monitorConfigValue = propertiesValue['monitorConfig']; if (monitorConfigValue !== null && monitorConfigValue !== undefined) { var monitorConfigInstance = {}; propertiesInstance.monitorConfig = monitorConfigInstance; var profileMonitorStatusValue = monitorConfigValue['profileMonitorStatus']; if (profileMonitorStatusValue !== null && profileMonitorStatusValue !== undefined) { var profileMonitorStatusInstance = profileMonitorStatusValue; monitorConfigInstance.profileMonitorStatus = profileMonitorStatusInstance; } var protocolValue = monitorConfigValue['protocol']; if (protocolValue !== null && protocolValue !== undefined) { var protocolInstance = protocolValue; monitorConfigInstance.protocol = protocolInstance; } var portValue = monitorConfigValue['port']; if (portValue !== null && portValue !== undefined) { var portInstance = portValue; monitorConfigInstance.port = portInstance; } var pathValue = monitorConfigValue['path']; if (pathValue !== null && pathValue !== undefined) { var pathInstance = pathValue; monitorConfigInstance.path = pathInstance; } } var endpointsArray = propertiesValue['endpoints']; if (endpointsArray !== null && endpointsArray !== undefined) { propertiesInstance.endpoints = []; for (var loweredIndex1 = 0; loweredIndex1 < endpointsArray.length; loweredIndex1 = loweredIndex1 + 1) { var endpointsValue = endpointsArray[loweredIndex1]; var endpointInstance = {}; propertiesInstance.endpoints.push(endpointInstance); var idValue = endpointsValue['id']; if (idValue !== null && idValue !== undefined) { var idInstance = idValue; endpointInstance.id = idInstance; } var nameValue = endpointsValue['name']; if (nameValue !== null && nameValue !== undefined) { var nameInstance = nameValue; endpointInstance.name = nameInstance; } var typeValue = endpointsValue['type']; if (typeValue !== null && typeValue !== undefined) { var typeInstance = typeValue; endpointInstance.type = typeInstance; } var propertiesValue2 = endpointsValue['properties']; if (propertiesValue2 !== null && propertiesValue2 !== undefined) { var propertiesInstance2 = {}; endpointInstance.properties = propertiesInstance2; var targetResourceIdValue = propertiesValue2['targetResourceId']; if (targetResourceIdValue !== null && targetResourceIdValue !== undefined) { var targetResourceIdInstance = targetResourceIdValue; propertiesInstance2.targetResourceId = targetResourceIdInstance; } var targetValue = propertiesValue2['target']; if (targetValue !== null && targetValue !== undefined) { var targetInstance = targetValue; propertiesInstance2.target = targetInstance; } var endpointStatusValue = propertiesValue2['endpointStatus']; if (endpointStatusValue !== null && endpointStatusValue !== undefined) { var endpointStatusInstance = endpointStatusValue; propertiesInstance2.endpointStatus = endpointStatusInstance; } var weightValue = propertiesValue2['weight']; if (weightValue !== null && weightValue !== undefined) { var weightInstance = weightValue; propertiesInstance2.weight = weightInstance; } var priorityValue = propertiesValue2['priority']; if (priorityValue !== null && priorityValue !== undefined) { var priorityInstance = priorityValue; propertiesInstance2.priority = priorityInstance; } var endpointLocationValue = propertiesValue2['endpointLocation']; if (endpointLocationValue !== null && endpointLocationValue !== undefined) { var endpointLocationInstance = endpointLocationValue; propertiesInstance2.endpointLocation = endpointLocationInstance; } var endpointMonitorStatusValue = propertiesValue2['endpointMonitorStatus']; if (endpointMonitorStatusValue !== null && endpointMonitorStatusValue !== undefined) { var endpointMonitorStatusInstance = endpointMonitorStatusValue; propertiesInstance2.endpointMonitorStatus = endpointMonitorStatusInstance; } } } } } var idValue2 = responseDoc['id']; if (idValue2 !== null && idValue2 !== undefined) { var idInstance2 = idValue2; profileInstance.id = idInstance2; } var nameValue2 = responseDoc['name']; if (nameValue2 !== null && nameValue2 !== undefined) { var nameInstance2 = nameValue2; profileInstance.name = nameInstance2; } var typeValue2 = responseDoc['type']; if (typeValue2 !== null && typeValue2 !== undefined) { var typeInstance2 = typeValue2; profileInstance.type = typeInstance2; } var locationValue = responseDoc['location']; if (locationValue !== null && locationValue !== undefined) { var locationInstance = locationValue; profileInstance.location = locationInstance; } var tagsSequenceElement = responseDoc['tags']; if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) { for (var property in tagsSequenceElement) { var tagsKey = property; var tagsValue = tagsSequenceElement[property]; profileInstance.tags[tagsKey] = tagsValue; } } } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * Lists all WATMv2 profile within a subscription. * * @param {function} callback * * @returns {Stream} The response stream. */ ProfileOperations.prototype.listAll = function(callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate // 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 + '/providers/'; url2 = url2 + 'microsoft.network'; url2 = url2 + '/trafficmanagerprofiles'; var queryParameters = []; queryParameters.push('api-version=2015-04-28-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 = 'GET'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; // 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 >= 400) { var error = new Error(body); error.statusCode = response.statusCode; return callback(error); } // Create Result var result = null; // Deserialize Response var responseContent = body; result = { profiles: [] }; var responseDoc = null; if (responseContent) { responseDoc = JSON.parse(responseContent); } if (responseDoc !== null && responseDoc !== undefined) { var valuesArray = responseDoc['values']; if (valuesArray !== null && valuesArray !== undefined) { for (var loweredIndex1 = 0; loweredIndex1 < valuesArray.length; loweredIndex1 = loweredIndex1 + 1) { var valuesValue = valuesArray[loweredIndex1]; var profileInstance = { tags: {} }; result.profiles.push(profileInstance); var propertiesValue = valuesValue['properties']; if (propertiesValue !== null && propertiesValue !== undefined) { var propertiesInstance = { endpoints: [] }; profileInstance.properties = propertiesInstance; var profileStatusValue = propertiesValue['profileStatus']; if (profileStatusValue !== null && profileStatusValue !== undefined) { var profileStatusInstance = profileStatusValue; propertiesInstance.profileStatus = profileStatusInstance; } var trafficRoutingMethodValue = propertiesValue['trafficRoutingMethod']; if (trafficRoutingMethodValue !== null && trafficRoutingMethodValue !== undefined) { var trafficRoutingMethodInstance = trafficRoutingMethodValue; propertiesInstance.trafficRoutingMethod = trafficRoutingMethodInstance; } var dnsConfigValue = propertiesValue['dnsConfig']; if (dnsConfigValue !== null && dnsConfigValue !== undefined) { var dnsConfigInstance = {}; propertiesInstance.dnsConfig = dnsConfigInstance; var relativeNameValue = dnsConfigValue['relativeName']; if (relativeNameValue !== null && relativeNameValue !== undefined) { var relativeNameInstance = relativeNameValue; dnsConfigInstance.relativeName = relativeNameInstance; } var fqdnValue = dnsConfigValue['fqdn']; if (fqdnValue !== null && fqdnValue !== undefined) { var fqdnInstance = fqdnValue; dnsConfigInstance.fqdn = fqdnInstance; } var ttlValue = dnsConfigValue['ttl']; if (ttlValue !== null && ttlValue !== undefined) { var ttlInstance = ttlValue; dnsConfigInstance.ttl = ttlInstance; } } var monitorConfigValue = propertiesValue['monitorConfig']; if (monitorConfigValue !== null && monitorConfigValue !== undefined) { var monitorConfigInstance = {}; propertiesInstance.monitorConfig = monitorConfigInstance; var profileMonitorStatusValue = monitorConfigValue['profileMonitorStatus']; if (profileMonitorStatusValue !== null && profileMonitorStatusValue !== undefined) { var profileMonitorStatusInstance = profileMonitorStatusValue; monitorConfigInstance.profileMonitorStatus = profileMonitorStatusInstance; } var protocolValue = monitorConfigValue['protocol']; if (protocolValue !== null && protocolValue !== undefined) { var protocolInstance = protocolValue; monitorConfigInstance.protocol = protocolInstance; } var portValue = monitorConfigValue['port']; if (portValue !== null && portValue !== undefined) { var portInstance = portValue; monitorConfigInstance.port = portInstance; } var pathValue = monitorConfigValue['path']; if (pathValue !== null && pathValue !== undefined) { var pathInstance = pathValue; monitorConfigInstance.path = pathInstance; } } var endpointsArray = propertiesValue['endpoints']; if (endpointsArray !== null && endpointsArray !== undefined) { propertiesInstance.endpoints = []; for (var loweredIndex2 = 0; loweredIndex2 < endpointsArray.length; loweredIndex2 = loweredIndex2 + 1) { var endpointsValue = endpointsArray[loweredIndex2]; var endpointInstance = {}; propertiesInstance.endpoints.push(endpointInstance); var idValue = endpointsValue['id']; if (idValue !== null && idValue !== undefined) { var idInstance = idValue; endpointInstance.id = idInstance; } var nameValue = endpointsValue['name']; if (nameValue !== null && nameValue !== undefined) { var nameInstance = nameValue; endpointInstance.name = nameInstance; } var typeValue = endpointsValue['type']; if (typeValue !== null && typeValue !== undefined) { var typeInstance = typeValue; endpointInstance.type = typeInstance; } var propertiesValue2 = endpointsValue['properties']; if (propertiesValue2 !== null && propertiesValue2 !== undefined) {