From 067baf8616687ea6641ff01b413e80ab774c9fb1 Mon Sep 17 00:00:00 2001 From: Andre Rodrigues Date: Thu, 26 Dec 2013 19:03:24 +0000 Subject: [PATCH] remove file --- .../storeManagement/storeManagementClient.js | 1006 ----------------- 1 file changed, 1006 deletions(-) delete mode 100644 lib/services/storeManagement/storeManagementClient.js diff --git a/lib/services/storeManagement/storeManagementClient.js b/lib/services/storeManagement/storeManagementClient.js deleted file mode 100644 index 1fd45400f..000000000 --- a/lib/services/storeManagement/storeManagementClient.js +++ /dev/null @@ -1,1006 +0,0 @@ -/* 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. - -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; - -/** - * The Windows Azure Store API is a REST API for managing Windows Azure Store - * add-ins. - * @class - */ -var StoreManagementClient = (function() { - /** - * Initializes a new instance of the StoreManagementClient class. - * @constructor - * - * @param {SubscriptionCloudCredentials} credentials When you create a - * Windows Azure subscription, it is uniquely identified by a subscription - * ID. The subscription ID forms part of the URI for every call that you - * make to the Service Management API. The Windows Azure Service - * ManagementAPI use mutual authentication of management certificates over - * SSL to ensure that a request made to the service is secure. No anonymous - * requests are allowed. - * - * @param {string} [credentials.subscriptionId] - * - * @param {object} [credentials.managementCertificate] - * - * @param {string} [baseUri] The URI used as the base for all Store requests. - */ - function StoreManagementClient(credentials, baseUri) { - if (credentials === null || credentials === undefined) { - throw new Error('credentials cannot be null.'); - } - - StoreManagementClient['super_'].call(this, credentials); - - this.credentials = credentials; - this.baseUri = baseUri; - if (this.baseUri === null || this.baseUri === undefined) { - this.baseUri = 'https://management.core.windows.net'; - } - this.addOns = new AddOnOperations(this); - this.cloudServices = new CloudServiceOperations(this); - } - - util.inherits(StoreManagementClient, Service); - - /** - * The Get Operation Status operation returns the status of thespecified - * 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. - */ - StoreManagementClient.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 = this.baseUri + '/' + this.credentials.subscriptionId + '/operations/' + requestId; - - // Create HTTP transport objects - var httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.headers = {}; - httpRequest.url = url2; - - // Set Headers - httpRequest.headers['x-ms-version'] = '2013-06-01'; - - // Send Request - return this.pipeline(httpRequest, function (err, response, body) { - if (err) { - return callback(err); - } - var statusCode = response.statusCode; - if (statusCode !== 200) { - return callback(body); - } - - // Create Result - var result = null; - // Deserialize Response - var responseContent = body; - result = {}; - var options = {}; - options.trim = true; - options.strict = false; - return xml.parseString(responseContent, options, function (err2, responseDoc) { - if (err2) { - return callback(err2); - } - - var operationElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (operationElement) { - var idElement = js2xml.getElement(responseDoc, operationElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (idElement) { - var idInstance = idElement; - result.id = idInstance; - } - - var statusElement = js2xml.getElement(responseDoc, operationElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (statusElement) { - var statusInstance = statusElement; - result.status = statusInstance; - } - - var httpStatusCodeElement = js2xml.getElement(responseDoc, operationElement, 'HTTPSTATUSCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (httpStatusCodeElement) { - var httpStatusCodeInstance = httpStatusCodeElement; - result.httpStatusCode = httpStatusCodeInstance; - } - - var errorElement = js2xml.getElement(responseDoc, operationElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (errorElement) { - var errorInstance = {}; - result.error = errorInstance; - - var codeElement = js2xml.getElement(responseDoc, errorElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (codeElement) { - var codeInstance = codeElement; - errorInstance.code = codeInstance; - } - - var messageElement = js2xml.getElement(responseDoc, errorElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (messageElement) { - var messageInstance = messageElement; - errorInstance.message = messageInstance; - } - } - } - - result.statusCode = statusCode; - result.requestId = response.headers['x-ms-request-id']; - - return callback(null, result); - }); - }); - }; - - return StoreManagementClient; -})(); -exports.StoreManagementClient = StoreManagementClient; - -/** - * Provides REST operations for working with Store add-ins from the Windows - * Azure store service. - * @class - */ -var AddOnOperations = (function() { - /** - * Initializes a new instance of the AddOnOperations class. - * @constructor - * - * @param {StoreManagementClient} client Reference to the service client. - */ - function AddOnOperations(client) { - this.client = client; - } - - /** - * The Create Store Item operation creates Windows Azure Store entries in a - * Windows Azure subscription. - * - * @param {string} cloudServiceName The name of the cloud service to which - * this store item will be assigned. - * - * @param {string} resourceName The name of this resource. - * - * @param {string} addOnName The add on name. - * - * @param {AddOnCreateParameters} parameters Parameters used to specify how - * the Create procedure will function. - * - * @param {string} parameters.type The type of store item to be created. - * - * @param {string} parameters.plan The selected plan for this store addon. - * - * @param {string} [parameters.promotionCode] The promotion code for this - * store addon. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - AddOnOperations.prototype.beginCreating = function(cloudServiceName, resourceName, addOnName, parameters, callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - // Validate - if (cloudServiceName === null || cloudServiceName === undefined) { - return callback(new Error('cloudServiceName cannot be null.')); - } - if (resourceName === null || resourceName === undefined) { - return callback(new Error('resourceName cannot be null.')); - } - if (addOnName === null || addOnName === undefined) { - return callback(new Error('addOnName cannot be null.')); - } - if (parameters === null || parameters === undefined) { - return callback(new Error('parameters cannot be null.')); - } - if (parameters.plan === null || parameters.plan === undefined) { - return callback(new Error('parameters.plan cannot be null.')); - } - if (parameters.type === null || parameters.type === undefined) { - return callback(new Error('parameters.type cannot be null.')); - } - - // Tracing - - // Construct URL - var url2 = this.client.baseUri + '/' + this.client.credentials.subscriptionId + '/CloudServices/' + cloudServiceName + '/resources/' + parameters.type + '/' + resourceName + '/' + addOnName; - - // 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'] = '2013-06-01'; - - // Serialize Request - var requestContent = null; - var requestDoc = {}; - - var resourceElement = js2xml.createElement('Resource', 'http://schemas.microsoft.com/windowsazure'); - js2xml.addChildElement(requestDoc, resourceElement); - - var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(typeElement, parameters.type); - js2xml.addChildElement(resourceElement, typeElement); - - var planElement = js2xml.createElement('Plan', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(planElement, parameters.plan); - js2xml.addChildElement(resourceElement, planElement); - - if (parameters.promotionCode) { - var promotionCodeElement = js2xml.createElement('PromotionCode', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(promotionCodeElement, parameters.promotionCode); - js2xml.addChildElement(resourceElement, promotionCodeElement); - } - - requestContent = js2xml.serializeDocument(requestDoc); - httpRequest.body = requestContent; - httpRequest.headers['Content-Length'] = Buffer.byteLength(requestContent, 'UTF8'); - // Send Request - return this.client.pipeline(httpRequest, function (err, response, body) { - if (err) { - return callback(err); - } - var statusCode = response.statusCode; - if (statusCode !== 202) { - return callback(body); - } - - // Create Result - var result = null; - result = {}; - result.statusCode = statusCode; - result.requestId = response.headers['x-ms-request-id']; - - return callback(null, result); - }); - }; - - /** - * The Delete Store Item operation deletes Windows Azure Store entries that - * re provisioned for a subscription. - * - * @param {string} cloudServiceName The name of the cloud service to which - * this store item will be assigned. - * - * @param {string} resourceProviderNamespace The namespace in which this - * store item resides. - * - * @param {string} resourceProviderType The type of store item to be deleted. - * - * @param {string} resourceProviderName The name of this resource provider. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - AddOnOperations.prototype.beginDeleting = function(cloudServiceName, resourceProviderNamespace, resourceProviderType, resourceProviderName, callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - // Validate - if (cloudServiceName === null || cloudServiceName === undefined) { - return callback(new Error('cloudServiceName cannot be null.')); - } - if (resourceProviderNamespace === null || resourceProviderNamespace === undefined) { - return callback(new Error('resourceProviderNamespace cannot be null.')); - } - if (resourceProviderType === null || resourceProviderType === undefined) { - return callback(new Error('resourceProviderType cannot be null.')); - } - if (resourceProviderName === null || resourceProviderName === undefined) { - return callback(new Error('resourceProviderName cannot be null.')); - } - - // Tracing - - // Construct URL - var url2 = this.client.baseUri + '/' + this.client.credentials.subscriptionId + '/CloudServices/' + cloudServiceName + '/resources/' + resourceProviderNamespace + '/' + resourceProviderType + '/' + resourceProviderName; - - // Create HTTP transport objects - var httpRequest = new WebResource(); - httpRequest.method = 'DELETE'; - httpRequest.headers = {}; - httpRequest.url = url2; - - // Set Headers - httpRequest.headers['x-ms-version'] = '2013-06-01'; - - // Send Request - return this.client.pipeline(httpRequest, function (err, response, body) { - if (err) { - return callback(err); - } - var statusCode = response.statusCode; - if (statusCode !== 202) { - return callback(body); - } - - // Create Result - var result = null; - result = {}; - result.statusCode = statusCode; - result.requestId = response.headers['x-ms-request-id']; - - return callback(null, result); - }); - }; - - /** - * The Create Store Item operation creates Windows Azure Store entries in a - * Windows Azure subscription. - * - * @param {string} cloudServiceName The name of the cloud service to which - * this store item will be assigned. - * - * @param {string} resourceName The name of this resource. - * - * @param {string} addOnName The add on name. - * - * @param {AddOnCreateParameters} parameters Parameters used to specify how - * the Create procedure will function. - * - * @param {string} parameters.type The type of store item to be created. - * - * @param {string} parameters.plan The selected plan for this store addon. - * - * @param {string} [parameters.promotionCode] The promotion code for this - * store addon. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - AddOnOperations.prototype.create = function(cloudServiceName, resourceName, addOnName, parameters, callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - var client2 = this.client; - - return client2.addOns.beginCreating(cloudServiceName, resourceName, addOnName, parameters, function (err, result) { - if (err) { - return callback(err); - } - var delayInSeconds = 30; - - var pollOperation = function () { - setTimeout(function () { - return client2.getOperationStatus(result.requestId, function (err2, result2) { - if (err2) { - return callback(err2); - } else { - if (result2.status !== 'InProgress') { - if (result2.status !== 'Succeeded') { - var ex = new Error(result2.error.code + ' : ' + result2.error.message); - ex.errorCode = result2.error.code; - ex.errorMessage = result2.error.message; - return callback(ex); - } - - return callback(null, result2); - } else { - delayInSeconds = 30; - pollOperation(); - } - } - }); - }, delayInSeconds * 1000); - }; - - pollOperation(); - }); - }; - - /** - * The Delete Store Item operation deletes Windows Azure Storeentries that - * are provisioned for a subscription. - * - * @param {string} cloudServiceName The name of the cloud service to which - * this store item will be assigned. - * - * @param {string} resourceProviderNamespace The namespace in which this - * store item resides. - * - * @param {string} resourceProviderType The type of store item to be deleted. - * - * @param {string} resourceProviderName The name of this resource provider. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - AddOnOperations.prototype.delete = function(cloudServiceName, resourceProviderNamespace, resourceProviderType, resourceProviderName, callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - var client2 = this.client; - - return client2.addOns.beginDeleting(cloudServiceName, resourceProviderNamespace, resourceProviderType, resourceProviderName, function (err, result) { - if (err) { - return callback(err); - } - var delayInSeconds = 30; - - var pollOperation = function () { - setTimeout(function () { - return client2.getOperationStatus(result.requestId, function (err2, result2) { - if (err2) { - return callback(err2); - } else { - if (result2.status !== 'InProgress') { - if (result2.status !== 'Succeeded') { - var ex = new Error(result2.error.code + ' : ' + result2.error.message); - ex.errorCode = result2.error.code; - ex.errorMessage = result2.error.message; - return callback(ex); - } - - return callback(null, result2); - } else { - delayInSeconds = 30; - pollOperation(); - } - } - }); - }, delayInSeconds * 1000); - }; - - pollOperation(); - }); - }; - - /** - * The Update Store Item operation creates Windows Azure Store entries in a - * Windows Azure subscription. - * - * @param {string} cloudServiceName The name of the cloud service to which - * this store item will be assigned. - * - * @param {string} resourceName The name of this resource. - * - * @param {string} addOnName The addon name. - * - * @param {AddOnUpdateParameters} parameters Parameters used to specify how - * the Create procedure will function. - * - * @param {string} parameters.type The type of store item to be created. - * - * @param {string} parameters.plan The selected plan for this store addon. - * - * @param {string} [parameters.promotionCode] The promotion code for this - * store addon. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - AddOnOperations.prototype.update = function(cloudServiceName, resourceName, addOnName, parameters, callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - // Validate - if (cloudServiceName === null || cloudServiceName === undefined) { - return callback(new Error('cloudServiceName cannot be null.')); - } - if (resourceName === null || resourceName === undefined) { - return callback(new Error('resourceName cannot be null.')); - } - if (addOnName === null || addOnName === undefined) { - return callback(new Error('addOnName cannot be null.')); - } - if (parameters === null || parameters === undefined) { - return callback(new Error('parameters cannot be null.')); - } - if (parameters.plan === null || parameters.plan === undefined) { - return callback(new Error('parameters.plan cannot be null.')); - } - if (parameters.type === null || parameters.type === undefined) { - return callback(new Error('parameters.type cannot be null.')); - } - - // Tracing - - // Construct URL - var url2 = this.client.baseUri + '/' + this.client.credentials.subscriptionId + '/CloudServices/' + cloudServiceName + '/resources/' + parameters.type + '/' + resourceName + '/' + addOnName; - - // 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['If-Match'] = '*'; - httpRequest.headers['x-ms-version'] = '2013-06-01'; - - // Serialize Request - var requestContent = null; - var requestDoc = {}; - - var resourceElement = js2xml.createElement('Resource', 'http://schemas.microsoft.com/windowsazure'); - js2xml.addChildElement(requestDoc, resourceElement); - - var typeElement = js2xml.createElement('Type', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(typeElement, parameters.type); - js2xml.addChildElement(resourceElement, typeElement); - - var planElement = js2xml.createElement('Plan', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(planElement, parameters.plan); - js2xml.addChildElement(resourceElement, planElement); - - if (parameters.promotionCode) { - var promotionCodeElement = js2xml.createElement('PromotionCode', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(promotionCodeElement, parameters.promotionCode); - js2xml.addChildElement(resourceElement, promotionCodeElement); - } - - requestContent = js2xml.serializeDocument(requestDoc); - httpRequest.body = requestContent; - httpRequest.headers['Content-Length'] = Buffer.byteLength(requestContent, 'UTF8'); - // Send Request - return this.client.pipeline(httpRequest, function (err, response, body) { - if (err) { - return callback(err); - } - var statusCode = response.statusCode; - if (statusCode !== 202) { - return callback(body); - } - - // Create Result - var result = null; - result = {}; - result.statusCode = statusCode; - result.requestId = response.headers['x-ms-request-id']; - - return callback(null, result); - }); - }; - - return AddOnOperations; -})(); - -/** - * Provides REST operations for working with cloud services from the Windows - * Azure store service. - * @class - */ -var CloudServiceOperations = (function() { - /** - * Initializes a new instance of the CloudServiceOperations class. - * @constructor - * - * @param {StoreManagementClient} client Reference to the service client. - */ - function CloudServiceOperations(client) { - this.client = client; - } - - /** - * The Create Cloud Service operation creates a Windows Azure cloud service - * in a Windows Azure subscription. - * - * @param {CloudServiceCreateParameters} parameters Parameters used to - * specify how the Create procedure will function. - * - * @param {string} parameters.name The name of the cloud service to be - * created. - * - * @param {string} parameters.label The label of the cloud service to be - * created. - * - * @param {string} parameters.description The description for the cloud - * service to be created. - * - * @param {string} parameters.geoRegion The geographical region to create the - * cloud service in. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - CloudServiceOperations.prototype.beginCreating = 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) { - return callback(new Error('parameters.description cannot be null.')); - } - if (parameters.geoRegion === null || parameters.geoRegion === undefined) { - return callback(new Error('parameters.geoRegion cannot be null.')); - } - if (parameters.label === null || parameters.label === undefined) { - return callback(new Error('parameters.label cannot be null.')); - } - if (parameters.name === null || parameters.name === undefined) { - return callback(new Error('parameters.name cannot be null.')); - } - - // Tracing - - // Construct URL - var url2 = this.client.baseUri + '/' + this.client.credentials.subscriptionId + '/CloudServices/' + parameters.name + '/'; - - // 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'] = '2013-06-01'; - - // Serialize Request - var requestContent = null; - var requestDoc = {}; - - var cloudServiceElement = js2xml.createElement('CloudService', 'http://schemas.microsoft.com/windowsazure'); - js2xml.addChildElement(requestDoc, cloudServiceElement); - - var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(nameElement, parameters.name); - js2xml.addChildElement(cloudServiceElement, nameElement); - - var labelElement = js2xml.createElement('Label', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(labelElement, parameters.label); - js2xml.addChildElement(cloudServiceElement, labelElement); - - var descriptionElement = js2xml.createElement('Description', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(descriptionElement, parameters.description); - js2xml.addChildElement(cloudServiceElement, descriptionElement); - - var geoRegionElement = js2xml.createElement('GeoRegion', 'http://schemas.microsoft.com/windowsazure'); - js2xml.setElementValue(geoRegionElement, parameters.geoRegion); - js2xml.addChildElement(cloudServiceElement, geoRegionElement); - - requestContent = js2xml.serializeDocument(requestDoc); - httpRequest.body = requestContent; - httpRequest.headers['Content-Length'] = Buffer.byteLength(requestContent, 'UTF8'); - // Send Request - return this.client.pipeline(httpRequest, function (err, response, body) { - if (err) { - return callback(err); - } - var statusCode = response.statusCode; - if (statusCode !== 202) { - return callback(body); - } - - // Create Result - var result = null; - result = {}; - result.statusCode = statusCode; - result.requestId = response.headers['x-ms-request-id']; - - return callback(null, result); - }); - }; - - /** - * The Create Cloud Service operation creates a Windows Azure cloud service - * in a Windows Azure subscription. - * - * @param {CloudServiceCreateParameters} parameters Parameters used to - * specify how the Create procedure will function. - * - * @param {string} parameters.name The name of the cloud service to be - * created. - * - * @param {string} parameters.label The label of the cloud service to be - * created. - * - * @param {string} parameters.description The description for the cloud - * service to be created. - * - * @param {string} parameters.geoRegion The geographical region to create the - * cloud service in. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - CloudServiceOperations.prototype.create = function(parameters, callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - var client2 = this.client; - - return client2.cloudServices.beginCreating(parameters, function (err, result) { - if (err) { - return callback(err); - } - var delayInSeconds = 30; - - var pollOperation = function () { - setTimeout(function () { - return client2.getOperationStatus(result.requestId, function (err2, result2) { - if (err2) { - return callback(err2); - } else { - if (result2.status !== 'InProgress') { - if (result2.status !== 'Succeeded') { - var ex = new Error(result2.error.code + ' : ' + result2.error.message); - ex.errorCode = result2.error.code; - ex.errorMessage = result2.error.message; - return callback(ex); - } - - return callback(null, result2); - } else { - delayInSeconds = 30; - pollOperation(); - } - } - }); - }, delayInSeconds * 1000); - }; - - pollOperation(); - }); - }; - - /** - * The List Cloud Services operation enumerates Windows Azure Store entries - * that are provisioned for a subscription. - * - * @param {function} callback - * - * @returns {Stream} The response stream. - */ - CloudServiceOperations.prototype.list = function(callback) { - if (callback === null || callback === undefined) { - throw new Error('callback cannot be null.'); - } - // Validate - - // Tracing - - // Construct URL - var url2 = this.client.baseUri + '/' + this.client.credentials.subscriptionId + '/CloudServices/'; - - // Create HTTP transport objects - var httpRequest = new WebResource(); - httpRequest.method = 'GET'; - httpRequest.headers = {}; - httpRequest.url = url2; - - // Set Headers - httpRequest.headers['x-ms-version'] = '2013-06-01'; - - // Send Request - return this.client.pipeline(httpRequest, function (err, response, body) { - if (err) { - return callback(err); - } - var statusCode = response.statusCode; - if (statusCode !== 200) { - return callback(body); - } - - // Create Result - var result = null; - // Deserialize Response - var responseContent = body; - result = { cloudServices: [] }; - var options = {}; - options.trim = true; - options.strict = false; - return xml.parseString(responseContent, options, function (err2, responseDoc) { - if (err2) { - return callback(err2); - } - - var cloudServicesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'CLOUDSERVICES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (cloudServicesSequenceElement) { - for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, cloudServicesSequenceElement, 'CLOUDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) { - var cloudServicesElement = js2xml.getElements(responseDoc, cloudServicesSequenceElement, 'CLOUDSERVICE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1]; - var cloudServiceInstance = { resources: [] }; - result.cloudServices.push(cloudServiceInstance); - - var nameElement = js2xml.getElement(responseDoc, cloudServicesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (nameElement) { - var nameInstance = nameElement; - cloudServiceInstance.name = nameInstance; - } - - var labelElement = js2xml.getElement(responseDoc, cloudServicesElement, 'LABEL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (labelElement) { - var labelInstance = new Buffer(labelElement, 'base64').toString('ascii'); - cloudServiceInstance.label = labelInstance; - } - - var descriptionElement = js2xml.getElement(responseDoc, cloudServicesElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (descriptionElement) { - var descriptionInstance = descriptionElement; - cloudServiceInstance.description = descriptionInstance; - } - - var geoRegionElement = js2xml.getElement(responseDoc, cloudServicesElement, 'GEOREGION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (geoRegionElement) { - var geoRegionInstance = geoRegionElement; - cloudServiceInstance.geoRegion = geoRegionInstance; - } - - var resourcesSequenceElement = js2xml.getElement(responseDoc, cloudServicesElement, 'RESOURCES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (resourcesSequenceElement) { - for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, resourcesSequenceElement, 'RESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) { - var resourcesElement = js2xml.getElements(responseDoc, resourcesSequenceElement, 'RESOURCE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2]; - var resourceInstance = { outputItems: {}, usageLimits: [] }; - cloudServiceInstance.resources.push(resourceInstance); - - var resourceProviderNamespaceElement = js2xml.getElement(responseDoc, resourcesElement, 'RESOURCEPROVIDERNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (resourceProviderNamespaceElement) { - var resourceProviderNamespaceInstance = resourceProviderNamespaceElement; - resourceInstance.namespace = resourceProviderNamespaceInstance; - } - - var typeElement = js2xml.getElement(responseDoc, resourcesElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (typeElement) { - var typeInstance = typeElement; - resourceInstance.type = typeInstance; - } - - var nameElement2 = js2xml.getElement(responseDoc, resourcesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (nameElement2) { - var nameInstance2 = nameElement2; - resourceInstance.name = nameInstance2; - } - - var planElement = js2xml.getElement(responseDoc, resourcesElement, 'PLAN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (planElement) { - var planInstance = planElement; - resourceInstance.plan = planInstance; - } - - var schemaVersionElement = js2xml.getElement(responseDoc, resourcesElement, 'SCHEMAVERSION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (schemaVersionElement) { - var schemaVersionInstance = schemaVersionElement; - resourceInstance.schemaVersion = schemaVersionInstance; - } - - var eTagElement = js2xml.getElement(responseDoc, resourcesElement, 'ETAG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (eTagElement) { - var eTagInstance = eTagElement; - resourceInstance.eTag = eTagInstance; - } - - var stateElement = js2xml.getElement(responseDoc, resourcesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (stateElement) { - var stateInstance = stateElement; - resourceInstance.state = stateInstance; - } - - var usageMetersSequenceElement = js2xml.getElement(responseDoc, resourcesElement, 'USAGEMETERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (usageMetersSequenceElement) { - for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, usageMetersSequenceElement, 'USAGEMETER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) { - var usageMetersElement = js2xml.getElements(responseDoc, usageMetersSequenceElement, 'USAGEMETER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3]; - var usageMeterInstance = {}; - resourceInstance.usageLimits.push(usageMeterInstance); - - var nameElement3 = js2xml.getElement(responseDoc, usageMetersElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (nameElement3) { - var nameInstance3 = nameElement3; - usageMeterInstance.name = nameInstance3; - } - - var unitElement = js2xml.getElement(responseDoc, usageMetersElement, 'UNIT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (unitElement) { - var unitInstance = unitElement; - usageMeterInstance.unit = unitInstance; - } - - var includedElement = js2xml.getElement(responseDoc, usageMetersElement, 'INCLUDED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (includedElement) { - var includedInstance = parseInt(includedElement, 10); - usageMeterInstance.amountIncluded = includedInstance; - } - - var usedElement = js2xml.getElement(responseDoc, usageMetersElement, 'USED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (usedElement) { - var usedInstance = parseInt(usedElement, 10); - usageMeterInstance.amountUsed = usedInstance; - } - } - } - - var outputItemsSequenceElement = js2xml.getElement(responseDoc, resourcesElement, 'OUTPUTITEMS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (outputItemsSequenceElement) { - for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, outputItemsSequenceElement, 'OUTPUTITEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) { - var outputItemsElement = js2xml.getElements(responseDoc, outputItemsSequenceElement, 'OUTPUTITEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4]; - var outputItemsKey = js2xml.getElement(responseDoc, outputItemsElement, 'KEY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - var outputItemsValue = js2xml.getElement(responseDoc, outputItemsElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - resourceInstance.outputItems[outputItemsKey] = outputItemsValue; - } - } - - var operationStatusElement = js2xml.getElement(responseDoc, resourcesElement, 'OPERATIONSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (operationStatusElement) { - var operationStatusInstance = {}; - resourceInstance.status = operationStatusInstance; - - var typeElement2 = js2xml.getElement(responseDoc, operationStatusElement, 'TYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (typeElement2) { - var typeInstance2 = typeElement2; - operationStatusInstance.type = typeInstance2; - } - - var resultElement = js2xml.getElement(responseDoc, operationStatusElement, 'RESULT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE'); - if (resultElement) { - var resultInstance = resultElement; - operationStatusInstance.result = resultInstance; - } - } - } - } - } - } - - result.statusCode = statusCode; - result.requestId = response.headers['x-ms-request-id']; - - return callback(null, result); - }); - }); - }; - - return CloudServiceOperations; -})();