UNPKG

azure-asm-mgmt

Version:

Microsoft Azure Management Client Library for node

1,059 lines (942 loc) 113 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 xml = azureCommon.xml2js; var js2xml = azureCommon.js2xml; var Service = azureCommon.Service; var WebResource = azureCommon.WebResource; var ManagementClient = ( /** @lends ManagementClient */ function() { /** * @class * The Service Management API provides programmatic access to much of the * functionality available through the Management Portal. The Service * Management API is a REST API. All API operations are performed over SSL * and are mutually authenticated using X.509 v3 certificates. (see * http://msdn.microsoft.com/en-us/library/windowsazure/ee460799.aspx for * more information) * Initializes a new instance of the ManagementClient 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 ManagementClient(credentials, baseUri, filters) { if (credentials === null || credentials === undefined) { throw new Error('credentials cannot be null.'); } ManagementClient['super_'].call(this, credentials, filters); this.credentials = credentials; this.baseUri = baseUri; if (this.baseUri === null || this.baseUri === undefined) { this.baseUri = 'https://management.core.windows.net'; } if (this.apiVersion === null || this.apiVersion === undefined) { this.apiVersion = '2014-10-01'; } 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 * [AffinityGroupOperations](-AffinityGroupOperations.html) object. * @type {object} */ this.affinityGroups = new AffinityGroupOperations(this); /** * Provides an instance of the * [LocationOperations](-LocationOperations.html) object. * @type {object} */ this.locations = new LocationOperations(this); /** * Provides an instance of the * [ManagementCertificateOperations](-ManagementCertificateOperations.html) * object. * @type {object} */ this.managementCertificates = new ManagementCertificateOperations(this); /** * Provides an instance of the * [RoleSizeOperations](-RoleSizeOperations.html) object. * @type {object} */ this.roleSizes = new RoleSizeOperations(this); /** * Provides an instance of the * [SubscriptionOperations](-SubscriptionOperations.html) object. * @type {object} */ this.subscriptions = new SubscriptionOperations(this); } util.inherits(ManagementClient, Service); /** * 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. (see * http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx for * more information) * * @param {string} requestId The request ID for the request you wish to * track. The request ID is returned in the x-ms-request-id response header * for every request. * * @param {function} callback * * @returns {Stream} The response stream. */ ManagementClient.prototype.getOperationStatus = function(requestId, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (requestId === null || requestId === undefined) { return callback(new Error('requestId cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.credentials.subscriptionId); } url2 = url2 + '/operations/'; url2 = url2 + encodeURIComponent(requestId); 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['x-ms-version'] = '2014-10-01'; // 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 options = {}; options.trim = false; options.strict = false; xml.parseString(responseContent, options, function (err2, responseDoc) { if (err2 !== null && err2 !== undefined) { return callback(err2); } var operationElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (operationElement !== null && operationElement !== undefined) { var idElement = js2xml.getElement(responseDoc, operationElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (idElement !== null && idElement !== undefined) { var idInstance = idElement; result.id = idInstance; } var statusElement = js2xml.getElement(responseDoc, operationElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) { var statusInstance = statusElement; result.status = statusInstance; } var httpStatusCodeElement = js2xml.getElement(responseDoc, operationElement, 'HTTPSTATUSCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (httpStatusCodeElement !== null && httpStatusCodeElement !== undefined && httpStatusCodeElement.length !== 0) { var httpStatusCodeInstance = httpStatusCodeElement; result.httpStatusCode = httpStatusCodeInstance; } var errorElement = js2xml.getElement(responseDoc, operationElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (errorElement !== null && errorElement !== undefined) { var errorInstance = {}; result.error = errorInstance; var codeElement = js2xml.getElement(responseDoc, errorElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (codeElement !== null && codeElement !== undefined) { var codeInstance = codeElement; errorInstance.code = codeInstance; } var messageElement = js2xml.getElement(responseDoc, errorElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (messageElement !== null && messageElement !== undefined) { var messageInstance = messageElement; errorInstance.message = messageInstance; } } } }); } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; return ManagementClient; })(); exports.ManagementClient = ManagementClient; var AffinityGroupOperations = ( /** @lends AffinityGroupOperations */ function() { /** * @class * Operations for managing affinity groups in your subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/ee460798.aspx for * more information) * __NOTE__: An instance of this class is automatically created for an * instance of the [ManagementClient] {@link * ManagementClient~ManagementClient}. * See [affinityGroups] {@link * ManagementClient~ManagementClient#affinityGroups}. * Initializes a new instance of the AffinityGroupOperations class. * @constructor * * @param {ManagementClient} client Reference to the service client. */ function AffinityGroupOperations(client) { this.client = client; } /** * The Create Affinity Group operation creates a new affinity group for the * specified subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/gg715317.aspx for * more information) * * @param {AffinityGroupCreateParameters} parameters Parameters supplied to * the Create Affinity Group operation. * * @param {string} parameters.name A name for the affinity group that is * unique to the subscription. * * @param {string} parameters.label A base-64-encoded name for the affinity * group. The name can be up to 100 characters in length. Its value defaults * to the Name of the affinity group if not provided. * * @param {string} [parameters.description] A description for the affinity * group. The description can be up to 1024 characters in length. * * @param {string} parameters.location The data center location where the * affinity group will be created. To list available locations, see the List * Locations operation. * * @param {function} callback * * @returns {Stream} The response stream. */ AffinityGroupOperations.prototype.create = function(parameters, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (parameters === null || parameters === undefined) { return callback(new Error('parameters cannot be null.')); } if (parameters.description !== null && parameters.description !== undefined && parameters.description.length > 1024) { return callback(new Error('parameters.description is outside the valid range.')); } if (parameters.label === null || parameters.label === undefined) { return callback(new Error('parameters.label cannot be null.')); } if (parameters.label.length > 100) { return callback(new Error('parameters.label is outside the valid range.')); } if (parameters.location === null || parameters.location === undefined) { return callback(new Error('parameters.location cannot be null.')); } if (parameters.name === null || parameters.name === undefined) { return callback(new Error('parameters.name cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/affinitygroups'; 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 = 'POST'; httpRequest.headers = {}; httpRequest.url = url2; // Set Headers httpRequest.headers['Content-Type'] = 'application/xml'; httpRequest.headers['x-ms-version'] = '2014-10-01'; // Serialize Request var requestContent = null; var requestDoc = {}; var createAffinityGroupElement = js2xml.createElement('CreateAffinityGroup', 'http://schemas.microsoft.com/windowsazure'); js2xml.addChildElement(requestDoc, createAffinityGroupElement); var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure'); js2xml.setElementValue(nameElement, parameters.name); js2xml.addChildElement(createAffinityGroupElement, nameElement); var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure'); js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64')); js2xml.addChildElement(createAffinityGroupElement, labelElement); if (parameters.description !== null && parameters.description !== undefined) { var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure'); js2xml.setElementValue(descriptionElement, parameters.description); js2xml.addChildElement(createAffinityGroupElement, descriptionElement); } var locationElement = js2xml.createElement('Location', 'http://schemas.microsoft.com/windowsazure'); js2xml.setElementValue(locationElement, parameters.location); js2xml.addChildElement(createAffinityGroupElement, locationElement); requestContent = js2xml.serializeDocument(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 !== 201) { 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); }); }; /** * The Delete Affinity Group operation deletes an affinity group in the * specified subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/gg715314.aspx for * more information) * * @param {string} affinityGroupName The name of the affinity group. * * @param {function} callback * * @returns {Stream} The response stream. */ AffinityGroupOperations.prototype.deleteMethod = function(affinityGroupName, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (affinityGroupName === null || affinityGroupName === undefined) { return callback(new Error('affinityGroupName cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/affinitygroups/'; url2 = url2 + encodeURIComponent(affinityGroupName); 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['x-ms-version'] = '2014-10-01'; // 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) { 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); }); }; /** * The Get Affinity Group Properties operation returns the system properties * associated with the specified affinity group. (see * http://msdn.microsoft.com/en-us/library/windowsazure/ee460789.aspx for * more information) * * @param {string} affinityGroupName The name of the desired affinity group * as returned by the name element of the List Affinity Groups operation. * * @param {function} callback * * @returns {Stream} The response stream. */ AffinityGroupOperations.prototype.get = function(affinityGroupName, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (affinityGroupName === null || affinityGroupName === undefined) { return callback(new Error('affinityGroupName cannot be null.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/affinitygroups/'; url2 = url2 + encodeURIComponent(affinityGroupName); 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['x-ms-version'] = '2014-10-01'; // 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) { 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 = { capabilities: [], hostedServices: [], storageServices: [] }; var options = {}; options.trim = false; options.strict = false; xml.parseString(responseContent, options, function (err2, responseDoc) { if (err2 !== null && err2 !== undefined) { return callback(err2); } var affinityGroupElement = js2xml.getElement(responseDoc, responseDoc, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (affinityGroupElement !== null && affinityGroupElement !== undefined) { var nameElement = js2xml.getElement(responseDoc, affinityGroupElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (nameElement !== null && nameElement !== undefined) { var nameInstance = nameElement; result.name = nameInstance; } var labelElement = js2xml.getElement(responseDoc, affinityGroupElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (labelElement !== null && labelElement !== undefined) { var labelInstance = new Buffer(labelElement, 'base64').toString('utf8'); result.label = labelInstance; } var descriptionElement = js2xml.getElement(responseDoc, affinityGroupElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (descriptionElement !== null && descriptionElement !== undefined) { var descriptionInstance = descriptionElement; result.description = descriptionInstance; } var locationElement = js2xml.getElement(responseDoc, affinityGroupElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (locationElement !== null && locationElement !== undefined) { var locationInstance = locationElement; result.location = locationInstance; } var hostedServicesSequenceElement = js2xml.getElement(responseDoc, affinityGroupElement, 'HOSTEDSERVICES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (hostedServicesSequenceElement !== null && hostedServicesSequenceElement !== undefined) { for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, hostedServicesSequenceElement, 'HOSTEDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) { var hostedServicesElement = js2xml.getElements(responseDoc, hostedServicesSequenceElement, 'HOSTEDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1]; var hostedServiceInstance = {}; result.hostedServices.push(hostedServiceInstance); var urlElement = js2xml.getElement(responseDoc, hostedServicesElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (urlElement !== null && urlElement !== undefined) { var urlInstance = urlElement; hostedServiceInstance.uri = urlInstance; } var serviceNameElement = js2xml.getElement(responseDoc, hostedServicesElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (serviceNameElement !== null && serviceNameElement !== undefined) { var serviceNameInstance = serviceNameElement; hostedServiceInstance.serviceName = serviceNameInstance; } } } var storageServicesSequenceElement = js2xml.getElement(responseDoc, affinityGroupElement, 'STORAGESERVICES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (storageServicesSequenceElement !== null && storageServicesSequenceElement !== undefined) { for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, storageServicesSequenceElement, 'STORAGESERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) { var storageServicesElement = js2xml.getElements(responseDoc, storageServicesSequenceElement, 'STORAGESERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2]; var storageServiceInstance = {}; result.storageServices.push(storageServiceInstance); var urlElement2 = js2xml.getElement(responseDoc, storageServicesElement, 'URL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (urlElement2 !== null && urlElement2 !== undefined) { var urlInstance2 = urlElement2; storageServiceInstance.uri = urlInstance2; } var serviceNameElement2 = js2xml.getElement(responseDoc, storageServicesElement, 'SERVICENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (serviceNameElement2 !== null && serviceNameElement2 !== undefined) { var serviceNameInstance2 = serviceNameElement2; storageServiceInstance.serviceName = serviceNameInstance2; } } } var capabilitiesSequenceElement = js2xml.getElement(responseDoc, affinityGroupElement, 'CAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (capabilitiesSequenceElement !== null && capabilitiesSequenceElement !== undefined) { for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, capabilitiesSequenceElement, 'CAPABILITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) { var capabilitiesElement = js2xml.getElements(responseDoc, capabilitiesSequenceElement, 'CAPABILITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3]; result.capabilities.push(capabilitiesElement); } } var createdTimeElement = js2xml.getElement(responseDoc, affinityGroupElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) { var createdTimeInstance = new Date(createdTimeElement); result.createdTime = createdTimeInstance; } var computeCapabilitiesElement = js2xml.getElement(responseDoc, affinityGroupElement, 'COMPUTECAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (computeCapabilitiesElement !== null && computeCapabilitiesElement !== undefined) { var computeCapabilitiesInstance = { virtualMachinesRoleSizes: [], webWorkerRoleSizes: [] }; result.computeCapabilities = computeCapabilitiesInstance; var virtualMachinesRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'VIRTUALMACHINESROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (virtualMachinesRoleSizesSequenceElement !== null && virtualMachinesRoleSizesSequenceElement !== undefined) { for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) { var virtualMachinesRoleSizesElement = js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4]; computeCapabilitiesInstance.virtualMachinesRoleSizes.push(virtualMachinesRoleSizesElement); } } var webWorkerRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'WEBWORKERROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (webWorkerRoleSizesSequenceElement !== null && webWorkerRoleSizesSequenceElement !== undefined) { for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) { var webWorkerRoleSizesElement = js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5]; computeCapabilitiesInstance.webWorkerRoleSizes.push(webWorkerRoleSizesElement); } } } } }); } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * The List Affinity Groups operation lists the affinity groups associated * with the specified subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/ee460797.aspx for * more information) * * @param {function} callback * * @returns {Stream} The response stream. */ AffinityGroupOperations.prototype.list = function(callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/affinitygroups'; 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['x-ms-version'] = '2014-10-01'; // 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) { 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 = { affinityGroups: [] }; var options = {}; options.trim = false; options.strict = false; xml.parseString(responseContent, options, function (err2, responseDoc) { if (err2 !== null && err2 !== undefined) { return callback(err2); } var affinityGroupsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'AFFINITYGROUPS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (affinityGroupsSequenceElement !== null && affinityGroupsSequenceElement !== undefined) { for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, affinityGroupsSequenceElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) { var affinityGroupsElement = js2xml.getElements(responseDoc, affinityGroupsSequenceElement, 'AFFINITYGROUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1]; var affinityGroupInstance = { capabilities: [] }; result.affinityGroups.push(affinityGroupInstance); var nameElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (nameElement !== null && nameElement !== undefined) { var nameInstance = nameElement; affinityGroupInstance.name = nameInstance; } var labelElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (labelElement !== null && labelElement !== undefined) { var labelInstance = new Buffer(labelElement, 'base64').toString('utf8'); affinityGroupInstance.label = labelInstance; } var descriptionElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (descriptionElement !== null && descriptionElement !== undefined) { var descriptionInstance = descriptionElement; affinityGroupInstance.description = descriptionInstance; } var locationElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (locationElement !== null && locationElement !== undefined) { var locationInstance = locationElement; affinityGroupInstance.location = locationInstance; } var capabilitiesSequenceElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'CAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (capabilitiesSequenceElement !== null && capabilitiesSequenceElement !== undefined) { for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, capabilitiesSequenceElement, 'CAPABILITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) { var capabilitiesElement = js2xml.getElements(responseDoc, capabilitiesSequenceElement, 'CAPABILITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2]; affinityGroupInstance.capabilities.push(capabilitiesElement); } } var createdTimeElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) { var createdTimeInstance = new Date(createdTimeElement); affinityGroupInstance.createdTime = createdTimeInstance; } var computeCapabilitiesElement = js2xml.getElement(responseDoc, affinityGroupsElement, 'COMPUTECAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (computeCapabilitiesElement !== null && computeCapabilitiesElement !== undefined) { var computeCapabilitiesInstance = { virtualMachinesRoleSizes: [], webWorkerRoleSizes: [] }; affinityGroupInstance.computeCapabilities = computeCapabilitiesInstance; var virtualMachinesRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'VIRTUALMACHINESROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (virtualMachinesRoleSizesSequenceElement !== null && virtualMachinesRoleSizesSequenceElement !== undefined) { for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) { var virtualMachinesRoleSizesElement = js2xml.getElements(responseDoc, virtualMachinesRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3]; computeCapabilitiesInstance.virtualMachinesRoleSizes.push(virtualMachinesRoleSizesElement); } } var webWorkerRoleSizesSequenceElement = js2xml.getElement(responseDoc, computeCapabilitiesElement, 'WEBWORKERROLESIZES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (webWorkerRoleSizesSequenceElement !== null && webWorkerRoleSizesSequenceElement !== undefined) { for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) { var webWorkerRoleSizesElement = js2xml.getElements(responseDoc, webWorkerRoleSizesSequenceElement, 'ROLESIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4]; computeCapabilitiesInstance.webWorkerRoleSizes.push(webWorkerRoleSizesElement); } } } } } }); } result.statusCode = statusCode; result.requestId = response.headers['x-ms-request-id']; return callback(null, result); }); }; /** * The Update Affinity Group operation updates the label and/or the * description for an affinity group for the specified subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/gg715316.aspx for * more information) * * @param {string} affinityGroupName The name of the affinity group. * * @param {AffinityGroupUpdateParameters} parameters Parameters supplied to * the Update Affinity Group operation. * * @param {string} parameters.label A name for the affinity specified as a * base-64-encoded string. The label can be up to 100 characters in length. * * @param {string} [parameters.description] A description for the affinity * group. The description can be up to 1024 characters in length. * * @param {function} callback * * @returns {Stream} The response stream. */ AffinityGroupOperations.prototype.update = function(affinityGroupName, parameters, callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate if (affinityGroupName === null || affinityGroupName === undefined) { return callback(new Error('affinityGroupName cannot be null.')); } if (parameters === null || parameters === undefined) { return callback(new Error('parameters cannot be null.')); } if (parameters.description !== null && parameters.description !== undefined && parameters.description.length > 1024) { return callback(new Error('parameters.description is outside the valid range.')); } if (parameters.label === null || parameters.label === undefined) { return callback(new Error('parameters.label cannot be null.')); } if (parameters.label.length > 100) { return callback(new Error('parameters.label is outside the valid range.')); } // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/affinitygroups/'; url2 = url2 + encodeURIComponent(affinityGroupName); 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/xml'; httpRequest.headers['x-ms-version'] = '2014-10-01'; // Serialize Request var requestContent = null; var requestDoc = {}; var updateAffinityGroupElement = js2xml.createElement('UpdateAffinityGroup', 'http://schemas.microsoft.com/windowsazure'); js2xml.addChildElement(requestDoc, updateAffinityGroupElement); var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure'); js2xml.setElementValue(labelElement, new Buffer(parameters.label).toString('base64')); js2xml.addChildElement(updateAffinityGroupElement, labelElement); if (parameters.description !== null && parameters.description !== undefined) { var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure'); js2xml.setElementValue(descriptionElement, parameters.description); js2xml.addChildElement(updateAffinityGroupElement, descriptionElement); } requestContent = js2xml.serializeDocument(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) { 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); }); }; return AffinityGroupOperations; })(); var LocationOperations = ( /** @lends LocationOperations */ function() { /** * @class * The Service Management API includes operations for listing the available * data center locations for a hosted service in your subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/gg441299.aspx for * more information) * __NOTE__: An instance of this class is automatically created for an * instance of the [ManagementClient] {@link * ManagementClient~ManagementClient}. * See [locations] {@link ManagementClient~ManagementClient#locations}. * Initializes a new instance of the LocationOperations class. * @constructor * * @param {ManagementClient} client Reference to the service client. */ function LocationOperations(client) { this.client = client; } /** * The List Locations operation lists all of the data center locations that * are valid for your subscription. (see * http://msdn.microsoft.com/en-us/library/windowsazure/gg441293.aspx for * more information) * * @param {function} callback * * @returns {Stream} The response stream. */ LocationOperations.prototype.list = function(callback) { if (callback === null || callback === undefined) { throw new Error('callback cannot be null.'); } // Validate // Tracing // Construct URL var url2 = ''; url2 = url2 + '/'; if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) { url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId); } url2 = url2 + '/locations'; 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['x-ms-version'] = '2014-10-01'; // 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) { 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 = { locations: [] }; var options = {}; options.trim = false; options.strict = false; xml.parseString(responseContent, options, function (err2, responseDoc) { if (err2 !== null && err2 !== undefined) { return callback(err2); } var locationsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'LOCATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (locationsSequenceElement !== null && locationsSequenceElement !== undefined) { for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, locationsSequenceElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) { var locationsElement = js2xml.getElements(responseDoc, locationsSequenceElement, 'LOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1]; var locationInstance = { availableServices: [] }; result.locations.push(locationInstance); var nameElement = js2xml.getElement(responseDoc, locationsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (nameElement !== null && nameElement !== undefined) { var nameInstance = nameElement; locationInstance.name = nameInstance; } var displayNameElement = js2xml.getElement(responseDoc, locationsElement, 'DISPLAYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (displayNameElement !== null && displayNameElement !== undefined) { var displayNameInstance = displayNameElement; locationInstance.displayName = displayNameInstance; } var availableServicesSequenceElement = js2xml.getElement(responseDoc, locationsElement, 'AVAILABLESERVICES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (availableServicesSequenceElement !== null && availableServicesSequenceElement !== undefined) { for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, availableServicesSequenceElement, 'AVAILABLESERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) { var availableServicesElement = js2xml.getElements(responseDoc, availableServicesSequenceElement, 'AVAILABLESERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2]; locationInstance.availableServices.push(availableServicesElement); } } var storageCapabilitiesElement = js2xml.getElement(responseDoc, locationsElement, 'STORAGECAPABILITIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (storageCapabilitiesElement !== null && storageCapabilitiesElement !== undefined) { var storageCapabilitiesInstance = { storageAccountTypes: [] }; locationInstance.storageCapabilities = storageCapabilitiesInstance; var storageAccountTypesSequenceElement = js2xml.getElement(responseDoc, storageCapabilitiesElement, 'STORAGEACCOUNTTYPES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); if (storageAccountTypesSequenceElement !== null && storageAccountTypesSequenceElement !== undefined) { storageCapabilitiesInstance.storageAccountTypes = []; for (var loweredIndex3 = 0; loweredIn