Best JavaScript code snippet using pact-foundation-pact
webSiteManagementClient.js
Source:webSiteManagementClient.js
1/* jshint latedef:false */2/* jshint forin:false */3/* jshint noempty:false */45// 6// Copyright (c) Microsoft and contributors. All rights reserved.7// 8// Licensed under the Apache License, Version 2.0 (the "License");9// you may not use this file except in compliance with the License.10// You may obtain a copy of the License at11// http://www.apache.org/licenses/LICENSE-2.012// 13// Unless required by applicable law or agreed to in writing, software14// distributed under the License is distributed on an "AS IS" BASIS,15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16// 17// See the License for the specific language governing permissions and18// limitations under the License.19// 2021// Warning: This code was generated by a tool.22// 23// Changes to this file may cause incorrect behavior and will be lost if the24// code is regenerated.2526'use strict';2728var util = require('util');29var _ = require('underscore');30var azureCommon = require('azure-common');31var xml = azureCommon.xml2js;32var js2xml = azureCommon.js2xml;33var Service = azureCommon.Service;34var WebResource = azureCommon.WebResource;3536var WebSiteManagementClient = ( /** @lends WebSiteManagementClient */ function() {37 /**38 * @class39 * The Windows Azure Web Sites management API provides a RESTful set of web40 * services that interact with Windows Azure Web Sites service to manage41 * your web sites. The API has entities that capture the relationship42 * between an end user and the Windows Azure Web Sites service. (see43 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166981.aspx for44 * more information)45 * Initializes a new instance of the WebSiteManagementClient class.46 * @constructor47 * 48 * @param {SubscriptionCloudCredentials} credentials Gets subscription49 * credentials which uniquely identify Microsoft Azure subscription. The50 * subscription ID forms part of the URI for every service call.51 * 52 * @param {string} [credentials.subscriptionId]53 * 54 * @param {string} [baseUri] Gets the URI used as the base for all cloud55 * service requests.56 * 57 * @param {Array} filters58 */59 function WebSiteManagementClient(credentials, baseUri, filters) {60 if (credentials === null || credentials === undefined) {61 throw new Error('credentials cannot be null.');62 }63 64 WebSiteManagementClient['super_'].call(this, credentials, filters);65 66 this.credentials = credentials;67 this.baseUri = baseUri;68 if (this.baseUri === null || this.baseUri === undefined) {69 this.baseUri = 'https://management.azure.com';70 }71 if (this.apiVersion === null || this.apiVersion === undefined) {72 this.apiVersion = '2014-06-01';73 }74 if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) {75 this.longRunningOperationInitialTimeout = -1;76 }77 if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) {78 this.longRunningOperationRetryTimeout = -1;79 }80 /**81 * Provides an instance of the82 * [SourceControlOperations](-SourceControlOperations.html) object.83 * @type {object}84 */85 this.sourceControls = new SourceControlOperations(this);86 /**87 * Provides an instance of the88 * [WebHostingPlanOperations](-WebHostingPlanOperations.html) object.89 * @type {object}90 */91 this.webHostingPlans = new WebHostingPlanOperations(this);92 /**93 * Provides an instance of the [WebSiteOperations](-WebSiteOperations.html)94 * object.95 * @type {object}96 */97 this.webSites = new WebSiteOperations(this);98 }99 100 util.inherits(WebSiteManagementClient, Service);101 102 103 return WebSiteManagementClient;104})();105exports.WebSiteManagementClient = WebSiteManagementClient;106107var SourceControlOperations = ( /** @lends SourceControlOperations */ function() {108 /**109 * @class110 * User source controls operations111 * __NOTE__: An instance of this class is automatically created for an112 * instance of the [WebSiteManagementClient] {@link113 * WebSiteManagementClient~WebSiteManagementClient}.114 * See [sourceControls] {@link115 * WebSiteManagementClient~WebSiteManagementClient#sourceControls}.116 * Initializes a new instance of the SourceControlOperations class.117 * @constructor118 * 119 * @param {WebSiteManagementClient} client Reference to the service client.120 */121 function SourceControlOperations(client) {122 this.client = client;123 }124 125 /**126 * Get user source control127 * 128 * @param {string} name The name of the source control (GitHub, Bitbucket,129 * CodePlex or Dropbox)130 * 131 * @param {function} callback132 * 133 * @returns {Stream} The response stream.134 */135 SourceControlOperations.prototype.get = function(name, callback) {136 if (callback === null || callback === undefined) {137 throw new Error('callback cannot be null.');138 }139 // Validate140 if (name === null || name === undefined) {141 return callback(new Error('name cannot be null.'));142 }143 144 // Tracing145 146 // Construct URL147 var url2 = '';148 url2 = url2 + '/providers/';149 url2 = url2 + 'Microsoft.Web';150 url2 = url2 + '/SourceControls/';151 url2 = url2 + encodeURIComponent(name);152 var queryParameters = [];153 queryParameters.push('api-version=2014-06-01');154 if (queryParameters.length > 0) {155 url2 = url2 + '?' + queryParameters.join('&');156 }157 var baseUrl = this.client.baseUri;158 // Trim '/' character from the end of baseUrl and beginning of url.159 if (baseUrl[baseUrl.length - 1] === '/') {160 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);161 }162 if (url2[0] === '/') {163 url2 = url2.substring(1);164 }165 url2 = baseUrl + '/' + url2;166 url2 = url2.replace(' ', '%20');167 168 // Create HTTP transport objects169 var httpRequest = new WebResource();170 httpRequest.method = 'GET';171 httpRequest.headers = {};172 httpRequest.url = url2;173 174 // Set Headers175 176 // Send Request177 return this.client.pipeline(httpRequest, function (err, response, body) {178 if (err !== null && err !== undefined) {179 return callback(err);180 }181 var statusCode = response.statusCode;182 if (statusCode !== 200) {183 var error = new Error(body);184 error.statusCode = response.statusCode;185 return callback(error);186 }187 188 // Create Result189 var result = null;190 // Deserialize Response191 if (statusCode === 200) {192 var responseContent = body;193 result = {};194 var responseDoc = null;195 if (responseContent) {196 responseDoc = JSON.parse(responseContent);197 }198 199 if (responseDoc !== null && responseDoc !== undefined) {200 var sourceControlInstance = { tags: {} };201 result.sourceControl = sourceControlInstance;202 203 var propertiesValue = responseDoc['properties'];204 if (propertiesValue !== null && propertiesValue !== undefined) {205 var propertiesInstance = {};206 sourceControlInstance.properties = propertiesInstance;207 208 var tokenValue = propertiesValue['token'];209 if (tokenValue !== null && tokenValue !== undefined) {210 var tokenInstance = tokenValue;211 propertiesInstance.token = tokenInstance;212 }213 214 var tokenSecretValue = propertiesValue['tokenSecret'];215 if (tokenSecretValue !== null && tokenSecretValue !== undefined) {216 var tokenSecretInstance = tokenSecretValue;217 propertiesInstance.tokenSecret = tokenSecretInstance;218 }219 }220 221 var idValue = responseDoc['id'];222 if (idValue !== null && idValue !== undefined) {223 var idInstance = idValue;224 sourceControlInstance.id = idInstance;225 }226 227 var nameValue = responseDoc['name'];228 if (nameValue !== null && nameValue !== undefined) {229 var nameInstance = nameValue;230 sourceControlInstance.name = nameInstance;231 }232 233 var locationValue = responseDoc['location'];234 if (locationValue !== null && locationValue !== undefined) {235 var locationInstance = locationValue;236 sourceControlInstance.location = locationInstance;237 }238 239 var tagsSequenceElement = responseDoc['tags'];240 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {241 for (var property in tagsSequenceElement) {242 var tagsKey = property;243 var tagsValue = tagsSequenceElement[property];244 sourceControlInstance.tags[tagsKey] = tagsValue;245 }246 }247 248 var typeValue = responseDoc['type'];249 if (typeValue !== null && typeValue !== undefined) {250 var typeInstance = typeValue;251 sourceControlInstance.type = typeInstance;252 }253 }254 255 }256 result.statusCode = statusCode;257 result.requestId = response.headers['x-ms-request-id'];258 259 return callback(null, result);260 });261 };262 263 /**264 * List source controls for user.265 * 266 * @param {function} callback267 * 268 * @returns {Stream} The response stream.269 */270 SourceControlOperations.prototype.list = function(callback) {271 if (callback === null || callback === undefined) {272 throw new Error('callback cannot be null.');273 }274 // Validate275 276 // Tracing277 278 // Construct URL279 var url2 = '';280 url2 = url2 + '/providers/';281 url2 = url2 + 'Microsoft.Web';282 url2 = url2 + '/SourceControls';283 var queryParameters = [];284 queryParameters.push('api-version=2014-06-01');285 if (queryParameters.length > 0) {286 url2 = url2 + '?' + queryParameters.join('&');287 }288 var baseUrl = this.client.baseUri;289 // Trim '/' character from the end of baseUrl and beginning of url.290 if (baseUrl[baseUrl.length - 1] === '/') {291 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);292 }293 if (url2[0] === '/') {294 url2 = url2.substring(1);295 }296 url2 = baseUrl + '/' + url2;297 url2 = url2.replace(' ', '%20');298 299 // Create HTTP transport objects300 var httpRequest = new WebResource();301 httpRequest.method = 'GET';302 httpRequest.headers = {};303 httpRequest.url = url2;304 305 // Set Headers306 307 // Send Request308 return this.client.pipeline(httpRequest, function (err, response, body) {309 if (err !== null && err !== undefined) {310 return callback(err);311 }312 var statusCode = response.statusCode;313 if (statusCode !== 200) {314 var error = new Error(body);315 error.statusCode = response.statusCode;316 return callback(error);317 }318 319 // Create Result320 var result = null;321 // Deserialize Response322 if (statusCode === 200) {323 var responseContent = body;324 result = { sourceControls: [] };325 var responseDoc = null;326 if (responseContent) {327 responseDoc = JSON.parse(responseContent);328 }329 330 if (responseDoc !== null && responseDoc !== undefined) {331 var valueArray = responseDoc['value'];332 if (valueArray !== null && valueArray !== undefined) {333 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {334 var valueValue = valueArray[loweredIndex1];335 var propertiesInstance = { tags: {} };336 result.sourceControls.push(propertiesInstance);337 338 var propertiesValue = valueValue['properties'];339 if (propertiesValue !== null && propertiesValue !== undefined) {340 var propertiesInstance2 = {};341 propertiesInstance.properties = propertiesInstance2;342 343 var tokenValue = propertiesValue['token'];344 if (tokenValue !== null && tokenValue !== undefined) {345 var tokenInstance = tokenValue;346 propertiesInstance2.token = tokenInstance;347 }348 349 var tokenSecretValue = propertiesValue['tokenSecret'];350 if (tokenSecretValue !== null && tokenSecretValue !== undefined) {351 var tokenSecretInstance = tokenSecretValue;352 propertiesInstance2.tokenSecret = tokenSecretInstance;353 }354 }355 356 var idValue = valueValue['id'];357 if (idValue !== null && idValue !== undefined) {358 var idInstance = idValue;359 propertiesInstance.id = idInstance;360 }361 362 var nameValue = valueValue['name'];363 if (nameValue !== null && nameValue !== undefined) {364 var nameInstance = nameValue;365 propertiesInstance.name = nameInstance;366 }367 368 var locationValue = valueValue['location'];369 if (locationValue !== null && locationValue !== undefined) {370 var locationInstance = locationValue;371 propertiesInstance.location = locationInstance;372 }373 374 var tagsSequenceElement = valueValue['tags'];375 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {376 for (var property in tagsSequenceElement) {377 var tagsKey = property;378 var tagsValue = tagsSequenceElement[property];379 propertiesInstance.tags[tagsKey] = tagsValue;380 }381 }382 383 var typeValue = valueValue['type'];384 if (typeValue !== null && typeValue !== undefined) {385 var typeInstance = typeValue;386 propertiesInstance.type = typeInstance;387 }388 }389 }390 }391 392 }393 result.statusCode = statusCode;394 result.requestId = response.headers['x-ms-request-id'];395 396 return callback(null, result);397 });398 };399 400 /**401 * Update source control for user.402 * 403 * @param {string} name The name of the source control (can be: GitHub,404 * Bitbucket, CodePlex, Dropbox)405 * 406 * @param {SourceControlUpdateParameters} parameters Parameters supplied to407 * the Update Source Control operation.408 * 409 * @param {SourceControlProperties} parameters.properties Gets or sets the410 * properties of the source control.411 * 412 * @param {string} [parameters.properties.token] Gets or sets the token.413 * 414 * @param {string} [parameters.properties.tokenSecret] Gets or sets the token415 * secret.416 * 417 * @param {function} callback418 * 419 * @returns {Stream} The response stream.420 */421 SourceControlOperations.prototype.update = function(name, parameters, callback) {422 if (callback === null || callback === undefined) {423 throw new Error('callback cannot be null.');424 }425 // Validate426 if (name === null || name === undefined) {427 return callback(new Error('name cannot be null.'));428 }429 if (parameters === null || parameters === undefined) {430 return callback(new Error('parameters cannot be null.'));431 }432 if (parameters.properties === null || parameters.properties === undefined) {433 return callback(new Error('parameters.properties cannot be null.'));434 }435 436 // Tracing437 438 // Construct URL439 var url2 = '';440 url2 = url2 + '/providers/';441 url2 = url2 + 'Microsoft.Web';442 url2 = url2 + '/SourceControls/';443 url2 = url2 + encodeURIComponent(name);444 var queryParameters = [];445 queryParameters.push('api-version=2014-06-01');446 if (queryParameters.length > 0) {447 url2 = url2 + '?' + queryParameters.join('&');448 }449 var baseUrl = this.client.baseUri;450 // Trim '/' character from the end of baseUrl and beginning of url.451 if (baseUrl[baseUrl.length - 1] === '/') {452 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);453 }454 if (url2[0] === '/') {455 url2 = url2.substring(1);456 }457 url2 = baseUrl + '/' + url2;458 url2 = url2.replace(' ', '%20');459 460 // Create HTTP transport objects461 var httpRequest = new WebResource();462 httpRequest.method = 'PUT';463 httpRequest.headers = {};464 httpRequest.url = url2;465 466 // Set Headers467 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';468 469 // Serialize Request470 var requestContent = null;471 var requestDoc = null;472 473 var sourceControlUpdateParametersValue = {};474 requestDoc = sourceControlUpdateParametersValue;475 476 var propertiesValue = {};477 sourceControlUpdateParametersValue['properties'] = propertiesValue;478 479 if (parameters.properties.token !== null && parameters.properties.token !== undefined) {480 propertiesValue['token'] = parameters.properties.token;481 }482 483 if (parameters.properties.tokenSecret !== null && parameters.properties.tokenSecret !== undefined) {484 propertiesValue['tokenSecret'] = parameters.properties.tokenSecret;485 }486 487 requestContent = JSON.stringify(requestDoc);488 httpRequest.body = requestContent;489 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');490 // Send Request491 return this.client.pipeline(httpRequest, function (err, response, body) {492 if (err !== null && err !== undefined) {493 return callback(err);494 }495 var statusCode = response.statusCode;496 if (statusCode !== 200) {497 var error = new Error(body);498 error.statusCode = response.statusCode;499 return callback(error);500 }501 502 // Create Result503 var result = null;504 // Deserialize Response505 if (statusCode === 200) {506 var responseContent = body;507 result = {};508 var responseDoc = null;509 if (responseContent) {510 responseDoc = JSON.parse(responseContent);511 }512 513 var sourceControlValue = responseDoc['SourceControl'];514 if (sourceControlValue !== null && sourceControlValue !== undefined) {515 var sourceControlInstance = {};516 517 var sourceControlInstance2 = { tags: {} };518 result.sourceControl = sourceControlInstance2;519 520 var propertiesValue2 = sourceControlValue['properties'];521 if (propertiesValue2 !== null && propertiesValue2 !== undefined) {522 var propertiesInstance = {};523 sourceControlInstance2.properties = propertiesInstance;524 525 var tokenValue = propertiesValue2['token'];526 if (tokenValue !== null && tokenValue !== undefined) {527 var tokenInstance = tokenValue;528 propertiesInstance.token = tokenInstance;529 }530 531 var tokenSecretValue = propertiesValue2['tokenSecret'];532 if (tokenSecretValue !== null && tokenSecretValue !== undefined) {533 var tokenSecretInstance = tokenSecretValue;534 propertiesInstance.tokenSecret = tokenSecretInstance;535 }536 }537 538 var idValue = sourceControlValue['id'];539 if (idValue !== null && idValue !== undefined) {540 var idInstance = idValue;541 sourceControlInstance2.id = idInstance;542 }543 544 var nameValue = sourceControlValue['name'];545 if (nameValue !== null && nameValue !== undefined) {546 var nameInstance = nameValue;547 sourceControlInstance2.name = nameInstance;548 }549 550 var locationValue = sourceControlValue['location'];551 if (locationValue !== null && locationValue !== undefined) {552 var locationInstance = locationValue;553 sourceControlInstance2.location = locationInstance;554 }555 556 var tagsSequenceElement = sourceControlValue['tags'];557 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {558 for (var property in tagsSequenceElement) {559 var tagsKey = property;560 var tagsValue = tagsSequenceElement[property];561 sourceControlInstance2.tags[tagsKey] = tagsValue;562 }563 }564 565 var typeValue = sourceControlValue['type'];566 if (typeValue !== null && typeValue !== undefined) {567 var typeInstance = typeValue;568 sourceControlInstance2.type = typeInstance;569 }570 }571 572 }573 result.statusCode = statusCode;574 result.requestId = response.headers['x-ms-request-id'];575 576 return callback(null, result);577 });578 };579 580 return SourceControlOperations;581})();582583var WebHostingPlanOperations = ( /** @lends WebHostingPlanOperations */ function() {584 /**585 * @class586 * Operations for managing the Web Hosting Plans in a resource group. Web587 * hosting plans (WHPs) represent a set of features and capacity that you588 * can share across your web sites. Web hosting plans support the 4 Azure589 * Web Sites pricing tiers (Free, Shared, Basic, and Standard) where each590 * tier has its own capabilities and capacity. Sites in the same591 * subscription, resource group, and geographic location can share a web592 * hosting plan. All the sites sharing a web hosting plan can leverage all593 * the capabilities and features defined by the web hosting plan tier. All594 * web sites associated with a given web hosting plan run on the resources595 * defined by the web hosting plan. (see596 * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/597 * for more information)598 * __NOTE__: An instance of this class is automatically created for an599 * instance of the [WebSiteManagementClient] {@link600 * WebSiteManagementClient~WebSiteManagementClient}.601 * See [webHostingPlans] {@link602 * WebSiteManagementClient~WebSiteManagementClient#webHostingPlans}.603 * Initializes a new instance of the WebHostingPlanOperations class.604 * @constructor605 * 606 * @param {WebSiteManagementClient} client Reference to the service client.607 */608 function WebHostingPlanOperations(client) {609 this.client = client;610 }611 612 /**613 * Creates a new Web Hosting Plan or updates an existing one. (see614 * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/615 * for more information)616 * 617 * @param {string} resourceGroupName The name of the resource group.618 * 619 * @param {WebHostingPlanCreateOrUpdateParameters} parameters Parameters620 * supplied to the Create Server Farm operation.621 * 622 * @param {WebHostingPlan} parameters.webHostingPlan Gets or sets information623 * about a Web Hosting Plan being created of updated.624 * 625 * @param {WebHostingPlanProperties} [parameters.webHostingPlan.properties]626 * Represents the properties of the Web Hosting Plan.627 * 628 * @param {SkuOptions} [parameters.webHostingPlan.properties.sku] The Web629 * Hosting Plan SKU.630 * 631 * @param {number} [parameters.webHostingPlan.properties.numberOfWorkers] The632 * instance count, which is the number of virtual machines dedicated to the633 * Web Hosting Plan. Supported values are positive integers.634 * 635 * @param {WorkerSizeOptions}636 * [parameters.webHostingPlan.properties.workerSize] The instance size.637 * Possible values are Small, Medium, or Large.638 * 639 * @param {string} [parameters.webHostingPlan.properties.adminSiteName] The640 * admin site. The admin site is used to deploy site extensions or contents641 * shared by all site in the plan.642 * 643 * @param {string} [parameters.webHostingPlan.id] Gets the ID of the resource.644 * 645 * @param {string} [parameters.webHostingPlan.name] The name of the resource.646 * 647 * @param {string} parameters.webHostingPlan.location Gets or sets the648 * location of the resource.649 * 650 * @param {object} [parameters.webHostingPlan.tags] Gets or sets the tags651 * attached to the resource.652 * 653 * @param {string} [parameters.webHostingPlan.type] The type of the resource654 * 655 * @param {function} callback656 * 657 * @returns {Stream} The response stream.658 */659 WebHostingPlanOperations.prototype.createOrUpdate = function(resourceGroupName, parameters, callback) {660 if (callback === null || callback === undefined) {661 throw new Error('callback cannot be null.');662 }663 // Validate664 if (resourceGroupName === null || resourceGroupName === undefined) {665 return callback(new Error('resourceGroupName cannot be null.'));666 }667 if (parameters === null || parameters === undefined) {668 return callback(new Error('parameters cannot be null.'));669 }670 if (parameters.webHostingPlan === null || parameters.webHostingPlan === undefined) {671 return callback(new Error('parameters.webHostingPlan cannot be null.'));672 }673 if (parameters.webHostingPlan.location === null || parameters.webHostingPlan.location === undefined) {674 return callback(new Error('parameters.webHostingPlan.location cannot be null.'));675 }676 677 // Tracing678 679 // Construct URL680 var url2 = '';681 url2 = url2 + '/subscriptions/';682 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {683 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);684 }685 url2 = url2 + '/resourceGroups/';686 url2 = url2 + encodeURIComponent(resourceGroupName);687 url2 = url2 + '/providers/';688 url2 = url2 + 'Microsoft.Web';689 url2 = url2 + '/serverFarms/';690 if (parameters.webHostingPlan.name !== null && parameters.webHostingPlan.name !== undefined) {691 url2 = url2 + encodeURIComponent(parameters.webHostingPlan.name);692 }693 var queryParameters = [];694 queryParameters.push('api-version=2014-06-01');695 if (queryParameters.length > 0) {696 url2 = url2 + '?' + queryParameters.join('&');697 }698 var baseUrl = this.client.baseUri;699 // Trim '/' character from the end of baseUrl and beginning of url.700 if (baseUrl[baseUrl.length - 1] === '/') {701 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);702 }703 if (url2[0] === '/') {704 url2 = url2.substring(1);705 }706 url2 = baseUrl + '/' + url2;707 url2 = url2.replace(' ', '%20');708 709 // Create HTTP transport objects710 var httpRequest = new WebResource();711 httpRequest.method = 'PUT';712 httpRequest.headers = {};713 httpRequest.url = url2;714 715 // Set Headers716 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';717 718 // Serialize Request719 var requestContent = null;720 var requestDoc = null;721 722 var webHostingPlanCreateOrUpdateParametersValue = {};723 requestDoc = webHostingPlanCreateOrUpdateParametersValue;724 725 if (parameters.webHostingPlan.properties !== null && parameters.webHostingPlan.properties !== undefined) {726 var propertiesValue = {};727 webHostingPlanCreateOrUpdateParametersValue['properties'] = propertiesValue;728 729 if (parameters.webHostingPlan.properties.sku !== null && parameters.webHostingPlan.properties.sku !== undefined) {730 propertiesValue['sku'] = parameters.webHostingPlan.properties.sku !== null && parameters.webHostingPlan.properties.sku !== undefined ? parameters.webHostingPlan.properties.sku.toString() : 'Free';731 }732 733 if (parameters.webHostingPlan.properties.numberOfWorkers !== null && parameters.webHostingPlan.properties.numberOfWorkers !== undefined) {734 propertiesValue['numberOfWorkers'] = parameters.webHostingPlan.properties.numberOfWorkers;735 }736 737 if (parameters.webHostingPlan.properties.workerSize !== null && parameters.webHostingPlan.properties.workerSize !== undefined) {738 propertiesValue['workerSize'] = parameters.webHostingPlan.properties.workerSize !== null && parameters.webHostingPlan.properties.workerSize !== undefined ? parameters.webHostingPlan.properties.workerSize.toString() : 'Small';739 }740 741 if (parameters.webHostingPlan.properties.adminSiteName !== null && parameters.webHostingPlan.properties.adminSiteName !== undefined) {742 propertiesValue['adminSiteName'] = parameters.webHostingPlan.properties.adminSiteName;743 }744 }745 746 if (parameters.webHostingPlan.id !== null && parameters.webHostingPlan.id !== undefined) {747 webHostingPlanCreateOrUpdateParametersValue['id'] = parameters.webHostingPlan.id;748 }749 750 if (parameters.webHostingPlan.name !== null && parameters.webHostingPlan.name !== undefined) {751 webHostingPlanCreateOrUpdateParametersValue['name'] = parameters.webHostingPlan.name;752 }753 754 webHostingPlanCreateOrUpdateParametersValue['location'] = parameters.webHostingPlan.location;755 756 if (parameters.webHostingPlan.tags !== null && parameters.webHostingPlan.tags !== undefined) {757 var tagsDictionary = {};758 for (var tagsKey in parameters.webHostingPlan.tags) {759 var tagsValue = parameters.webHostingPlan.tags[tagsKey];760 tagsDictionary[tagsKey] = tagsValue;761 }762 webHostingPlanCreateOrUpdateParametersValue['tags'] = tagsDictionary;763 }764 765 if (parameters.webHostingPlan.type !== null && parameters.webHostingPlan.type !== undefined) {766 webHostingPlanCreateOrUpdateParametersValue['type'] = parameters.webHostingPlan.type;767 }768 769 requestContent = JSON.stringify(requestDoc);770 httpRequest.body = requestContent;771 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');772 // Send Request773 return this.client.pipeline(httpRequest, function (err, response, body) {774 if (err !== null && err !== undefined) {775 return callback(err);776 }777 var statusCode = response.statusCode;778 if (statusCode !== 200) {779 var error = new Error(body);780 error.statusCode = response.statusCode;781 return callback(error);782 }783 784 // Create Result785 var result = null;786 // Deserialize Response787 if (statusCode === 200) {788 var responseContent = body;789 result = {};790 var responseDoc = null;791 if (responseContent) {792 responseDoc = JSON.parse(responseContent);793 }794 795 var serverFarmValue = responseDoc['ServerFarm'];796 if (serverFarmValue !== null && serverFarmValue !== undefined) {797 var serverFarmInstance = {};798 799 var webHostingPlanInstance = { tags: {} };800 result.webHostingPlan = webHostingPlanInstance;801 802 var propertiesValue2 = serverFarmValue['properties'];803 if (propertiesValue2 !== null && propertiesValue2 !== undefined) {804 var propertiesInstance = {};805 webHostingPlanInstance.properties = propertiesInstance;806 807 var skuValue = propertiesValue2['sku'];808 if (skuValue !== null && skuValue !== undefined) {809 var skuInstance = skuValue;810 propertiesInstance.sku = skuInstance;811 }812 813 var numberOfWorkersValue = propertiesValue2['numberOfWorkers'];814 if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {815 var numberOfWorkersInstance = numberOfWorkersValue;816 propertiesInstance.numberOfWorkers = numberOfWorkersInstance;817 }818 819 var workerSizeValue = propertiesValue2['workerSize'];820 if (workerSizeValue !== null && workerSizeValue !== undefined) {821 var workerSizeInstance = workerSizeValue;822 propertiesInstance.workerSize = workerSizeInstance;823 }824 825 var adminSiteNameValue = propertiesValue2['adminSiteName'];826 if (adminSiteNameValue !== null && adminSiteNameValue !== undefined) {827 var adminSiteNameInstance = adminSiteNameValue;828 propertiesInstance.adminSiteName = adminSiteNameInstance;829 }830 }831 832 var idValue = serverFarmValue['id'];833 if (idValue !== null && idValue !== undefined) {834 var idInstance = idValue;835 webHostingPlanInstance.id = idInstance;836 }837 838 var nameValue = serverFarmValue['name'];839 if (nameValue !== null && nameValue !== undefined) {840 var nameInstance = nameValue;841 webHostingPlanInstance.name = nameInstance;842 }843 844 var locationValue = serverFarmValue['location'];845 if (locationValue !== null && locationValue !== undefined) {846 var locationInstance = locationValue;847 webHostingPlanInstance.location = locationInstance;848 }849 850 var tagsSequenceElement = serverFarmValue['tags'];851 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {852 for (var property in tagsSequenceElement) {853 var tagsKey2 = property;854 var tagsValue2 = tagsSequenceElement[property];855 webHostingPlanInstance.tags[tagsKey2] = tagsValue2;856 }857 }858 859 var typeValue = serverFarmValue['type'];860 if (typeValue !== null && typeValue !== undefined) {861 var typeInstance = typeValue;862 webHostingPlanInstance.type = typeInstance;863 }864 }865 866 }867 result.statusCode = statusCode;868 result.requestId = response.headers['x-ms-request-id'];869 870 return callback(null, result);871 });872 };873 874 /**875 * Deletes a Web Hosting Plan (see876 * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/877 * for more information)878 * 879 * @param {string} resourceGroupName The name of the resource group.880 * 881 * @param {string} webHostingPlanName The name of the Web Hosting Plan to882 * delete.883 * 884 * @param {function} callback885 * 886 * @returns {Stream} The response stream.887 */888 WebHostingPlanOperations.prototype.deleteMethod = function(resourceGroupName, webHostingPlanName, callback) {889 if (callback === null || callback === undefined) {890 throw new Error('callback cannot be null.');891 }892 // Validate893 if (resourceGroupName === null || resourceGroupName === undefined) {894 return callback(new Error('resourceGroupName cannot be null.'));895 }896 if (webHostingPlanName === null || webHostingPlanName === undefined) {897 return callback(new Error('webHostingPlanName cannot be null.'));898 }899 900 // Tracing901 902 // Construct URL903 var url2 = '';904 url2 = url2 + '/subscriptions/';905 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {906 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);907 }908 url2 = url2 + '/resourceGroups/';909 url2 = url2 + encodeURIComponent(resourceGroupName);910 url2 = url2 + '/providers/';911 url2 = url2 + 'Microsoft.Web';912 url2 = url2 + '/serverFarms/';913 url2 = url2 + encodeURIComponent(webHostingPlanName);914 var queryParameters = [];915 queryParameters.push('api-version=2014-06-01');916 if (queryParameters.length > 0) {917 url2 = url2 + '?' + queryParameters.join('&');918 }919 var baseUrl = this.client.baseUri;920 // Trim '/' character from the end of baseUrl and beginning of url.921 if (baseUrl[baseUrl.length - 1] === '/') {922 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);923 }924 if (url2[0] === '/') {925 url2 = url2.substring(1);926 }927 url2 = baseUrl + '/' + url2;928 url2 = url2.replace(' ', '%20');929 930 // Create HTTP transport objects931 var httpRequest = new WebResource();932 httpRequest.method = 'DELETE';933 httpRequest.headers = {};934 httpRequest.url = url2;935 936 // Set Headers937 938 // Send Request939 return this.client.pipeline(httpRequest, function (err, response, body) {940 if (err !== null && err !== undefined) {941 return callback(err);942 }943 var statusCode = response.statusCode;944 if (statusCode !== 200) {945 var error = new Error(body);946 error.statusCode = response.statusCode;947 return callback(error);948 }949 950 // Create Result951 var result = null;952 // Deserialize Response953 result = {};954 result.statusCode = statusCode;955 result.requestId = response.headers['x-ms-request-id'];956 957 return callback(null, result);958 });959 };960 961 /**962 * Gets details of an existing Web Hosting Plan (see963 * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/964 * for more information)965 * 966 * @param {string} resourceGroupName The name of the resource group.967 * 968 * @param {string} webHostingPlanName The name of the Web Hosting Plan.969 * 970 * @param {function} callback971 * 972 * @returns {Stream} The response stream.973 */974 WebHostingPlanOperations.prototype.get = function(resourceGroupName, webHostingPlanName, callback) {975 if (callback === null || callback === undefined) {976 throw new Error('callback cannot be null.');977 }978 // Validate979 if (resourceGroupName === null || resourceGroupName === undefined) {980 return callback(new Error('resourceGroupName cannot be null.'));981 }982 if (webHostingPlanName === null || webHostingPlanName === undefined) {983 return callback(new Error('webHostingPlanName cannot be null.'));984 }985 986 // Tracing987 988 // Construct URL989 var url2 = '';990 url2 = url2 + '/subscriptions/';991 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {992 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);993 }994 url2 = url2 + '/resourceGroups/';995 url2 = url2 + encodeURIComponent(resourceGroupName);996 url2 = url2 + '/providers/';997 url2 = url2 + 'Microsoft.Web';998 url2 = url2 + '/serverFarms/';999 url2 = url2 + encodeURIComponent(webHostingPlanName);1000 var queryParameters = [];1001 queryParameters.push('api-version=2014-06-01');1002 if (queryParameters.length > 0) {1003 url2 = url2 + '?' + queryParameters.join('&');1004 }1005 var baseUrl = this.client.baseUri;1006 // Trim '/' character from the end of baseUrl and beginning of url.1007 if (baseUrl[baseUrl.length - 1] === '/') {1008 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1009 }1010 if (url2[0] === '/') {1011 url2 = url2.substring(1);1012 }1013 url2 = baseUrl + '/' + url2;1014 url2 = url2.replace(' ', '%20');1015 1016 // Create HTTP transport objects1017 var httpRequest = new WebResource();1018 httpRequest.method = 'GET';1019 httpRequest.headers = {};1020 httpRequest.url = url2;1021 1022 // Set Headers1023 1024 // Send Request1025 return this.client.pipeline(httpRequest, function (err, response, body) {1026 if (err !== null && err !== undefined) {1027 return callback(err);1028 }1029 var statusCode = response.statusCode;1030 if (statusCode !== 200) {1031 var error = new Error(body);1032 error.statusCode = response.statusCode;1033 return callback(error);1034 }1035 1036 // Create Result1037 var result = null;1038 // Deserialize Response1039 if (statusCode === 200) {1040 var responseContent = body;1041 result = {};1042 var responseDoc = null;1043 if (responseContent) {1044 responseDoc = JSON.parse(responseContent);1045 }1046 1047 if (responseDoc !== null && responseDoc !== undefined) {1048 var webHostingPlanInstance = { tags: {} };1049 result.webHostingPlan = webHostingPlanInstance;1050 1051 var propertiesValue = responseDoc['properties'];1052 if (propertiesValue !== null && propertiesValue !== undefined) {1053 var propertiesInstance = {};1054 webHostingPlanInstance.properties = propertiesInstance;1055 1056 var skuValue = propertiesValue['sku'];1057 if (skuValue !== null && skuValue !== undefined) {1058 var skuInstance = skuValue;1059 propertiesInstance.sku = skuInstance;1060 }1061 1062 var numberOfWorkersValue = propertiesValue['numberOfWorkers'];1063 if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {1064 var numberOfWorkersInstance = numberOfWorkersValue;1065 propertiesInstance.numberOfWorkers = numberOfWorkersInstance;1066 }1067 1068 var workerSizeValue = propertiesValue['workerSize'];1069 if (workerSizeValue !== null && workerSizeValue !== undefined) {1070 var workerSizeInstance = workerSizeValue;1071 propertiesInstance.workerSize = workerSizeInstance;1072 }1073 1074 var adminSiteNameValue = propertiesValue['adminSiteName'];1075 if (adminSiteNameValue !== null && adminSiteNameValue !== undefined) {1076 var adminSiteNameInstance = adminSiteNameValue;1077 propertiesInstance.adminSiteName = adminSiteNameInstance;1078 }1079 }1080 1081 var idValue = responseDoc['id'];1082 if (idValue !== null && idValue !== undefined) {1083 var idInstance = idValue;1084 webHostingPlanInstance.id = idInstance;1085 }1086 1087 var nameValue = responseDoc['name'];1088 if (nameValue !== null && nameValue !== undefined) {1089 var nameInstance = nameValue;1090 webHostingPlanInstance.name = nameInstance;1091 }1092 1093 var locationValue = responseDoc['location'];1094 if (locationValue !== null && locationValue !== undefined) {1095 var locationInstance = locationValue;1096 webHostingPlanInstance.location = locationInstance;1097 }1098 1099 var tagsSequenceElement = responseDoc['tags'];1100 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {1101 for (var property in tagsSequenceElement) {1102 var tagsKey = property;1103 var tagsValue = tagsSequenceElement[property];1104 webHostingPlanInstance.tags[tagsKey] = tagsValue;1105 }1106 }1107 1108 var typeValue = responseDoc['type'];1109 if (typeValue !== null && typeValue !== undefined) {1110 var typeInstance = typeValue;1111 webHostingPlanInstance.type = typeInstance;1112 }1113 }1114 1115 }1116 result.statusCode = statusCode;1117 result.requestId = response.headers['x-ms-request-id'];1118 1119 return callback(null, result);1120 });1121 };1122 1123 /**1124 * You can retrieve historical usage metrics for a site by issuing an HTTP1125 * GET request. (see1126 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166964.aspx for1127 * more information)1128 * 1129 * @param {string} resourceGroupName The name of the resource group.1130 * 1131 * @param {string} webHostingPlanName The name of the web hosting plan.1132 * 1133 * @param {WebHostingPlanGetHistoricalUsageMetricsParameters} parameters1134 * Parameters supplied to the Get Historical Usage Metrics Web hosting plan1135 * operation.1136 * 1137 * @param {array} [parameters.metricNames] Specifies a comma-separated list1138 * of the names of the metrics to return. If the names parameter is not1139 * specified, then all available metrics are returned.1140 * 1141 * @param {date} [parameters.startTime] The starting time of the metrics to1142 * return. If this parameter is not specified, the beginning of the current1143 * hour is used.1144 * 1145 * @param {date} [parameters.endTime] The ending time of the metrics to1146 * return. If this parameter is not specified, the current time is used.1147 * 1148 * @param {string} [parameters.timeGrain] The grain at which the metrics are1149 * returned. Supported values are PT1M (minute), PT1H (hour), P1D (day).1150 * 1151 * @param {boolean} [parameters.includeInstanceBreakdown] Flag which1152 * specifies if the metrics for each machine instance should be included.1153 * For sites that run on more than one machine this could be useful to1154 * identify a bad machine.1155 * 1156 * @param {function} callback1157 * 1158 * @returns {Stream} The response stream.1159 */1160 WebHostingPlanOperations.prototype.getHistoricalUsageMetrics = function(resourceGroupName, webHostingPlanName, parameters, callback) {1161 if (callback === null || callback === undefined) {1162 throw new Error('callback cannot be null.');1163 }1164 // Validate1165 if (resourceGroupName === null || resourceGroupName === undefined) {1166 return callback(new Error('resourceGroupName cannot be null.'));1167 }1168 if (webHostingPlanName === null || webHostingPlanName === undefined) {1169 return callback(new Error('webHostingPlanName cannot be null.'));1170 }1171 if (parameters === null || parameters === undefined) {1172 return callback(new Error('parameters cannot be null.'));1173 }1174 1175 // Tracing1176 1177 // Construct URL1178 var url2 = '';1179 url2 = url2 + '/subscriptions/';1180 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {1181 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);1182 }1183 url2 = url2 + '/resourceGroups/';1184 url2 = url2 + encodeURIComponent(resourceGroupName);1185 url2 = url2 + '/providers/';1186 url2 = url2 + 'Microsoft.Web';1187 url2 = url2 + '/serverFarms/';1188 url2 = url2 + encodeURIComponent(webHostingPlanName);1189 url2 = url2 + '/metrics';1190 var queryParameters = [];1191 queryParameters.push('api-version=2014-06-01');1192 if (parameters.metricNames !== null && parameters.metricNames !== undefined && parameters.metricNames.length > 0) {1193 queryParameters.push('names=' + encodeURIComponent(parameters.metricNames.join(',')));1194 }1195 if (parameters.startTime !== null && parameters.startTime !== undefined) {1196 queryParameters.push('StartTime=' + encodeURIComponent(parameters.startTime.toISOString()));1197 }1198 if (parameters.endTime !== null && parameters.endTime !== undefined) {1199 queryParameters.push('EndTime=' + encodeURIComponent(parameters.endTime.toISOString()));1200 }1201 if (parameters.timeGrain !== null && parameters.timeGrain !== undefined) {1202 queryParameters.push('timeGrain=' + encodeURIComponent(parameters.timeGrain));1203 }1204 if (parameters.includeInstanceBreakdown !== null && parameters.includeInstanceBreakdown !== undefined) {1205 queryParameters.push('details=' + encodeURIComponent(parameters.includeInstanceBreakdown.toString()));1206 }1207 if (queryParameters.length > 0) {1208 url2 = url2 + '?' + queryParameters.join('&');1209 }1210 var baseUrl = this.client.baseUri;1211 // Trim '/' character from the end of baseUrl and beginning of url.1212 if (baseUrl[baseUrl.length - 1] === '/') {1213 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1214 }1215 if (url2[0] === '/') {1216 url2 = url2.substring(1);1217 }1218 url2 = baseUrl + '/' + url2;1219 url2 = url2.replace(' ', '%20');1220 1221 // Create HTTP transport objects1222 var httpRequest = new WebResource();1223 httpRequest.method = 'GET';1224 httpRequest.headers = {};1225 httpRequest.url = url2;1226 1227 // Set Headers1228 httpRequest.headers['x-ms-version'] = '2014-06-01';1229 1230 // Send Request1231 return this.client.pipeline(httpRequest, function (err, response, body) {1232 if (err !== null && err !== undefined) {1233 return callback(err);1234 }1235 var statusCode = response.statusCode;1236 if (statusCode !== 200) {1237 var error = new Error(body);1238 error.statusCode = response.statusCode;1239 return callback(error);1240 }1241 1242 // Create Result1243 var result = null;1244 // Deserialize Response1245 if (statusCode === 200) {1246 var responseContent = body;1247 result = { usageMetrics: [] };1248 var responseDoc = null;1249 if (responseContent) {1250 responseDoc = JSON.parse(responseContent);1251 }1252 1253 if (responseDoc !== null && responseDoc !== undefined) {1254 var propertiesArray = responseDoc['properties'];1255 if (propertiesArray !== null && propertiesArray !== undefined) {1256 for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {1257 var propertiesValue = propertiesArray[loweredIndex1];1258 var historicalUsageMetricInstance = {};1259 result.usageMetrics.push(historicalUsageMetricInstance);1260 1261 var codeValue = propertiesValue['code'];1262 if (codeValue !== null && codeValue !== undefined) {1263 var codeInstance = codeValue;1264 historicalUsageMetricInstance.code = codeInstance;1265 }1266 1267 var dataValue = propertiesValue['data'];1268 if (dataValue !== null && dataValue !== undefined) {1269 var dataInstance = { values: [] };1270 historicalUsageMetricInstance.data = dataInstance;1271 1272 var displayNameValue = dataValue['displayName'];1273 if (displayNameValue !== null && displayNameValue !== undefined) {1274 var displayNameInstance = displayNameValue;1275 dataInstance.displayName = displayNameInstance;1276 }1277 1278 var endTimeValue = dataValue['EndTime'];1279 if (endTimeValue !== null && endTimeValue !== undefined) {1280 var endTimeInstance = endTimeValue;1281 dataInstance.endTime = endTimeInstance;1282 }1283 1284 var nameValue = dataValue['name'];1285 if (nameValue !== null && nameValue !== undefined) {1286 var nameInstance = nameValue;1287 dataInstance.name = nameInstance;1288 }1289 1290 var primaryAggregationTypeValue = dataValue['primaryAggregationType'];1291 if (primaryAggregationTypeValue !== null && primaryAggregationTypeValue !== undefined) {1292 var primaryAggregationTypeInstance = primaryAggregationTypeValue;1293 dataInstance.primaryAggregationType = primaryAggregationTypeInstance;1294 }1295 1296 var startTimeValue = dataValue['startTime'];1297 if (startTimeValue !== null && startTimeValue !== undefined) {1298 var startTimeInstance = startTimeValue;1299 dataInstance.startTime = startTimeInstance;1300 }1301 1302 var timeGrainValue = dataValue['timeGrain'];1303 if (timeGrainValue !== null && timeGrainValue !== undefined) {1304 var timeGrainInstance = timeGrainValue;1305 dataInstance.timeGrain = timeGrainInstance;1306 }1307 1308 var unitValue = dataValue['unit'];1309 if (unitValue !== null && unitValue !== undefined) {1310 var unitInstance = unitValue;1311 dataInstance.unit = unitInstance;1312 }1313 1314 var valuesArray = dataValue['values'];1315 if (valuesArray !== null && valuesArray !== undefined) {1316 for (var loweredIndex2 = 0; loweredIndex2 < valuesArray.length; loweredIndex2 = loweredIndex2 + 1) {1317 var valuesValue = valuesArray[loweredIndex2];1318 var metricSampleInstance = {};1319 dataInstance.values.push(metricSampleInstance);1320 1321 var countValue = valuesValue['count'];1322 if (countValue !== null && countValue !== undefined) {1323 var countInstance = countValue;1324 metricSampleInstance.count = countInstance;1325 }1326 1327 var maximumValue = valuesValue['maximum'];1328 if (maximumValue !== null && maximumValue !== undefined) {1329 var maximumInstance = maximumValue;1330 metricSampleInstance.maximum = maximumInstance;1331 }1332 1333 var minimumValue = valuesValue['minimum'];1334 if (minimumValue !== null && minimumValue !== undefined) {1335 var minimumInstance = minimumValue;1336 metricSampleInstance.minimum = minimumInstance;1337 }1338 1339 var timeCreatedValue = valuesValue['timeCreated'];1340 if (timeCreatedValue !== null && timeCreatedValue !== undefined) {1341 var timeCreatedInstance = timeCreatedValue;1342 metricSampleInstance.timeCreated = timeCreatedInstance;1343 }1344 1345 var totalValue = valuesValue['total'];1346 if (totalValue !== null && totalValue !== undefined) {1347 var totalInstance = totalValue;1348 metricSampleInstance.total = totalInstance;1349 }1350 1351 var instanceNameValue = valuesValue['instanceName'];1352 if (instanceNameValue !== null && instanceNameValue !== undefined) {1353 var instanceNameInstance = instanceNameValue;1354 metricSampleInstance.instanceName = instanceNameInstance;1355 }1356 }1357 }1358 }1359 1360 var messageValue = propertiesValue['message'];1361 if (messageValue !== null && messageValue !== undefined) {1362 var messageInstance = messageValue;1363 historicalUsageMetricInstance.message = messageInstance;1364 }1365 }1366 }1367 }1368 1369 }1370 result.statusCode = statusCode;1371 result.requestId = response.headers['x-ms-request-id'];1372 1373 return callback(null, result);1374 });1375 };1376 1377 /**1378 * Gets all Web Hosting Plans in a current subscription and Resource Group.1379 * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn194277.aspx1380 * for more information)1381 * 1382 * @param {string} resourceGroupName The name of the resource group.1383 * 1384 * @param {function} callback1385 * 1386 * @returns {Stream} The response stream.1387 */1388 WebHostingPlanOperations.prototype.list = function(resourceGroupName, callback) {1389 if (callback === null || callback === undefined) {1390 throw new Error('callback cannot be null.');1391 }1392 // Validate1393 if (resourceGroupName === null || resourceGroupName === undefined) {1394 return callback(new Error('resourceGroupName cannot be null.'));1395 }1396 1397 // Tracing1398 1399 // Construct URL1400 var url2 = '';1401 url2 = url2 + '/subscriptions/';1402 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {1403 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);1404 }1405 url2 = url2 + '/resourceGroups/';1406 url2 = url2 + encodeURIComponent(resourceGroupName);1407 url2 = url2 + '/providers/';1408 url2 = url2 + 'Microsoft.Web';1409 url2 = url2 + '/serverFarms';1410 var queryParameters = [];1411 queryParameters.push('api-version=2014-06-01');1412 if (queryParameters.length > 0) {1413 url2 = url2 + '?' + queryParameters.join('&');1414 }1415 var baseUrl = this.client.baseUri;1416 // Trim '/' character from the end of baseUrl and beginning of url.1417 if (baseUrl[baseUrl.length - 1] === '/') {1418 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1419 }1420 if (url2[0] === '/') {1421 url2 = url2.substring(1);1422 }1423 url2 = baseUrl + '/' + url2;1424 url2 = url2.replace(' ', '%20');1425 1426 // Create HTTP transport objects1427 var httpRequest = new WebResource();1428 httpRequest.method = 'GET';1429 httpRequest.headers = {};1430 httpRequest.url = url2;1431 1432 // Set Headers1433 1434 // Send Request1435 return this.client.pipeline(httpRequest, function (err, response, body) {1436 if (err !== null && err !== undefined) {1437 return callback(err);1438 }1439 var statusCode = response.statusCode;1440 if (statusCode !== 200) {1441 var error = new Error(body);1442 error.statusCode = response.statusCode;1443 return callback(error);1444 }1445 1446 // Create Result1447 var result = null;1448 // Deserialize Response1449 if (statusCode === 200) {1450 var responseContent = body;1451 result = { webHostingPlans: [] };1452 var responseDoc = null;1453 if (responseContent) {1454 responseDoc = JSON.parse(responseContent);1455 }1456 1457 if (responseDoc !== null && responseDoc !== undefined) {1458 var valueArray = responseDoc['value'];1459 if (valueArray !== null && valueArray !== undefined) {1460 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {1461 var valueValue = valueArray[loweredIndex1];1462 var webHostingPlanInstance = { tags: {} };1463 result.webHostingPlans.push(webHostingPlanInstance);1464 1465 var propertiesValue = valueValue['properties'];1466 if (propertiesValue !== null && propertiesValue !== undefined) {1467 var propertiesInstance = {};1468 webHostingPlanInstance.properties = propertiesInstance;1469 1470 var skuValue = propertiesValue['sku'];1471 if (skuValue !== null && skuValue !== undefined) {1472 var skuInstance = skuValue;1473 propertiesInstance.sku = skuInstance;1474 }1475 1476 var numberOfWorkersValue = propertiesValue['numberOfWorkers'];1477 if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {1478 var numberOfWorkersInstance = numberOfWorkersValue;1479 propertiesInstance.numberOfWorkers = numberOfWorkersInstance;1480 }1481 1482 var workerSizeValue = propertiesValue['workerSize'];1483 if (workerSizeValue !== null && workerSizeValue !== undefined) {1484 var workerSizeInstance = workerSizeValue;1485 propertiesInstance.workerSize = workerSizeInstance;1486 }1487 1488 var adminSiteNameValue = propertiesValue['adminSiteName'];1489 if (adminSiteNameValue !== null && adminSiteNameValue !== undefined) {1490 var adminSiteNameInstance = adminSiteNameValue;1491 propertiesInstance.adminSiteName = adminSiteNameInstance;1492 }1493 }1494 1495 var idValue = valueValue['id'];1496 if (idValue !== null && idValue !== undefined) {1497 var idInstance = idValue;1498 webHostingPlanInstance.id = idInstance;1499 }1500 1501 var nameValue = valueValue['name'];1502 if (nameValue !== null && nameValue !== undefined) {1503 var nameInstance = nameValue;1504 webHostingPlanInstance.name = nameInstance;1505 }1506 1507 var locationValue = valueValue['location'];1508 if (locationValue !== null && locationValue !== undefined) {1509 var locationInstance = locationValue;1510 webHostingPlanInstance.location = locationInstance;1511 }1512 1513 var tagsSequenceElement = valueValue['tags'];1514 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {1515 for (var property in tagsSequenceElement) {1516 var tagsKey = property;1517 var tagsValue = tagsSequenceElement[property];1518 webHostingPlanInstance.tags[tagsKey] = tagsValue;1519 }1520 }1521 1522 var typeValue = valueValue['type'];1523 if (typeValue !== null && typeValue !== undefined) {1524 var typeInstance = typeValue;1525 webHostingPlanInstance.type = typeInstance;1526 }1527 }1528 }1529 }1530 1531 }1532 result.statusCode = statusCode;1533 result.requestId = response.headers['x-ms-request-id'];1534 1535 return callback(null, result);1536 });1537 };1538 1539 return WebHostingPlanOperations;1540})();15411542var WebSiteOperations = ( /** @lends WebSiteOperations */ function() {1543 /**1544 * @class1545 * Operations for managing the web sites in a web space.1546 * __NOTE__: An instance of this class is automatically created for an1547 * instance of the [WebSiteManagementClient] {@link1548 * WebSiteManagementClient~WebSiteManagementClient}.1549 * See [webSites] {@link1550 * WebSiteManagementClient~WebSiteManagementClient#webSites}.1551 * Initializes a new instance of the WebSiteOperations class.1552 * @constructor1553 * 1554 * @param {WebSiteManagementClient} client Reference to the service client.1555 */1556 function WebSiteOperations(client) {1557 this.client = client;1558 }1559 1560 /**1561 * Backups a site on-demand.1562 * 1563 * @param {string} resourceGroupName The name of the web space.1564 * 1565 * @param {string} webSiteName The name of the web site.1566 * 1567 * @param {string} [slotName] The name of the slot.1568 * 1569 * @param {BackupRequestEnvelope} backupRequestEnvelope A backup1570 * specification.1571 * 1572 * @param {BackupRequest} [backupRequestEnvelope.request] TODO.1573 * 1574 * @param {BackupSchedule} [backupRequestEnvelope.request.backupSchedule] The1575 * backup schedule structure - valid only when setting up a schedule. Should1576 * be Null for on-demand backups.1577 * 1578 * @param {number}1579 * [backupRequestEnvelope.request.backupSchedule.frequencyInterval] The1580 * frequency of backups.1581 * 1582 * @param {FrequencyUnit}1583 * [backupRequestEnvelope.request.backupSchedule.frequencyUnit] Units for1584 * FrequencyInterval - e.g. Day or Hour1585 * 1586 * @param {boolean}1587 * [backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup]1588 * Retention policy deletes backups after predefined number of days. If this1589 * is true, there will be always at least one backup left. regardless of the1590 * policy. If false, all backups can be deleted.1591 * 1592 * @param {date}1593 * [backupRequestEnvelope.request.backupSchedule.lastExecutionTime] The last1594 * time when this schedule started a backup, Null if didn't start anything1595 * yet.1596 * 1597 * @param {number}1598 * [backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays]1599 * Backups older N days (N defined by this value) will be automatically1600 * deleted.1601 * 1602 * @param {date} [backupRequestEnvelope.request.backupSchedule.startTime]1603 * When this schedule should start backing up the site. Null means1604 * immediately.1605 * 1606 * @param {IEnumerable} [backupRequestEnvelope.request.databases] Database1607 * settings for backup.1608 * 1609 * @param {boolean} [backupRequestEnvelope.request.enabled] Valid only for a1610 * backup schedule (can be Null for on-demand backups). True if enabled;1611 * false if disabled (no backups will be performed).1612 * 1613 * @param {string} [backupRequestEnvelope.request.name] The name of this1614 * backup - will be used for generating a blob name.1615 * 1616 * @param {string} [backupRequestEnvelope.request.storageAccountUrl] SAS URL1617 * for a container in a storage account. E.g.1618 * https://NAME.blob.core.windows.net/CONTAINERNAME/?sv=2012-02-12&st=2013-12-05T19%3A30%3A45Z&se=2017-12-04T19%3A30%3A45Z&sr=c&sp=rwdl&sig=abcdefABCDEFabcdef01234567891619 * 1620 * @param {string} [backupRequestEnvelope.id] Gets the ID of the resource.1621 * 1622 * @param {string} [backupRequestEnvelope.name] The name of the resource.1623 * 1624 * @param {string} backupRequestEnvelope.location Gets or sets the location1625 * of the resource.1626 * 1627 * @param {object} [backupRequestEnvelope.tags] Gets or sets the tags1628 * attached to the resource.1629 * 1630 * @param {string} [backupRequestEnvelope.type] The type of the resource1631 * 1632 * @param {function} callback1633 * 1634 * @returns {Stream} The response stream.1635 */1636 WebSiteOperations.prototype.backup = function(resourceGroupName, webSiteName, slotName, backupRequestEnvelope, callback) {1637 if (callback === null || callback === undefined) {1638 throw new Error('callback cannot be null.');1639 }1640 // Validate1641 if (resourceGroupName === null || resourceGroupName === undefined) {1642 return callback(new Error('resourceGroupName cannot be null.'));1643 }1644 if (webSiteName === null || webSiteName === undefined) {1645 return callback(new Error('webSiteName cannot be null.'));1646 }1647 if (backupRequestEnvelope === null || backupRequestEnvelope === undefined) {1648 return callback(new Error('backupRequestEnvelope cannot be null.'));1649 }1650 if (backupRequestEnvelope.location === null || backupRequestEnvelope.location === undefined) {1651 return callback(new Error('backupRequestEnvelope.location cannot be null.'));1652 }1653 1654 // Tracing1655 1656 // Construct URL1657 var url2 = '';1658 url2 = url2 + '/subscriptions/';1659 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {1660 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);1661 }1662 url2 = url2 + '/resourceGroups/';1663 url2 = url2 + encodeURIComponent(resourceGroupName);1664 url2 = url2 + '/providers/';1665 url2 = url2 + 'Microsoft.Web';1666 url2 = url2 + '/';1667 url2 = url2 + 'sites';1668 url2 = url2 + '/';1669 url2 = url2 + encodeURIComponent(webSiteName);1670 if (slotName !== null && slotName !== undefined) {1671 url2 = url2 + '/slots/' + encodeURIComponent(slotName);1672 }1673 url2 = url2 + '/backup';1674 var queryParameters = [];1675 queryParameters.push('api-version=2014-06-01');1676 if (queryParameters.length > 0) {1677 url2 = url2 + '?' + queryParameters.join('&');1678 }1679 var baseUrl = this.client.baseUri;1680 // Trim '/' character from the end of baseUrl and beginning of url.1681 if (baseUrl[baseUrl.length - 1] === '/') {1682 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1683 }1684 if (url2[0] === '/') {1685 url2 = url2.substring(1);1686 }1687 url2 = baseUrl + '/' + url2;1688 url2 = url2.replace(' ', '%20');1689 1690 // Create HTTP transport objects1691 var httpRequest = new WebResource();1692 httpRequest.method = 'PUT';1693 httpRequest.headers = {};1694 httpRequest.url = url2;1695 1696 // Set Headers1697 httpRequest.headers['Content-Type'] = 'application/json';1698 httpRequest.headers['x-ms-version'] = '2014-06-01';1699 1700 // Serialize Request1701 var requestContent = null;1702 var requestDoc = null;1703 1704 var backupRequestEnvelopeValue = {};1705 requestDoc = backupRequestEnvelopeValue;1706 1707 if (backupRequestEnvelope.request !== null && backupRequestEnvelope.request !== undefined) {1708 var propertiesValue = {};1709 backupRequestEnvelopeValue['properties'] = propertiesValue;1710 1711 if (backupRequestEnvelope.request.backupSchedule !== null && backupRequestEnvelope.request.backupSchedule !== undefined) {1712 var backupScheduleValue = {};1713 propertiesValue['backupSchedule'] = backupScheduleValue;1714 1715 if (backupRequestEnvelope.request.backupSchedule.frequencyInterval !== null && backupRequestEnvelope.request.backupSchedule.frequencyInterval !== undefined) {1716 backupScheduleValue['frequencyInterval'] = backupRequestEnvelope.request.backupSchedule.frequencyInterval;1717 }1718 1719 if (backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined) {1720 backupScheduleValue['frequencyUnit'] = backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined ? backupRequestEnvelope.request.backupSchedule.frequencyUnit.toString() : 'Day';1721 }1722 1723 if (backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== null && backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== undefined) {1724 backupScheduleValue['keepAtLeastOneBackup'] = backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup;1725 }1726 1727 if (backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== null && backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== undefined) {1728 backupScheduleValue['lastExecutionTime'] = backupRequestEnvelope.request.backupSchedule.lastExecutionTime;1729 }1730 1731 if (backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== null && backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== undefined) {1732 backupScheduleValue['retentionPeriodInDays'] = backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays;1733 }1734 1735 if (backupRequestEnvelope.request.backupSchedule.startTime !== null && backupRequestEnvelope.request.backupSchedule.startTime !== undefined) {1736 backupScheduleValue['startTime'] = backupRequestEnvelope.request.backupSchedule.startTime;1737 }1738 }1739 1740 if (backupRequestEnvelope.request.databases !== null && backupRequestEnvelope.request.databases !== undefined) {1741 var databasesArray = [];1742 for (var loweredIndex1 = 0; loweredIndex1 < backupRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {1743 var databasesItem = backupRequestEnvelope.request.databases[loweredIndex1];1744 var databaseBackupSettingValue = {};1745 databasesArray.push(databaseBackupSettingValue);1746 1747 if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {1748 databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;1749 }1750 1751 if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {1752 databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;1753 }1754 1755 if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {1756 databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;1757 }1758 1759 if (databasesItem.name !== null && databasesItem.name !== undefined) {1760 databaseBackupSettingValue['name'] = databasesItem.name;1761 }1762 }1763 propertiesValue['databases'] = databasesArray;1764 }1765 1766 if (backupRequestEnvelope.request.enabled !== null && backupRequestEnvelope.request.enabled !== undefined) {1767 propertiesValue['enabled'] = backupRequestEnvelope.request.enabled;1768 }1769 1770 if (backupRequestEnvelope.request.name !== null && backupRequestEnvelope.request.name !== undefined) {1771 propertiesValue['name'] = backupRequestEnvelope.request.name;1772 }1773 1774 if (backupRequestEnvelope.request.storageAccountUrl !== null && backupRequestEnvelope.request.storageAccountUrl !== undefined) {1775 propertiesValue['storageAccountUrl'] = backupRequestEnvelope.request.storageAccountUrl;1776 }1777 }1778 1779 if (backupRequestEnvelope.id !== null && backupRequestEnvelope.id !== undefined) {1780 backupRequestEnvelopeValue['id'] = backupRequestEnvelope.id;1781 }1782 1783 if (backupRequestEnvelope.name !== null && backupRequestEnvelope.name !== undefined) {1784 backupRequestEnvelopeValue['name'] = backupRequestEnvelope.name;1785 }1786 1787 backupRequestEnvelopeValue['location'] = backupRequestEnvelope.location;1788 1789 if (backupRequestEnvelope.tags !== null && backupRequestEnvelope.tags !== undefined) {1790 var tagsDictionary = {};1791 for (var tagsKey in backupRequestEnvelope.tags) {1792 var tagsValue = backupRequestEnvelope.tags[tagsKey];1793 tagsDictionary[tagsKey] = tagsValue;1794 }1795 backupRequestEnvelopeValue['tags'] = tagsDictionary;1796 }1797 1798 if (backupRequestEnvelope.type !== null && backupRequestEnvelope.type !== undefined) {1799 backupRequestEnvelopeValue['type'] = backupRequestEnvelope.type;1800 }1801 1802 requestContent = JSON.stringify(requestDoc);1803 httpRequest.body = requestContent;1804 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');1805 // Send Request1806 return this.client.pipeline(httpRequest, function (err, response, body) {1807 if (err !== null && err !== undefined) {1808 return callback(err);1809 }1810 var statusCode = response.statusCode;1811 if (statusCode !== 200) {1812 var error = new Error(body);1813 error.statusCode = response.statusCode;1814 return callback(error);1815 }1816 1817 // Create Result1818 var result = null;1819 // Deserialize Response1820 if (statusCode === 200) {1821 var responseContent = body;1822 result = {};1823 var responseDoc = null;1824 if (responseContent) {1825 responseDoc = JSON.parse(responseContent);1826 }1827 1828 if (responseDoc !== null && responseDoc !== undefined) {1829 var backupItemInstance = { tags: {} };1830 result.backupItem = backupItemInstance;1831 1832 var propertiesValue2 = responseDoc['properties'];1833 if (propertiesValue2 !== null && propertiesValue2 !== undefined) {1834 var propertiesInstance = { databases: [] };1835 backupItemInstance.properties = propertiesInstance;1836 1837 var storageAccountUrlValue = propertiesValue2['storageAccountUrl'];1838 if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {1839 var storageAccountUrlInstance = storageAccountUrlValue;1840 propertiesInstance.storageAccountUrl = storageAccountUrlInstance;1841 }1842 1843 var blobNameValue = propertiesValue2['blobName'];1844 if (blobNameValue !== null && blobNameValue !== undefined) {1845 var blobNameInstance = blobNameValue;1846 propertiesInstance.blobName = blobNameInstance;1847 }1848 1849 var nameValue = propertiesValue2['name'];1850 if (nameValue !== null && nameValue !== undefined) {1851 var nameInstance = nameValue;1852 propertiesInstance.name = nameInstance;1853 }1854 1855 var statusValue = propertiesValue2['status'];1856 if (statusValue !== null && statusValue !== undefined) {1857 var statusInstance = statusValue;1858 propertiesInstance.status = statusInstance;1859 }1860 1861 var sizeInBytesValue = propertiesValue2['sizeInBytes'];1862 if (sizeInBytesValue !== null && sizeInBytesValue !== undefined) {1863 var sizeInBytesInstance = sizeInBytesValue;1864 propertiesInstance.sizeInBytes = sizeInBytesInstance;1865 }1866 1867 var createdValue = propertiesValue2['created'];1868 if (createdValue !== null && createdValue !== undefined) {1869 var createdInstance = createdValue;1870 propertiesInstance.created = createdInstance;1871 }1872 1873 var logValue = propertiesValue2['log'];1874 if (logValue !== null && logValue !== undefined) {1875 var logInstance = logValue;1876 propertiesInstance.log = logInstance;1877 }1878 1879 var databasesArray2 = propertiesValue2['databases'];1880 if (databasesArray2 !== null && databasesArray2 !== undefined) {1881 for (var loweredIndex2 = 0; loweredIndex2 < databasesArray2.length; loweredIndex2 = loweredIndex2 + 1) {1882 var databasesValue = databasesArray2[loweredIndex2];1883 var databaseBackupSettingInstance = {};1884 propertiesInstance.databases.push(databaseBackupSettingInstance);1885 1886 var connectionStringValue = databasesValue['connectionString'];1887 if (connectionStringValue !== null && connectionStringValue !== undefined) {1888 var connectionStringInstance = connectionStringValue;1889 databaseBackupSettingInstance.connectionString = connectionStringInstance;1890 }1891 1892 var connectionStringNameValue = databasesValue['connectionStringName'];1893 if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {1894 var connectionStringNameInstance = connectionStringNameValue;1895 databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;1896 }1897 1898 var databaseTypeValue = databasesValue['databaseType'];1899 if (databaseTypeValue !== null && databaseTypeValue !== undefined) {1900 var databaseTypeInstance = databaseTypeValue;1901 databaseBackupSettingInstance.databaseType = databaseTypeInstance;1902 }1903 1904 var nameValue2 = databasesValue['name'];1905 if (nameValue2 !== null && nameValue2 !== undefined) {1906 var nameInstance2 = nameValue2;1907 databaseBackupSettingInstance.name = nameInstance2;1908 }1909 }1910 }1911 1912 var scheduledValue = propertiesValue2['scheduled'];1913 if (scheduledValue !== null && scheduledValue !== undefined) {1914 var scheduledInstance = scheduledValue;1915 propertiesInstance.scheduled = scheduledInstance;1916 }1917 1918 var lastRestoreTimeStampValue = propertiesValue2['lastRestoreTimeStamp'];1919 if (lastRestoreTimeStampValue !== null && lastRestoreTimeStampValue !== undefined) {1920 var lastRestoreTimeStampInstance = lastRestoreTimeStampValue;1921 propertiesInstance.lastRestoreTimeStamp = lastRestoreTimeStampInstance;1922 }1923 1924 var finishedTimeStampValue = propertiesValue2['finishedTimeStamp'];1925 if (finishedTimeStampValue !== null && finishedTimeStampValue !== undefined) {1926 var finishedTimeStampInstance = finishedTimeStampValue;1927 propertiesInstance.finishedTimeStamp = finishedTimeStampInstance;1928 }1929 1930 var correlationIdValue = propertiesValue2['correlationId'];1931 if (correlationIdValue !== null && correlationIdValue !== undefined) {1932 var correlationIdInstance = correlationIdValue;1933 propertiesInstance.correlationId = correlationIdInstance;1934 }1935 }1936 1937 var idValue = responseDoc['id'];1938 if (idValue !== null && idValue !== undefined) {1939 var idInstance = idValue;1940 backupItemInstance.id = idInstance;1941 }1942 1943 var nameValue3 = responseDoc['name'];1944 if (nameValue3 !== null && nameValue3 !== undefined) {1945 var nameInstance3 = nameValue3;1946 backupItemInstance.name = nameInstance3;1947 }1948 1949 var locationValue = responseDoc['location'];1950 if (locationValue !== null && locationValue !== undefined) {1951 var locationInstance = locationValue;1952 backupItemInstance.location = locationInstance;1953 }1954 1955 var tagsSequenceElement = responseDoc['tags'];1956 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {1957 for (var property in tagsSequenceElement) {1958 var tagsKey2 = property;1959 var tagsValue2 = tagsSequenceElement[property];1960 backupItemInstance.tags[tagsKey2] = tagsValue2;1961 }1962 }1963 1964 var typeValue = responseDoc['type'];1965 if (typeValue !== null && typeValue !== undefined) {1966 var typeInstance = typeValue;1967 backupItemInstance.type = typeInstance;1968 }1969 }1970 1971 }1972 result.statusCode = statusCode;1973 result.requestId = response.headers['x-ms-request-id'];1974 1975 return callback(null, result);1976 });1977 };1978 1979 /**1980 * You can clone a web site by using a PUT request that includes the name of1981 * the web site and other information in the request body. (see1982 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166986.aspx for1983 * more information)1984 * 1985 * @param {string} resourceGroupName The name of the resource group.1986 * 1987 * @param {string} webSiteName The name of the web site.1988 * 1989 * @param {string} [slotName] The name of the slot.1990 * 1991 * @param {WebSiteCloneParameters} parameters Parameters supplied to the1992 * clone Web Site operation.1993 * 1994 * @param {WebSiteCloneBase} parameters.webSiteClone Gets or sets information1995 * about the website being cloned.1996 * 1997 * @param {WebSiteCloneBaseProperties} [parameters.webSiteClone.properties]1998 * Represents the properties of the website.1999 * 2000 * @param {string} [parameters.webSiteClone.properties.serverFarm] The name2001 * of the Server Farm (Web Hosting Plan) associated with this website.2002 * 2003 * @param {CloningInfo} [parameters.webSiteClone.properties.cloningInfo] The2004 * per site limits.2005 * 2006 * @param {Guid}2007 * [parameters.webSiteClone.properties.cloningInfo.correlationId]2008 * Correlation Id. Used for bulk cloning operations2009 * 2010 * @param {boolean}2011 * [parameters.webSiteClone.properties.cloningInfo.overwrite] Overwrite2012 * target site2013 * 2014 * @param {boolean}2015 * [parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames]2016 * Clone custom hostnames2017 * 2018 * @param {SourceWebSite}2019 * [parameters.webSiteClone.properties.cloningInfo.source] Source website to2020 * clone2021 * 2022 * @param {string}2023 * [parameters.webSiteClone.properties.cloningInfo.source.name] Name of2024 * source site2025 * 2026 * @param {string}2027 * [parameters.webSiteClone.properties.cloningInfo.source.location] Locatio2028 * (georegion) of source site2029 * 2030 * @param {string}2031 * [parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName]2032 * Name of resource group of source site2033 * 2034 * @param {string}2035 * [parameters.webSiteClone.properties.cloningInfo.source.subscriptionId]2036 * Subscription Id of source site2037 * 2038 * @param {string}2039 * [parameters.webSiteClone.properties.cloningInfo.source.slot] Name of slot2040 * of source site2041 * 2042 * @param {string}2043 * [parameters.webSiteClone.properties.cloningInfo.hostingEnvironment]2044 * Hosting environment2045 * 2046 * @param {string} [parameters.webSiteClone.id] Gets the ID of the resource.2047 * 2048 * @param {string} [parameters.webSiteClone.name] The name of the resource.2049 * 2050 * @param {string} parameters.webSiteClone.location Gets or sets the location2051 * of the resource.2052 * 2053 * @param {object} [parameters.webSiteClone.tags] Gets or sets the tags2054 * attached to the resource.2055 * 2056 * @param {string} [parameters.webSiteClone.type] The type of the resource2057 * 2058 * @param {function} callback2059 * 2060 * @returns {Stream} The response stream.2061 */2062 WebSiteOperations.prototype.clone = function(resourceGroupName, webSiteName, slotName, parameters, callback) {2063 if (callback === null || callback === undefined) {2064 throw new Error('callback cannot be null.');2065 }2066 // Validate2067 if (resourceGroupName === null || resourceGroupName === undefined) {2068 return callback(new Error('resourceGroupName cannot be null.'));2069 }2070 if (webSiteName === null || webSiteName === undefined) {2071 return callback(new Error('webSiteName cannot be null.'));2072 }2073 if (parameters === null || parameters === undefined) {2074 return callback(new Error('parameters cannot be null.'));2075 }2076 if (parameters.webSiteClone === null || parameters.webSiteClone === undefined) {2077 return callback(new Error('parameters.webSiteClone cannot be null.'));2078 }2079 if (parameters.webSiteClone.location === null || parameters.webSiteClone.location === undefined) {2080 return callback(new Error('parameters.webSiteClone.location cannot be null.'));2081 }2082 2083 // Tracing2084 2085 // Construct URL2086 var url2 = '';2087 url2 = url2 + '/subscriptions/';2088 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2089 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2090 }2091 url2 = url2 + '/resourceGroups/';2092 url2 = url2 + encodeURIComponent(resourceGroupName);2093 url2 = url2 + '/providers/';2094 url2 = url2 + 'Microsoft.Web';2095 url2 = url2 + '/';2096 url2 = url2 + 'sites';2097 url2 = url2 + '/';2098 url2 = url2 + encodeURIComponent(webSiteName);2099 if (slotName !== null && slotName !== undefined) {2100 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2101 }2102 var queryParameters = [];2103 queryParameters.push('api-version=2014-06-01');2104 if (queryParameters.length > 0) {2105 url2 = url2 + '?' + queryParameters.join('&');2106 }2107 var baseUrl = this.client.baseUri;2108 // Trim '/' character from the end of baseUrl and beginning of url.2109 if (baseUrl[baseUrl.length - 1] === '/') {2110 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2111 }2112 if (url2[0] === '/') {2113 url2 = url2.substring(1);2114 }2115 url2 = baseUrl + '/' + url2;2116 url2 = url2.replace(' ', '%20');2117 2118 // Create HTTP transport objects2119 var httpRequest = new WebResource();2120 httpRequest.method = 'PUT';2121 httpRequest.headers = {};2122 httpRequest.url = url2;2123 2124 // Set Headers2125 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2126 2127 // Serialize Request2128 var requestContent = null;2129 var requestDoc = null;2130 2131 var webSiteCloneParametersValue = {};2132 requestDoc = webSiteCloneParametersValue;2133 2134 if (parameters.webSiteClone.properties !== null && parameters.webSiteClone.properties !== undefined) {2135 var propertiesValue = {};2136 webSiteCloneParametersValue['properties'] = propertiesValue;2137 2138 if (parameters.webSiteClone.properties.serverFarm !== null && parameters.webSiteClone.properties.serverFarm !== undefined) {2139 propertiesValue['ServerFarm'] = parameters.webSiteClone.properties.serverFarm;2140 }2141 2142 if (parameters.webSiteClone.properties.cloningInfo !== null && parameters.webSiteClone.properties.cloningInfo !== undefined) {2143 var cloningInfoValue = {};2144 propertiesValue['cloningInfo'] = cloningInfoValue;2145 2146 if (parameters.webSiteClone.properties.cloningInfo.correlationId !== null && parameters.webSiteClone.properties.cloningInfo.correlationId !== undefined) {2147 cloningInfoValue['CorrelationId'] = parameters.webSiteClone.properties.cloningInfo.correlationId;2148 }2149 2150 if (parameters.webSiteClone.properties.cloningInfo.overwrite !== null && parameters.webSiteClone.properties.cloningInfo.overwrite !== undefined) {2151 cloningInfoValue['Overwrite'] = parameters.webSiteClone.properties.cloningInfo.overwrite;2152 }2153 2154 if (parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames !== null && parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames !== undefined) {2155 cloningInfoValue['CloneCustomHostNames'] = parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames;2156 }2157 2158 if (parameters.webSiteClone.properties.cloningInfo.source !== null && parameters.webSiteClone.properties.cloningInfo.source !== undefined) {2159 var sourceValue = {};2160 cloningInfoValue['Source'] = sourceValue;2161 2162 if (parameters.webSiteClone.properties.cloningInfo.source.name !== null && parameters.webSiteClone.properties.cloningInfo.source.name !== undefined) {2163 sourceValue['Name'] = parameters.webSiteClone.properties.cloningInfo.source.name;2164 }2165 2166 if (parameters.webSiteClone.properties.cloningInfo.source.location !== null && parameters.webSiteClone.properties.cloningInfo.source.location !== undefined) {2167 sourceValue['Location'] = parameters.webSiteClone.properties.cloningInfo.source.location;2168 }2169 2170 if (parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName !== null && parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName !== undefined) {2171 sourceValue['ResourceGroupName'] = parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName;2172 }2173 2174 if (parameters.webSiteClone.properties.cloningInfo.source.subscriptionId !== null && parameters.webSiteClone.properties.cloningInfo.source.subscriptionId !== undefined) {2175 sourceValue['SubscriptionId'] = parameters.webSiteClone.properties.cloningInfo.source.subscriptionId;2176 }2177 2178 if (parameters.webSiteClone.properties.cloningInfo.source.slot !== null && parameters.webSiteClone.properties.cloningInfo.source.slot !== undefined) {2179 sourceValue['Slot'] = parameters.webSiteClone.properties.cloningInfo.source.slot;2180 }2181 }2182 2183 if (parameters.webSiteClone.properties.cloningInfo.hostingEnvironment !== null && parameters.webSiteClone.properties.cloningInfo.hostingEnvironment !== undefined) {2184 cloningInfoValue['HostingEnvironment'] = parameters.webSiteClone.properties.cloningInfo.hostingEnvironment;2185 }2186 }2187 }2188 2189 if (parameters.webSiteClone.id !== null && parameters.webSiteClone.id !== undefined) {2190 webSiteCloneParametersValue['id'] = parameters.webSiteClone.id;2191 }2192 2193 if (parameters.webSiteClone.name !== null && parameters.webSiteClone.name !== undefined) {2194 webSiteCloneParametersValue['name'] = parameters.webSiteClone.name;2195 }2196 2197 webSiteCloneParametersValue['location'] = parameters.webSiteClone.location;2198 2199 if (parameters.webSiteClone.tags !== null && parameters.webSiteClone.tags !== undefined) {2200 var tagsDictionary = {};2201 for (var tagsKey in parameters.webSiteClone.tags) {2202 var tagsValue = parameters.webSiteClone.tags[tagsKey];2203 tagsDictionary[tagsKey] = tagsValue;2204 }2205 webSiteCloneParametersValue['tags'] = tagsDictionary;2206 }2207 2208 if (parameters.webSiteClone.type !== null && parameters.webSiteClone.type !== undefined) {2209 webSiteCloneParametersValue['type'] = parameters.webSiteClone.type;2210 }2211 2212 requestContent = JSON.stringify(requestDoc);2213 httpRequest.body = requestContent;2214 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');2215 // Send Request2216 return this.client.pipeline(httpRequest, function (err, response, body) {2217 if (err !== null && err !== undefined) {2218 return callback(err);2219 }2220 var statusCode = response.statusCode;2221 if (statusCode !== 202) {2222 var error = new Error(body);2223 error.statusCode = response.statusCode;2224 return callback(error);2225 }2226 2227 // Create Result2228 var result = null;2229 // Deserialize Response2230 if (statusCode === 202) {2231 var responseContent = body;2232 result = {};2233 var responseDoc = null;2234 if (responseContent) {2235 responseDoc = JSON.parse(responseContent);2236 }2237 2238 if (responseDoc !== null && responseDoc !== undefined) {2239 var locationValue = responseDoc['location'];2240 if (locationValue !== null && locationValue !== undefined) {2241 var locationInstance = locationValue;2242 result.location = locationInstance;2243 }2244 2245 var retryAfterValue = responseDoc['retry-after'];2246 if (retryAfterValue !== null && retryAfterValue !== undefined) {2247 var retryAfterInstance = retryAfterValue;2248 result.retryAfter = retryAfterInstance;2249 }2250 }2251 2252 }2253 result.statusCode = statusCode;2254 result.location = response.headers['location'];2255 result.retryAfter = response.headers['retry-after'];2256 result.requestId = response.headers['x-ms-request-id'];2257 2258 return callback(null, result);2259 });2260 };2261 2262 /**2263 * You can create a web site by using a POST request that includes the name2264 * of the web site and other information in the request body. (see2265 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166986.aspx for2266 * more information)2267 * 2268 * @param {string} resourceGroupName The name of the resource group.2269 * 2270 * @param {string} webSiteName The name of the web site.2271 * 2272 * @param {string} [slotName] The name of the slot.2273 * 2274 * @param {WebSiteCreateOrUpdateParameters} parameters Parameters supplied to2275 * the Create Web Site operation.2276 * 2277 * @param {WebSiteBase} parameters.webSite Gets or sets information about a2278 * website being created of updated.2279 * 2280 * @param {WebSiteBaseProperties} [parameters.webSite.properties] Represents2281 * the properties of the website.2282 * 2283 * @param {string} [parameters.webSite.properties.serverFarm] The name of the2284 * Server Farm (Web Hosting Plan) associated with this website.2285 * 2286 * @param {string} [parameters.webSite.id] Gets the ID of the resource.2287 * 2288 * @param {string} [parameters.webSite.name] The name of the resource.2289 * 2290 * @param {string} parameters.webSite.location Gets or sets the location of2291 * the resource.2292 * 2293 * @param {object} [parameters.webSite.tags] Gets or sets the tags attached2294 * to the resource.2295 * 2296 * @param {string} [parameters.webSite.type] The type of the resource2297 * 2298 * @param {function} callback2299 * 2300 * @returns {Stream} The response stream.2301 */2302 WebSiteOperations.prototype.createOrUpdate = function(resourceGroupName, webSiteName, slotName, parameters, callback) {2303 if (callback === null || callback === undefined) {2304 throw new Error('callback cannot be null.');2305 }2306 // Validate2307 if (resourceGroupName === null || resourceGroupName === undefined) {2308 return callback(new Error('resourceGroupName cannot be null.'));2309 }2310 if (webSiteName === null || webSiteName === undefined) {2311 return callback(new Error('webSiteName cannot be null.'));2312 }2313 if (parameters === null || parameters === undefined) {2314 return callback(new Error('parameters cannot be null.'));2315 }2316 if (parameters.webSite === null || parameters.webSite === undefined) {2317 return callback(new Error('parameters.webSite cannot be null.'));2318 }2319 if (parameters.webSite.location === null || parameters.webSite.location === undefined) {2320 return callback(new Error('parameters.webSite.location cannot be null.'));2321 }2322 if (parameters.webSite.properties !== null && parameters.webSite.properties !== undefined) {2323 if (parameters.webSite.properties.serverFarm === null || parameters.webSite.properties.serverFarm === undefined) {2324 return callback(new Error('parameters.webSite.properties.serverFarm cannot be null.'));2325 }2326 }2327 2328 // Tracing2329 2330 // Construct URL2331 var url2 = '';2332 url2 = url2 + '/subscriptions/';2333 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2334 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2335 }2336 url2 = url2 + '/resourceGroups/';2337 url2 = url2 + encodeURIComponent(resourceGroupName);2338 url2 = url2 + '/providers/';2339 url2 = url2 + 'Microsoft.Web';2340 url2 = url2 + '/';2341 url2 = url2 + 'sites';2342 url2 = url2 + '/';2343 url2 = url2 + encodeURIComponent(webSiteName);2344 if (slotName !== null && slotName !== undefined) {2345 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2346 }2347 var queryParameters = [];2348 queryParameters.push('api-version=2014-06-01');2349 if (queryParameters.length > 0) {2350 url2 = url2 + '?' + queryParameters.join('&');2351 }2352 var baseUrl = this.client.baseUri;2353 // Trim '/' character from the end of baseUrl and beginning of url.2354 if (baseUrl[baseUrl.length - 1] === '/') {2355 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2356 }2357 if (url2[0] === '/') {2358 url2 = url2.substring(1);2359 }2360 url2 = baseUrl + '/' + url2;2361 url2 = url2.replace(' ', '%20');2362 2363 // Create HTTP transport objects2364 var httpRequest = new WebResource();2365 httpRequest.method = 'PUT';2366 httpRequest.headers = {};2367 httpRequest.url = url2;2368 2369 // Set Headers2370 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2371 2372 // Serialize Request2373 var requestContent = null;2374 var requestDoc = null;2375 2376 var webSiteCreateOrUpdateParametersValue = {};2377 requestDoc = webSiteCreateOrUpdateParametersValue;2378 2379 if (parameters.webSite.properties !== null && parameters.webSite.properties !== undefined) {2380 var propertiesValue = {};2381 webSiteCreateOrUpdateParametersValue['properties'] = propertiesValue;2382 2383 propertiesValue['ServerFarm'] = parameters.webSite.properties.serverFarm;2384 }2385 2386 if (parameters.webSite.id !== null && parameters.webSite.id !== undefined) {2387 webSiteCreateOrUpdateParametersValue['id'] = parameters.webSite.id;2388 }2389 2390 if (parameters.webSite.name !== null && parameters.webSite.name !== undefined) {2391 webSiteCreateOrUpdateParametersValue['name'] = parameters.webSite.name;2392 }2393 2394 webSiteCreateOrUpdateParametersValue['location'] = parameters.webSite.location;2395 2396 if (parameters.webSite.tags !== null && parameters.webSite.tags !== undefined) {2397 var tagsDictionary = {};2398 for (var tagsKey in parameters.webSite.tags) {2399 var tagsValue = parameters.webSite.tags[tagsKey];2400 tagsDictionary[tagsKey] = tagsValue;2401 }2402 webSiteCreateOrUpdateParametersValue['tags'] = tagsDictionary;2403 }2404 2405 if (parameters.webSite.type !== null && parameters.webSite.type !== undefined) {2406 webSiteCreateOrUpdateParametersValue['type'] = parameters.webSite.type;2407 }2408 2409 requestContent = JSON.stringify(requestDoc);2410 httpRequest.body = requestContent;2411 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');2412 // Send Request2413 return this.client.pipeline(httpRequest, function (err, response, body) {2414 if (err !== null && err !== undefined) {2415 return callback(err);2416 }2417 var statusCode = response.statusCode;2418 if (statusCode !== 200) {2419 var error = new Error(body);2420 error.statusCode = response.statusCode;2421 return callback(error);2422 }2423 2424 // Create Result2425 var result = null;2426 // Deserialize Response2427 if (statusCode === 200) {2428 var responseContent = body;2429 result = {};2430 var responseDoc = null;2431 if (responseContent) {2432 responseDoc = JSON.parse(responseContent);2433 }2434 2435 if (responseDoc !== null && responseDoc !== undefined) {2436 }2437 2438 }2439 result.statusCode = statusCode;2440 result.requestId = response.headers['x-ms-request-id'];2441 2442 return callback(null, result);2443 });2444 };2445 2446 /**2447 * A web site repository is essentially a GIT repository that you can use to2448 * manage your web site content. By using GIT source control tools, you can2449 * push or pull version controlled changes to your site. You can create a2450 * repository for your web site by issuing an HTTP POST request, or retrieve2451 * information about the repository by using HTTP GET. (see2452 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for2453 * more information)2454 * 2455 * @param {string} resourceGroupName The name of the resource group.2456 * 2457 * @param {string} webSiteName The name of the web site.2458 * 2459 * @param {string} [slotName] The name of the slot.2460 * 2461 * @param {function} callback2462 * 2463 * @returns {Stream} The response stream.2464 */2465 WebSiteOperations.prototype.createRepository = function(resourceGroupName, webSiteName, slotName, callback) {2466 if (callback === null || callback === undefined) {2467 throw new Error('callback cannot be null.');2468 }2469 // Validate2470 if (resourceGroupName === null || resourceGroupName === undefined) {2471 return callback(new Error('resourceGroupName cannot be null.'));2472 }2473 if (webSiteName === null || webSiteName === undefined) {2474 return callback(new Error('webSiteName cannot be null.'));2475 }2476 2477 // Tracing2478 2479 // Construct URL2480 var url2 = '';2481 url2 = url2 + '/subscriptions/';2482 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2483 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2484 }2485 url2 = url2 + '/resourceGroups/';2486 url2 = url2 + encodeURIComponent(resourceGroupName);2487 url2 = url2 + '/providers/';2488 url2 = url2 + 'Microsoft.Web';2489 url2 = url2 + '/';2490 url2 = url2 + 'sites';2491 url2 = url2 + '/';2492 url2 = url2 + encodeURIComponent(webSiteName);2493 if (slotName !== null && slotName !== undefined) {2494 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2495 }2496 url2 = url2 + '/repository';2497 var queryParameters = [];2498 queryParameters.push('api-version=2014-06-01');2499 if (queryParameters.length > 0) {2500 url2 = url2 + '?' + queryParameters.join('&');2501 }2502 var baseUrl = this.client.baseUri;2503 // Trim '/' character from the end of baseUrl and beginning of url.2504 if (baseUrl[baseUrl.length - 1] === '/') {2505 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2506 }2507 if (url2[0] === '/') {2508 url2 = url2.substring(1);2509 }2510 url2 = baseUrl + '/' + url2;2511 url2 = url2.replace(' ', '%20');2512 2513 // Create HTTP transport objects2514 var httpRequest = new WebResource();2515 httpRequest.method = 'POST';2516 httpRequest.headers = {};2517 httpRequest.url = url2;2518 2519 // Set Headers2520 httpRequest.headers['Content-Length'] = '0';2521 2522 // Send Request2523 return this.client.pipeline(httpRequest, function (err, response, body) {2524 if (err !== null && err !== undefined) {2525 return callback(err);2526 }2527 var statusCode = response.statusCode;2528 if (statusCode !== 200) {2529 var error = new Error(body);2530 error.statusCode = response.statusCode;2531 return callback(error);2532 }2533 2534 // Create Result2535 var result = null;2536 // Deserialize Response2537 result = {};2538 result.statusCode = statusCode;2539 result.requestId = response.headers['x-ms-request-id'];2540 2541 return callback(null, result);2542 });2543 };2544 2545 /**2546 * Deletes the web site.2547 * 2548 * @param {string} resourceGroupName The name of the resource group..2549 * 2550 * @param {string} webSiteName The name of the Web Site resource.2551 * 2552 * @param {string} [slotName] The name of the slot.2553 * 2554 * @param {WebSiteDeleteParameters} parameters The parameters to delete a web2555 * site.2556 * 2557 * @param {boolean} parameters.deleteEmptyServerFarm If the site being2558 * deleted is the last web site in a server farm, you can delete the server2559 * farm.2560 * 2561 * @param {boolean} parameters.deleteMetrics Delete the metrics for the web2562 * site.2563 * 2564 * @param {boolean} parameters.deleteAllSlots Delete all slots for the web2565 * site.2566 * 2567 * @param {function} callback2568 * 2569 * @returns {Stream} The response stream.2570 */2571 WebSiteOperations.prototype.deleteMethod = function(resourceGroupName, webSiteName, slotName, parameters, callback) {2572 if (callback === null || callback === undefined) {2573 throw new Error('callback cannot be null.');2574 }2575 // Validate2576 if (resourceGroupName === null || resourceGroupName === undefined) {2577 return callback(new Error('resourceGroupName cannot be null.'));2578 }2579 if (webSiteName === null || webSiteName === undefined) {2580 return callback(new Error('webSiteName cannot be null.'));2581 }2582 if (parameters === null || parameters === undefined) {2583 return callback(new Error('parameters cannot be null.'));2584 }2585 if (parameters.deleteAllSlots === null || parameters.deleteAllSlots === undefined) {2586 return callback(new Error('parameters.deleteAllSlots cannot be null.'));2587 }2588 if (parameters.deleteEmptyServerFarm === null || parameters.deleteEmptyServerFarm === undefined) {2589 return callback(new Error('parameters.deleteEmptyServerFarm cannot be null.'));2590 }2591 if (parameters.deleteMetrics === null || parameters.deleteMetrics === undefined) {2592 return callback(new Error('parameters.deleteMetrics cannot be null.'));2593 }2594 2595 // Tracing2596 2597 // Construct URL2598 var url2 = '';2599 url2 = url2 + '/subscriptions/';2600 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2601 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2602 }2603 url2 = url2 + '/resourceGroups/';2604 url2 = url2 + encodeURIComponent(resourceGroupName);2605 url2 = url2 + '/providers/';2606 url2 = url2 + 'Microsoft.Web';2607 url2 = url2 + '/';2608 url2 = url2 + 'sites';2609 url2 = url2 + '/';2610 url2 = url2 + encodeURIComponent(webSiteName);2611 if (slotName !== null && slotName !== undefined) {2612 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2613 }2614 var queryParameters = [];2615 queryParameters.push('api-version=2014-06-01');2616 queryParameters.push('deleteEmptyServerFarm=' + encodeURIComponent(parameters.deleteEmptyServerFarm.toString()));2617 queryParameters.push('deleteMetrics=' + encodeURIComponent(parameters.deleteMetrics.toString()));2618 queryParameters.push('deleteAllSlots=' + encodeURIComponent(parameters.deleteAllSlots.toString()));2619 if (queryParameters.length > 0) {2620 url2 = url2 + '?' + queryParameters.join('&');2621 }2622 var baseUrl = this.client.baseUri;2623 // Trim '/' character from the end of baseUrl and beginning of url.2624 if (baseUrl[baseUrl.length - 1] === '/') {2625 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2626 }2627 if (url2[0] === '/') {2628 url2 = url2.substring(1);2629 }2630 url2 = baseUrl + '/' + url2;2631 url2 = url2.replace(' ', '%20');2632 2633 // Create HTTP transport objects2634 var httpRequest = new WebResource();2635 httpRequest.method = 'DELETE';2636 httpRequest.headers = {};2637 httpRequest.url = url2;2638 2639 // Set Headers2640 2641 // Send Request2642 return this.client.pipeline(httpRequest, function (err, response, body) {2643 if (err !== null && err !== undefined) {2644 return callback(err);2645 }2646 var statusCode = response.statusCode;2647 if (statusCode !== 200) {2648 var error = new Error(body);2649 error.statusCode = response.statusCode;2650 return callback(error);2651 }2652 2653 // Create Result2654 var result = null;2655 // Deserialize Response2656 result = {};2657 result.statusCode = statusCode;2658 result.requestId = response.headers['x-ms-request-id'];2659 2660 return callback(null, result);2661 });2662 };2663 2664 /**2665 * A web site repository is essentially a GIT repository that you can use to2666 * manage your web site content. By using GIT source control tools, you can2667 * push or pull version controlled changes to your site. You can create a2668 * repository for your web site by issuing an HTTP POST request, or retrieve2669 * information about the repository by using HTTP GET. (see2670 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for2671 * more information)2672 * 2673 * @param {string} resourceGroupName The name of the resource group.2674 * 2675 * @param {string} webSiteName The name of the web site.2676 * 2677 * @param {string} [slotName] The name of the slot.2678 * 2679 * @param {function} callback2680 * 2681 * @returns {Stream} The response stream.2682 */2683 WebSiteOperations.prototype.deleteRepository = function(resourceGroupName, webSiteName, slotName, callback) {2684 if (callback === null || callback === undefined) {2685 throw new Error('callback cannot be null.');2686 }2687 // Validate2688 if (resourceGroupName === null || resourceGroupName === undefined) {2689 return callback(new Error('resourceGroupName cannot be null.'));2690 }2691 if (webSiteName === null || webSiteName === undefined) {2692 return callback(new Error('webSiteName cannot be null.'));2693 }2694 2695 // Tracing2696 2697 // Construct URL2698 var url2 = '';2699 url2 = url2 + '/subscriptions/';2700 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2701 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2702 }2703 url2 = url2 + '/resourceGroups/';2704 url2 = url2 + encodeURIComponent(resourceGroupName);2705 url2 = url2 + '/providers/';2706 url2 = url2 + 'Microsoft.Web';2707 url2 = url2 + '/';2708 url2 = url2 + 'sites';2709 url2 = url2 + '/';2710 url2 = url2 + encodeURIComponent(webSiteName);2711 if (slotName !== null && slotName !== undefined) {2712 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2713 }2714 url2 = url2 + '/repository';2715 var queryParameters = [];2716 queryParameters.push('api-version=2014-06-01');2717 if (queryParameters.length > 0) {2718 url2 = url2 + '?' + queryParameters.join('&');2719 }2720 var baseUrl = this.client.baseUri;2721 // Trim '/' character from the end of baseUrl and beginning of url.2722 if (baseUrl[baseUrl.length - 1] === '/') {2723 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2724 }2725 if (url2[0] === '/') {2726 url2 = url2.substring(1);2727 }2728 url2 = baseUrl + '/' + url2;2729 url2 = url2.replace(' ', '%20');2730 2731 // Create HTTP transport objects2732 var httpRequest = new WebResource();2733 httpRequest.method = 'DELETE';2734 httpRequest.headers = {};2735 httpRequest.url = url2;2736 2737 // Set Headers2738 2739 // Send Request2740 return this.client.pipeline(httpRequest, function (err, response, body) {2741 if (err !== null && err !== undefined) {2742 return callback(err);2743 }2744 var statusCode = response.statusCode;2745 if (statusCode !== 200) {2746 var error = new Error(body);2747 error.statusCode = response.statusCode;2748 return callback(error);2749 }2750 2751 // Create Result2752 var result = null;2753 // Deserialize Response2754 if (statusCode === 200) {2755 var responseContent = body;2756 result = {};2757 var responseDoc = null;2758 if (responseContent) {2759 responseDoc = JSON.parse(responseContent);2760 }2761 2762 if (responseDoc !== null && responseDoc !== undefined) {2763 var uriValue = responseDoc['uri'];2764 if (uriValue !== null && uriValue !== undefined) {2765 var uriInstance = uriValue;2766 result.uri = uriInstance;2767 }2768 }2769 2770 }2771 result.statusCode = statusCode;2772 result.requestId = response.headers['x-ms-request-id'];2773 2774 return callback(null, result);2775 });2776 };2777 2778 /**2779 * Unlink source control from website2780 * 2781 * @param {string} resourceGroupName The name of the resource group.2782 * 2783 * @param {string} webSiteName The name of the web site.2784 * 2785 * @param {string} [slotName] The name of the slot.2786 * 2787 * @param {string} repoUrl The repository url.2788 * 2789 * @param {function} callback2790 * 2791 * @returns {Stream} The response stream.2792 */2793 WebSiteOperations.prototype.deleteSiteSourceControl = function(resourceGroupName, webSiteName, slotName, repoUrl, callback) {2794 if (callback === null || callback === undefined) {2795 throw new Error('callback cannot be null.');2796 }2797 // Validate2798 if (resourceGroupName === null || resourceGroupName === undefined) {2799 return callback(new Error('resourceGroupName cannot be null.'));2800 }2801 if (webSiteName === null || webSiteName === undefined) {2802 return callback(new Error('webSiteName cannot be null.'));2803 }2804 if (repoUrl === null || repoUrl === undefined) {2805 return callback(new Error('repoUrl cannot be null.'));2806 }2807 2808 // Tracing2809 2810 // Construct URL2811 var url2 = '';2812 url2 = url2 + '/subscriptions/';2813 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2814 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2815 }2816 url2 = url2 + '/resourceGroups/';2817 url2 = url2 + encodeURIComponent(resourceGroupName);2818 url2 = url2 + '/providers/';2819 url2 = url2 + 'Microsoft.Web';2820 url2 = url2 + '/';2821 url2 = url2 + 'sites';2822 url2 = url2 + '/';2823 url2 = url2 + encodeURIComponent(webSiteName);2824 if (slotName !== null && slotName !== undefined) {2825 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2826 }2827 url2 = url2 + '/sourcecontrols/web';2828 var queryParameters = [];2829 queryParameters.push('api-version=2014-06-01');2830 if (queryParameters.length > 0) {2831 url2 = url2 + '?' + queryParameters.join('&');2832 }2833 var baseUrl = this.client.baseUri;2834 // Trim '/' character from the end of baseUrl and beginning of url.2835 if (baseUrl[baseUrl.length - 1] === '/') {2836 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2837 }2838 if (url2[0] === '/') {2839 url2 = url2.substring(1);2840 }2841 url2 = baseUrl + '/' + url2;2842 url2 = url2.replace(' ', '%20');2843 2844 // Create HTTP transport objects2845 var httpRequest = new WebResource();2846 httpRequest.method = 'DELETE';2847 httpRequest.headers = {};2848 httpRequest.url = url2;2849 2850 // Set Headers2851 2852 // Send Request2853 return this.client.pipeline(httpRequest, function (err, response, body) {2854 if (err !== null && err !== undefined) {2855 return callback(err);2856 }2857 var statusCode = response.statusCode;2858 if (statusCode !== 200) {2859 var error = new Error(body);2860 error.statusCode = response.statusCode;2861 return callback(error);2862 }2863 2864 // Create Result2865 var result = null;2866 // Deserialize Response2867 result = {};2868 result.statusCode = statusCode;2869 result.requestId = response.headers['x-ms-request-id'];2870 2871 return callback(null, result);2872 });2873 };2874 2875 /**2876 * Scans a backup in a storage account and returns database information etc.2877 * Should be called before calling Restore to discover what parameters are2878 * needed for the restore operation. KNOWN BUG: This has to be called2879 * against an exisingsite, otherwise will hit an error about non-existing2880 * resource.2881 * 2882 * @param {string} resourceGroupName The name of the web space.2883 * 2884 * @param {string} webSiteName The name of the web site.2885 * 2886 * @param {string} [slotName] The name of the slot.2887 * 2888 * @param {RestoreRequestEnvelope} restoreRequestEnvelope A restore request.2889 * 2890 * @param {RestoreRequest} [restoreRequestEnvelope.request] TODO.2891 * 2892 * @param {boolean} [restoreRequestEnvelope.request.adjustConnectionStrings]2893 * If the restore operation also restores a database along with the website2894 * and the database is on a different server than when the original site h2895 * 2896 * @param {string} [restoreRequestEnvelope.request.blobName] The blob name2897 * where the backup is stored. E.g. mysite1_20140203.zip2898 * 2899 * @param {IEnumerable} [restoreRequestEnvelope.request.databases] Database2900 * settings for backup.2901 * 2902 * @param {boolean}2903 * [restoreRequestEnvelope.request.ignoreConflictingHostNames] When2904 * restoring a site, custom domains might conflict with other site in the2905 * same datacenter. If this value is true, such hostnames will be ignored2906 * during restore. If this is false, the restore operation will fail on such2907 * conflict.2908 * 2909 * @param {boolean} [restoreRequestEnvelope.request.overwrite] True if the2910 * restore operation will be used for overwrite an existing site; false2911 * otherwise.2912 * 2913 * @param {string} [restoreRequestEnvelope.request.storageAccountUrl] SAS URL2914 * for a container in a storage account. E.g.2915 * https://NAME.blob.core.windows.net/CONTAINERNAME/?sv=2012-02-12&st=2013-12-05T19%3A30%3A45Z&se=2017-12-04T19%3A30%3A45Z&sr=c&sp=rwdl&sig=abcdefABCDEFabcdef01234567892916 * 2917 * @param {string} [restoreRequestEnvelope.id] Gets the ID of the resource.2918 * 2919 * @param {string} [restoreRequestEnvelope.name] The name of the resource.2920 * 2921 * @param {string} restoreRequestEnvelope.location Gets or sets the location2922 * of the resource.2923 * 2924 * @param {object} [restoreRequestEnvelope.tags] Gets or sets the tags2925 * attached to the resource.2926 * 2927 * @param {string} [restoreRequestEnvelope.type] The type of the resource2928 * 2929 * @param {function} callback2930 * 2931 * @returns {Stream} The response stream.2932 */2933 WebSiteOperations.prototype.discover = function(resourceGroupName, webSiteName, slotName, restoreRequestEnvelope, callback) {2934 if (callback === null || callback === undefined) {2935 throw new Error('callback cannot be null.');2936 }2937 // Validate2938 if (resourceGroupName === null || resourceGroupName === undefined) {2939 return callback(new Error('resourceGroupName cannot be null.'));2940 }2941 if (webSiteName === null || webSiteName === undefined) {2942 return callback(new Error('webSiteName cannot be null.'));2943 }2944 if (restoreRequestEnvelope === null || restoreRequestEnvelope === undefined) {2945 return callback(new Error('restoreRequestEnvelope cannot be null.'));2946 }2947 if (restoreRequestEnvelope.location === null || restoreRequestEnvelope.location === undefined) {2948 return callback(new Error('restoreRequestEnvelope.location cannot be null.'));2949 }2950 2951 // Tracing2952 2953 // Construct URL2954 var url2 = '';2955 url2 = url2 + '/subscriptions/';2956 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {2957 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);2958 }2959 url2 = url2 + '/resourceGroups/';2960 url2 = url2 + encodeURIComponent(resourceGroupName);2961 url2 = url2 + '/providers/';2962 url2 = url2 + 'Microsoft.Web';2963 url2 = url2 + '/';2964 url2 = url2 + 'sites';2965 url2 = url2 + '/';2966 url2 = url2 + encodeURIComponent(webSiteName);2967 if (slotName !== null && slotName !== undefined) {2968 url2 = url2 + '/slots/' + encodeURIComponent(slotName);2969 }2970 url2 = url2 + '/restore/discover';2971 var queryParameters = [];2972 queryParameters.push('api-version=2014-06-01');2973 if (queryParameters.length > 0) {2974 url2 = url2 + '?' + queryParameters.join('&');2975 }2976 var baseUrl = this.client.baseUri;2977 // Trim '/' character from the end of baseUrl and beginning of url.2978 if (baseUrl[baseUrl.length - 1] === '/') {2979 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2980 }2981 if (url2[0] === '/') {2982 url2 = url2.substring(1);2983 }2984 url2 = baseUrl + '/' + url2;2985 url2 = url2.replace(' ', '%20');2986 2987 // Create HTTP transport objects2988 var httpRequest = new WebResource();2989 httpRequest.method = 'PUT';2990 httpRequest.headers = {};2991 httpRequest.url = url2;2992 2993 // Set Headers2994 httpRequest.headers['Content-Type'] = 'application/json';2995 httpRequest.headers['x-ms-version'] = '2014-06-01';2996 2997 // Serialize Request2998 var requestContent = null;2999 var requestDoc = null;3000 3001 var restoreRequestEnvelopeValue = {};3002 requestDoc = restoreRequestEnvelopeValue;3003 3004 if (restoreRequestEnvelope.request !== null && restoreRequestEnvelope.request !== undefined) {3005 var propertiesValue = {};3006 restoreRequestEnvelopeValue['properties'] = propertiesValue;3007 3008 if (restoreRequestEnvelope.request.adjustConnectionStrings !== null && restoreRequestEnvelope.request.adjustConnectionStrings !== undefined) {3009 propertiesValue['AdjustConnectionStrings'] = restoreRequestEnvelope.request.adjustConnectionStrings;3010 }3011 3012 if (restoreRequestEnvelope.request.blobName !== null && restoreRequestEnvelope.request.blobName !== undefined) {3013 propertiesValue['BlobName'] = restoreRequestEnvelope.request.blobName;3014 }3015 3016 if (restoreRequestEnvelope.request.databases !== null && restoreRequestEnvelope.request.databases !== undefined) {3017 var databasesArray = [];3018 for (var loweredIndex1 = 0; loweredIndex1 < restoreRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {3019 var databasesItem = restoreRequestEnvelope.request.databases[loweredIndex1];3020 var databaseBackupSettingValue = {};3021 databasesArray.push(databaseBackupSettingValue);3022 3023 if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {3024 databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;3025 }3026 3027 if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {3028 databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;3029 }3030 3031 if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {3032 databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;3033 }3034 3035 if (databasesItem.name !== null && databasesItem.name !== undefined) {3036 databaseBackupSettingValue['name'] = databasesItem.name;3037 }3038 }3039 propertiesValue['Databases'] = databasesArray;3040 }3041 3042 if (restoreRequestEnvelope.request.ignoreConflictingHostNames !== null && restoreRequestEnvelope.request.ignoreConflictingHostNames !== undefined) {3043 propertiesValue['IgnoreConflictingHostNames'] = restoreRequestEnvelope.request.ignoreConflictingHostNames;3044 }3045 3046 if (restoreRequestEnvelope.request.overwrite !== null && restoreRequestEnvelope.request.overwrite !== undefined) {3047 propertiesValue['Overwrite'] = restoreRequestEnvelope.request.overwrite;3048 }3049 3050 if (restoreRequestEnvelope.request.storageAccountUrl !== null && restoreRequestEnvelope.request.storageAccountUrl !== undefined) {3051 propertiesValue['StorageAccountUrl'] = restoreRequestEnvelope.request.storageAccountUrl;3052 }3053 }3054 3055 if (restoreRequestEnvelope.id !== null && restoreRequestEnvelope.id !== undefined) {3056 restoreRequestEnvelopeValue['id'] = restoreRequestEnvelope.id;3057 }3058 3059 if (restoreRequestEnvelope.name !== null && restoreRequestEnvelope.name !== undefined) {3060 restoreRequestEnvelopeValue['name'] = restoreRequestEnvelope.name;3061 }3062 3063 restoreRequestEnvelopeValue['location'] = restoreRequestEnvelope.location;3064 3065 if (restoreRequestEnvelope.tags !== null && restoreRequestEnvelope.tags !== undefined) {3066 var tagsDictionary = {};3067 for (var tagsKey in restoreRequestEnvelope.tags) {3068 var tagsValue = restoreRequestEnvelope.tags[tagsKey];3069 tagsDictionary[tagsKey] = tagsValue;3070 }3071 restoreRequestEnvelopeValue['tags'] = tagsDictionary;3072 }3073 3074 if (restoreRequestEnvelope.type !== null && restoreRequestEnvelope.type !== undefined) {3075 restoreRequestEnvelopeValue['type'] = restoreRequestEnvelope.type;3076 }3077 3078 requestContent = JSON.stringify(requestDoc);3079 httpRequest.body = requestContent;3080 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');3081 // Send Request3082 return this.client.pipeline(httpRequest, function (err, response, body) {3083 if (err !== null && err !== undefined) {3084 return callback(err);3085 }3086 var statusCode = response.statusCode;3087 if (statusCode !== 200) {3088 var error = new Error(body);3089 error.statusCode = response.statusCode;3090 return callback(error);3091 }3092 3093 // Create Result3094 var result = null;3095 // Deserialize Response3096 if (statusCode === 200) {3097 var responseContent = body;3098 result = {};3099 var responseDoc = null;3100 if (responseContent) {3101 responseDoc = JSON.parse(responseContent);3102 }3103 3104 if (responseDoc !== null && responseDoc !== undefined) {3105 var envelopeInstance = { tags: {} };3106 result.envelope = envelopeInstance;3107 3108 var propertiesValue2 = responseDoc['properties'];3109 if (propertiesValue2 !== null && propertiesValue2 !== undefined) {3110 var propertiesInstance = { databases: [] };3111 envelopeInstance.properties = propertiesInstance;3112 3113 var storageAccountUrlValue = propertiesValue2['storageAccountUrl'];3114 if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {3115 var storageAccountUrlInstance = storageAccountUrlValue;3116 propertiesInstance.storageAccountUrl = storageAccountUrlInstance;3117 }3118 3119 var blobNameValue = propertiesValue2['blobName'];3120 if (blobNameValue !== null && blobNameValue !== undefined) {3121 var blobNameInstance = blobNameValue;3122 propertiesInstance.blobName = blobNameInstance;3123 }3124 3125 var overwriteValue = propertiesValue2['overwrite'];3126 if (overwriteValue !== null && overwriteValue !== undefined) {3127 var overwriteInstance = overwriteValue;3128 propertiesInstance.overwrite = overwriteInstance;3129 }3130 3131 var databasesArray2 = propertiesValue2['databases'];3132 if (databasesArray2 !== null && databasesArray2 !== undefined) {3133 for (var loweredIndex2 = 0; loweredIndex2 < databasesArray2.length; loweredIndex2 = loweredIndex2 + 1) {3134 var databasesValue = databasesArray2[loweredIndex2];3135 var databaseBackupSettingInstance = {};3136 propertiesInstance.databases.push(databaseBackupSettingInstance);3137 3138 var connectionStringValue = databasesValue['connectionString'];3139 if (connectionStringValue !== null && connectionStringValue !== undefined) {3140 var connectionStringInstance = connectionStringValue;3141 databaseBackupSettingInstance.connectionString = connectionStringInstance;3142 }3143 3144 var connectionStringNameValue = databasesValue['connectionStringName'];3145 if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {3146 var connectionStringNameInstance = connectionStringNameValue;3147 databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;3148 }3149 3150 var databaseTypeValue = databasesValue['databaseType'];3151 if (databaseTypeValue !== null && databaseTypeValue !== undefined) {3152 var databaseTypeInstance = databaseTypeValue;3153 databaseBackupSettingInstance.databaseType = databaseTypeInstance;3154 }3155 3156 var nameValue = databasesValue['name'];3157 if (nameValue !== null && nameValue !== undefined) {3158 var nameInstance = nameValue;3159 databaseBackupSettingInstance.name = nameInstance;3160 }3161 }3162 }3163 3164 var ignoreConflictingHostNamesValue = propertiesValue2['ignoreConflictingHostNames'];3165 if (ignoreConflictingHostNamesValue !== null && ignoreConflictingHostNamesValue !== undefined) {3166 var ignoreConflictingHostNamesInstance = ignoreConflictingHostNamesValue;3167 propertiesInstance.ignoreConflictingHostNames = ignoreConflictingHostNamesInstance;3168 }3169 3170 var adjustConnectionStringsValue = propertiesValue2['adjustConnectionStrings'];3171 if (adjustConnectionStringsValue !== null && adjustConnectionStringsValue !== undefined) {3172 var adjustConnectionStringsInstance = adjustConnectionStringsValue;3173 propertiesInstance.adjustConnectionStrings = adjustConnectionStringsInstance;3174 }3175 }3176 3177 var idValue = responseDoc['id'];3178 if (idValue !== null && idValue !== undefined) {3179 var idInstance = idValue;3180 envelopeInstance.id = idInstance;3181 }3182 3183 var nameValue2 = responseDoc['name'];3184 if (nameValue2 !== null && nameValue2 !== undefined) {3185 var nameInstance2 = nameValue2;3186 envelopeInstance.name = nameInstance2;3187 }3188 3189 var locationValue = responseDoc['location'];3190 if (locationValue !== null && locationValue !== undefined) {3191 var locationInstance = locationValue;3192 envelopeInstance.location = locationInstance;3193 }3194 3195 var tagsSequenceElement = responseDoc['tags'];3196 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {3197 for (var property in tagsSequenceElement) {3198 var tagsKey2 = property;3199 var tagsValue2 = tagsSequenceElement[property];3200 envelopeInstance.tags[tagsKey2] = tagsValue2;3201 }3202 }3203 3204 var typeValue = responseDoc['type'];3205 if (typeValue !== null && typeValue !== undefined) {3206 var typeInstance = typeValue;3207 envelopeInstance.type = typeInstance;3208 }3209 }3210 3211 }3212 result.statusCode = statusCode;3213 result.requestId = response.headers['x-ms-request-id'];3214 3215 return callback(null, result);3216 });3217 };3218 3219 /**3220 * You can generate a new random password for publishing a site by issuing an3221 * HTTP POST request. Tip: If you want to verify that the publish password3222 * has changed, call HTTP GET on /publishxml before calling /newpassword. In3223 * the publish XML, note the hash value in the userPWD attribute. After3224 * calling /newpassword, call /publishxml again. You can then compare the3225 * new value of userPWD in the Publish XML with the one you noted earlier.3226 * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn236428.aspx3227 * for more information)3228 * 3229 * @param {string} resourceGroupName The name of the resource group.3230 * 3231 * @param {string} webSiteName The name of the web site.3232 * 3233 * @param {string} [slotName] The name of the slot.3234 * 3235 * @param {function} callback3236 * 3237 * @returns {Stream} The response stream.3238 */3239 WebSiteOperations.prototype.generatePassword = function(resourceGroupName, webSiteName, slotName, callback) {3240 if (callback === null || callback === undefined) {3241 throw new Error('callback cannot be null.');3242 }3243 // Validate3244 if (resourceGroupName === null || resourceGroupName === undefined) {3245 return callback(new Error('resourceGroupName cannot be null.'));3246 }3247 if (webSiteName === null || webSiteName === undefined) {3248 return callback(new Error('webSiteName cannot be null.'));3249 }3250 3251 // Tracing3252 3253 // Construct URL3254 var url2 = '';3255 url2 = url2 + '/subscriptions/';3256 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {3257 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);3258 }3259 url2 = url2 + '/resourceGroups/';3260 url2 = url2 + encodeURIComponent(resourceGroupName);3261 url2 = url2 + '/providers/';3262 url2 = url2 + 'Microsoft.Web';3263 url2 = url2 + '/';3264 url2 = url2 + 'sites';3265 url2 = url2 + '/';3266 url2 = url2 + encodeURIComponent(webSiteName);3267 if (slotName !== null && slotName !== undefined) {3268 url2 = url2 + '/slots/' + encodeURIComponent(slotName);3269 }3270 url2 = url2 + '/newPassword';3271 var queryParameters = [];3272 queryParameters.push('api-version=2014-06-01');3273 if (queryParameters.length > 0) {3274 url2 = url2 + '?' + queryParameters.join('&');3275 }3276 var baseUrl = this.client.baseUri;3277 // Trim '/' character from the end of baseUrl and beginning of url.3278 if (baseUrl[baseUrl.length - 1] === '/') {3279 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3280 }3281 if (url2[0] === '/') {3282 url2 = url2.substring(1);3283 }3284 url2 = baseUrl + '/' + url2;3285 url2 = url2.replace(' ', '%20');3286 3287 // Create HTTP transport objects3288 var httpRequest = new WebResource();3289 httpRequest.method = 'POST';3290 httpRequest.headers = {};3291 httpRequest.url = url2;3292 3293 // Set Headers3294 httpRequest.headers['Content-Length'] = '0';3295 3296 // Send Request3297 return this.client.pipeline(httpRequest, function (err, response, body) {3298 if (err !== null && err !== undefined) {3299 return callback(err);3300 }3301 var statusCode = response.statusCode;3302 if (statusCode !== 200) {3303 var error = new Error(body);3304 error.statusCode = response.statusCode;3305 return callback(error);3306 }3307 3308 // Create Result3309 var result = null;3310 // Deserialize Response3311 result = {};3312 result.statusCode = statusCode;3313 result.requestId = response.headers['x-ms-request-id'];3314 3315 return callback(null, result);3316 });3317 };3318 3319 /**3320 * You can retrieve details for a web site by issuing an HTTP GET request.3321 * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn167007.aspx3322 * for more information)3323 * 3324 * @param {string} resourceGroupName The name of the resource group.3325 * 3326 * @param {string} webSiteName The name of the web site.3327 * 3328 * @param {string} [slotName] The name of the slot.3329 * 3330 * @param {WebSiteGetParameters} [parametersOrCallback] Additional parameters.3331 * 3332 * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list3333 * of the names of any addtional parameters to return.3334 * 3335 * @param {function} callback3336 * 3337 * @returns {Stream} The response stream.3338 */3339 WebSiteOperations.prototype.get = function(resourceGroupName, webSiteName, slotName, parametersOrCallback, callback) {3340 var parameters = parametersOrCallback;3341 if (_.isFunction(parameters)) {3342 callback = parameters;3343 parameters = null;3344 }3345 if (callback === null || callback === undefined) {3346 throw new Error('callback cannot be null.');3347 }3348 // Validate3349 if (resourceGroupName === null || resourceGroupName === undefined) {3350 return callback(new Error('resourceGroupName cannot be null.'));3351 }3352 if (webSiteName === null || webSiteName === undefined) {3353 return callback(new Error('webSiteName cannot be null.'));3354 }3355 3356 // Tracing3357 3358 // Construct URL3359 var url2 = '';3360 url2 = url2 + '/subscriptions/';3361 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {3362 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);3363 }3364 url2 = url2 + '/resourceGroups/';3365 url2 = url2 + encodeURIComponent(resourceGroupName);3366 url2 = url2 + '/providers/';3367 url2 = url2 + 'Microsoft.Web';3368 url2 = url2 + '/';3369 url2 = url2 + 'sites';3370 url2 = url2 + '/';3371 url2 = url2 + encodeURIComponent(webSiteName);3372 if (slotName !== null && slotName !== undefined) {3373 url2 = url2 + '/slots/' + encodeURIComponent(slotName);3374 }3375 var queryParameters = [];3376 queryParameters.push('api-version=2014-06-01');3377 if (parameters !== null && parameters !== undefined && parameters.propertiesToInclude !== null && parameters.propertiesToInclude !== undefined && parameters.propertiesToInclude.length > 0) {3378 queryParameters.push('propertiesToInclude=' + encodeURIComponent(parameters.propertiesToInclude.join(',')));3379 }3380 if (queryParameters.length > 0) {3381 url2 = url2 + '?' + queryParameters.join('&');3382 }3383 var baseUrl = this.client.baseUri;3384 // Trim '/' character from the end of baseUrl and beginning of url.3385 if (baseUrl[baseUrl.length - 1] === '/') {3386 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3387 }3388 if (url2[0] === '/') {3389 url2 = url2.substring(1);3390 }3391 url2 = baseUrl + '/' + url2;3392 url2 = url2.replace(' ', '%20');3393 3394 // Create HTTP transport objects3395 var httpRequest = new WebResource();3396 httpRequest.method = 'GET';3397 httpRequest.headers = {};3398 httpRequest.url = url2;3399 3400 // Set Headers3401 3402 // Send Request3403 return this.client.pipeline(httpRequest, function (err, response, body) {3404 if (err !== null && err !== undefined) {3405 return callback(err);3406 }3407 var statusCode = response.statusCode;3408 if (statusCode !== 200) {3409 var error = new Error(body);3410 error.statusCode = response.statusCode;3411 return callback(error);3412 }3413 3414 // Create Result3415 var result = null;3416 // Deserialize Response3417 if (statusCode === 200) {3418 var responseContent = body;3419 result = {};3420 var responseDoc = null;3421 if (responseContent) {3422 responseDoc = JSON.parse(responseContent);3423 }3424 3425 if (responseDoc !== null && responseDoc !== undefined) {3426 var webSiteInstance = { tags: {} };3427 result.webSite = webSiteInstance;3428 3429 var propertiesValue = responseDoc['properties'];3430 if (propertiesValue !== null && propertiesValue !== undefined) {3431 var propertiesInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [], trafficManagerHostNames: [] };3432 webSiteInstance.properties = propertiesInstance;3433 3434 var adminEnabledValue = propertiesValue['adminEnabled'];3435 if (adminEnabledValue !== null && adminEnabledValue !== undefined) {3436 var adminEnabledInstance = adminEnabledValue;3437 propertiesInstance.adminEnabled = adminEnabledInstance;3438 }3439 3440 var availabilityStateValue = propertiesValue['availabilityState'];3441 if (availabilityStateValue !== null && availabilityStateValue !== undefined) {3442 var availabilityStateInstance = availabilityStateValue;3443 propertiesInstance.availabilityState = availabilityStateInstance;3444 }3445 3446 var enabledValue = propertiesValue['enabled'];3447 if (enabledValue !== null && enabledValue !== undefined) {3448 var enabledInstance = enabledValue;3449 propertiesInstance.enabled = enabledInstance;3450 }3451 3452 var enabledHostNamesArray = propertiesValue['enabledHostNames'];3453 if (enabledHostNamesArray !== null && enabledHostNamesArray !== undefined) {3454 for (var loweredIndex1 = 0; loweredIndex1 < enabledHostNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {3455 var enabledHostNamesValue = enabledHostNamesArray[loweredIndex1];3456 propertiesInstance.enabledHostNames.push(enabledHostNamesValue);3457 }3458 }3459 3460 var hostNameSslStatesArray = propertiesValue['hostNameSslStates'];3461 if (hostNameSslStatesArray !== null && hostNameSslStatesArray !== undefined) {3462 for (var loweredIndex2 = 0; loweredIndex2 < hostNameSslStatesArray.length; loweredIndex2 = loweredIndex2 + 1) {3463 var hostNameSslStatesValue = hostNameSslStatesArray[loweredIndex2];3464 var webSiteHostNameSslStateInstance = {};3465 propertiesInstance.hostNameSslStates.push(webSiteHostNameSslStateInstance);3466 3467 var nameValue = hostNameSslStatesValue['name'];3468 if (nameValue !== null && nameValue !== undefined) {3469 var nameInstance = nameValue;3470 webSiteHostNameSslStateInstance.name = nameInstance;3471 }3472 3473 var sslStateValue = hostNameSslStatesValue['sslState'];3474 if (sslStateValue !== null && sslStateValue !== undefined) {3475 var sslStateInstance = sslStateValue;3476 webSiteHostNameSslStateInstance.sslState = sslStateInstance;3477 }3478 3479 var thumbprintValue = hostNameSslStatesValue['thumbprint'];3480 if (thumbprintValue !== null && thumbprintValue !== undefined) {3481 var thumbprintInstance = thumbprintValue;3482 webSiteHostNameSslStateInstance.thumbprint = thumbprintInstance;3483 }3484 3485 var virtualIPValue = hostNameSslStatesValue['virtualIP'];3486 if (virtualIPValue !== null && virtualIPValue !== undefined) {3487 var virtualIPInstance = virtualIPValue;3488 webSiteHostNameSslStateInstance.virtualIP = virtualIPInstance;3489 }3490 3491 var ipBasedSslResultValue = hostNameSslStatesValue['ipBasedSslResult'];3492 if (ipBasedSslResultValue !== null && ipBasedSslResultValue !== undefined) {3493 var ipBasedSslResultInstance = ipBasedSslResultValue;3494 webSiteHostNameSslStateInstance.ipBasedSslResult = ipBasedSslResultInstance;3495 }3496 3497 var toUpdateValue = hostNameSslStatesValue['toUpdate'];3498 if (toUpdateValue !== null && toUpdateValue !== undefined) {3499 var toUpdateInstance = toUpdateValue;3500 webSiteHostNameSslStateInstance.toUpdate = toUpdateInstance;3501 }3502 3503 var toUpdateIpBasedSslValue = hostNameSslStatesValue['toUpdateIpBasedSsl'];3504 if (toUpdateIpBasedSslValue !== null && toUpdateIpBasedSslValue !== undefined) {3505 var toUpdateIpBasedSslInstance = toUpdateIpBasedSslValue;3506 webSiteHostNameSslStateInstance.toUpdateIpBasedSsl = toUpdateIpBasedSslInstance;3507 }3508 }3509 }3510 3511 var hostNamesArray = propertiesValue['hostNames'];3512 if (hostNamesArray !== null && hostNamesArray !== undefined) {3513 for (var loweredIndex3 = 0; loweredIndex3 < hostNamesArray.length; loweredIndex3 = loweredIndex3 + 1) {3514 var hostNamesValue = hostNamesArray[loweredIndex3];3515 propertiesInstance.hostNames.push(hostNamesValue);3516 }3517 }3518 3519 var lastModifiedTimeUtcValue = propertiesValue['lastModifiedTimeUtc'];3520 if (lastModifiedTimeUtcValue !== null && lastModifiedTimeUtcValue !== undefined) {3521 var lastModifiedTimeUtcInstance = lastModifiedTimeUtcValue;3522 propertiesInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;3523 }3524 3525 var repositorySiteNameValue = propertiesValue['repositorySiteName'];3526 if (repositorySiteNameValue !== null && repositorySiteNameValue !== undefined) {3527 var repositorySiteNameInstance = repositorySiteNameValue;3528 propertiesInstance.repositorySiteName = repositorySiteNameInstance;3529 }3530 3531 var runtimeAvailabilityStateValue = propertiesValue['runtimeAvailabilityState'];3532 if (runtimeAvailabilityStateValue !== null && runtimeAvailabilityStateValue !== undefined) {3533 var runtimeAvailabilityStateInstance = runtimeAvailabilityStateValue;3534 propertiesInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;3535 }3536 3537 var trafficManagerHostNamesArray = propertiesValue['trafficManagerHostNames'];3538 if (trafficManagerHostNamesArray !== null && trafficManagerHostNamesArray !== undefined) {3539 for (var loweredIndex4 = 0; loweredIndex4 < trafficManagerHostNamesArray.length; loweredIndex4 = loweredIndex4 + 1) {3540 var trafficManagerHostNamesValue = trafficManagerHostNamesArray[loweredIndex4];3541 propertiesInstance.trafficManagerHostNames.push(trafficManagerHostNamesValue);3542 }3543 }3544 3545 var selfLinkValue = propertiesValue['selfLink'];3546 if (selfLinkValue !== null && selfLinkValue !== undefined) {3547 var selfLinkInstance = selfLinkValue;3548 propertiesInstance.uri = selfLinkInstance;3549 }3550 3551 var serverFarmValue = propertiesValue['serverFarm'];3552 if (serverFarmValue !== null && serverFarmValue !== undefined) {3553 var serverFarmInstance = serverFarmValue;3554 propertiesInstance.serverFarm = serverFarmInstance;3555 }3556 3557 var skuValue = propertiesValue['sku'];3558 if (skuValue !== null && skuValue !== undefined) {3559 var skuInstance = skuValue;3560 propertiesInstance.sku = skuInstance;3561 }3562 3563 var sitePropertiesValue = propertiesValue['siteProperties'];3564 if (sitePropertiesValue !== null && sitePropertiesValue !== undefined) {3565 var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };3566 propertiesInstance.properties = sitePropertiesInstance;3567 3568 var appSettingsSequenceElement = sitePropertiesValue['appSettings'];3569 if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {3570 for (var property in appSettingsSequenceElement) {3571 var appSettingsKey = property;3572 var appSettingsValue = appSettingsSequenceElement[property];3573 sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;3574 }3575 }3576 3577 var metadataSequenceElement = sitePropertiesValue['metadata'];3578 if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {3579 for (var property2 in metadataSequenceElement) {3580 var metadataKey = property2;3581 var metadataValue = metadataSequenceElement[property2];3582 sitePropertiesInstance.metadata[metadataKey] = metadataValue;3583 }3584 }3585 3586 var propertiesSequenceElement = sitePropertiesValue['properties'];3587 if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {3588 for (var property3 in propertiesSequenceElement) {3589 var propertiesKey = property3;3590 var propertiesValue2 = propertiesSequenceElement[property3];3591 sitePropertiesInstance.properties[propertiesKey] = propertiesValue2;3592 }3593 }3594 }3595 3596 var stateValue = propertiesValue['state'];3597 if (stateValue !== null && stateValue !== undefined) {3598 var stateInstance = stateValue;3599 propertiesInstance.state = stateInstance;3600 }3601 3602 var usageStateValue = propertiesValue['usageState'];3603 if (usageStateValue !== null && usageStateValue !== undefined) {3604 var usageStateInstance = usageStateValue;3605 propertiesInstance.usageState = usageStateInstance;3606 }3607 3608 var webSpaceValue = propertiesValue['webSpace'];3609 if (webSpaceValue !== null && webSpaceValue !== undefined) {3610 var webSpaceInstance = webSpaceValue;3611 propertiesInstance.webSpace = webSpaceInstance;3612 }3613 3614 var provisioningStateValue = propertiesValue['provisioningState'];3615 if (provisioningStateValue !== null && provisioningStateValue !== undefined) {3616 var provisioningStateInstance = provisioningStateValue;3617 propertiesInstance.provisioningState = provisioningStateInstance;3618 }3619 }3620 3621 var idValue = responseDoc['id'];3622 if (idValue !== null && idValue !== undefined) {3623 var idInstance = idValue;3624 webSiteInstance.id = idInstance;3625 }3626 3627 var nameValue2 = responseDoc['name'];3628 if (nameValue2 !== null && nameValue2 !== undefined) {3629 var nameInstance2 = nameValue2;3630 webSiteInstance.name = nameInstance2;3631 }3632 3633 var locationValue = responseDoc['location'];3634 if (locationValue !== null && locationValue !== undefined) {3635 var locationInstance = locationValue;3636 webSiteInstance.location = locationInstance;3637 }3638 3639 var tagsSequenceElement = responseDoc['tags'];3640 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {3641 for (var property4 in tagsSequenceElement) {3642 var tagsKey = property4;3643 var tagsValue = tagsSequenceElement[property4];3644 webSiteInstance.tags[tagsKey] = tagsValue;3645 }3646 }3647 3648 var typeValue = responseDoc['type'];3649 if (typeValue !== null && typeValue !== undefined) {3650 var typeInstance = typeValue;3651 webSiteInstance.type = typeInstance;3652 }3653 }3654 3655 }3656 result.statusCode = statusCode;3657 result.requestId = response.headers['x-ms-request-id'];3658 3659 return callback(null, result);3660 });3661 };3662 3663 /**3664 * Restart the web site.3665 * 3666 * @param {string} resourceGroupName The name of the resource group3667 * 3668 * @param {string} webSiteName Name of website3669 * 3670 * @param {string} [slotName] The name of the slot of the website3671 * 3672 * @param {function} callback3673 * 3674 * @returns {Stream} The response stream.3675 */3676 WebSiteOperations.prototype.getAppSettings = function(resourceGroupName, webSiteName, slotName, callback) {3677 if (callback === null || callback === undefined) {3678 throw new Error('callback cannot be null.');3679 }3680 // Validate3681 if (resourceGroupName === null || resourceGroupName === undefined) {3682 return callback(new Error('resourceGroupName cannot be null.'));3683 }3684 if (webSiteName === null || webSiteName === undefined) {3685 return callback(new Error('webSiteName cannot be null.'));3686 }3687 3688 // Tracing3689 3690 // Construct URL3691 var url2 = '';3692 url2 = url2 + '/subscriptions/';3693 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {3694 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);3695 }3696 url2 = url2 + '/resourceGroups/';3697 url2 = url2 + encodeURIComponent(resourceGroupName);3698 url2 = url2 + '/providers/';3699 url2 = url2 + 'Microsoft.Web';3700 url2 = url2 + '/';3701 url2 = url2 + 'sites';3702 url2 = url2 + '/';3703 url2 = url2 + encodeURIComponent(webSiteName);3704 if (slotName !== null && slotName !== undefined) {3705 url2 = url2 + '/slots/' + encodeURIComponent(slotName);3706 }3707 url2 = url2 + '/config/appsettings/list';3708 var queryParameters = [];3709 queryParameters.push('api-version=2014-06-01');3710 if (queryParameters.length > 0) {3711 url2 = url2 + '?' + queryParameters.join('&');3712 }3713 var baseUrl = this.client.baseUri;3714 // Trim '/' character from the end of baseUrl and beginning of url.3715 if (baseUrl[baseUrl.length - 1] === '/') {3716 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3717 }3718 if (url2[0] === '/') {3719 url2 = url2.substring(1);3720 }3721 url2 = baseUrl + '/' + url2;3722 url2 = url2.replace(' ', '%20');3723 3724 // Create HTTP transport objects3725 var httpRequest = new WebResource();3726 httpRequest.method = 'POST';3727 httpRequest.headers = {};3728 httpRequest.url = url2;3729 3730 // Set Headers3731 httpRequest.headers['Content-Length'] = '0';3732 3733 // Send Request3734 return this.client.pipeline(httpRequest, function (err, response, body) {3735 if (err !== null && err !== undefined) {3736 return callback(err);3737 }3738 var statusCode = response.statusCode;3739 if (statusCode !== 200) {3740 var error = new Error(body);3741 error.statusCode = response.statusCode;3742 return callback(error);3743 }3744 3745 // Create Result3746 var result = null;3747 // Deserialize Response3748 if (statusCode === 200) {3749 var responseContent = body;3750 result = {};3751 var responseDoc = null;3752 if (responseContent) {3753 responseDoc = JSON.parse(responseContent);3754 }3755 3756 if (responseDoc !== null && responseDoc !== undefined) {3757 var resourceInstance = { properties: [], tags: {} };3758 result.resource = resourceInstance;3759 3760 var propertiesArray = responseDoc['properties'];3761 if (propertiesArray !== null && propertiesArray !== undefined) {3762 for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {3763 var propertiesValue = propertiesArray[loweredIndex1];3764 var nameValuePairInstance = {};3765 resourceInstance.properties.push(nameValuePairInstance);3766 3767 var nameValue = propertiesValue['name'];3768 if (nameValue !== null && nameValue !== undefined) {3769 var nameInstance = nameValue;3770 nameValuePairInstance.name = nameInstance;3771 }3772 3773 var valueValue = propertiesValue['value'];3774 if (valueValue !== null && valueValue !== undefined) {3775 var valueInstance = valueValue;3776 nameValuePairInstance.value = valueInstance;3777 }3778 }3779 }3780 3781 var idValue = responseDoc['id'];3782 if (idValue !== null && idValue !== undefined) {3783 var idInstance = idValue;3784 resourceInstance.id = idInstance;3785 }3786 3787 var nameValue2 = responseDoc['name'];3788 if (nameValue2 !== null && nameValue2 !== undefined) {3789 var nameInstance2 = nameValue2;3790 resourceInstance.name = nameInstance2;3791 }3792 3793 var locationValue = responseDoc['location'];3794 if (locationValue !== null && locationValue !== undefined) {3795 var locationInstance = locationValue;3796 resourceInstance.location = locationInstance;3797 }3798 3799 var tagsSequenceElement = responseDoc['tags'];3800 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {3801 for (var property in tagsSequenceElement) {3802 var tagsKey = property;3803 var tagsValue = tagsSequenceElement[property];3804 resourceInstance.tags[tagsKey] = tagsValue;3805 }3806 }3807 3808 var typeValue = responseDoc['type'];3809 if (typeValue !== null && typeValue !== undefined) {3810 var typeInstance = typeValue;3811 resourceInstance.type = typeInstance;3812 }3813 }3814 3815 }3816 result.statusCode = statusCode;3817 result.requestId = response.headers['x-ms-request-id'];3818 3819 return callback(null, result);3820 });3821 };3822 3823 /**3824 * Gets a schedule configuration for site backups.3825 * 3826 * @param {string} resourceGroupName The name of the web space.3827 * 3828 * @param {string} webSiteName The name of the web site.3829 * 3830 * @param {string} [slotName] The name of the slot.3831 * 3832 * @param {function} callback3833 * 3834 * @returns {Stream} The response stream.3835 */3836 WebSiteOperations.prototype.getBackupConfiguration = function(resourceGroupName, webSiteName, slotName, callback) {3837 if (callback === null || callback === undefined) {3838 throw new Error('callback cannot be null.');3839 }3840 // Validate3841 if (resourceGroupName === null || resourceGroupName === undefined) {3842 return callback(new Error('resourceGroupName cannot be null.'));3843 }3844 if (webSiteName === null || webSiteName === undefined) {3845 return callback(new Error('webSiteName cannot be null.'));3846 }3847 3848 // Tracing3849 3850 // Construct URL3851 var url2 = '';3852 url2 = url2 + '/subscriptions/';3853 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {3854 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);3855 }3856 url2 = url2 + '/resourceGroups/';3857 url2 = url2 + encodeURIComponent(resourceGroupName);3858 url2 = url2 + '/providers/';3859 url2 = url2 + 'Microsoft.Web';3860 url2 = url2 + '/';3861 url2 = url2 + 'sites';3862 url2 = url2 + '/';3863 url2 = url2 + encodeURIComponent(webSiteName);3864 if (slotName !== null && slotName !== undefined) {3865 url2 = url2 + '/slots/' + encodeURIComponent(slotName);3866 }3867 url2 = url2 + '/backup/config';3868 var queryParameters = [];3869 queryParameters.push('api-version=2014-06-01');3870 if (queryParameters.length > 0) {3871 url2 = url2 + '?' + queryParameters.join('&');3872 }3873 var baseUrl = this.client.baseUri;3874 // Trim '/' character from the end of baseUrl and beginning of url.3875 if (baseUrl[baseUrl.length - 1] === '/') {3876 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3877 }3878 if (url2[0] === '/') {3879 url2 = url2.substring(1);3880 }3881 url2 = baseUrl + '/' + url2;3882 url2 = url2.replace(' ', '%20');3883 3884 // Create HTTP transport objects3885 var httpRequest = new WebResource();3886 httpRequest.method = 'GET';3887 httpRequest.headers = {};3888 httpRequest.url = url2;3889 3890 // Set Headers3891 httpRequest.headers['x-ms-version'] = '2014-06-01';3892 3893 // Send Request3894 return this.client.pipeline(httpRequest, function (err, response, body) {3895 if (err !== null && err !== undefined) {3896 return callback(err);3897 }3898 var statusCode = response.statusCode;3899 if (statusCode !== 200) {3900 var error = new Error(body);3901 error.statusCode = response.statusCode;3902 return callback(error);3903 }3904 3905 // Create Result3906 var result = null;3907 // Deserialize Response3908 if (statusCode === 200) {3909 var responseContent = body;3910 result = {};3911 var responseDoc = null;3912 if (responseContent) {3913 responseDoc = JSON.parse(responseContent);3914 }3915 3916 if (responseDoc !== null && responseDoc !== undefined) {3917 var backupScheduleInstance = { tags: {} };3918 result.backupSchedule = backupScheduleInstance;3919 3920 var propertiesValue = responseDoc['properties'];3921 if (propertiesValue !== null && propertiesValue !== undefined) {3922 var propertiesInstance = { databases: [] };3923 backupScheduleInstance.properties = propertiesInstance;3924 3925 var enabledValue = propertiesValue['enabled'];3926 if (enabledValue !== null && enabledValue !== undefined) {3927 var enabledInstance = enabledValue;3928 propertiesInstance.enabled = enabledInstance;3929 }3930 3931 var nameValue = propertiesValue['name'];3932 if (nameValue !== null && nameValue !== undefined) {3933 var nameInstance = nameValue;3934 propertiesInstance.name = nameInstance;3935 }3936 3937 var storageAccountUrlValue = propertiesValue['storageAccountUrl'];3938 if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {3939 var storageAccountUrlInstance = storageAccountUrlValue;3940 propertiesInstance.storageAccountUrl = storageAccountUrlInstance;3941 }3942 3943 var backupScheduleValue = propertiesValue['backupSchedule'];3944 if (backupScheduleValue !== null && backupScheduleValue !== undefined) {3945 var backupScheduleInstance2 = {};3946 propertiesInstance.backupSchedule = backupScheduleInstance2;3947 3948 var frequencyIntervalValue = backupScheduleValue['frequencyInterval'];3949 if (frequencyIntervalValue !== null && frequencyIntervalValue !== undefined) {3950 var frequencyIntervalInstance = frequencyIntervalValue;3951 backupScheduleInstance2.frequencyInterval = frequencyIntervalInstance;3952 }3953 3954 var frequencyUnitValue = backupScheduleValue['frequencyUnit'];3955 if (frequencyUnitValue !== null && frequencyUnitValue !== undefined) {3956 var frequencyUnitInstance = frequencyUnitValue;3957 backupScheduleInstance2.frequencyUnit = frequencyUnitInstance;3958 }3959 3960 var keepAtLeastOneBackupValue = backupScheduleValue['keepAtLeastOneBackup'];3961 if (keepAtLeastOneBackupValue !== null && keepAtLeastOneBackupValue !== undefined) {3962 var keepAtLeastOneBackupInstance = keepAtLeastOneBackupValue;3963 backupScheduleInstance2.keepAtLeastOneBackup = keepAtLeastOneBackupInstance;3964 }3965 3966 var lastExecutionTimeValue = backupScheduleValue['lastExecutionTime'];3967 if (lastExecutionTimeValue !== null && lastExecutionTimeValue !== undefined) {3968 var lastExecutionTimeInstance = lastExecutionTimeValue;3969 backupScheduleInstance2.lastExecutionTime = lastExecutionTimeInstance;3970 }3971 3972 var retentionPeriodInDaysValue = backupScheduleValue['retentionPeriodInDays'];3973 if (retentionPeriodInDaysValue !== null && retentionPeriodInDaysValue !== undefined) {3974 var retentionPeriodInDaysInstance = retentionPeriodInDaysValue;3975 backupScheduleInstance2.retentionPeriodInDays = retentionPeriodInDaysInstance;3976 }3977 3978 var startTimeValue = backupScheduleValue['startTime'];3979 if (startTimeValue !== null && startTimeValue !== undefined) {3980 var startTimeInstance = startTimeValue;3981 backupScheduleInstance2.startTime = startTimeInstance;3982 }3983 }3984 3985 var databasesArray = propertiesValue['databases'];3986 if (databasesArray !== null && databasesArray !== undefined) {3987 for (var loweredIndex1 = 0; loweredIndex1 < databasesArray.length; loweredIndex1 = loweredIndex1 + 1) {3988 var databasesValue = databasesArray[loweredIndex1];3989 var databaseBackupSettingInstance = {};3990 propertiesInstance.databases.push(databaseBackupSettingInstance);3991 3992 var connectionStringValue = databasesValue['connectionString'];3993 if (connectionStringValue !== null && connectionStringValue !== undefined) {3994 var connectionStringInstance = connectionStringValue;3995 databaseBackupSettingInstance.connectionString = connectionStringInstance;3996 }3997 3998 var connectionStringNameValue = databasesValue['connectionStringName'];3999 if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {4000 var connectionStringNameInstance = connectionStringNameValue;4001 databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;4002 }4003 4004 var databaseTypeValue = databasesValue['databaseType'];4005 if (databaseTypeValue !== null && databaseTypeValue !== undefined) {4006 var databaseTypeInstance = databaseTypeValue;4007 databaseBackupSettingInstance.databaseType = databaseTypeInstance;4008 }4009 4010 var nameValue2 = databasesValue['name'];4011 if (nameValue2 !== null && nameValue2 !== undefined) {4012 var nameInstance2 = nameValue2;4013 databaseBackupSettingInstance.name = nameInstance2;4014 }4015 }4016 }4017 }4018 4019 var idValue = responseDoc['id'];4020 if (idValue !== null && idValue !== undefined) {4021 var idInstance = idValue;4022 backupScheduleInstance.id = idInstance;4023 }4024 4025 var nameValue3 = responseDoc['name'];4026 if (nameValue3 !== null && nameValue3 !== undefined) {4027 var nameInstance3 = nameValue3;4028 backupScheduleInstance.name = nameInstance3;4029 }4030 4031 var locationValue = responseDoc['location'];4032 if (locationValue !== null && locationValue !== undefined) {4033 var locationInstance = locationValue;4034 backupScheduleInstance.location = locationInstance;4035 }4036 4037 var tagsSequenceElement = responseDoc['tags'];4038 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {4039 for (var property in tagsSequenceElement) {4040 var tagsKey = property;4041 var tagsValue = tagsSequenceElement[property];4042 backupScheduleInstance.tags[tagsKey] = tagsValue;4043 }4044 }4045 4046 var typeValue = responseDoc['type'];4047 if (typeValue !== null && typeValue !== undefined) {4048 var typeInstance = typeValue;4049 backupScheduleInstance.type = typeInstance;4050 }4051 }4052 4053 }4054 result.statusCode = statusCode;4055 result.requestId = response.headers['x-ms-request-id'];4056 4057 return callback(null, result);4058 });4059 };4060 4061 /**4062 * You can retrieve the config settings for a web site by issuing an HTTP GET4063 * request, or update them by using HTTP PUT with a request body that4064 * contains the settings to be updated. (see4065 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for4066 * more information)4067 * 4068 * @param {string} resourceGroupName The name of the resource group.4069 * 4070 * @param {string} webSiteName The name of the web site.4071 * 4072 * @param {string} [slotName] The name of the slot.4073 * 4074 * @param {WebSiteGetConfigurationParameters} [parametersOrCallback]4075 * Additional parameters.4076 * 4077 * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list4078 * of the names of any addtional parameters to return.4079 * 4080 * @param {function} callback4081 * 4082 * @returns {Stream} The response stream.4083 */4084 WebSiteOperations.prototype.getConfiguration = function(resourceGroupName, webSiteName, slotName, parametersOrCallback, callback) {4085 var parameters = parametersOrCallback;4086 if (_.isFunction(parameters)) {4087 callback = parameters;4088 parameters = null;4089 }4090 if (callback === null || callback === undefined) {4091 throw new Error('callback cannot be null.');4092 }4093 // Validate4094 if (resourceGroupName === null || resourceGroupName === undefined) {4095 return callback(new Error('resourceGroupName cannot be null.'));4096 }4097 if (webSiteName === null || webSiteName === undefined) {4098 return callback(new Error('webSiteName cannot be null.'));4099 }4100 4101 // Tracing4102 4103 // Construct URL4104 var url2 = '';4105 url2 = url2 + '/subscriptions/';4106 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {4107 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);4108 }4109 url2 = url2 + '/resourceGroups/';4110 url2 = url2 + encodeURIComponent(resourceGroupName);4111 url2 = url2 + '/providers/';4112 url2 = url2 + 'Microsoft.Web';4113 url2 = url2 + '/';4114 url2 = url2 + 'sites';4115 url2 = url2 + '/';4116 url2 = url2 + encodeURIComponent(webSiteName);4117 if (slotName !== null && slotName !== undefined) {4118 url2 = url2 + '/slots/' + encodeURIComponent(slotName);4119 }4120 url2 = url2 + '/config/web';4121 var queryParameters = [];4122 queryParameters.push('api-version=2014-06-01');4123 if (parameters !== null && parameters !== undefined && parameters.propertiesToInclude !== null && parameters.propertiesToInclude !== undefined && parameters.propertiesToInclude.length > 0) {4124 queryParameters.push('propertiesToInclude=' + encodeURIComponent(parameters.propertiesToInclude.join(',')));4125 }4126 if (queryParameters.length > 0) {4127 url2 = url2 + '?' + queryParameters.join('&');4128 }4129 var baseUrl = this.client.baseUri;4130 // Trim '/' character from the end of baseUrl and beginning of url.4131 if (baseUrl[baseUrl.length - 1] === '/') {4132 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);4133 }4134 if (url2[0] === '/') {4135 url2 = url2.substring(1);4136 }4137 url2 = baseUrl + '/' + url2;4138 url2 = url2.replace(' ', '%20');4139 4140 // Create HTTP transport objects4141 var httpRequest = new WebResource();4142 httpRequest.method = 'GET';4143 httpRequest.headers = {};4144 httpRequest.url = url2;4145 4146 // Set Headers4147 4148 // Send Request4149 return this.client.pipeline(httpRequest, function (err, response, body) {4150 if (err !== null && err !== undefined) {4151 return callback(err);4152 }4153 var statusCode = response.statusCode;4154 if (statusCode !== 200) {4155 var error = new Error(body);4156 error.statusCode = response.statusCode;4157 return callback(error);4158 }4159 4160 // Create Result4161 var result = null;4162 // Deserialize Response4163 if (statusCode === 200) {4164 var responseContent = body;4165 result = {};4166 var responseDoc = null;4167 if (responseContent) {4168 responseDoc = JSON.parse(responseContent);4169 }4170 4171 if (responseDoc !== null && responseDoc !== undefined) {4172 var resourceInstance = { tags: {} };4173 result.resource = resourceInstance;4174 4175 var propertiesValue = responseDoc['properties'];4176 if (propertiesValue !== null && propertiesValue !== undefined) {4177 var propertiesInstance = { appSettings: {}, connectionStrings: [], defaultDocuments: [], handlerMappings: [], metadata: {} };4178 resourceInstance.properties = propertiesInstance;4179 4180 var appSettingsSequenceElement = propertiesValue['appSettings'];4181 if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {4182 for (var property in appSettingsSequenceElement) {4183 var appSettingsKey = property;4184 var appSettingsValue = appSettingsSequenceElement[property];4185 propertiesInstance.appSettings[appSettingsKey] = appSettingsValue;4186 }4187 }4188 4189 var connectionStringsArray = propertiesValue['connectionStrings'];4190 if (connectionStringsArray !== null && connectionStringsArray !== undefined) {4191 for (var loweredIndex1 = 0; loweredIndex1 < connectionStringsArray.length; loweredIndex1 = loweredIndex1 + 1) {4192 var connectionStringsValue = connectionStringsArray[loweredIndex1];4193 var connStringInfoInstance = {};4194 propertiesInstance.connectionStrings.push(connStringInfoInstance);4195 4196 var connectionStringValue = connectionStringsValue['connectionString'];4197 if (connectionStringValue !== null && connectionStringValue !== undefined) {4198 var connectionStringInstance = connectionStringValue;4199 connStringInfoInstance.connectionString = connectionStringInstance;4200 }4201 4202 var nameValue = connectionStringsValue['name'];4203 if (nameValue !== null && nameValue !== undefined) {4204 var nameInstance = nameValue;4205 connStringInfoInstance.name = nameInstance;4206 }4207 4208 var typeValue = connectionStringsValue['type'];4209 if (typeValue !== null && typeValue !== undefined) {4210 var typeInstance = typeValue;4211 connStringInfoInstance.type = typeInstance;4212 }4213 }4214 }4215 4216 var defaultDocumentsArray = propertiesValue['defaultDocuments'];4217 if (defaultDocumentsArray !== null && defaultDocumentsArray !== undefined) {4218 for (var loweredIndex2 = 0; loweredIndex2 < defaultDocumentsArray.length; loweredIndex2 = loweredIndex2 + 1) {4219 var defaultDocumentsValue = defaultDocumentsArray[loweredIndex2];4220 propertiesInstance.defaultDocuments.push(defaultDocumentsValue);4221 }4222 }4223 4224 var detailedErrorLoggingEnabledValue = propertiesValue['detailedErrorLoggingEnabled'];4225 if (detailedErrorLoggingEnabledValue !== null && detailedErrorLoggingEnabledValue !== undefined) {4226 var detailedErrorLoggingEnabledInstance = detailedErrorLoggingEnabledValue;4227 propertiesInstance.detailedErrorLoggingEnabled = detailedErrorLoggingEnabledInstance;4228 }4229 4230 var documentRootValue = propertiesValue['documentRoot'];4231 if (documentRootValue !== null && documentRootValue !== undefined) {4232 var documentRootInstance = documentRootValue;4233 propertiesInstance.documentRoot = documentRootInstance;4234 }4235 4236 var handlerMappingsArray = propertiesValue['handlerMappings'];4237 if (handlerMappingsArray !== null && handlerMappingsArray !== undefined) {4238 for (var loweredIndex3 = 0; loweredIndex3 < handlerMappingsArray.length; loweredIndex3 = loweredIndex3 + 1) {4239 var handlerMappingsValue = handlerMappingsArray[loweredIndex3];4240 var handlerMappingInstance = {};4241 propertiesInstance.handlerMappings.push(handlerMappingInstance);4242 4243 var argumentsValue = handlerMappingsValue['arguments'];4244 if (argumentsValue !== null && argumentsValue !== undefined) {4245 var argumentsInstance = argumentsValue;4246 handlerMappingInstance.arguments = argumentsInstance;4247 }4248 4249 var extensionValue = handlerMappingsValue['extension'];4250 if (extensionValue !== null && extensionValue !== undefined) {4251 var extensionInstance = extensionValue;4252 handlerMappingInstance.extension = extensionInstance;4253 }4254 4255 var scriptProcessorValue = handlerMappingsValue['scriptProcessor'];4256 if (scriptProcessorValue !== null && scriptProcessorValue !== undefined) {4257 var scriptProcessorInstance = scriptProcessorValue;4258 handlerMappingInstance.scriptProcessor = scriptProcessorInstance;4259 }4260 }4261 }4262 4263 var httpLoggingEnabledValue = propertiesValue['httpLoggingEnabled'];4264 if (httpLoggingEnabledValue !== null && httpLoggingEnabledValue !== undefined) {4265 var httpLoggingEnabledInstance = httpLoggingEnabledValue;4266 propertiesInstance.httpLoggingEnabled = httpLoggingEnabledInstance;4267 }4268 4269 var logsDirectorySizeLimitValue = propertiesValue['logsDirectorySizeLimit'];4270 if (logsDirectorySizeLimitValue !== null && logsDirectorySizeLimitValue !== undefined) {4271 var logsDirectorySizeLimitInstance = logsDirectorySizeLimitValue;4272 propertiesInstance.logsDirectorySizeLimit = logsDirectorySizeLimitInstance;4273 }4274 4275 var managedPipelineModeValue = propertiesValue['managedPipelineMode'];4276 if (managedPipelineModeValue !== null && managedPipelineModeValue !== undefined) {4277 var managedPipelineModeInstance = managedPipelineModeValue;4278 propertiesInstance.managedPipelineMode = managedPipelineModeInstance;4279 }4280 4281 var metadataSequenceElement = propertiesValue['metadata'];4282 if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {4283 for (var property2 in metadataSequenceElement) {4284 var metadataKey = property2;4285 var metadataValue = metadataSequenceElement[property2];4286 propertiesInstance.metadata[metadataKey] = metadataValue;4287 }4288 }4289 4290 var netFrameworkVersionValue = propertiesValue['netFrameworkVersion'];4291 if (netFrameworkVersionValue !== null && netFrameworkVersionValue !== undefined) {4292 var netFrameworkVersionInstance = netFrameworkVersionValue;4293 propertiesInstance.netFrameworkVersion = netFrameworkVersionInstance;4294 }4295 4296 var numberOfWorkersValue = propertiesValue['numberOfWorkers'];4297 if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {4298 var numberOfWorkersInstance = numberOfWorkersValue;4299 propertiesInstance.numberOfWorkers = numberOfWorkersInstance;4300 }4301 4302 var phpVersionValue = propertiesValue['phpVersion'];4303 if (phpVersionValue !== null && phpVersionValue !== undefined) {4304 var phpVersionInstance = phpVersionValue;4305 propertiesInstance.phpVersion = phpVersionInstance;4306 }4307 4308 var pythonVersionValue = propertiesValue['pythonVersion'];4309 if (pythonVersionValue !== null && pythonVersionValue !== undefined) {4310 var pythonVersionInstance = pythonVersionValue;4311 propertiesInstance.pythonVersion = pythonVersionInstance;4312 }4313 4314 var publishingPasswordValue = propertiesValue['publishingPassword'];4315 if (publishingPasswordValue !== null && publishingPasswordValue !== undefined) {4316 var publishingPasswordInstance = publishingPasswordValue;4317 propertiesInstance.publishingPassword = publishingPasswordInstance;4318 }4319 4320 var publishingUsernameValue = propertiesValue['publishingUsername'];4321 if (publishingUsernameValue !== null && publishingUsernameValue !== undefined) {4322 var publishingUsernameInstance = publishingUsernameValue;4323 propertiesInstance.publishingUserName = publishingUsernameInstance;4324 }4325 4326 var remoteDebuggingEnabledValue = propertiesValue['RemoteDebuggingEnabled'];4327 if (remoteDebuggingEnabledValue !== null && remoteDebuggingEnabledValue !== undefined) {4328 var remoteDebuggingEnabledInstance = remoteDebuggingEnabledValue;4329 propertiesInstance.remoteDebuggingEnabled = remoteDebuggingEnabledInstance;4330 }4331 4332 var remoteDebuggingVersionValue = propertiesValue['remoteDebuggingVersion'];4333 if (remoteDebuggingVersionValue !== null && remoteDebuggingVersionValue !== undefined) {4334 var remoteDebuggingVersionInstance = remoteDebuggingVersionValue;4335 propertiesInstance.remoteDebuggingVersion = remoteDebuggingVersionInstance;4336 }4337 4338 var requestTracingEnabledValue = propertiesValue['requestTracingEnabled'];4339 if (requestTracingEnabledValue !== null && requestTracingEnabledValue !== undefined) {4340 var requestTracingEnabledInstance = requestTracingEnabledValue;4341 propertiesInstance.requestTracingEnabled = requestTracingEnabledInstance;4342 }4343 4344 var requestTracingExpirationTimeValue = propertiesValue['requestTracingExpirationTime'];4345 if (requestTracingExpirationTimeValue !== null && requestTracingExpirationTimeValue !== undefined) {4346 var requestTracingExpirationTimeInstance = requestTracingExpirationTimeValue;4347 propertiesInstance.requestTracingExpirationTime = requestTracingExpirationTimeInstance;4348 }4349 4350 var scmTypeValue = propertiesValue['scmType'];4351 if (scmTypeValue !== null && scmTypeValue !== undefined) {4352 var scmTypeInstance = scmTypeValue;4353 propertiesInstance.scmType = scmTypeInstance;4354 }4355 4356 var autoSwapSlotNameValue = propertiesValue['autoSwapSlotName'];4357 if (autoSwapSlotNameValue !== null && autoSwapSlotNameValue !== undefined) {4358 var autoSwapSlotNameInstance = autoSwapSlotNameValue;4359 propertiesInstance.autoSwapSlotName = autoSwapSlotNameInstance;4360 }4361 4362 var use32BitWorkerProcessValue = propertiesValue['use32BitWorkerProcess'];4363 if (use32BitWorkerProcessValue !== null && use32BitWorkerProcessValue !== undefined) {4364 var use32BitWorkerProcessInstance = use32BitWorkerProcessValue;4365 propertiesInstance.use32BitWorkerProcess = use32BitWorkerProcessInstance;4366 }4367 4368 var webSocketsEnabledValue = propertiesValue['webSocketsEnabled'];4369 if (webSocketsEnabledValue !== null && webSocketsEnabledValue !== undefined) {4370 var webSocketsEnabledInstance = webSocketsEnabledValue;4371 propertiesInstance.webSocketsEnabled = webSocketsEnabledInstance;4372 }4373 4374 var limitsValue = propertiesValue['limits'];4375 if (limitsValue !== null && limitsValue !== undefined) {4376 var limitsInstance = {};4377 propertiesInstance.limits = limitsInstance;4378 4379 var maxPercentageCpuValue = limitsValue['maxPercentageCpu'];4380 if (maxPercentageCpuValue !== null && maxPercentageCpuValue !== undefined) {4381 var maxPercentageCpuInstance = maxPercentageCpuValue;4382 limitsInstance.maxPercentageCpu = maxPercentageCpuInstance;4383 }4384 4385 var maxMemoryInMbValue = limitsValue['maxMemoryInMb'];4386 if (maxMemoryInMbValue !== null && maxMemoryInMbValue !== undefined) {4387 var maxMemoryInMbInstance = maxMemoryInMbValue;4388 limitsInstance.maxMemoryInMb = maxMemoryInMbInstance;4389 }4390 4391 var maxDiskSizeInMbValue = limitsValue['maxDiskSizeInMb'];4392 if (maxDiskSizeInMbValue !== null && maxDiskSizeInMbValue !== undefined) {4393 var maxDiskSizeInMbInstance = maxDiskSizeInMbValue;4394 limitsInstance.maxDiskSizeInMb = maxDiskSizeInMbInstance;4395 }4396 }4397 }4398 4399 var idValue = responseDoc['id'];4400 if (idValue !== null && idValue !== undefined) {4401 var idInstance = idValue;4402 resourceInstance.id = idInstance;4403 }4404 4405 var nameValue2 = responseDoc['name'];4406 if (nameValue2 !== null && nameValue2 !== undefined) {4407 var nameInstance2 = nameValue2;4408 resourceInstance.name = nameInstance2;4409 }4410 4411 var locationValue = responseDoc['location'];4412 if (locationValue !== null && locationValue !== undefined) {4413 var locationInstance = locationValue;4414 resourceInstance.location = locationInstance;4415 }4416 4417 var tagsSequenceElement = responseDoc['tags'];4418 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {4419 for (var property3 in tagsSequenceElement) {4420 var tagsKey = property3;4421 var tagsValue = tagsSequenceElement[property3];4422 resourceInstance.tags[tagsKey] = tagsValue;4423 }4424 }4425 4426 var typeValue2 = responseDoc['type'];4427 if (typeValue2 !== null && typeValue2 !== undefined) {4428 var typeInstance2 = typeValue2;4429 resourceInstance.type = typeInstance2;4430 }4431 }4432 4433 }4434 result.statusCode = statusCode;4435 result.requestId = response.headers['x-ms-request-id'];4436 4437 return callback(null, result);4438 });4439 };4440 4441 /**4442 * Restart the web site.4443 * 4444 * @param {string} resourceGroupName The name of the resource group4445 * 4446 * @param {string} webSiteName Name of website4447 * 4448 * @param {string} [slotName] The name of the slot of the web site4449 * 4450 * @param {function} callback4451 * 4452 * @returns {Stream} The response stream.4453 */4454 WebSiteOperations.prototype.getConnectionStrings = function(resourceGroupName, webSiteName, slotName, callback) {4455 if (callback === null || callback === undefined) {4456 throw new Error('callback cannot be null.');4457 }4458 // Validate4459 if (resourceGroupName === null || resourceGroupName === undefined) {4460 return callback(new Error('resourceGroupName cannot be null.'));4461 }4462 if (webSiteName === null || webSiteName === undefined) {4463 return callback(new Error('webSiteName cannot be null.'));4464 }4465 4466 // Tracing4467 4468 // Construct URL4469 var url2 = '';4470 url2 = url2 + '/subscriptions/';4471 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {4472 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);4473 }4474 url2 = url2 + '/resourceGroups/';4475 url2 = url2 + encodeURIComponent(resourceGroupName);4476 url2 = url2 + '/providers/';4477 url2 = url2 + 'Microsoft.Web';4478 url2 = url2 + '/';4479 url2 = url2 + 'sites';4480 url2 = url2 + '/';4481 url2 = url2 + encodeURIComponent(webSiteName);4482 if (slotName !== null && slotName !== undefined) {4483 url2 = url2 + '/slots/' + encodeURIComponent(slotName);4484 }4485 url2 = url2 + '/config/connectionstrings/list';4486 var queryParameters = [];4487 queryParameters.push('api-version=2014-06-01');4488 if (queryParameters.length > 0) {4489 url2 = url2 + '?' + queryParameters.join('&');4490 }4491 var baseUrl = this.client.baseUri;4492 // Trim '/' character from the end of baseUrl and beginning of url.4493 if (baseUrl[baseUrl.length - 1] === '/') {4494 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);4495 }4496 if (url2[0] === '/') {4497 url2 = url2.substring(1);4498 }4499 url2 = baseUrl + '/' + url2;4500 url2 = url2.replace(' ', '%20');4501 4502 // Create HTTP transport objects4503 var httpRequest = new WebResource();4504 httpRequest.method = 'POST';4505 httpRequest.headers = {};4506 httpRequest.url = url2;4507 4508 // Set Headers4509 httpRequest.headers['Content-Length'] = '0';4510 4511 // Send Request4512 return this.client.pipeline(httpRequest, function (err, response, body) {4513 if (err !== null && err !== undefined) {4514 return callback(err);4515 }4516 var statusCode = response.statusCode;4517 if (statusCode !== 200) {4518 var error = new Error(body);4519 error.statusCode = response.statusCode;4520 return callback(error);4521 }4522 4523 // Create Result4524 var result = null;4525 // Deserialize Response4526 if (statusCode === 200) {4527 var responseContent = body;4528 result = {};4529 var responseDoc = null;4530 if (responseContent) {4531 responseDoc = JSON.parse(responseContent);4532 }4533 4534 if (responseDoc !== null && responseDoc !== undefined) {4535 var resourceInstance = { properties: [], tags: {} };4536 result.resource = resourceInstance;4537 4538 var propertiesArray = responseDoc['properties'];4539 if (propertiesArray !== null && propertiesArray !== undefined) {4540 for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {4541 var propertiesValue = propertiesArray[loweredIndex1];4542 var connStringInfoInstance = {};4543 resourceInstance.properties.push(connStringInfoInstance);4544 4545 var connectionStringValue = propertiesValue['connectionString'];4546 if (connectionStringValue !== null && connectionStringValue !== undefined) {4547 var connectionStringInstance = connectionStringValue;4548 connStringInfoInstance.connectionString = connectionStringInstance;4549 }4550 4551 var nameValue = propertiesValue['name'];4552 if (nameValue !== null && nameValue !== undefined) {4553 var nameInstance = nameValue;4554 connStringInfoInstance.name = nameInstance;4555 }4556 4557 var typeValue = propertiesValue['type'];4558 if (typeValue !== null && typeValue !== undefined) {4559 var typeInstance = typeValue;4560 connStringInfoInstance.type = typeInstance;4561 }4562 }4563 }4564 4565 var idValue = responseDoc['id'];4566 if (idValue !== null && idValue !== undefined) {4567 var idInstance = idValue;4568 resourceInstance.id = idInstance;4569 }4570 4571 var nameValue2 = responseDoc['name'];4572 if (nameValue2 !== null && nameValue2 !== undefined) {4573 var nameInstance2 = nameValue2;4574 resourceInstance.name = nameInstance2;4575 }4576 4577 var locationValue = responseDoc['location'];4578 if (locationValue !== null && locationValue !== undefined) {4579 var locationInstance = locationValue;4580 resourceInstance.location = locationInstance;4581 }4582 4583 var tagsSequenceElement = responseDoc['tags'];4584 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {4585 for (var property in tagsSequenceElement) {4586 var tagsKey = property;4587 var tagsValue = tagsSequenceElement[property];4588 resourceInstance.tags[tagsKey] = tagsValue;4589 }4590 }4591 4592 var typeValue2 = responseDoc['type'];4593 if (typeValue2 !== null && typeValue2 !== undefined) {4594 var typeInstance2 = typeValue2;4595 resourceInstance.type = typeInstance2;4596 }4597 }4598 4599 }4600 result.statusCode = statusCode;4601 result.requestId = response.headers['x-ms-request-id'];4602 4603 return callback(null, result);4604 });4605 };4606 4607 /**4608 * You can retrieve historical usage metrics for a site by issuing an HTTP4609 * GET request. (see4610 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166964.aspx for4611 * more information)4612 * 4613 * @param {string} resourceGroupName The name of the resource group.4614 * 4615 * @param {string} webSiteName The name of the web site.4616 * 4617 * @param {string} [slotName] The name of the slot.4618 * 4619 * @param {WebSiteGetHistoricalUsageMetricsParameters} parameters The Get Web4620 * Site Historical Usage Metrics parameters.4621 * 4622 * @param {array} [parameters.metricNames] Specifies a comma-separated list4623 * of the names of the metrics to return. If the names parameter is not4624 * specified, then all available metrics are returned.4625 * 4626 * @param {date} [parameters.startTime] The starting time of the metrics to4627 * return. If this parameter is not specified, the beginning of the current4628 * hour is used.4629 * 4630 * @param {date} [parameters.endTime] The ending time of the metrics to4631 * return. If this parameter is not specified, the current time is used.4632 * 4633 * @param {string} [parameters.timeGrain] The grain at which the metrics are4634 * returned. Supported values are PT1M (minute), PT1H (hour), P1D (day).4635 * 4636 * @param {boolean} [parameters.includeInstanceBreakdown] Flag which4637 * specifies if the metrics for each machine instance should be included.4638 * For sites that run on more than one machine this could be useful to4639 * identify a bad machine.4640 * 4641 * @param {boolean} [parameters.slotView] Flag which specifies if the metrics4642 * returned should reflect slot swaps. Let's take for example following4643 * case: if production slot has hostname www.contos.com and take traffic for4644 * 12 hours and later is swapped with staging slot. Getting metrics with4645 * SlotView=false will reflect the swap - e.g. there will be a increase on4646 * the staging slot metrics after it goes to production.If SlotView=true is4647 * used it will show the metrics for the www.contoso.com regardless which4648 * slot was serving at the moment.4649 * 4650 * @param {function} callback4651 * 4652 * @returns {Stream} The response stream.4653 */4654 WebSiteOperations.prototype.getHistoricalUsageMetrics = function(resourceGroupName, webSiteName, slotName, parameters, callback) {4655 if (callback === null || callback === undefined) {4656 throw new Error('callback cannot be null.');4657 }4658 // Validate4659 if (resourceGroupName === null || resourceGroupName === undefined) {4660 return callback(new Error('resourceGroupName cannot be null.'));4661 }4662 if (webSiteName === null || webSiteName === undefined) {4663 return callback(new Error('webSiteName cannot be null.'));4664 }4665 if (parameters === null || parameters === undefined) {4666 return callback(new Error('parameters cannot be null.'));4667 }4668 4669 // Tracing4670 4671 // Construct URL4672 var url2 = '';4673 url2 = url2 + '/subscriptions/';4674 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {4675 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);4676 }4677 url2 = url2 + '/resourceGroups/';4678 url2 = url2 + encodeURIComponent(resourceGroupName);4679 url2 = url2 + '/providers/';4680 url2 = url2 + 'Microsoft.Web';4681 url2 = url2 + '/';4682 url2 = url2 + 'sites';4683 url2 = url2 + '/';4684 url2 = url2 + encodeURIComponent(webSiteName);4685 if (slotName !== null && slotName !== undefined) {4686 url2 = url2 + '/slots/' + encodeURIComponent(slotName);4687 }4688 url2 = url2 + '/metrics';4689 var queryParameters = [];4690 queryParameters.push('api-version=2014-06-01');4691 if (parameters.metricNames !== null && parameters.metricNames !== undefined && parameters.metricNames.length > 0) {4692 queryParameters.push('names=' + encodeURIComponent(parameters.metricNames.join(',')));4693 }4694 if (parameters.startTime !== null && parameters.startTime !== undefined) {4695 queryParameters.push('StartTime=' + encodeURIComponent(parameters.startTime.toISOString()));4696 }4697 if (parameters.endTime !== null && parameters.endTime !== undefined) {4698 queryParameters.push('EndTime=' + encodeURIComponent(parameters.endTime.toISOString()));4699 }4700 if (parameters.timeGrain !== null && parameters.timeGrain !== undefined) {4701 queryParameters.push('timeGrain=' + encodeURIComponent(parameters.timeGrain));4702 }4703 if (parameters.includeInstanceBreakdown !== null && parameters.includeInstanceBreakdown !== undefined) {4704 queryParameters.push('details=' + encodeURIComponent(parameters.includeInstanceBreakdown.toString()));4705 }4706 if (parameters.slotView !== null && parameters.slotView !== undefined) {4707 queryParameters.push('slotView=' + encodeURIComponent(parameters.slotView.toString()));4708 }4709 if (queryParameters.length > 0) {4710 url2 = url2 + '?' + queryParameters.join('&');4711 }4712 var baseUrl = this.client.baseUri;4713 // Trim '/' character from the end of baseUrl and beginning of url.4714 if (baseUrl[baseUrl.length - 1] === '/') {4715 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);4716 }4717 if (url2[0] === '/') {4718 url2 = url2.substring(1);4719 }4720 url2 = baseUrl + '/' + url2;4721 url2 = url2.replace(' ', '%20');4722 4723 // Create HTTP transport objects4724 var httpRequest = new WebResource();4725 httpRequest.method = 'GET';4726 httpRequest.headers = {};4727 httpRequest.url = url2;4728 4729 // Set Headers4730 4731 // Send Request4732 return this.client.pipeline(httpRequest, function (err, response, body) {4733 if (err !== null && err !== undefined) {4734 return callback(err);4735 }4736 var statusCode = response.statusCode;4737 if (statusCode !== 200) {4738 var error = new Error(body);4739 error.statusCode = response.statusCode;4740 return callback(error);4741 }4742 4743 // Create Result4744 var result = null;4745 // Deserialize Response4746 if (statusCode === 200) {4747 var responseContent = body;4748 result = { usageMetrics: [] };4749 var responseDoc = null;4750 if (responseContent) {4751 responseDoc = JSON.parse(responseContent);4752 }4753 4754 if (responseDoc !== null && responseDoc !== undefined) {4755 var propertiesArray = responseDoc['properties'];4756 if (propertiesArray !== null && propertiesArray !== undefined) {4757 for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {4758 var propertiesValue = propertiesArray[loweredIndex1];4759 var historicalUsageMetricInstance = {};4760 result.usageMetrics.push(historicalUsageMetricInstance);4761 4762 var codeValue = propertiesValue['code'];4763 if (codeValue !== null && codeValue !== undefined) {4764 var codeInstance = codeValue;4765 historicalUsageMetricInstance.code = codeInstance;4766 }4767 4768 var dataValue = propertiesValue['data'];4769 if (dataValue !== null && dataValue !== undefined) {4770 var dataInstance = { values: [] };4771 historicalUsageMetricInstance.data = dataInstance;4772 4773 var displayNameValue = dataValue['displayName'];4774 if (displayNameValue !== null && displayNameValue !== undefined) {4775 var displayNameInstance = displayNameValue;4776 dataInstance.displayName = displayNameInstance;4777 }4778 4779 var endTimeValue = dataValue['EndTime'];4780 if (endTimeValue !== null && endTimeValue !== undefined) {4781 var endTimeInstance = endTimeValue;4782 dataInstance.endTime = endTimeInstance;4783 }4784 4785 var nameValue = dataValue['name'];4786 if (nameValue !== null && nameValue !== undefined) {4787 var nameInstance = nameValue;4788 dataInstance.name = nameInstance;4789 }4790 4791 var primaryAggregationTypeValue = dataValue['primaryAggregationType'];4792 if (primaryAggregationTypeValue !== null && primaryAggregationTypeValue !== undefined) {4793 var primaryAggregationTypeInstance = primaryAggregationTypeValue;4794 dataInstance.primaryAggregationType = primaryAggregationTypeInstance;4795 }4796 4797 var startTimeValue = dataValue['startTime'];4798 if (startTimeValue !== null && startTimeValue !== undefined) {4799 var startTimeInstance = startTimeValue;4800 dataInstance.startTime = startTimeInstance;4801 }4802 4803 var timeGrainValue = dataValue['timeGrain'];4804 if (timeGrainValue !== null && timeGrainValue !== undefined) {4805 var timeGrainInstance = timeGrainValue;4806 dataInstance.timeGrain = timeGrainInstance;4807 }4808 4809 var unitValue = dataValue['unit'];4810 if (unitValue !== null && unitValue !== undefined) {4811 var unitInstance = unitValue;4812 dataInstance.unit = unitInstance;4813 }4814 4815 var valuesArray = dataValue['values'];4816 if (valuesArray !== null && valuesArray !== undefined) {4817 for (var loweredIndex2 = 0; loweredIndex2 < valuesArray.length; loweredIndex2 = loweredIndex2 + 1) {4818 var valuesValue = valuesArray[loweredIndex2];4819 var metricSampleInstance = {};4820 dataInstance.values.push(metricSampleInstance);4821 4822 var countValue = valuesValue['count'];4823 if (countValue !== null && countValue !== undefined) {4824 var countInstance = countValue;4825 metricSampleInstance.count = countInstance;4826 }4827 4828 var maximumValue = valuesValue['maximum'];4829 if (maximumValue !== null && maximumValue !== undefined) {4830 var maximumInstance = maximumValue;4831 metricSampleInstance.maximum = maximumInstance;4832 }4833 4834 var minimumValue = valuesValue['minimum'];4835 if (minimumValue !== null && minimumValue !== undefined) {4836 var minimumInstance = minimumValue;4837 metricSampleInstance.minimum = minimumInstance;4838 }4839 4840 var timeCreatedValue = valuesValue['timeCreated'];4841 if (timeCreatedValue !== null && timeCreatedValue !== undefined) {4842 var timeCreatedInstance = timeCreatedValue;4843 metricSampleInstance.timeCreated = timeCreatedInstance;4844 }4845 4846 var totalValue = valuesValue['total'];4847 if (totalValue !== null && totalValue !== undefined) {4848 var totalInstance = totalValue;4849 metricSampleInstance.total = totalInstance;4850 }4851 4852 var instanceNameValue = valuesValue['instanceName'];4853 if (instanceNameValue !== null && instanceNameValue !== undefined) {4854 var instanceNameInstance = instanceNameValue;4855 metricSampleInstance.instanceName = instanceNameInstance;4856 }4857 }4858 }4859 }4860 4861 var messageValue = propertiesValue['message'];4862 if (messageValue !== null && messageValue !== undefined) {4863 var messageInstance = messageValue;4864 historicalUsageMetricInstance.message = messageInstance;4865 }4866 }4867 }4868 }4869 4870 }4871 result.statusCode = statusCode;4872 result.requestId = response.headers['x-ms-request-id'];4873 4874 return callback(null, result);4875 });4876 };4877 4878 /**4879 * Restart the web site.4880 * 4881 * @param {string} resourceGroupName The name of the resource group4882 * 4883 * @param {string} webSiteName Name of website4884 * 4885 * @param {string} [slotName] The name of the slot of the web site4886 * 4887 * @param {function} callback4888 * 4889 * @returns {Stream} The response stream.4890 */4891 WebSiteOperations.prototype.getMetadata = function(resourceGroupName, webSiteName, slotName, callback) {4892 if (callback === null || callback === undefined) {4893 throw new Error('callback cannot be null.');4894 }4895 // Validate4896 if (resourceGroupName === null || resourceGroupName === undefined) {4897 return callback(new Error('resourceGroupName cannot be null.'));4898 }4899 if (webSiteName === null || webSiteName === undefined) {4900 return callback(new Error('webSiteName cannot be null.'));4901 }4902 4903 // Tracing4904 4905 // Construct URL4906 var url2 = '';4907 url2 = url2 + '/subscriptions/';4908 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {4909 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);4910 }4911 url2 = url2 + '/resourceGroups/';4912 url2 = url2 + encodeURIComponent(resourceGroupName);4913 url2 = url2 + '/providers/';4914 url2 = url2 + 'Microsoft.Web';4915 url2 = url2 + '/';4916 url2 = url2 + 'sites';4917 url2 = url2 + '/';4918 url2 = url2 + encodeURIComponent(webSiteName);4919 if (slotName !== null && slotName !== undefined) {4920 url2 = url2 + '/slots/' + encodeURIComponent(slotName);4921 }4922 url2 = url2 + '/config/metadata/list';4923 var queryParameters = [];4924 queryParameters.push('api-version=2014-06-01');4925 if (queryParameters.length > 0) {4926 url2 = url2 + '?' + queryParameters.join('&');4927 }4928 var baseUrl = this.client.baseUri;4929 // Trim '/' character from the end of baseUrl and beginning of url.4930 if (baseUrl[baseUrl.length - 1] === '/') {4931 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);4932 }4933 if (url2[0] === '/') {4934 url2 = url2.substring(1);4935 }4936 url2 = baseUrl + '/' + url2;4937 url2 = url2.replace(' ', '%20');4938 4939 // Create HTTP transport objects4940 var httpRequest = new WebResource();4941 httpRequest.method = 'POST';4942 httpRequest.headers = {};4943 httpRequest.url = url2;4944 4945 // Set Headers4946 httpRequest.headers['Content-Length'] = '0';4947 4948 // Send Request4949 return this.client.pipeline(httpRequest, function (err, response, body) {4950 if (err !== null && err !== undefined) {4951 return callback(err);4952 }4953 var statusCode = response.statusCode;4954 if (statusCode !== 200) {4955 var error = new Error(body);4956 error.statusCode = response.statusCode;4957 return callback(error);4958 }4959 4960 // Create Result4961 var result = null;4962 // Deserialize Response4963 if (statusCode === 200) {4964 var responseContent = body;4965 result = {};4966 var responseDoc = null;4967 if (responseContent) {4968 responseDoc = JSON.parse(responseContent);4969 }4970 4971 if (responseDoc !== null && responseDoc !== undefined) {4972 var resourceInstance = { properties: [], tags: {} };4973 result.resource = resourceInstance;4974 4975 var propertiesArray = responseDoc['properties'];4976 if (propertiesArray !== null && propertiesArray !== undefined) {4977 for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {4978 var propertiesValue = propertiesArray[loweredIndex1];4979 var nameValuePairInstance = {};4980 resourceInstance.properties.push(nameValuePairInstance);4981 4982 var nameValue = propertiesValue['name'];4983 if (nameValue !== null && nameValue !== undefined) {4984 var nameInstance = nameValue;4985 nameValuePairInstance.name = nameInstance;4986 }4987 4988 var valueValue = propertiesValue['value'];4989 if (valueValue !== null && valueValue !== undefined) {4990 var valueInstance = valueValue;4991 nameValuePairInstance.value = valueInstance;4992 }4993 }4994 }4995 4996 var idValue = responseDoc['id'];4997 if (idValue !== null && idValue !== undefined) {4998 var idInstance = idValue;4999 resourceInstance.id = idInstance;5000 }5001 5002 var nameValue2 = responseDoc['name'];5003 if (nameValue2 !== null && nameValue2 !== undefined) {5004 var nameInstance2 = nameValue2;5005 resourceInstance.name = nameInstance2;5006 }5007 5008 var locationValue = responseDoc['location'];5009 if (locationValue !== null && locationValue !== undefined) {5010 var locationInstance = locationValue;5011 resourceInstance.location = locationInstance;5012 }5013 5014 var tagsSequenceElement = responseDoc['tags'];5015 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {5016 for (var property in tagsSequenceElement) {5017 var tagsKey = property;5018 var tagsValue = tagsSequenceElement[property];5019 resourceInstance.tags[tagsKey] = tagsValue;5020 }5021 }5022 5023 var typeValue = responseDoc['type'];5024 if (typeValue !== null && typeValue !== undefined) {5025 var typeInstance = typeValue;5026 resourceInstance.type = typeInstance;5027 }5028 }5029 5030 }5031 result.statusCode = statusCode;5032 result.requestId = response.headers['x-ms-request-id'];5033 5034 return callback(null, result);5035 });5036 };5037 5038 /**5039 * You can retrieve details for a web site by issuing an HTTP GET request.5040 * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn167007.aspx5041 * for more information)5042 * 5043 * @param {string} resourceGroupName The name of the resource group.5044 * 5045 * @param {string} webSiteName The name of the web site.5046 * 5047 * @param {string} [slotName] The name of the slot.5048 * 5049 * @param {Guid} [operationId] Additional parameters.5050 * 5051 * @param {function} callback5052 * 5053 * @returns {Stream} The response stream.5054 */5055 WebSiteOperations.prototype.getOperation = function(resourceGroupName, webSiteName, slotName, operationId, callback) {5056 if (callback === null || callback === undefined) {5057 throw new Error('callback cannot be null.');5058 }5059 // Validate5060 if (resourceGroupName === null || resourceGroupName === undefined) {5061 return callback(new Error('resourceGroupName cannot be null.'));5062 }5063 if (webSiteName === null || webSiteName === undefined) {5064 return callback(new Error('webSiteName cannot be null.'));5065 }5066 5067 // Tracing5068 5069 // Construct URL5070 var url2 = '';5071 url2 = url2 + '/subscriptions/';5072 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5073 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5074 }5075 url2 = url2 + '/resourceGroups/';5076 url2 = url2 + encodeURIComponent(resourceGroupName);5077 url2 = url2 + '/providers/';5078 url2 = url2 + 'Microsoft.Web';5079 url2 = url2 + '/';5080 url2 = url2 + 'sites';5081 url2 = url2 + '/';5082 url2 = url2 + encodeURIComponent(webSiteName);5083 if (slotName !== null && slotName !== undefined) {5084 url2 = url2 + '/slots/' + encodeURIComponent(slotName);5085 }5086 url2 = url2 + '/operations/';5087 if (operationId !== null && operationId !== undefined) {5088 url2 = url2 + encodeURIComponent(operationId);5089 }5090 var queryParameters = [];5091 queryParameters.push('api-version=2014-06-01');5092 if (queryParameters.length > 0) {5093 url2 = url2 + '?' + queryParameters.join('&');5094 }5095 var baseUrl = this.client.baseUri;5096 // Trim '/' character from the end of baseUrl and beginning of url.5097 if (baseUrl[baseUrl.length - 1] === '/') {5098 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);5099 }5100 if (url2[0] === '/') {5101 url2 = url2.substring(1);5102 }5103 url2 = baseUrl + '/' + url2;5104 url2 = url2.replace(' ', '%20');5105 5106 // Create HTTP transport objects5107 var httpRequest = new WebResource();5108 httpRequest.method = 'GET';5109 httpRequest.headers = {};5110 httpRequest.url = url2;5111 5112 // Set Headers5113 5114 // Send Request5115 return this.client.pipeline(httpRequest, function (err, response, body) {5116 if (err !== null && err !== undefined) {5117 return callback(err);5118 }5119 var statusCode = response.statusCode;5120 if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202) {5121 var error = new Error(body);5122 error.statusCode = response.statusCode;5123 return callback(error);5124 }5125 5126 // Create Result5127 var result = null;5128 // Deserialize Response5129 if (statusCode === 200 || statusCode === 201 || statusCode === 202) {5130 var responseContent = body;5131 result = {};5132 var responseDoc = null;5133 if (responseContent) {5134 responseDoc = JSON.parse(responseContent);5135 }5136 5137 if (responseDoc !== null && responseDoc !== undefined) {5138 var locationValue = responseDoc['location'];5139 if (locationValue !== null && locationValue !== undefined) {5140 var locationInstance = locationValue;5141 result.location = locationInstance;5142 }5143 5144 var retryAfterValue = responseDoc['retry-after'];5145 if (retryAfterValue !== null && retryAfterValue !== undefined) {5146 var retryAfterInstance = retryAfterValue;5147 result.retryAfter = retryAfterInstance;5148 }5149 }5150 5151 }5152 result.statusCode = statusCode;5153 result.location = response.headers['location'];5154 result.retryAfter = response.headers['retry-after'];5155 result.requestId = response.headers['x-ms-request-id'];5156 5157 return callback(null, result);5158 });5159 };5160 5161 /**5162 * Get publishing credentials for the web site.5163 * 5164 * @param {string} resourceGroupName The name of the resource group.5165 * 5166 * @param {string} webSiteName Name of website5167 * 5168 * @param {string} [slotName] The name of the slot of the web site.5169 * 5170 * @param {function} callback5171 * 5172 * @returns {Stream} The response stream.5173 */5174 WebSiteOperations.prototype.getPublishingCredentials = function(resourceGroupName, webSiteName, slotName, callback) {5175 if (callback === null || callback === undefined) {5176 throw new Error('callback cannot be null.');5177 }5178 // Validate5179 if (resourceGroupName === null || resourceGroupName === undefined) {5180 return callback(new Error('resourceGroupName cannot be null.'));5181 }5182 if (webSiteName === null || webSiteName === undefined) {5183 return callback(new Error('webSiteName cannot be null.'));5184 }5185 5186 // Tracing5187 5188 // Construct URL5189 var url2 = '';5190 url2 = url2 + '/subscriptions/';5191 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5192 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5193 }5194 url2 = url2 + '/resourceGroups/';5195 url2 = url2 + encodeURIComponent(resourceGroupName);5196 url2 = url2 + '/providers/';5197 url2 = url2 + 'Microsoft.Web';5198 url2 = url2 + '/';5199 url2 = url2 + 'sites';5200 url2 = url2 + '/';5201 url2 = url2 + encodeURIComponent(webSiteName);5202 if (slotName !== null && slotName !== undefined) {5203 url2 = url2 + '/slots/' + encodeURIComponent(slotName);5204 }5205 url2 = url2 + '/config/publishingcredentials/list';5206 var queryParameters = [];5207 queryParameters.push('api-version=2014-06-01');5208 if (queryParameters.length > 0) {5209 url2 = url2 + '?' + queryParameters.join('&');5210 }5211 var baseUrl = this.client.baseUri;5212 // Trim '/' character from the end of baseUrl and beginning of url.5213 if (baseUrl[baseUrl.length - 1] === '/') {5214 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);5215 }5216 if (url2[0] === '/') {5217 url2 = url2.substring(1);5218 }5219 url2 = baseUrl + '/' + url2;5220 url2 = url2.replace(' ', '%20');5221 5222 // Create HTTP transport objects5223 var httpRequest = new WebResource();5224 httpRequest.method = 'POST';5225 httpRequest.headers = {};5226 httpRequest.url = url2;5227 5228 // Set Headers5229 httpRequest.headers['Content-Length'] = '0';5230 5231 // Send Request5232 return this.client.pipeline(httpRequest, function (err, response, body) {5233 if (err !== null && err !== undefined) {5234 return callback(err);5235 }5236 var statusCode = response.statusCode;5237 if (statusCode !== 200) {5238 var error = new Error(body);5239 error.statusCode = response.statusCode;5240 return callback(error);5241 }5242 5243 // Create Result5244 var result = null;5245 // Deserialize Response5246 if (statusCode === 200) {5247 var responseContent = body;5248 result = {};5249 var responseDoc = null;5250 if (responseContent) {5251 responseDoc = JSON.parse(responseContent);5252 }5253 5254 if (responseDoc !== null && responseDoc !== undefined) {5255 var resourceInstance = { tags: {} };5256 result.resource = resourceInstance;5257 5258 var propertiesValue = responseDoc['properties'];5259 if (propertiesValue !== null && propertiesValue !== undefined) {5260 var propertiesInstance = {};5261 resourceInstance.properties = propertiesInstance;5262 5263 var publishingPasswordValue = propertiesValue['publishingPassword'];5264 if (publishingPasswordValue !== null && publishingPasswordValue !== undefined) {5265 var publishingPasswordInstance = publishingPasswordValue;5266 propertiesInstance.publishingPassword = publishingPasswordInstance;5267 }5268 5269 var publishingUserNameValue = propertiesValue['publishingUserName'];5270 if (publishingUserNameValue !== null && publishingUserNameValue !== undefined) {5271 var publishingUserNameInstance = publishingUserNameValue;5272 propertiesInstance.publishingUserName = publishingUserNameInstance;5273 }5274 }5275 5276 var idValue = responseDoc['id'];5277 if (idValue !== null && idValue !== undefined) {5278 var idInstance = idValue;5279 resourceInstance.id = idInstance;5280 }5281 5282 var nameValue = responseDoc['name'];5283 if (nameValue !== null && nameValue !== undefined) {5284 var nameInstance = nameValue;5285 resourceInstance.name = nameInstance;5286 }5287 5288 var locationValue = responseDoc['location'];5289 if (locationValue !== null && locationValue !== undefined) {5290 var locationInstance = locationValue;5291 resourceInstance.location = locationInstance;5292 }5293 5294 var tagsSequenceElement = responseDoc['tags'];5295 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {5296 for (var property in tagsSequenceElement) {5297 var tagsKey = property;5298 var tagsValue = tagsSequenceElement[property];5299 resourceInstance.tags[tagsKey] = tagsValue;5300 }5301 }5302 5303 var typeValue = responseDoc['type'];5304 if (typeValue !== null && typeValue !== undefined) {5305 var typeInstance = typeValue;5306 resourceInstance.type = typeInstance;5307 }5308 }5309 5310 }5311 result.statusCode = statusCode;5312 result.requestId = response.headers['x-ms-request-id'];5313 5314 return callback(null, result);5315 });5316 };5317 5318 /**5319 * Retrieve the publish settings information for a web site. (see5320 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166996.aspx for5321 * more information)5322 * 5323 * @param {string} resourceGroupName The name of the resource group.5324 * 5325 * @param {string} webSiteName The name of the web site.5326 * 5327 * @param {string} [slotName] The name of the slot.5328 * 5329 * @param {function} callback5330 * 5331 * @returns {Stream} The response stream.5332 */5333 WebSiteOperations.prototype.getPublishProfile = function(resourceGroupName, webSiteName, slotName, callback) {5334 if (callback === null || callback === undefined) {5335 throw new Error('callback cannot be null.');5336 }5337 // Validate5338 if (resourceGroupName === null || resourceGroupName === undefined) {5339 return callback(new Error('resourceGroupName cannot be null.'));5340 }5341 if (webSiteName === null || webSiteName === undefined) {5342 return callback(new Error('webSiteName cannot be null.'));5343 }5344 5345 // Tracing5346 5347 // Construct URL5348 var url2 = '';5349 url2 = url2 + '/subscriptions/';5350 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5351 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5352 }5353 url2 = url2 + '/resourceGroups/';5354 url2 = url2 + encodeURIComponent(resourceGroupName);5355 url2 = url2 + '/providers/';5356 url2 = url2 + 'Microsoft.Web';5357 url2 = url2 + '/';5358 url2 = url2 + 'sites';5359 url2 = url2 + '/';5360 url2 = url2 + encodeURIComponent(webSiteName);5361 if (slotName !== null && slotName !== undefined) {5362 url2 = url2 + '/slots/' + encodeURIComponent(slotName);5363 }5364 url2 = url2 + '/publishxml';5365 var queryParameters = [];5366 queryParameters.push('api-version=2014-06-01');5367 if (queryParameters.length > 0) {5368 url2 = url2 + '?' + queryParameters.join('&');5369 }5370 var baseUrl = this.client.baseUri;5371 // Trim '/' character from the end of baseUrl and beginning of url.5372 if (baseUrl[baseUrl.length - 1] === '/') {5373 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);5374 }5375 if (url2[0] === '/') {5376 url2 = url2.substring(1);5377 }5378 url2 = baseUrl + '/' + url2;5379 url2 = url2.replace(' ', '%20');5380 5381 // Create HTTP transport objects5382 var httpRequest = new WebResource();5383 httpRequest.method = 'POST';5384 httpRequest.headers = {};5385 httpRequest.url = url2;5386 5387 // Set Headers5388 httpRequest.headers['Content-Type'] = 'application/xml';5389 5390 // Send Request5391 return this.client.pipeline(httpRequest, function (err, response, body) {5392 if (err !== null && err !== undefined) {5393 return callback(err);5394 }5395 var statusCode = response.statusCode;5396 if (statusCode !== 200) {5397 var error = new Error(body);5398 error.statusCode = response.statusCode;5399 return callback(error);5400 }5401 5402 // Create Result5403 var result = null;5404 // Deserialize Response5405 if (statusCode === 200) {5406 var responseContent = body;5407 result = { publishProfiles: [] };5408 var options = {};5409 options.trim = false;5410 options.strict = false;5411 xml.parseString(responseContent, options, function (err2, responseDoc) {5412 if (err2 !== null && err2 !== undefined) {5413 return callback(err2);5414 }5415 5416 var publishDataSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'PUBLISHDATA', '');5417 if (publishDataSequenceElement !== null && publishDataSequenceElement !== undefined) {5418 for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, publishDataSequenceElement, 'PUBLISHPROFILE', '').length; loweredIndex1 = loweredIndex1 + 1) {5419 var publishDataElement = js2xml.getElements(responseDoc, publishDataSequenceElement, 'PUBLISHPROFILE', '')[loweredIndex1];5420 var publishProfileInstance = { databases: [] };5421 result.publishProfiles.push(publishProfileInstance);5422 5423 var profileNameAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'PROFILENAME', '');5424 if (profileNameAttribute !== null && profileNameAttribute !== undefined) {5425 publishProfileInstance.profileName = profileNameAttribute;5426 }5427 5428 var publishMethodAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'PUBLISHMETHOD', '');5429 if (publishMethodAttribute !== null && publishMethodAttribute !== undefined) {5430 publishProfileInstance.publishMethod = publishMethodAttribute;5431 }5432 5433 var publishUrlAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'PUBLISHURL', '');5434 if (publishUrlAttribute !== null && publishUrlAttribute !== undefined) {5435 publishProfileInstance.publishUrl = publishUrlAttribute;5436 }5437 5438 var msdeploySiteAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'MSDEPLOYSITE', '');5439 if (msdeploySiteAttribute !== null && msdeploySiteAttribute !== undefined) {5440 publishProfileInstance.mSDeploySite = msdeploySiteAttribute;5441 }5442 5443 var ftpPassiveModeAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'FTPPASSIVEMODE', '');5444 if (ftpPassiveModeAttribute !== null && ftpPassiveModeAttribute !== undefined && (ftpPassiveModeAttribute === null || ftpPassiveModeAttribute === undefined || ftpPassiveModeAttribute.length === 0) === false) {5445 publishProfileInstance.ftpPassiveMode = ftpPassiveModeAttribute === 'true';5446 }5447 5448 var userNameAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'USERNAME', '');5449 if (userNameAttribute !== null && userNameAttribute !== undefined) {5450 publishProfileInstance.userName = userNameAttribute;5451 }5452 5453 var userPWDAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'USERPWD', '');5454 if (userPWDAttribute !== null && userPWDAttribute !== undefined) {5455 publishProfileInstance.userPassword = userPWDAttribute;5456 }5457 5458 var destinationAppUrlAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'DESTINATIONAPPURL', '');5459 if (destinationAppUrlAttribute !== null && destinationAppUrlAttribute !== undefined) {5460 publishProfileInstance.destinationAppUri = destinationAppUrlAttribute;5461 }5462 5463 var sQLServerDBConnectionStringAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'SQLSERVERDBCONNECTIONSTRING', '');5464 if (sQLServerDBConnectionStringAttribute !== null && sQLServerDBConnectionStringAttribute !== undefined) {5465 publishProfileInstance.sqlServerConnectionString = sQLServerDBConnectionStringAttribute;5466 }5467 5468 var mySQLDBConnectionStringAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'MYSQLDBCONNECTIONSTRING', '');5469 if (mySQLDBConnectionStringAttribute !== null && mySQLDBConnectionStringAttribute !== undefined) {5470 publishProfileInstance.mySqlConnectionString = mySQLDBConnectionStringAttribute;5471 }5472 5473 var hostingProviderForumLinkAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'HOSTINGPROVIDERFORUMLINK', '');5474 if (hostingProviderForumLinkAttribute !== null && hostingProviderForumLinkAttribute !== undefined) {5475 publishProfileInstance.hostingProviderForumUri = hostingProviderForumLinkAttribute;5476 }5477 5478 var controlPanelLinkAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'CONTROLPANELLINK', '');5479 if (controlPanelLinkAttribute !== null && controlPanelLinkAttribute !== undefined) {5480 publishProfileInstance.controlPanelUri = controlPanelLinkAttribute;5481 }5482 5483 var databasesSequenceElement = js2xml.getElement(responseDoc, publishDataElement, 'DATABASES', '');5484 if (databasesSequenceElement !== null && databasesSequenceElement !== undefined) {5485 for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, databasesSequenceElement, 'ADD', '').length; loweredIndex2 = loweredIndex2 + 1) {5486 var databasesElement = js2xml.getElements(responseDoc, databasesSequenceElement, 'ADD', '')[loweredIndex2];5487 var addInstance = {};5488 publishProfileInstance.databases.push(addInstance);5489 5490 var nameAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'NAME', '');5491 if (nameAttribute !== null && nameAttribute !== undefined) {5492 addInstance.name = nameAttribute;5493 }5494 5495 var connectionStringAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'CONNECTIONSTRING', '');5496 if (connectionStringAttribute !== null && connectionStringAttribute !== undefined) {5497 addInstance.connectionString = connectionStringAttribute;5498 }5499 5500 var providerNameAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'PROVIDERNAME', '');5501 if (providerNameAttribute !== null && providerNameAttribute !== undefined) {5502 addInstance.providerName = providerNameAttribute;5503 }5504 5505 var typeAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'TYPE', '');5506 if (typeAttribute !== null && typeAttribute !== undefined) {5507 addInstance.type = typeAttribute;5508 }5509 }5510 }5511 }5512 }5513 5514 });5515 }5516 result.statusCode = statusCode;5517 result.requestId = response.headers['x-ms-request-id'];5518 5519 return callback(null, result);5520 });5521 };5522 5523 /**5524 * A web site repository is essentially a GIT repository that you can use to5525 * manage your web site content. By using GIT source control tools, you can5526 * push or pull version controlled changes to your site. You can create a5527 * repository for your web site by issuing an HTTP POST request, or retrieve5528 * information about the repository by using HTTP GET. (see5529 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for5530 * more information)5531 * 5532 * @param {string} resourceGroupName The name of the resource group.5533 * 5534 * @param {string} webSiteName The name of the web site.5535 * 5536 * @param {string} [slotName] The name of the slot.5537 * 5538 * @param {function} callback5539 * 5540 * @returns {Stream} The response stream.5541 */5542 WebSiteOperations.prototype.getRepository = function(resourceGroupName, webSiteName, slotName, callback) {5543 if (callback === null || callback === undefined) {5544 throw new Error('callback cannot be null.');5545 }5546 // Validate5547 if (resourceGroupName === null || resourceGroupName === undefined) {5548 return callback(new Error('resourceGroupName cannot be null.'));5549 }5550 if (webSiteName === null || webSiteName === undefined) {5551 return callback(new Error('webSiteName cannot be null.'));5552 }5553 5554 // Tracing5555 5556 // Construct URL5557 var url2 = '';5558 url2 = url2 + '/subscriptions/';5559 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5560 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5561 }5562 url2 = url2 + '/resourceGroups/';5563 url2 = url2 + encodeURIComponent(resourceGroupName);5564 url2 = url2 + '/providers/';5565 url2 = url2 + 'Microsoft.Web';5566 url2 = url2 + '/';5567 url2 = url2 + 'sites';5568 url2 = url2 + '/';5569 url2 = url2 + encodeURIComponent(webSiteName);5570 if (slotName !== null && slotName !== undefined) {5571 url2 = url2 + '/slots/' + encodeURIComponent(slotName);5572 }5573 url2 = url2 + '/repository';5574 var queryParameters = [];5575 queryParameters.push('api-version=2014-06-01');5576 if (queryParameters.length > 0) {5577 url2 = url2 + '?' + queryParameters.join('&');5578 }5579 var baseUrl = this.client.baseUri;5580 // Trim '/' character from the end of baseUrl and beginning of url.5581 if (baseUrl[baseUrl.length - 1] === '/') {5582 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);5583 }5584 if (url2[0] === '/') {5585 url2 = url2.substring(1);5586 }5587 url2 = baseUrl + '/' + url2;5588 url2 = url2.replace(' ', '%20');5589 5590 // Create HTTP transport objects5591 var httpRequest = new WebResource();5592 httpRequest.method = 'GET';5593 httpRequest.headers = {};5594 httpRequest.url = url2;5595 5596 // Set Headers5597 5598 // Send Request5599 return this.client.pipeline(httpRequest, function (err, response, body) {5600 if (err !== null && err !== undefined) {5601 return callback(err);5602 }5603 var statusCode = response.statusCode;5604 if (statusCode !== 200) {5605 var error = new Error(body);5606 error.statusCode = response.statusCode;5607 return callback(error);5608 }5609 5610 // Create Result5611 var result = null;5612 // Deserialize Response5613 if (statusCode === 200) {5614 var responseContent = body;5615 result = {};5616 var responseDoc = null;5617 if (responseContent) {5618 responseDoc = JSON.parse(responseContent);5619 }5620 5621 if (responseDoc !== null && responseDoc !== undefined) {5622 var uriValue = responseDoc['uri'];5623 if (uriValue !== null && uriValue !== undefined) {5624 var uriInstance = uriValue;5625 result.uri = uriInstance;5626 }5627 }5628 5629 }5630 result.statusCode = statusCode;5631 result.requestId = response.headers['x-ms-request-id'];5632 5633 return callback(null, result);5634 });5635 };5636 5637 /**5638 * Update list of app settings and connection strings which to be slot5639 * specific. E.g. settings in staging slots remain in staging after swap5640 * with production.5641 * 5642 * @param {string} resourceGroupName The name of the resource group5643 * 5644 * @param {string} webSiteName The name of the website5645 * 5646 * @param {function} callback5647 * 5648 * @returns {Stream} The response stream.5649 */5650 WebSiteOperations.prototype.getSlotConfigNames = function(resourceGroupName, webSiteName, callback) {5651 if (callback === null || callback === undefined) {5652 throw new Error('callback cannot be null.');5653 }5654 // Validate5655 if (resourceGroupName === null || resourceGroupName === undefined) {5656 return callback(new Error('resourceGroupName cannot be null.'));5657 }5658 if (webSiteName === null || webSiteName === undefined) {5659 return callback(new Error('webSiteName cannot be null.'));5660 }5661 5662 // Tracing5663 5664 // Construct URL5665 var url2 = '';5666 url2 = url2 + '/subscriptions/';5667 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5668 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5669 }5670 url2 = url2 + '/resourceGroups/';5671 url2 = url2 + encodeURIComponent(resourceGroupName);5672 url2 = url2 + '/providers/';5673 url2 = url2 + 'Microsoft.Web';5674 url2 = url2 + '/';5675 url2 = url2 + 'sites';5676 url2 = url2 + '/';5677 url2 = url2 + encodeURIComponent(webSiteName);5678 url2 = url2 + '/slotConfigNames';5679 var queryParameters = [];5680 queryParameters.push('api-version=2014-06-01');5681 if (queryParameters.length > 0) {5682 url2 = url2 + '?' + queryParameters.join('&');5683 }5684 var baseUrl = this.client.baseUri;5685 // Trim '/' character from the end of baseUrl and beginning of url.5686 if (baseUrl[baseUrl.length - 1] === '/') {5687 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);5688 }5689 if (url2[0] === '/') {5690 url2 = url2.substring(1);5691 }5692 url2 = baseUrl + '/' + url2;5693 url2 = url2.replace(' ', '%20');5694 5695 // Create HTTP transport objects5696 var httpRequest = new WebResource();5697 httpRequest.method = 'GET';5698 httpRequest.headers = {};5699 httpRequest.url = url2;5700 5701 // Set Headers5702 httpRequest.headers['accept'] = 'application/json';5703 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';5704 5705 // Send Request5706 return this.client.pipeline(httpRequest, function (err, response, body) {5707 if (err !== null && err !== undefined) {5708 return callback(err);5709 }5710 var statusCode = response.statusCode;5711 if (statusCode !== 200) {5712 var error = new Error(body);5713 error.statusCode = response.statusCode;5714 return callback(error);5715 }5716 5717 // Create Result5718 var result = null;5719 // Deserialize Response5720 if (statusCode === 200) {5721 var responseContent = body;5722 result = {};5723 var responseDoc = null;5724 if (responseContent) {5725 responseDoc = JSON.parse(responseContent);5726 }5727 5728 if (responseDoc !== null && responseDoc !== undefined) {5729 var resourceInstance = { tags: {} };5730 result.resource = resourceInstance;5731 5732 var propertiesValue = responseDoc['properties'];5733 if (propertiesValue !== null && propertiesValue !== undefined) {5734 var propertiesInstance = { appSettingNames: [], connectionStringNames: [] };5735 resourceInstance.properties = propertiesInstance;5736 5737 var connectionStringNamesArray = propertiesValue['connectionStringNames'];5738 if (connectionStringNamesArray !== null && connectionStringNamesArray !== undefined) {5739 for (var loweredIndex1 = 0; loweredIndex1 < connectionStringNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {5740 var connectionStringNamesValue = connectionStringNamesArray[loweredIndex1];5741 propertiesInstance.connectionStringNames.push(connectionStringNamesValue);5742 }5743 }5744 5745 var appSettingNamesArray = propertiesValue['appSettingNames'];5746 if (appSettingNamesArray !== null && appSettingNamesArray !== undefined) {5747 for (var loweredIndex2 = 0; loweredIndex2 < appSettingNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {5748 var appSettingNamesValue = appSettingNamesArray[loweredIndex2];5749 propertiesInstance.appSettingNames.push(appSettingNamesValue);5750 }5751 }5752 }5753 5754 var idValue = responseDoc['id'];5755 if (idValue !== null && idValue !== undefined) {5756 var idInstance = idValue;5757 resourceInstance.id = idInstance;5758 }5759 5760 var nameValue = responseDoc['name'];5761 if (nameValue !== null && nameValue !== undefined) {5762 var nameInstance = nameValue;5763 resourceInstance.name = nameInstance;5764 }5765 5766 var locationValue = responseDoc['location'];5767 if (locationValue !== null && locationValue !== undefined) {5768 var locationInstance = locationValue;5769 resourceInstance.location = locationInstance;5770 }5771 5772 var tagsSequenceElement = responseDoc['tags'];5773 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {5774 for (var property in tagsSequenceElement) {5775 var tagsKey = property;5776 var tagsValue = tagsSequenceElement[property];5777 resourceInstance.tags[tagsKey] = tagsValue;5778 }5779 }5780 5781 var typeValue = responseDoc['type'];5782 if (typeValue !== null && typeValue !== undefined) {5783 var typeInstance = typeValue;5784 resourceInstance.type = typeInstance;5785 }5786 }5787 5788 }5789 result.statusCode = statusCode;5790 result.requestId = response.headers['x-ms-request-id'];5791 5792 return callback(null, result);5793 });5794 };5795 5796 /**5797 * Get a web site's current usage metrics. The metrics returned include CPU5798 * Time, Data In, Data Out, Local bytes read, Local bytes written, Network5799 * bytes read, Network bytes written, WP stop requests, Memory Usage, CPU5800 * Time - Minute Limit, and File System Storage. (see5801 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166991.aspx for5802 * more information)5803 * 5804 * @param {string} resourceGroupName The name of the resource group.5805 * 5806 * @param {string} webSiteName The name of the web site.5807 * 5808 * @param {string} [slotName] The name of the slot.5809 * 5810 * @param {function} callback5811 * 5812 * @returns {Stream} The response stream.5813 */5814 WebSiteOperations.prototype.getUsageMetrics = function(resourceGroupName, webSiteName, slotName, callback) {5815 if (callback === null || callback === undefined) {5816 throw new Error('callback cannot be null.');5817 }5818 // Validate5819 if (resourceGroupName === null || resourceGroupName === undefined) {5820 return callback(new Error('resourceGroupName cannot be null.'));5821 }5822 if (webSiteName === null || webSiteName === undefined) {5823 return callback(new Error('webSiteName cannot be null.'));5824 }5825 5826 // Tracing5827 5828 // Construct URL5829 var url2 = '';5830 url2 = url2 + '/subscriptions/';5831 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5832 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5833 }5834 url2 = url2 + '/resourceGroups/';5835 url2 = url2 + encodeURIComponent(resourceGroupName);5836 url2 = url2 + '/providers/';5837 url2 = url2 + 'Microsoft.Web';5838 url2 = url2 + '/';5839 url2 = url2 + 'sites';5840 url2 = url2 + '/';5841 url2 = url2 + encodeURIComponent(webSiteName);5842 if (slotName !== null && slotName !== undefined) {5843 url2 = url2 + '/slots/' + encodeURIComponent(slotName);5844 }5845 url2 = url2 + '/usages';5846 var queryParameters = [];5847 queryParameters.push('api-version=2014-06-01');5848 if (queryParameters.length > 0) {5849 url2 = url2 + '?' + queryParameters.join('&');5850 }5851 var baseUrl = this.client.baseUri;5852 // Trim '/' character from the end of baseUrl and beginning of url.5853 if (baseUrl[baseUrl.length - 1] === '/') {5854 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);5855 }5856 if (url2[0] === '/') {5857 url2 = url2.substring(1);5858 }5859 url2 = baseUrl + '/' + url2;5860 url2 = url2.replace(' ', '%20');5861 5862 // Create HTTP transport objects5863 var httpRequest = new WebResource();5864 httpRequest.method = 'GET';5865 httpRequest.headers = {};5866 httpRequest.url = url2;5867 5868 // Set Headers5869 5870 // Send Request5871 return this.client.pipeline(httpRequest, function (err, response, body) {5872 if (err !== null && err !== undefined) {5873 return callback(err);5874 }5875 var statusCode = response.statusCode;5876 if (statusCode !== 200) {5877 var error = new Error(body);5878 error.statusCode = response.statusCode;5879 return callback(error);5880 }5881 5882 // Create Result5883 var result = null;5884 // Deserialize Response5885 if (statusCode === 200) {5886 var responseContent = body;5887 result = { usageMetrics: [] };5888 var responseDoc = null;5889 if (responseContent) {5890 responseDoc = JSON.parse(responseContent);5891 }5892 5893 var usagesValue = responseDoc['usages'];5894 if (usagesValue !== null && usagesValue !== undefined) {5895 var usagesInstance = { usageMetrics: [] };5896 5897 var usageMetricsArray = usagesValue;5898 if (usageMetricsArray !== null && usageMetricsArray !== undefined) {5899 for (var loweredIndex1 = 0; loweredIndex1 < usageMetricsArray.length; loweredIndex1 = loweredIndex1 + 1) {5900 var usageMetricsValue = usageMetricsArray[loweredIndex1];5901 var usageInstance = {};5902 usagesInstance.usageMetrics.push(usageInstance);5903 5904 var currentValueValue = usageMetricsValue['currentValue'];5905 if (currentValueValue !== null && currentValueValue !== undefined) {5906 var currentValueInstance = currentValueValue;5907 usageInstance.currentValue = currentValueInstance;5908 }5909 5910 var displayNameValue = usageMetricsValue['displayName'];5911 if (displayNameValue !== null && displayNameValue !== undefined) {5912 var displayNameInstance = displayNameValue;5913 usageInstance.displayName = displayNameInstance;5914 }5915 5916 var limitValue = usageMetricsValue['limit'];5917 if (limitValue !== null && limitValue !== undefined) {5918 var limitInstance = limitValue;5919 usageInstance.limit = limitInstance;5920 }5921 5922 var nameValue = usageMetricsValue['name'];5923 if (nameValue !== null && nameValue !== undefined) {5924 var nameInstance = nameValue;5925 usageInstance.name = nameInstance;5926 }5927 5928 var nextResetTimeValue = usageMetricsValue['nextResetTime'];5929 if (nextResetTimeValue !== null && nextResetTimeValue !== undefined) {5930 var nextResetTimeInstance = nextResetTimeValue;5931 usageInstance.nextResetTime = nextResetTimeInstance;5932 }5933 5934 var resourceNameValue = usageMetricsValue['resourceName'];5935 if (resourceNameValue !== null && resourceNameValue !== undefined) {5936 var resourceNameInstance = resourceNameValue;5937 usageInstance.resourceName = resourceNameInstance;5938 }5939 5940 var unitValue = usageMetricsValue['unit'];5941 if (unitValue !== null && unitValue !== undefined) {5942 var unitInstance = unitValue;5943 usageInstance.unit = unitInstance;5944 }5945 }5946 }5947 }5948 5949 }5950 result.statusCode = statusCode;5951 result.requestId = response.headers['x-ms-request-id'];5952 5953 return callback(null, result);5954 });5955 };5956 5957 /**5958 * List the Web Sites in a resource group.5959 * 5960 * @param {string} resourceGroupName The name of the resource group.5961 * 5962 * @param {string} [webSiteName] The name of the web site.5963 * 5964 * @param {WebSiteListParameters} [parametersOrCallback] Additional5965 * parameters.5966 * 5967 * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list5968 * of the names of any addtional parameters to return.5969 * 5970 * @param {function} callback5971 * 5972 * @returns {Stream} The response stream.5973 */5974 WebSiteOperations.prototype.list = function(resourceGroupName, webSiteName, parametersOrCallback, callback) {5975 var parameters = parametersOrCallback;5976 if (_.isFunction(parameters)) {5977 callback = parameters;5978 parameters = null;5979 }5980 if (callback === null || callback === undefined) {5981 throw new Error('callback cannot be null.');5982 }5983 // Validate5984 if (resourceGroupName === null || resourceGroupName === undefined) {5985 return callback(new Error('resourceGroupName cannot be null.'));5986 }5987 5988 // Tracing5989 5990 // Construct URL5991 var url2 = '';5992 url2 = url2 + '/subscriptions/';5993 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {5994 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);5995 }5996 url2 = url2 + '/resourceGroups/';5997 url2 = url2 + encodeURIComponent(resourceGroupName);5998 url2 = url2 + '/providers/';5999 url2 = url2 + 'Microsoft.Web';6000 url2 = url2 + '/';6001 url2 = url2 + 'sites';6002 if (webSiteName !== null && webSiteName !== undefined) {6003 url2 = url2 + '/' + encodeURIComponent(webSiteName) + '/slots/';6004 }6005 var queryParameters = [];6006 queryParameters.push('api-version=2014-06-01');6007 if (parameters !== null && parameters !== undefined && parameters.propertiesToInclude !== null && parameters.propertiesToInclude !== undefined && parameters.propertiesToInclude.length > 0) {6008 queryParameters.push('propertiesToInclude=' + encodeURIComponent(parameters.propertiesToInclude.join(',')));6009 }6010 if (queryParameters.length > 0) {6011 url2 = url2 + '?' + queryParameters.join('&');6012 }6013 var baseUrl = this.client.baseUri;6014 // Trim '/' character from the end of baseUrl and beginning of url.6015 if (baseUrl[baseUrl.length - 1] === '/') {6016 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);6017 }6018 if (url2[0] === '/') {6019 url2 = url2.substring(1);6020 }6021 url2 = baseUrl + '/' + url2;6022 url2 = url2.replace(' ', '%20');6023 6024 // Create HTTP transport objects6025 var httpRequest = new WebResource();6026 httpRequest.method = 'GET';6027 httpRequest.headers = {};6028 httpRequest.url = url2;6029 6030 // Set Headers6031 6032 // Send Request6033 return this.client.pipeline(httpRequest, function (err, response, body) {6034 if (err !== null && err !== undefined) {6035 return callback(err);6036 }6037 var statusCode = response.statusCode;6038 if (statusCode !== 200) {6039 var error = new Error(body);6040 error.statusCode = response.statusCode;6041 return callback(error);6042 }6043 6044 // Create Result6045 var result = null;6046 // Deserialize Response6047 if (statusCode === 200) {6048 var responseContent = body;6049 result = { webSites: [] };6050 var responseDoc = null;6051 if (responseContent) {6052 responseDoc = JSON.parse(responseContent);6053 }6054 6055 if (responseDoc !== null && responseDoc !== undefined) {6056 var valueArray = responseDoc['value'];6057 if (valueArray !== null && valueArray !== undefined) {6058 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {6059 var valueValue = valueArray[loweredIndex1];6060 var webSiteInstance = { tags: {} };6061 result.webSites.push(webSiteInstance);6062 6063 var propertiesValue = valueValue['properties'];6064 if (propertiesValue !== null && propertiesValue !== undefined) {6065 var propertiesInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [], trafficManagerHostNames: [] };6066 webSiteInstance.properties = propertiesInstance;6067 6068 var adminEnabledValue = propertiesValue['adminEnabled'];6069 if (adminEnabledValue !== null && adminEnabledValue !== undefined) {6070 var adminEnabledInstance = adminEnabledValue;6071 propertiesInstance.adminEnabled = adminEnabledInstance;6072 }6073 6074 var availabilityStateValue = propertiesValue['availabilityState'];6075 if (availabilityStateValue !== null && availabilityStateValue !== undefined) {6076 var availabilityStateInstance = availabilityStateValue;6077 propertiesInstance.availabilityState = availabilityStateInstance;6078 }6079 6080 var enabledValue = propertiesValue['enabled'];6081 if (enabledValue !== null && enabledValue !== undefined) {6082 var enabledInstance = enabledValue;6083 propertiesInstance.enabled = enabledInstance;6084 }6085 6086 var enabledHostNamesArray = propertiesValue['enabledHostNames'];6087 if (enabledHostNamesArray !== null && enabledHostNamesArray !== undefined) {6088 for (var loweredIndex2 = 0; loweredIndex2 < enabledHostNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {6089 var enabledHostNamesValue = enabledHostNamesArray[loweredIndex2];6090 propertiesInstance.enabledHostNames.push(enabledHostNamesValue);6091 }6092 }6093 6094 var hostNameSslStatesArray = propertiesValue['hostNameSslStates'];6095 if (hostNameSslStatesArray !== null && hostNameSslStatesArray !== undefined) {6096 for (var loweredIndex3 = 0; loweredIndex3 < hostNameSslStatesArray.length; loweredIndex3 = loweredIndex3 + 1) {6097 var hostNameSslStatesValue = hostNameSslStatesArray[loweredIndex3];6098 var webSiteHostNameSslStateInstance = {};6099 propertiesInstance.hostNameSslStates.push(webSiteHostNameSslStateInstance);6100 6101 var nameValue = hostNameSslStatesValue['name'];6102 if (nameValue !== null && nameValue !== undefined) {6103 var nameInstance = nameValue;6104 webSiteHostNameSslStateInstance.name = nameInstance;6105 }6106 6107 var sslStateValue = hostNameSslStatesValue['sslState'];6108 if (sslStateValue !== null && sslStateValue !== undefined) {6109 var sslStateInstance = sslStateValue;6110 webSiteHostNameSslStateInstance.sslState = sslStateInstance;6111 }6112 6113 var thumbprintValue = hostNameSslStatesValue['thumbprint'];6114 if (thumbprintValue !== null && thumbprintValue !== undefined) {6115 var thumbprintInstance = thumbprintValue;6116 webSiteHostNameSslStateInstance.thumbprint = thumbprintInstance;6117 }6118 6119 var virtualIPValue = hostNameSslStatesValue['virtualIP'];6120 if (virtualIPValue !== null && virtualIPValue !== undefined) {6121 var virtualIPInstance = virtualIPValue;6122 webSiteHostNameSslStateInstance.virtualIP = virtualIPInstance;6123 }6124 6125 var ipBasedSslResultValue = hostNameSslStatesValue['ipBasedSslResult'];6126 if (ipBasedSslResultValue !== null && ipBasedSslResultValue !== undefined) {6127 var ipBasedSslResultInstance = ipBasedSslResultValue;6128 webSiteHostNameSslStateInstance.ipBasedSslResult = ipBasedSslResultInstance;6129 }6130 6131 var toUpdateValue = hostNameSslStatesValue['toUpdate'];6132 if (toUpdateValue !== null && toUpdateValue !== undefined) {6133 var toUpdateInstance = toUpdateValue;6134 webSiteHostNameSslStateInstance.toUpdate = toUpdateInstance;6135 }6136 6137 var toUpdateIpBasedSslValue = hostNameSslStatesValue['toUpdateIpBasedSsl'];6138 if (toUpdateIpBasedSslValue !== null && toUpdateIpBasedSslValue !== undefined) {6139 var toUpdateIpBasedSslInstance = toUpdateIpBasedSslValue;6140 webSiteHostNameSslStateInstance.toUpdateIpBasedSsl = toUpdateIpBasedSslInstance;6141 }6142 }6143 }6144 6145 var hostNamesArray = propertiesValue['hostNames'];6146 if (hostNamesArray !== null && hostNamesArray !== undefined) {6147 for (var loweredIndex4 = 0; loweredIndex4 < hostNamesArray.length; loweredIndex4 = loweredIndex4 + 1) {6148 var hostNamesValue = hostNamesArray[loweredIndex4];6149 propertiesInstance.hostNames.push(hostNamesValue);6150 }6151 }6152 6153 var lastModifiedTimeUtcValue = propertiesValue['lastModifiedTimeUtc'];6154 if (lastModifiedTimeUtcValue !== null && lastModifiedTimeUtcValue !== undefined) {6155 var lastModifiedTimeUtcInstance = lastModifiedTimeUtcValue;6156 propertiesInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;6157 }6158 6159 var repositorySiteNameValue = propertiesValue['repositorySiteName'];6160 if (repositorySiteNameValue !== null && repositorySiteNameValue !== undefined) {6161 var repositorySiteNameInstance = repositorySiteNameValue;6162 propertiesInstance.repositorySiteName = repositorySiteNameInstance;6163 }6164 6165 var runtimeAvailabilityStateValue = propertiesValue['runtimeAvailabilityState'];6166 if (runtimeAvailabilityStateValue !== null && runtimeAvailabilityStateValue !== undefined) {6167 var runtimeAvailabilityStateInstance = runtimeAvailabilityStateValue;6168 propertiesInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;6169 }6170 6171 var trafficManagerHostNamesArray = propertiesValue['trafficManagerHostNames'];6172 if (trafficManagerHostNamesArray !== null && trafficManagerHostNamesArray !== undefined) {6173 for (var loweredIndex5 = 0; loweredIndex5 < trafficManagerHostNamesArray.length; loweredIndex5 = loweredIndex5 + 1) {6174 var trafficManagerHostNamesValue = trafficManagerHostNamesArray[loweredIndex5];6175 propertiesInstance.trafficManagerHostNames.push(trafficManagerHostNamesValue);6176 }6177 }6178 6179 var selfLinkValue = propertiesValue['selfLink'];6180 if (selfLinkValue !== null && selfLinkValue !== undefined) {6181 var selfLinkInstance = selfLinkValue;6182 propertiesInstance.uri = selfLinkInstance;6183 }6184 6185 var serverFarmValue = propertiesValue['serverFarm'];6186 if (serverFarmValue !== null && serverFarmValue !== undefined) {6187 var serverFarmInstance = serverFarmValue;6188 propertiesInstance.serverFarm = serverFarmInstance;6189 }6190 6191 var skuValue = propertiesValue['sku'];6192 if (skuValue !== null && skuValue !== undefined) {6193 var skuInstance = skuValue;6194 propertiesInstance.sku = skuInstance;6195 }6196 6197 var sitePropertiesValue = propertiesValue['siteProperties'];6198 if (sitePropertiesValue !== null && sitePropertiesValue !== undefined) {6199 var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };6200 propertiesInstance.properties = sitePropertiesInstance;6201 6202 var appSettingsSequenceElement = sitePropertiesValue['appSettings'];6203 if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {6204 for (var property in appSettingsSequenceElement) {6205 var appSettingsKey = property;6206 var appSettingsValue = appSettingsSequenceElement[property];6207 sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;6208 }6209 }6210 6211 var metadataSequenceElement = sitePropertiesValue['metadata'];6212 if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {6213 for (var property2 in metadataSequenceElement) {6214 var metadataKey = property2;6215 var metadataValue = metadataSequenceElement[property2];6216 sitePropertiesInstance.metadata[metadataKey] = metadataValue;6217 }6218 }6219 6220 var propertiesSequenceElement = sitePropertiesValue['properties'];6221 if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {6222 for (var property3 in propertiesSequenceElement) {6223 var propertiesKey = property3;6224 var propertiesValue2 = propertiesSequenceElement[property3];6225 sitePropertiesInstance.properties[propertiesKey] = propertiesValue2;6226 }6227 }6228 }6229 6230 var stateValue = propertiesValue['state'];6231 if (stateValue !== null && stateValue !== undefined) {6232 var stateInstance = stateValue;6233 propertiesInstance.state = stateInstance;6234 }6235 6236 var usageStateValue = propertiesValue['usageState'];6237 if (usageStateValue !== null && usageStateValue !== undefined) {6238 var usageStateInstance = usageStateValue;6239 propertiesInstance.usageState = usageStateInstance;6240 }6241 6242 var webSpaceValue = propertiesValue['webSpace'];6243 if (webSpaceValue !== null && webSpaceValue !== undefined) {6244 var webSpaceInstance = webSpaceValue;6245 propertiesInstance.webSpace = webSpaceInstance;6246 }6247 6248 var provisioningStateValue = propertiesValue['provisioningState'];6249 if (provisioningStateValue !== null && provisioningStateValue !== undefined) {6250 var provisioningStateInstance = provisioningStateValue;6251 propertiesInstance.provisioningState = provisioningStateInstance;6252 }6253 }6254 6255 var idValue = valueValue['id'];6256 if (idValue !== null && idValue !== undefined) {6257 var idInstance = idValue;6258 webSiteInstance.id = idInstance;6259 }6260 6261 var nameValue2 = valueValue['name'];6262 if (nameValue2 !== null && nameValue2 !== undefined) {6263 var nameInstance2 = nameValue2;6264 webSiteInstance.name = nameInstance2;6265 }6266 6267 var locationValue = valueValue['location'];6268 if (locationValue !== null && locationValue !== undefined) {6269 var locationInstance = locationValue;6270 webSiteInstance.location = locationInstance;6271 }6272 6273 var tagsSequenceElement = valueValue['tags'];6274 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {6275 for (var property4 in tagsSequenceElement) {6276 var tagsKey = property4;6277 var tagsValue = tagsSequenceElement[property4];6278 webSiteInstance.tags[tagsKey] = tagsValue;6279 }6280 }6281 6282 var typeValue = valueValue['type'];6283 if (typeValue !== null && typeValue !== undefined) {6284 var typeInstance = typeValue;6285 webSiteInstance.type = typeInstance;6286 }6287 }6288 }6289 }6290 6291 }6292 result.statusCode = statusCode;6293 result.requestId = response.headers['x-ms-request-id'];6294 6295 return callback(null, result);6296 });6297 };6298 6299 /**6300 * Returns list of all backups which are tracked by the system.6301 * 6302 * @param {string} resourceGroupName The name of the resource group.6303 * 6304 * @param {string} webSiteName The name of the web site.6305 * 6306 * @param {string} [slotName] The name of the slot.6307 * 6308 * @param {function} callback6309 * 6310 * @returns {Stream} The response stream.6311 */6312 WebSiteOperations.prototype.listBackups = function(resourceGroupName, webSiteName, slotName, callback) {6313 if (callback === null || callback === undefined) {6314 throw new Error('callback cannot be null.');6315 }6316 // Validate6317 if (resourceGroupName === null || resourceGroupName === undefined) {6318 return callback(new Error('resourceGroupName cannot be null.'));6319 }6320 if (webSiteName === null || webSiteName === undefined) {6321 return callback(new Error('webSiteName cannot be null.'));6322 }6323 6324 // Tracing6325 6326 // Construct URL6327 var url2 = '';6328 url2 = url2 + '/subscriptions/';6329 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {6330 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);6331 }6332 url2 = url2 + '/resourceGroups/';6333 url2 = url2 + encodeURIComponent(resourceGroupName);6334 url2 = url2 + '/providers/';6335 url2 = url2 + 'Microsoft.Web';6336 url2 = url2 + '/';6337 url2 = url2 + 'sites';6338 url2 = url2 + '/';6339 url2 = url2 + encodeURIComponent(webSiteName);6340 if (slotName !== null && slotName !== undefined) {6341 url2 = url2 + '/slots/' + encodeURIComponent(slotName);6342 }6343 url2 = url2 + '/restore';6344 var queryParameters = [];6345 queryParameters.push('api-version=2014-06-01');6346 if (queryParameters.length > 0) {6347 url2 = url2 + '?' + queryParameters.join('&');6348 }6349 var baseUrl = this.client.baseUri;6350 // Trim '/' character from the end of baseUrl and beginning of url.6351 if (baseUrl[baseUrl.length - 1] === '/') {6352 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);6353 }6354 if (url2[0] === '/') {6355 url2 = url2.substring(1);6356 }6357 url2 = baseUrl + '/' + url2;6358 url2 = url2.replace(' ', '%20');6359 6360 // Create HTTP transport objects6361 var httpRequest = new WebResource();6362 httpRequest.method = 'GET';6363 httpRequest.headers = {};6364 httpRequest.url = url2;6365 6366 // Set Headers6367 httpRequest.headers['x-ms-version'] = '2014-06-01';6368 6369 // Send Request6370 return this.client.pipeline(httpRequest, function (err, response, body) {6371 if (err !== null && err !== undefined) {6372 return callback(err);6373 }6374 var statusCode = response.statusCode;6375 if (statusCode !== 200) {6376 var error = new Error(body);6377 error.statusCode = response.statusCode;6378 return callback(error);6379 }6380 6381 // Create Result6382 var result = null;6383 // Deserialize Response6384 if (statusCode === 200) {6385 var responseContent = body;6386 result = {};6387 var responseDoc = null;6388 if (responseContent) {6389 responseDoc = JSON.parse(responseContent);6390 }6391 6392 if (responseDoc !== null && responseDoc !== undefined) {6393 var backupListInstance = { properties: [], tags: {} };6394 result.backupList = backupListInstance;6395 6396 var propertiesArray = responseDoc['properties'];6397 if (propertiesArray !== null && propertiesArray !== undefined) {6398 for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {6399 var propertiesValue = propertiesArray[loweredIndex1];6400 var backupItemInstance = { databases: [] };6401 backupListInstance.properties.push(backupItemInstance);6402 6403 var storageAccountUrlValue = propertiesValue['storageAccountUrl'];6404 if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {6405 var storageAccountUrlInstance = storageAccountUrlValue;6406 backupItemInstance.storageAccountUrl = storageAccountUrlInstance;6407 }6408 6409 var blobNameValue = propertiesValue['blobName'];6410 if (blobNameValue !== null && blobNameValue !== undefined) {6411 var blobNameInstance = blobNameValue;6412 backupItemInstance.blobName = blobNameInstance;6413 }6414 6415 var nameValue = propertiesValue['name'];6416 if (nameValue !== null && nameValue !== undefined) {6417 var nameInstance = nameValue;6418 backupItemInstance.name = nameInstance;6419 }6420 6421 var statusValue = propertiesValue['status'];6422 if (statusValue !== null && statusValue !== undefined) {6423 var statusInstance = statusValue;6424 backupItemInstance.status = statusInstance;6425 }6426 6427 var sizeInBytesValue = propertiesValue['sizeInBytes'];6428 if (sizeInBytesValue !== null && sizeInBytesValue !== undefined) {6429 var sizeInBytesInstance = sizeInBytesValue;6430 backupItemInstance.sizeInBytes = sizeInBytesInstance;6431 }6432 6433 var createdValue = propertiesValue['created'];6434 if (createdValue !== null && createdValue !== undefined) {6435 var createdInstance = createdValue;6436 backupItemInstance.created = createdInstance;6437 }6438 6439 var logValue = propertiesValue['log'];6440 if (logValue !== null && logValue !== undefined) {6441 var logInstance = logValue;6442 backupItemInstance.log = logInstance;6443 }6444 6445 var databasesArray = propertiesValue['databases'];6446 if (databasesArray !== null && databasesArray !== undefined) {6447 for (var loweredIndex2 = 0; loweredIndex2 < databasesArray.length; loweredIndex2 = loweredIndex2 + 1) {6448 var databasesValue = databasesArray[loweredIndex2];6449 var databaseBackupSettingInstance = {};6450 backupItemInstance.databases.push(databaseBackupSettingInstance);6451 6452 var connectionStringValue = databasesValue['connectionString'];6453 if (connectionStringValue !== null && connectionStringValue !== undefined) {6454 var connectionStringInstance = connectionStringValue;6455 databaseBackupSettingInstance.connectionString = connectionStringInstance;6456 }6457 6458 var connectionStringNameValue = databasesValue['connectionStringName'];6459 if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {6460 var connectionStringNameInstance = connectionStringNameValue;6461 databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;6462 }6463 6464 var databaseTypeValue = databasesValue['databaseType'];6465 if (databaseTypeValue !== null && databaseTypeValue !== undefined) {6466 var databaseTypeInstance = databaseTypeValue;6467 databaseBackupSettingInstance.databaseType = databaseTypeInstance;6468 }6469 6470 var nameValue2 = databasesValue['name'];6471 if (nameValue2 !== null && nameValue2 !== undefined) {6472 var nameInstance2 = nameValue2;6473 databaseBackupSettingInstance.name = nameInstance2;6474 }6475 }6476 }6477 6478 var scheduledValue = propertiesValue['scheduled'];6479 if (scheduledValue !== null && scheduledValue !== undefined) {6480 var scheduledInstance = scheduledValue;6481 backupItemInstance.scheduled = scheduledInstance;6482 }6483 6484 var lastRestoreTimeStampValue = propertiesValue['lastRestoreTimeStamp'];6485 if (lastRestoreTimeStampValue !== null && lastRestoreTimeStampValue !== undefined) {6486 var lastRestoreTimeStampInstance = lastRestoreTimeStampValue;6487 backupItemInstance.lastRestoreTimeStamp = lastRestoreTimeStampInstance;6488 }6489 6490 var finishedTimeStampValue = propertiesValue['finishedTimeStamp'];6491 if (finishedTimeStampValue !== null && finishedTimeStampValue !== undefined) {6492 var finishedTimeStampInstance = finishedTimeStampValue;6493 backupItemInstance.finishedTimeStamp = finishedTimeStampInstance;6494 }6495 6496 var correlationIdValue = propertiesValue['correlationId'];6497 if (correlationIdValue !== null && correlationIdValue !== undefined) {6498 var correlationIdInstance = correlationIdValue;6499 backupItemInstance.correlationId = correlationIdInstance;6500 }6501 }6502 }6503 6504 var idValue = responseDoc['id'];6505 if (idValue !== null && idValue !== undefined) {6506 var idInstance = idValue;6507 backupListInstance.id = idInstance;6508 }6509 6510 var nameValue3 = responseDoc['name'];6511 if (nameValue3 !== null && nameValue3 !== undefined) {6512 var nameInstance3 = nameValue3;6513 backupListInstance.name = nameInstance3;6514 }6515 6516 var locationValue = responseDoc['location'];6517 if (locationValue !== null && locationValue !== undefined) {6518 var locationInstance = locationValue;6519 backupListInstance.location = locationInstance;6520 }6521 6522 var tagsSequenceElement = responseDoc['tags'];6523 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {6524 for (var property in tagsSequenceElement) {6525 var tagsKey = property;6526 var tagsValue = tagsSequenceElement[property];6527 backupListInstance.tags[tagsKey] = tagsValue;6528 }6529 }6530 6531 var typeValue = responseDoc['type'];6532 if (typeValue !== null && typeValue !== undefined) {6533 var typeInstance = typeValue;6534 backupListInstance.type = typeInstance;6535 }6536 }6537 6538 }6539 result.statusCode = statusCode;6540 result.requestId = response.headers['x-ms-request-id'];6541 6542 return callback(null, result);6543 });6544 };6545 6546 /**6547 * Restart the web site.6548 * 6549 * @param {string} resourceGroupName The name of the resource group6550 * 6551 * @param {string} webSiteName Name of website6552 * 6553 * @param {string} [slotName] The name of the slot.6554 * 6555 * @param {function} callback6556 * 6557 * @returns {Stream} The response stream.6558 */6559 WebSiteOperations.prototype.restart = function(resourceGroupName, webSiteName, slotName, callback) {6560 if (callback === null || callback === undefined) {6561 throw new Error('callback cannot be null.');6562 }6563 // Validate6564 if (resourceGroupName === null || resourceGroupName === undefined) {6565 return callback(new Error('resourceGroupName cannot be null.'));6566 }6567 if (webSiteName === null || webSiteName === undefined) {6568 return callback(new Error('webSiteName cannot be null.'));6569 }6570 6571 // Tracing6572 6573 // Construct URL6574 var url2 = '';6575 url2 = url2 + '/subscriptions/';6576 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {6577 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);6578 }6579 url2 = url2 + '/resourceGroups/';6580 url2 = url2 + encodeURIComponent(resourceGroupName);6581 url2 = url2 + '/providers/';6582 url2 = url2 + 'Microsoft.Web';6583 url2 = url2 + '/';6584 url2 = url2 + 'sites';6585 url2 = url2 + '/';6586 url2 = url2 + encodeURIComponent(webSiteName);6587 if (slotName !== null && slotName !== undefined) {6588 url2 = url2 + '/slots/' + encodeURIComponent(slotName);6589 }6590 url2 = url2 + '/restart';6591 var queryParameters = [];6592 queryParameters.push('api-version=2014-06-01');6593 if (queryParameters.length > 0) {6594 url2 = url2 + '?' + queryParameters.join('&');6595 }6596 var baseUrl = this.client.baseUri;6597 // Trim '/' character from the end of baseUrl and beginning of url.6598 if (baseUrl[baseUrl.length - 1] === '/') {6599 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);6600 }6601 if (url2[0] === '/') {6602 url2 = url2.substring(1);6603 }6604 url2 = baseUrl + '/' + url2;6605 url2 = url2.replace(' ', '%20');6606 6607 // Create HTTP transport objects6608 var httpRequest = new WebResource();6609 httpRequest.method = 'POST';6610 httpRequest.headers = {};6611 httpRequest.url = url2;6612 6613 // Set Headers6614 httpRequest.headers['Content-Length'] = '0';6615 6616 // Send Request6617 return this.client.pipeline(httpRequest, function (err, response, body) {6618 if (err !== null && err !== undefined) {6619 return callback(err);6620 }6621 var statusCode = response.statusCode;6622 if (statusCode !== 200) {6623 var error = new Error(body);6624 error.statusCode = response.statusCode;6625 return callback(error);6626 }6627 6628 // Create Result6629 var result = null;6630 // Deserialize Response6631 result = {};6632 result.statusCode = statusCode;6633 result.requestId = response.headers['x-ms-request-id'];6634 6635 return callback(null, result);6636 });6637 };6638 6639 /**6640 * Restores a site to either a new site or existing site (Overwrite flag has6641 * to be set to true for that).6642 * 6643 * @param {string} resourceGroupName The name of the web space.6644 * 6645 * @param {string} webSiteName The name of the web site.6646 * 6647 * @param {string} [slotName] The name of the slot.6648 * 6649 * @param {RestoreRequestEnvelope} restoreRequestEnvelope A restore request.6650 * 6651 * @param {RestoreRequest} [restoreRequestEnvelope.request] TODO.6652 * 6653 * @param {boolean} [restoreRequestEnvelope.request.adjustConnectionStrings]6654 * If the restore operation also restores a database along with the website6655 * and the database is on a different server than when the original site h6656 * 6657 * @param {string} [restoreRequestEnvelope.request.blobName] The blob name6658 * where the backup is stored. E.g. mysite1_20140203.zip6659 * 6660 * @param {IEnumerable} [restoreRequestEnvelope.request.databases] Database6661 * settings for backup.6662 * 6663 * @param {boolean}6664 * [restoreRequestEnvelope.request.ignoreConflictingHostNames] When6665 * restoring a site, custom domains might conflict with other site in the6666 * same datacenter. If this value is true, such hostnames will be ignored6667 * during restore. If this is false, the restore operation will fail on such6668 * conflict.6669 * 6670 * @param {boolean} [restoreRequestEnvelope.request.overwrite] True if the6671 * restore operation will be used for overwrite an existing site; false6672 * otherwise.6673 * 6674 * @param {string} [restoreRequestEnvelope.request.storageAccountUrl] SAS URL6675 * for a container in a storage account. E.g.6676 * https://NAME.blob.core.windows.net/CONTAINERNAME/?sv=2012-02-12&st=2013-12-05T19%3A30%3A45Z&se=2017-12-04T19%3A30%3A45Z&sr=c&sp=rwdl&sig=abcdefABCDEFabcdef01234567896677 * 6678 * @param {string} [restoreRequestEnvelope.id] Gets the ID of the resource.6679 * 6680 * @param {string} [restoreRequestEnvelope.name] The name of the resource.6681 * 6682 * @param {string} restoreRequestEnvelope.location Gets or sets the location6683 * of the resource.6684 * 6685 * @param {object} [restoreRequestEnvelope.tags] Gets or sets the tags6686 * attached to the resource.6687 * 6688 * @param {string} [restoreRequestEnvelope.type] The type of the resource6689 * 6690 * @param {function} callback6691 * 6692 * @returns {Stream} The response stream.6693 */6694 WebSiteOperations.prototype.restore = function(resourceGroupName, webSiteName, slotName, restoreRequestEnvelope, callback) {6695 if (callback === null || callback === undefined) {6696 throw new Error('callback cannot be null.');6697 }6698 // Validate6699 if (resourceGroupName === null || resourceGroupName === undefined) {6700 return callback(new Error('resourceGroupName cannot be null.'));6701 }6702 if (webSiteName === null || webSiteName === undefined) {6703 return callback(new Error('webSiteName cannot be null.'));6704 }6705 if (restoreRequestEnvelope === null || restoreRequestEnvelope === undefined) {6706 return callback(new Error('restoreRequestEnvelope cannot be null.'));6707 }6708 if (restoreRequestEnvelope.location === null || restoreRequestEnvelope.location === undefined) {6709 return callback(new Error('restoreRequestEnvelope.location cannot be null.'));6710 }6711 6712 // Tracing6713 6714 // Construct URL6715 var url2 = '';6716 url2 = url2 + '/subscriptions/';6717 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {6718 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);6719 }6720 url2 = url2 + '/resourceGroups/';6721 url2 = url2 + encodeURIComponent(resourceGroupName);6722 url2 = url2 + '/providers/';6723 url2 = url2 + 'Microsoft.Web';6724 url2 = url2 + '/';6725 url2 = url2 + 'sites';6726 url2 = url2 + '/';6727 url2 = url2 + encodeURIComponent(webSiteName);6728 var queryParameters = [];6729 queryParameters.push('api-version=2014-06-01');6730 queryParameters.push('operation=restore');6731 if (queryParameters.length > 0) {6732 url2 = url2 + '?' + queryParameters.join('&');6733 }6734 var baseUrl = this.client.baseUri;6735 // Trim '/' character from the end of baseUrl and beginning of url.6736 if (baseUrl[baseUrl.length - 1] === '/') {6737 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);6738 }6739 if (url2[0] === '/') {6740 url2 = url2.substring(1);6741 }6742 url2 = baseUrl + '/' + url2;6743 url2 = url2.replace(' ', '%20');6744 6745 // Create HTTP transport objects6746 var httpRequest = new WebResource();6747 httpRequest.method = 'PUT';6748 httpRequest.headers = {};6749 httpRequest.url = url2;6750 6751 // Set Headers6752 httpRequest.headers['Content-Type'] = 'application/json';6753 httpRequest.headers['x-ms-version'] = '2014-06-01';6754 6755 // Serialize Request6756 var requestContent = null;6757 var requestDoc = null;6758 6759 var restoreRequestEnvelopeValue = {};6760 requestDoc = restoreRequestEnvelopeValue;6761 6762 if (restoreRequestEnvelope.request !== null && restoreRequestEnvelope.request !== undefined) {6763 var propertiesValue = {};6764 restoreRequestEnvelopeValue['properties'] = propertiesValue;6765 6766 if (restoreRequestEnvelope.request.adjustConnectionStrings !== null && restoreRequestEnvelope.request.adjustConnectionStrings !== undefined) {6767 propertiesValue['AdjustConnectionStrings'] = restoreRequestEnvelope.request.adjustConnectionStrings;6768 }6769 6770 if (restoreRequestEnvelope.request.blobName !== null && restoreRequestEnvelope.request.blobName !== undefined) {6771 propertiesValue['BlobName'] = restoreRequestEnvelope.request.blobName;6772 }6773 6774 if (restoreRequestEnvelope.request.databases !== null && restoreRequestEnvelope.request.databases !== undefined) {6775 var databasesArray = [];6776 for (var loweredIndex1 = 0; loweredIndex1 < restoreRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {6777 var databasesItem = restoreRequestEnvelope.request.databases[loweredIndex1];6778 var databaseBackupSettingValue = {};6779 databasesArray.push(databaseBackupSettingValue);6780 6781 if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {6782 databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;6783 }6784 6785 if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {6786 databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;6787 }6788 6789 if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {6790 databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;6791 }6792 6793 if (databasesItem.name !== null && databasesItem.name !== undefined) {6794 databaseBackupSettingValue['name'] = databasesItem.name;6795 }6796 }6797 propertiesValue['Databases'] = databasesArray;6798 }6799 6800 if (restoreRequestEnvelope.request.ignoreConflictingHostNames !== null && restoreRequestEnvelope.request.ignoreConflictingHostNames !== undefined) {6801 propertiesValue['IgnoreConflictingHostNames'] = restoreRequestEnvelope.request.ignoreConflictingHostNames;6802 }6803 6804 if (restoreRequestEnvelope.request.overwrite !== null && restoreRequestEnvelope.request.overwrite !== undefined) {6805 propertiesValue['Overwrite'] = restoreRequestEnvelope.request.overwrite;6806 }6807 6808 if (restoreRequestEnvelope.request.storageAccountUrl !== null && restoreRequestEnvelope.request.storageAccountUrl !== undefined) {6809 propertiesValue['StorageAccountUrl'] = restoreRequestEnvelope.request.storageAccountUrl;6810 }6811 }6812 6813 if (restoreRequestEnvelope.id !== null && restoreRequestEnvelope.id !== undefined) {6814 restoreRequestEnvelopeValue['id'] = restoreRequestEnvelope.id;6815 }6816 6817 if (restoreRequestEnvelope.name !== null && restoreRequestEnvelope.name !== undefined) {6818 restoreRequestEnvelopeValue['name'] = restoreRequestEnvelope.name;6819 }6820 6821 restoreRequestEnvelopeValue['location'] = restoreRequestEnvelope.location;6822 6823 if (restoreRequestEnvelope.tags !== null && restoreRequestEnvelope.tags !== undefined) {6824 var tagsDictionary = {};6825 for (var tagsKey in restoreRequestEnvelope.tags) {6826 var tagsValue = restoreRequestEnvelope.tags[tagsKey];6827 tagsDictionary[tagsKey] = tagsValue;6828 }6829 restoreRequestEnvelopeValue['tags'] = tagsDictionary;6830 }6831 6832 if (restoreRequestEnvelope.type !== null && restoreRequestEnvelope.type !== undefined) {6833 restoreRequestEnvelopeValue['type'] = restoreRequestEnvelope.type;6834 }6835 6836 requestContent = JSON.stringify(requestDoc);6837 httpRequest.body = requestContent;6838 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');6839 // Send Request6840 return this.client.pipeline(httpRequest, function (err, response, body) {6841 if (err !== null && err !== undefined) {6842 return callback(err);6843 }6844 var statusCode = response.statusCode;6845 if (statusCode !== 200) {6846 var error = new Error(body);6847 error.statusCode = response.statusCode;6848 return callback(error);6849 }6850 6851 // Create Result6852 var result = null;6853 // Deserialize Response6854 if (statusCode === 200) {6855 var responseContent = body;6856 result = {};6857 var responseDoc = null;6858 if (responseContent) {6859 responseDoc = JSON.parse(responseContent);6860 }6861 6862 var restoreResponseValue = responseDoc['RestoreResponse'];6863 if (restoreResponseValue !== null && restoreResponseValue !== undefined) {6864 var restoreResponseInstance = {};6865 6866 var operationIdValue = restoreResponseValue['operationId'];6867 if (operationIdValue !== null && operationIdValue !== undefined) {6868 var operationIdInstance = operationIdValue;6869 restoreResponseInstance.operationId = operationIdInstance;6870 }6871 }6872 6873 }6874 result.statusCode = statusCode;6875 result.requestId = response.headers['x-ms-request-id'];6876 6877 return callback(null, result);6878 });6879 };6880 6881 /**6882 * Restart the web site.6883 * 6884 * @param {string} resourceGroupName The name of the resource group6885 * 6886 * @param {string} webSiteName Name of website6887 * 6888 * @param {string} [slotName] The name of the slot of the website6889 * 6890 * @param {function} callback6891 * 6892 * @returns {Stream} The response stream.6893 */6894 WebSiteOperations.prototype.start = function(resourceGroupName, webSiteName, slotName, callback) {6895 if (callback === null || callback === undefined) {6896 throw new Error('callback cannot be null.');6897 }6898 // Validate6899 if (resourceGroupName === null || resourceGroupName === undefined) {6900 return callback(new Error('resourceGroupName cannot be null.'));6901 }6902 if (webSiteName === null || webSiteName === undefined) {6903 return callback(new Error('webSiteName cannot be null.'));6904 }6905 6906 // Tracing6907 6908 // Construct URL6909 var url2 = '';6910 url2 = url2 + '/subscriptions/';6911 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {6912 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);6913 }6914 url2 = url2 + '/resourceGroups/';6915 url2 = url2 + encodeURIComponent(resourceGroupName);6916 url2 = url2 + '/providers/';6917 url2 = url2 + 'Microsoft.Web';6918 url2 = url2 + '/';6919 url2 = url2 + 'sites';6920 url2 = url2 + '/';6921 url2 = url2 + encodeURIComponent(webSiteName);6922 if (slotName !== null && slotName !== undefined) {6923 url2 = url2 + '/slots/' + encodeURIComponent(slotName);6924 }6925 url2 = url2 + '/start';6926 var queryParameters = [];6927 queryParameters.push('api-version=2014-06-01');6928 if (queryParameters.length > 0) {6929 url2 = url2 + '?' + queryParameters.join('&');6930 }6931 var baseUrl = this.client.baseUri;6932 // Trim '/' character from the end of baseUrl and beginning of url.6933 if (baseUrl[baseUrl.length - 1] === '/') {6934 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);6935 }6936 if (url2[0] === '/') {6937 url2 = url2.substring(1);6938 }6939 url2 = baseUrl + '/' + url2;6940 url2 = url2.replace(' ', '%20');6941 6942 // Create HTTP transport objects6943 var httpRequest = new WebResource();6944 httpRequest.method = 'POST';6945 httpRequest.headers = {};6946 httpRequest.url = url2;6947 6948 // Set Headers6949 httpRequest.headers['Content-Length'] = '0';6950 6951 // Send Request6952 return this.client.pipeline(httpRequest, function (err, response, body) {6953 if (err !== null && err !== undefined) {6954 return callback(err);6955 }6956 var statusCode = response.statusCode;6957 if (statusCode !== 200) {6958 var error = new Error(body);6959 error.statusCode = response.statusCode;6960 return callback(error);6961 }6962 6963 // Create Result6964 var result = null;6965 // Deserialize Response6966 result = {};6967 result.statusCode = statusCode;6968 result.requestId = response.headers['x-ms-request-id'];6969 6970 return callback(null, result);6971 });6972 };6973 6974 /**6975 * Restart the web site.6976 * 6977 * @param {string} resourceGroupName The name of the resource group6978 * 6979 * @param {string} webSiteName Name of website6980 * 6981 * @param {string} [slotName] The name of the slot of the web site6982 * 6983 * @param {function} callback6984 * 6985 * @returns {Stream} The response stream.6986 */6987 WebSiteOperations.prototype.stop = function(resourceGroupName, webSiteName, slotName, callback) {6988 if (callback === null || callback === undefined) {6989 throw new Error('callback cannot be null.');6990 }6991 // Validate6992 if (resourceGroupName === null || resourceGroupName === undefined) {6993 return callback(new Error('resourceGroupName cannot be null.'));6994 }6995 if (webSiteName === null || webSiteName === undefined) {6996 return callback(new Error('webSiteName cannot be null.'));6997 }6998 6999 // Tracing7000 7001 // Construct URL7002 var url2 = '';7003 url2 = url2 + '/subscriptions/';7004 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {7005 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);7006 }7007 url2 = url2 + '/resourceGroups/';7008 url2 = url2 + encodeURIComponent(resourceGroupName);7009 url2 = url2 + '/providers/';7010 url2 = url2 + 'Microsoft.Web';7011 url2 = url2 + '/';7012 url2 = url2 + 'sites';7013 url2 = url2 + '/';7014 url2 = url2 + encodeURIComponent(webSiteName);7015 if (slotName !== null && slotName !== undefined) {7016 url2 = url2 + '/slots/' + encodeURIComponent(slotName);7017 }7018 url2 = url2 + '/stop';7019 var queryParameters = [];7020 queryParameters.push('api-version=2014-06-01');7021 if (queryParameters.length > 0) {7022 url2 = url2 + '?' + queryParameters.join('&');7023 }7024 var baseUrl = this.client.baseUri;7025 // Trim '/' character from the end of baseUrl and beginning of url.7026 if (baseUrl[baseUrl.length - 1] === '/') {7027 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);7028 }7029 if (url2[0] === '/') {7030 url2 = url2.substring(1);7031 }7032 url2 = baseUrl + '/' + url2;7033 url2 = url2.replace(' ', '%20');7034 7035 // Create HTTP transport objects7036 var httpRequest = new WebResource();7037 httpRequest.method = 'POST';7038 httpRequest.headers = {};7039 httpRequest.url = url2;7040 7041 // Set Headers7042 httpRequest.headers['Content-Length'] = '0';7043 7044 // Send Request7045 return this.client.pipeline(httpRequest, function (err, response, body) {7046 if (err !== null && err !== undefined) {7047 return callback(err);7048 }7049 var statusCode = response.statusCode;7050 if (statusCode !== 200) {7051 var error = new Error(body);7052 error.statusCode = response.statusCode;7053 return callback(error);7054 }7055 7056 // Create Result7057 var result = null;7058 // Deserialize Response7059 result = {};7060 result.statusCode = statusCode;7061 result.requestId = response.headers['x-ms-request-id'];7062 7063 return callback(null, result);7064 });7065 };7066 7067 /**7068 * You can retrieve the application settings for a web site by issuing an7069 * HTTP GET request, or update them by using HTTP PUT with a request body7070 * that contains the settings to be updated. (see7071 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for7072 * more information)7073 * 7074 * @param {string} resourceGroupName The name of the resource group7075 * 7076 * @param {string} webSiteName The name of the web site7077 * 7078 * @param {string} [slotName] The name of the slot of the website7079 * 7080 * @param {WebSiteNameValueParameters} parameters The Update Web Site app7081 * settings parameters7082 * 7083 * @param {array} parameters.properties The name value pair parameters for7084 * the web site.7085 * 7086 * @param {string} [parameters.id] Gets the ID of the resource.7087 * 7088 * @param {string} [parameters.name] The name of the resource.7089 * 7090 * @param {string} parameters.location Gets or sets the location of the7091 * resource.7092 * 7093 * @param {object} [parameters.tags] Gets or sets the tags attached to the7094 * resource.7095 * 7096 * @param {string} [parameters.type] The type of the resource7097 * 7098 * @param {function} callback7099 * 7100 * @returns {Stream} The response stream.7101 */7102 WebSiteOperations.prototype.updateAppSettings = function(resourceGroupName, webSiteName, slotName, parameters, callback) {7103 if (callback === null || callback === undefined) {7104 throw new Error('callback cannot be null.');7105 }7106 // Validate7107 if (resourceGroupName === null || resourceGroupName === undefined) {7108 return callback(new Error('resourceGroupName cannot be null.'));7109 }7110 if (webSiteName === null || webSiteName === undefined) {7111 return callback(new Error('webSiteName cannot be null.'));7112 }7113 if (parameters === null || parameters === undefined) {7114 return callback(new Error('parameters cannot be null.'));7115 }7116 if (parameters.location === null || parameters.location === undefined) {7117 return callback(new Error('parameters.location cannot be null.'));7118 }7119 if (parameters.properties === null || parameters.properties === undefined) {7120 return callback(new Error('parameters.properties cannot be null.'));7121 }7122 7123 // Tracing7124 7125 // Construct URL7126 var url2 = '';7127 url2 = url2 + '/subscriptions/';7128 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {7129 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);7130 }7131 url2 = url2 + '/resourceGroups/';7132 url2 = url2 + encodeURIComponent(resourceGroupName);7133 url2 = url2 + '/providers/';7134 url2 = url2 + 'Microsoft.Web';7135 url2 = url2 + '/';7136 url2 = url2 + 'sites';7137 url2 = url2 + '/';7138 url2 = url2 + encodeURIComponent(webSiteName);7139 if (slotName !== null && slotName !== undefined) {7140 url2 = url2 + '/slots/' + encodeURIComponent(slotName);7141 }7142 url2 = url2 + '/config/appsettings';7143 var queryParameters = [];7144 queryParameters.push('api-version=2014-06-01');7145 if (queryParameters.length > 0) {7146 url2 = url2 + '?' + queryParameters.join('&');7147 }7148 var baseUrl = this.client.baseUri;7149 // Trim '/' character from the end of baseUrl and beginning of url.7150 if (baseUrl[baseUrl.length - 1] === '/') {7151 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);7152 }7153 if (url2[0] === '/') {7154 url2 = url2.substring(1);7155 }7156 url2 = baseUrl + '/' + url2;7157 url2 = url2.replace(' ', '%20');7158 7159 // Create HTTP transport objects7160 var httpRequest = new WebResource();7161 httpRequest.method = 'PUT';7162 httpRequest.headers = {};7163 httpRequest.url = url2;7164 7165 // Set Headers7166 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';7167 7168 // Serialize Request7169 var requestContent = null;7170 var requestDoc = null;7171 7172 var webSiteNameValueParametersValue = {};7173 requestDoc = webSiteNameValueParametersValue;7174 7175 if (parameters.properties !== null && parameters.properties !== undefined) {7176 var propertiesArray = [];7177 for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.length; loweredIndex1 = loweredIndex1 + 1) {7178 var propertiesItem = parameters.properties[loweredIndex1];7179 var nameValuePairValue = {};7180 propertiesArray.push(nameValuePairValue);7181 7182 if (propertiesItem.name !== null && propertiesItem.name !== undefined) {7183 nameValuePairValue['name'] = propertiesItem.name;7184 }7185 7186 if (propertiesItem.value !== null && propertiesItem.value !== undefined) {7187 nameValuePairValue['value'] = propertiesItem.value;7188 }7189 }7190 webSiteNameValueParametersValue['properties'] = propertiesArray;7191 }7192 7193 if (parameters.id !== null && parameters.id !== undefined) {7194 webSiteNameValueParametersValue['id'] = parameters.id;7195 }7196 7197 if (parameters.name !== null && parameters.name !== undefined) {7198 webSiteNameValueParametersValue['name'] = parameters.name;7199 }7200 7201 webSiteNameValueParametersValue['location'] = parameters.location;7202 7203 if (parameters.tags !== null && parameters.tags !== undefined) {7204 var tagsDictionary = {};7205 for (var tagsKey in parameters.tags) {7206 var tagsValue = parameters.tags[tagsKey];7207 tagsDictionary[tagsKey] = tagsValue;7208 }7209 webSiteNameValueParametersValue['tags'] = tagsDictionary;7210 }7211 7212 if (parameters.type !== null && parameters.type !== undefined) {7213 webSiteNameValueParametersValue['type'] = parameters.type;7214 }7215 7216 requestContent = JSON.stringify(requestDoc);7217 httpRequest.body = requestContent;7218 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');7219 // Send Request7220 return this.client.pipeline(httpRequest, function (err, response, body) {7221 if (err !== null && err !== undefined) {7222 return callback(err);7223 }7224 var statusCode = response.statusCode;7225 if (statusCode !== 200) {7226 var error = new Error(body);7227 error.statusCode = response.statusCode;7228 return callback(error);7229 }7230 7231 // Create Result7232 var result = null;7233 // Deserialize Response7234 if (statusCode === 200) {7235 var responseContent = body;7236 result = {};7237 var responseDoc = null;7238 if (responseContent) {7239 responseDoc = JSON.parse(responseContent);7240 }7241 7242 if (responseDoc !== null && responseDoc !== undefined) {7243 var resourceInstance = { properties: [], tags: {} };7244 result.resource = resourceInstance;7245 7246 var propertiesArray2 = responseDoc['properties'];7247 if (propertiesArray2 !== null && propertiesArray2 !== undefined) {7248 for (var loweredIndex2 = 0; loweredIndex2 < propertiesArray2.length; loweredIndex2 = loweredIndex2 + 1) {7249 var propertiesValue = propertiesArray2[loweredIndex2];7250 var nameValuePairInstance = {};7251 resourceInstance.properties.push(nameValuePairInstance);7252 7253 var nameValue = propertiesValue['name'];7254 if (nameValue !== null && nameValue !== undefined) {7255 var nameInstance = nameValue;7256 nameValuePairInstance.name = nameInstance;7257 }7258 7259 var valueValue = propertiesValue['value'];7260 if (valueValue !== null && valueValue !== undefined) {7261 var valueInstance = valueValue;7262 nameValuePairInstance.value = valueInstance;7263 }7264 }7265 }7266 7267 var idValue = responseDoc['id'];7268 if (idValue !== null && idValue !== undefined) {7269 var idInstance = idValue;7270 resourceInstance.id = idInstance;7271 }7272 7273 var nameValue2 = responseDoc['name'];7274 if (nameValue2 !== null && nameValue2 !== undefined) {7275 var nameInstance2 = nameValue2;7276 resourceInstance.name = nameInstance2;7277 }7278 7279 var locationValue = responseDoc['location'];7280 if (locationValue !== null && locationValue !== undefined) {7281 var locationInstance = locationValue;7282 resourceInstance.location = locationInstance;7283 }7284 7285 var tagsSequenceElement = responseDoc['tags'];7286 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {7287 for (var property in tagsSequenceElement) {7288 var tagsKey2 = property;7289 var tagsValue2 = tagsSequenceElement[property];7290 resourceInstance.tags[tagsKey2] = tagsValue2;7291 }7292 }7293 7294 var typeValue = responseDoc['type'];7295 if (typeValue !== null && typeValue !== undefined) {7296 var typeInstance = typeValue;7297 resourceInstance.type = typeInstance;7298 }7299 }7300 7301 }7302 result.statusCode = statusCode;7303 result.requestId = response.headers['x-ms-request-id'];7304 7305 return callback(null, result);7306 });7307 };7308 7309 /**7310 * Updates a backup schedule for a site.7311 * 7312 * @param {string} resourceGroupName The name of the web space.7313 * 7314 * @param {string} webSiteName The name of the web site.7315 * 7316 * @param {string} [slotName] The name of the slot.7317 * 7318 * @param {BackupRequestEnvelope} backupRequestEnvelope A backup schedule7319 * specification.7320 * 7321 * @param {BackupRequest} [backupRequestEnvelope.request] TODO.7322 * 7323 * @param {BackupSchedule} [backupRequestEnvelope.request.backupSchedule] The7324 * backup schedule structure - valid only when setting up a schedule. Should7325 * be Null for on-demand backups.7326 * 7327 * @param {number}7328 * [backupRequestEnvelope.request.backupSchedule.frequencyInterval] The7329 * frequency of backups.7330 * 7331 * @param {FrequencyUnit}7332 * [backupRequestEnvelope.request.backupSchedule.frequencyUnit] Units for7333 * FrequencyInterval - e.g. Day or Hour7334 * 7335 * @param {boolean}7336 * [backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup]7337 * Retention policy deletes backups after predefined number of days. If this7338 * is true, there will be always at least one backup left. regardless of the7339 * policy. If false, all backups can be deleted.7340 * 7341 * @param {date}7342 * [backupRequestEnvelope.request.backupSchedule.lastExecutionTime] The last7343 * time when this schedule started a backup, Null if didn't start anything7344 * yet.7345 * 7346 * @param {number}7347 * [backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays]7348 * Backups older N days (N defined by this value) will be automatically7349 * deleted.7350 * 7351 * @param {date} [backupRequestEnvelope.request.backupSchedule.startTime]7352 * When this schedule should start backing up the site. Null means7353 * immediately.7354 * 7355 * @param {IEnumerable} [backupRequestEnvelope.request.databases] Database7356 * settings for backup.7357 * 7358 * @param {boolean} [backupRequestEnvelope.request.enabled] Valid only for a7359 * backup schedule (can be Null for on-demand backups). True if enabled;7360 * false if disabled (no backups will be performed).7361 * 7362 * @param {string} [backupRequestEnvelope.request.name] The name of this7363 * backup - will be used for generating a blob name.7364 * 7365 * @param {string} [backupRequestEnvelope.request.storageAccountUrl] SAS URL7366 * for a container in a storage account. E.g.7367 * https://NAME.blob.core.windows.net/CONTAINERNAME/?sv=2012-02-12&st=2013-12-05T19%3A30%3A45Z&se=2017-12-04T19%3A30%3A45Z&sr=c&sp=rwdl&sig=abcdefABCDEFabcdef01234567897368 * 7369 * @param {string} [backupRequestEnvelope.id] Gets the ID of the resource.7370 * 7371 * @param {string} [backupRequestEnvelope.name] The name of the resource.7372 * 7373 * @param {string} backupRequestEnvelope.location Gets or sets the location7374 * of the resource.7375 * 7376 * @param {object} [backupRequestEnvelope.tags] Gets or sets the tags7377 * attached to the resource.7378 * 7379 * @param {string} [backupRequestEnvelope.type] The type of the resource7380 * 7381 * @param {function} callback7382 * 7383 * @returns {Stream} The response stream.7384 */7385 WebSiteOperations.prototype.updateBackupConfiguration = function(resourceGroupName, webSiteName, slotName, backupRequestEnvelope, callback) {7386 if (callback === null || callback === undefined) {7387 throw new Error('callback cannot be null.');7388 }7389 // Validate7390 if (resourceGroupName === null || resourceGroupName === undefined) {7391 return callback(new Error('resourceGroupName cannot be null.'));7392 }7393 if (webSiteName === null || webSiteName === undefined) {7394 return callback(new Error('webSiteName cannot be null.'));7395 }7396 if (backupRequestEnvelope === null || backupRequestEnvelope === undefined) {7397 return callback(new Error('backupRequestEnvelope cannot be null.'));7398 }7399 if (backupRequestEnvelope.location === null || backupRequestEnvelope.location === undefined) {7400 return callback(new Error('backupRequestEnvelope.location cannot be null.'));7401 }7402 7403 // Tracing7404 7405 // Construct URL7406 var url2 = '';7407 url2 = url2 + '/subscriptions/';7408 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {7409 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);7410 }7411 url2 = url2 + '/resourceGroups/';7412 url2 = url2 + encodeURIComponent(resourceGroupName);7413 url2 = url2 + '/providers/';7414 url2 = url2 + 'Microsoft.Web';7415 url2 = url2 + '/';7416 url2 = url2 + 'sites';7417 url2 = url2 + '/';7418 url2 = url2 + encodeURIComponent(webSiteName);7419 if (slotName !== null && slotName !== undefined) {7420 url2 = url2 + '/slots/' + encodeURIComponent(slotName);7421 }7422 url2 = url2 + '/backup/config';7423 var queryParameters = [];7424 queryParameters.push('api-version=2014-06-01');7425 if (queryParameters.length > 0) {7426 url2 = url2 + '?' + queryParameters.join('&');7427 }7428 var baseUrl = this.client.baseUri;7429 // Trim '/' character from the end of baseUrl and beginning of url.7430 if (baseUrl[baseUrl.length - 1] === '/') {7431 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);7432 }7433 if (url2[0] === '/') {7434 url2 = url2.substring(1);7435 }7436 url2 = baseUrl + '/' + url2;7437 url2 = url2.replace(' ', '%20');7438 7439 // Create HTTP transport objects7440 var httpRequest = new WebResource();7441 httpRequest.method = 'PUT';7442 httpRequest.headers = {};7443 httpRequest.url = url2;7444 7445 // Set Headers7446 httpRequest.headers['Content-Type'] = 'application/json';7447 httpRequest.headers['x-ms-version'] = '2014-06-01';7448 7449 // Serialize Request7450 var requestContent = null;7451 var requestDoc = null;7452 7453 var backupRequestEnvelopeValue = {};7454 requestDoc = backupRequestEnvelopeValue;7455 7456 if (backupRequestEnvelope.request !== null && backupRequestEnvelope.request !== undefined) {7457 var propertiesValue = {};7458 backupRequestEnvelopeValue['properties'] = propertiesValue;7459 7460 if (backupRequestEnvelope.request.backupSchedule !== null && backupRequestEnvelope.request.backupSchedule !== undefined) {7461 var backupScheduleValue = {};7462 propertiesValue['backupSchedule'] = backupScheduleValue;7463 7464 if (backupRequestEnvelope.request.backupSchedule.frequencyInterval !== null && backupRequestEnvelope.request.backupSchedule.frequencyInterval !== undefined) {7465 backupScheduleValue['frequencyInterval'] = backupRequestEnvelope.request.backupSchedule.frequencyInterval;7466 }7467 7468 if (backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined) {7469 backupScheduleValue['frequencyUnit'] = backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined ? backupRequestEnvelope.request.backupSchedule.frequencyUnit.toString() : 'Day';7470 }7471 7472 if (backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== null && backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== undefined) {7473 backupScheduleValue['keepAtLeastOneBackup'] = backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup;7474 }7475 7476 if (backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== null && backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== undefined) {7477 backupScheduleValue['lastExecutionTime'] = backupRequestEnvelope.request.backupSchedule.lastExecutionTime;7478 }7479 7480 if (backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== null && backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== undefined) {7481 backupScheduleValue['retentionPeriodInDays'] = backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays;7482 }7483 7484 if (backupRequestEnvelope.request.backupSchedule.startTime !== null && backupRequestEnvelope.request.backupSchedule.startTime !== undefined) {7485 backupScheduleValue['startTime'] = backupRequestEnvelope.request.backupSchedule.startTime;7486 }7487 }7488 7489 if (backupRequestEnvelope.request.databases !== null && backupRequestEnvelope.request.databases !== undefined) {7490 var databasesArray = [];7491 for (var loweredIndex1 = 0; loweredIndex1 < backupRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {7492 var databasesItem = backupRequestEnvelope.request.databases[loweredIndex1];7493 var databaseBackupSettingValue = {};7494 databasesArray.push(databaseBackupSettingValue);7495 7496 if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {7497 databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;7498 }7499 7500 if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {7501 databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;7502 }7503 7504 if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {7505 databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;7506 }7507 7508 if (databasesItem.name !== null && databasesItem.name !== undefined) {7509 databaseBackupSettingValue['name'] = databasesItem.name;7510 }7511 }7512 propertiesValue['databases'] = databasesArray;7513 }7514 7515 if (backupRequestEnvelope.request.enabled !== null && backupRequestEnvelope.request.enabled !== undefined) {7516 propertiesValue['enabled'] = backupRequestEnvelope.request.enabled;7517 }7518 7519 if (backupRequestEnvelope.request.name !== null && backupRequestEnvelope.request.name !== undefined) {7520 propertiesValue['name'] = backupRequestEnvelope.request.name;7521 }7522 7523 if (backupRequestEnvelope.request.storageAccountUrl !== null && backupRequestEnvelope.request.storageAccountUrl !== undefined) {7524 propertiesValue['storageAccountUrl'] = backupRequestEnvelope.request.storageAccountUrl;7525 }7526 }7527 7528 if (backupRequestEnvelope.id !== null && backupRequestEnvelope.id !== undefined) {7529 backupRequestEnvelopeValue['id'] = backupRequestEnvelope.id;7530 }7531 7532 if (backupRequestEnvelope.name !== null && backupRequestEnvelope.name !== undefined) {7533 backupRequestEnvelopeValue['name'] = backupRequestEnvelope.name;7534 }7535 7536 backupRequestEnvelopeValue['location'] = backupRequestEnvelope.location;7537 7538 if (backupRequestEnvelope.tags !== null && backupRequestEnvelope.tags !== undefined) {7539 var tagsDictionary = {};7540 for (var tagsKey in backupRequestEnvelope.tags) {7541 var tagsValue = backupRequestEnvelope.tags[tagsKey];7542 tagsDictionary[tagsKey] = tagsValue;7543 }7544 backupRequestEnvelopeValue['tags'] = tagsDictionary;7545 }7546 7547 if (backupRequestEnvelope.type !== null && backupRequestEnvelope.type !== undefined) {7548 backupRequestEnvelopeValue['type'] = backupRequestEnvelope.type;7549 }7550 7551 requestContent = JSON.stringify(requestDoc);7552 httpRequest.body = requestContent;7553 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');7554 // Send Request7555 return this.client.pipeline(httpRequest, function (err, response, body) {7556 if (err !== null && err !== undefined) {7557 return callback(err);7558 }7559 var statusCode = response.statusCode;7560 if (statusCode !== 200) {7561 var error = new Error(body);7562 error.statusCode = response.statusCode;7563 return callback(error);7564 }7565 7566 // Create Result7567 var result = null;7568 // Deserialize Response7569 result = {};7570 result.statusCode = statusCode;7571 result.requestId = response.headers['x-ms-request-id'];7572 7573 return callback(null, result);7574 });7575 };7576 7577 /**7578 * You can retrieve the config settings for a web site by issuing an HTTP GET7579 * request, or update them by using HTTP PUT with a request body that7580 * contains the settings to be updated. (see7581 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for7582 * more information)7583 * 7584 * @param {string} resourceGroupName The name of the resource group.7585 * 7586 * @param {string} webSiteName The name of the web site.7587 * 7588 * @param {string} [slotName] The name of the slot.7589 * 7590 * @param {WebSiteUpdateConfigurationParameters} parameters The Update Web7591 * Site Configuration parameters.7592 * 7593 * @param {WebSiteUpdateConfigurationDetails} parameters.properties The name7594 * value pair parameters for the web site.7595 * 7596 * @param {object} [parameters.properties.appSettings] A set of name/value7597 * pairs that contain application settings for a site.7598 * 7599 * @param {array} [parameters.properties.connectionStrings] Contains7600 * connection strings for database and other external resources.7601 * 7602 * @param {array} [parameters.properties.defaultDocuments] Contains one or7603 * more string elements that list, in order of preference, the name of the7604 * file that a web site returns when the web site's domain name is requested7605 * by itself. For example, if the default document for http://contoso.com is7606 * default.htm, the page http://www.contoso.com/default.htm is returned when7607 * the browser is pointed to http://www.contoso.com.7608 * 7609 * @param {boolean} [parameters.properties.detailedErrorLoggingEnabled] True7610 * if detailed error logging is enabled; otherwise, false.7611 * 7612 * @param {string} [parameters.properties.documentRoot] The document root.7613 * 7614 * @param {array} [parameters.properties.handlerMappings] Specifies custom7615 * executable programs for handling requests for specific file name7616 * extensions.7617 * 7618 * @param {boolean} [parameters.properties.httpLoggingEnabled] True if HTTP7619 * error logging is enabled; otherwise, false.7620 * 7621 * @param {number} [parameters.properties.logsDirectorySizeLimit] The limit7622 * of the logs directory.7623 * 7624 * @param {ManagedPipelineMode} [parameters.properties.managedPipelineMode]7625 * Managed pipeline modes.7626 * 7627 * @param {object} [parameters.properties.metadata] Contains name/value pairs7628 * for source control or other information.7629 * 7630 * @param {string} [parameters.properties.netFrameworkVersion] The .NET7631 * Framework version. Supported values are v2.0, v4.0 and v4.5.7632 * 7633 * @param {number} [parameters.properties.numberOfWorkers] The number of web7634 * workers allotted to the web site. If the site mode is Free, this value is7635 * 1. If the site mode is Shared, this value can range from 1 through 6. If7636 * the site mode is Standard, this value can range from 1 through 10.7637 * 7638 * @param {string} [parameters.properties.phpVersion] Supported values are an7639 * empty string (an empty string disables PHP), 5.3, 5.4, 5.5 and 5.6.7640 * 7641 * @param {string} [parameters.properties.pythonVersion] Supported values are7642 * an empty string (an empty string disables Python), 2.7 and 3.4.7643 * 7644 * @param {boolean} [parameters.properties.remoteDebuggingEnabled] True7645 * remote debugging is enabled; otherwise, false.7646 * 7647 * @param {RemoteDebuggingVersion}7648 * [parameters.properties.remoteDebuggingVersion] True remote debugging7649 * version.7650 * 7651 * @param {boolean} [parameters.properties.requestTracingEnabled] True if7652 * request tracing is enabled; otherwise, false.7653 * 7654 * @param {date} [parameters.properties.requestTracingExpirationTime] Time7655 * remaining until request tracing expires.7656 * 7657 * @param {string} [parameters.properties.scmType] The source control method7658 * that the web site is using (for example, Local Git). If deployment from7659 * source control has not been set up for the web site, this value is None.7660 * 7661 * @param {boolean} [parameters.properties.use32BitWorkerProcess] True if7662 * 32-bit mode is enabled; otherwise, false.7663 * 7664 * @param {boolean} [parameters.properties.webSocketsEnabled] True if Web7665 * Sockets are enabled; otherwise, false.7666 * 7667 * @param {boolean} [parameters.properties.alwaysOn] True if Always On7668 * functionality is enabled for the site; otherwise, false.7669 * 7670 * @param {string} [parameters.properties.autoSwapSlotName] Sets the slot7671 * name to swap with after successful deployment.7672 * 7673 * @param {SiteLimits} [parameters.properties.limits] The per site limits.7674 * 7675 * @param {number} [parameters.properties.limits.maxPercentageCpu] The name7676 * of the pair.7677 * 7678 * @param {number} [parameters.properties.limits.maxMemoryInMb] Maximum7679 * memory allowed in MB7680 * 7681 * @param {number} [parameters.properties.limits.maxDiskSizeInMb] Maximum7682 * disk size allowed in MB7683 * 7684 * @param {string} [parameters.id] Gets the ID of the resource.7685 * 7686 * @param {string} [parameters.name] The name of the resource.7687 * 7688 * @param {string} parameters.location Gets or sets the location of the7689 * resource.7690 * 7691 * @param {object} [parameters.tags] Gets or sets the tags attached to the7692 * resource.7693 * 7694 * @param {string} [parameters.type] The type of the resource7695 * 7696 * @param {function} callback7697 * 7698 * @returns {Stream} The response stream.7699 */7700 WebSiteOperations.prototype.updateConfiguration = function(resourceGroupName, webSiteName, slotName, parameters, callback) {7701 if (callback === null || callback === undefined) {7702 throw new Error('callback cannot be null.');7703 }7704 // Validate7705 if (resourceGroupName === null || resourceGroupName === undefined) {7706 return callback(new Error('resourceGroupName cannot be null.'));7707 }7708 if (webSiteName === null || webSiteName === undefined) {7709 return callback(new Error('webSiteName cannot be null.'));7710 }7711 if (parameters === null || parameters === undefined) {7712 return callback(new Error('parameters cannot be null.'));7713 }7714 if (parameters.location === null || parameters.location === undefined) {7715 return callback(new Error('parameters.location cannot be null.'));7716 }7717 if (parameters.properties === null || parameters.properties === undefined) {7718 return callback(new Error('parameters.properties cannot be null.'));7719 }7720 7721 // Tracing7722 7723 // Construct URL7724 var url2 = '';7725 url2 = url2 + '/subscriptions/';7726 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {7727 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);7728 }7729 url2 = url2 + '/resourceGroups/';7730 url2 = url2 + encodeURIComponent(resourceGroupName);7731 url2 = url2 + '/providers/';7732 url2 = url2 + 'Microsoft.Web';7733 url2 = url2 + '/';7734 url2 = url2 + 'sites';7735 url2 = url2 + '/';7736 url2 = url2 + encodeURIComponent(webSiteName);7737 if (slotName !== null && slotName !== undefined) {7738 url2 = url2 + '/slots/' + encodeURIComponent(slotName);7739 }7740 url2 = url2 + '/config/web';7741 var queryParameters = [];7742 queryParameters.push('api-version=2014-06-01');7743 if (queryParameters.length > 0) {7744 url2 = url2 + '?' + queryParameters.join('&');7745 }7746 var baseUrl = this.client.baseUri;7747 // Trim '/' character from the end of baseUrl and beginning of url.7748 if (baseUrl[baseUrl.length - 1] === '/') {7749 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);7750 }7751 if (url2[0] === '/') {7752 url2 = url2.substring(1);7753 }7754 url2 = baseUrl + '/' + url2;7755 url2 = url2.replace(' ', '%20');7756 7757 // Create HTTP transport objects7758 var httpRequest = new WebResource();7759 httpRequest.method = 'PUT';7760 httpRequest.headers = {};7761 httpRequest.url = url2;7762 7763 // Set Headers7764 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';7765 7766 // Serialize Request7767 var requestContent = null;7768 var requestDoc = null;7769 7770 var webSiteUpdateConfigurationParametersValue = {};7771 requestDoc = webSiteUpdateConfigurationParametersValue;7772 7773 var propertiesValue = {};7774 webSiteUpdateConfigurationParametersValue['properties'] = propertiesValue;7775 7776 if (parameters.properties.appSettings !== null && parameters.properties.appSettings !== undefined) {7777 var appSettingsDictionary = {};7778 for (var appSettingsKey in parameters.properties.appSettings) {7779 var appSettingsValue = parameters.properties.appSettings[appSettingsKey];7780 appSettingsDictionary[appSettingsKey] = appSettingsValue;7781 }7782 propertiesValue['appSettings'] = appSettingsDictionary;7783 }7784 7785 if (parameters.properties.connectionStrings !== null && parameters.properties.connectionStrings !== undefined) {7786 var connectionStringsArray = [];7787 for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.connectionStrings.length; loweredIndex1 = loweredIndex1 + 1) {7788 var connectionStringsItem = parameters.properties.connectionStrings[loweredIndex1];7789 var connStringInfoValue = {};7790 connectionStringsArray.push(connStringInfoValue);7791 7792 if (connectionStringsItem.connectionString !== null && connectionStringsItem.connectionString !== undefined) {7793 connStringInfoValue['connectionString'] = connectionStringsItem.connectionString;7794 }7795 7796 if (connectionStringsItem.name !== null && connectionStringsItem.name !== undefined) {7797 connStringInfoValue['name'] = connectionStringsItem.name;7798 }7799 7800 if (connectionStringsItem.type !== null && connectionStringsItem.type !== undefined) {7801 connStringInfoValue['type'] = connectionStringsItem.type !== null && connectionStringsItem.type !== undefined ? connectionStringsItem.type.toString() : 'MySql';7802 }7803 }7804 propertiesValue['connectionStrings'] = connectionStringsArray;7805 }7806 7807 if (parameters.properties.defaultDocuments !== null && parameters.properties.defaultDocuments !== undefined) {7808 var defaultDocumentsArray = [];7809 for (var loweredIndex2 = 0; loweredIndex2 < parameters.properties.defaultDocuments.length; loweredIndex2 = loweredIndex2 + 1) {7810 var defaultDocumentsItem = parameters.properties.defaultDocuments[loweredIndex2];7811 defaultDocumentsArray.push(defaultDocumentsItem);7812 }7813 propertiesValue['defaultDocuments'] = defaultDocumentsArray;7814 }7815 7816 if (parameters.properties.detailedErrorLoggingEnabled !== null && parameters.properties.detailedErrorLoggingEnabled !== undefined) {7817 propertiesValue['detailedErrorLoggingEnabled'] = parameters.properties.detailedErrorLoggingEnabled;7818 }7819 7820 if (parameters.properties.documentRoot !== null && parameters.properties.documentRoot !== undefined) {7821 propertiesValue['documentRoot'] = parameters.properties.documentRoot;7822 }7823 7824 if (parameters.properties.handlerMappings !== null && parameters.properties.handlerMappings !== undefined) {7825 var handlerMappingsArray = [];7826 for (var loweredIndex3 = 0; loweredIndex3 < parameters.properties.handlerMappings.length; loweredIndex3 = loweredIndex3 + 1) {7827 var handlerMappingsItem = parameters.properties.handlerMappings[loweredIndex3];7828 var handlerMappingValue = {};7829 handlerMappingsArray.push(handlerMappingValue);7830 7831 if (handlerMappingsItem.arguments !== null && handlerMappingsItem.arguments !== undefined) {7832 handlerMappingValue['arguments'] = handlerMappingsItem.arguments;7833 }7834 7835 if (handlerMappingsItem.extension !== null && handlerMappingsItem.extension !== undefined) {7836 handlerMappingValue['extension'] = handlerMappingsItem.extension;7837 }7838 7839 if (handlerMappingsItem.scriptProcessor !== null && handlerMappingsItem.scriptProcessor !== undefined) {7840 handlerMappingValue['scriptProcessor'] = handlerMappingsItem.scriptProcessor;7841 }7842 }7843 propertiesValue['handlerMappings'] = handlerMappingsArray;7844 }7845 7846 if (parameters.properties.httpLoggingEnabled !== null && parameters.properties.httpLoggingEnabled !== undefined) {7847 propertiesValue['httpLoggingEnabled'] = parameters.properties.httpLoggingEnabled;7848 }7849 7850 if (parameters.properties.logsDirectorySizeLimit !== null && parameters.properties.logsDirectorySizeLimit !== undefined) {7851 propertiesValue['logsDirectorySizeLimit'] = parameters.properties.logsDirectorySizeLimit;7852 }7853 7854 if (parameters.properties.managedPipelineMode !== null && parameters.properties.managedPipelineMode !== undefined) {7855 propertiesValue['managedPipelineMode'] = parameters.properties.managedPipelineMode !== null && parameters.properties.managedPipelineMode !== undefined ? parameters.properties.managedPipelineMode.toString() : 'Integrated';7856 }7857 7858 if (parameters.properties.metadata !== null && parameters.properties.metadata !== undefined) {7859 var metadataDictionary = {};7860 for (var metadataKey in parameters.properties.metadata) {7861 var metadataValue = parameters.properties.metadata[metadataKey];7862 metadataDictionary[metadataKey] = metadataValue;7863 }7864 propertiesValue['metadata'] = metadataDictionary;7865 }7866 7867 if (parameters.properties.netFrameworkVersion !== null && parameters.properties.netFrameworkVersion !== undefined) {7868 propertiesValue['netFrameworkVersion'] = parameters.properties.netFrameworkVersion;7869 }7870 7871 if (parameters.properties.numberOfWorkers !== null && parameters.properties.numberOfWorkers !== undefined) {7872 propertiesValue['numberOfWorkers'] = parameters.properties.numberOfWorkers;7873 }7874 7875 if (parameters.properties.phpVersion !== null && parameters.properties.phpVersion !== undefined) {7876 propertiesValue['phpVersion'] = parameters.properties.phpVersion;7877 }7878 7879 if (parameters.properties.pythonVersion !== null && parameters.properties.pythonVersion !== undefined) {7880 propertiesValue['pythonVersion'] = parameters.properties.pythonVersion;7881 }7882 7883 if (parameters.properties.remoteDebuggingEnabled !== null && parameters.properties.remoteDebuggingEnabled !== undefined) {7884 propertiesValue['remoteDebuggingEnabled'] = parameters.properties.remoteDebuggingEnabled;7885 }7886 7887 if (parameters.properties.remoteDebuggingVersion !== null && parameters.properties.remoteDebuggingVersion !== undefined) {7888 propertiesValue['remoteDebuggingVersion'] = parameters.properties.remoteDebuggingVersion !== null && parameters.properties.remoteDebuggingVersion !== undefined ? parameters.properties.remoteDebuggingVersion.toString() : 'VS2012';7889 }7890 7891 if (parameters.properties.requestTracingEnabled !== null && parameters.properties.requestTracingEnabled !== undefined) {7892 propertiesValue['requestTracingEnabled'] = parameters.properties.requestTracingEnabled;7893 }7894 7895 if (parameters.properties.requestTracingExpirationTime !== null && parameters.properties.requestTracingExpirationTime !== undefined) {7896 propertiesValue['requestTracingExpirationTime'] = parameters.properties.requestTracingExpirationTime;7897 }7898 7899 if (parameters.properties.scmType !== null && parameters.properties.scmType !== undefined) {7900 propertiesValue['scmType'] = parameters.properties.scmType;7901 }7902 7903 if (parameters.properties.use32BitWorkerProcess !== null && parameters.properties.use32BitWorkerProcess !== undefined) {7904 propertiesValue['use32BitWorkerProcess'] = parameters.properties.use32BitWorkerProcess;7905 }7906 7907 if (parameters.properties.webSocketsEnabled !== null && parameters.properties.webSocketsEnabled !== undefined) {7908 propertiesValue['webSocketsEnabled'] = parameters.properties.webSocketsEnabled;7909 }7910 7911 if (parameters.properties.alwaysOn !== null && parameters.properties.alwaysOn !== undefined) {7912 propertiesValue['alwaysOn'] = parameters.properties.alwaysOn;7913 }7914 7915 if (parameters.properties.autoSwapSlotName !== null && parameters.properties.autoSwapSlotName !== undefined) {7916 propertiesValue['autoSwapSlotName'] = parameters.properties.autoSwapSlotName;7917 }7918 7919 if (parameters.properties.limits !== null && parameters.properties.limits !== undefined) {7920 var limitsValue = {};7921 propertiesValue['limits'] = limitsValue;7922 7923 if (parameters.properties.limits.maxPercentageCpu !== null && parameters.properties.limits.maxPercentageCpu !== undefined) {7924 limitsValue['maxPercentageCpu'] = parameters.properties.limits.maxPercentageCpu;7925 }7926 7927 if (parameters.properties.limits.maxMemoryInMb !== null && parameters.properties.limits.maxMemoryInMb !== undefined) {7928 limitsValue['maxMemoryInMb'] = parameters.properties.limits.maxMemoryInMb;7929 }7930 7931 if (parameters.properties.limits.maxDiskSizeInMb !== null && parameters.properties.limits.maxDiskSizeInMb !== undefined) {7932 limitsValue['maxDiskSizeInMb'] = parameters.properties.limits.maxDiskSizeInMb;7933 }7934 }7935 7936 if (parameters.id !== null && parameters.id !== undefined) {7937 webSiteUpdateConfigurationParametersValue['id'] = parameters.id;7938 }7939 7940 if (parameters.name !== null && parameters.name !== undefined) {7941 webSiteUpdateConfigurationParametersValue['name'] = parameters.name;7942 }7943 7944 webSiteUpdateConfigurationParametersValue['location'] = parameters.location;7945 7946 if (parameters.tags !== null && parameters.tags !== undefined) {7947 var tagsDictionary = {};7948 for (var tagsKey in parameters.tags) {7949 var tagsValue = parameters.tags[tagsKey];7950 tagsDictionary[tagsKey] = tagsValue;7951 }7952 webSiteUpdateConfigurationParametersValue['tags'] = tagsDictionary;7953 }7954 7955 if (parameters.type !== null && parameters.type !== undefined) {7956 webSiteUpdateConfigurationParametersValue['type'] = parameters.type;7957 }7958 7959 requestContent = JSON.stringify(requestDoc);7960 httpRequest.body = requestContent;7961 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');7962 // Send Request7963 return this.client.pipeline(httpRequest, function (err, response, body) {7964 if (err !== null && err !== undefined) {7965 return callback(err);7966 }7967 var statusCode = response.statusCode;7968 if (statusCode !== 200) {7969 var error = new Error(body);7970 error.statusCode = response.statusCode;7971 return callback(error);7972 }7973 7974 // Create Result7975 var result = null;7976 // Deserialize Response7977 result = {};7978 result.statusCode = statusCode;7979 result.requestId = response.headers['x-ms-request-id'];7980 7981 return callback(null, result);7982 });7983 };7984 7985 /**7986 * You can retrieve the connection strings for a web site by issuing an HTTP7987 * GET request, or update them by using HTTP PUT with a request body that7988 * contains the settings to be updated. (see7989 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for7990 * more information)7991 * 7992 * @param {string} resourceGroupName The name of the resource group7993 * 7994 * @param {string} webSiteName The name of the website7995 * 7996 * @param {string} [slotName] The name of the slot of the website7997 * 7998 * @param {WebSiteUpdateConnectionStringsParameters} parameters The Update7999 * Web Site connection strings parameters8000 * 8001 * @param {array} parameters.properties The connection strings for the web8002 * site.8003 * 8004 * @param {string} [parameters.id] Gets the ID of the resource.8005 * 8006 * @param {string} [parameters.name] The name of the resource.8007 * 8008 * @param {string} parameters.location Gets or sets the location of the8009 * resource.8010 * 8011 * @param {object} [parameters.tags] Gets or sets the tags attached to the8012 * resource.8013 * 8014 * @param {string} [parameters.type] The type of the resource8015 * 8016 * @param {function} callback8017 * 8018 * @returns {Stream} The response stream.8019 */8020 WebSiteOperations.prototype.updateConnectionStrings = function(resourceGroupName, webSiteName, slotName, parameters, callback) {8021 if (callback === null || callback === undefined) {8022 throw new Error('callback cannot be null.');8023 }8024 // Validate8025 if (resourceGroupName === null || resourceGroupName === undefined) {8026 return callback(new Error('resourceGroupName cannot be null.'));8027 }8028 if (webSiteName === null || webSiteName === undefined) {8029 return callback(new Error('webSiteName cannot be null.'));8030 }8031 if (parameters === null || parameters === undefined) {8032 return callback(new Error('parameters cannot be null.'));8033 }8034 if (parameters.location === null || parameters.location === undefined) {8035 return callback(new Error('parameters.location cannot be null.'));8036 }8037 if (parameters.properties === null || parameters.properties === undefined) {8038 return callback(new Error('parameters.properties cannot be null.'));8039 }8040 8041 // Tracing8042 8043 // Construct URL8044 var url2 = '';8045 url2 = url2 + '/subscriptions/';8046 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {8047 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);8048 }8049 url2 = url2 + '/resourceGroups/';8050 url2 = url2 + encodeURIComponent(resourceGroupName);8051 url2 = url2 + '/providers/';8052 url2 = url2 + 'Microsoft.Web';8053 url2 = url2 + '/';8054 url2 = url2 + 'sites';8055 url2 = url2 + '/';8056 url2 = url2 + encodeURIComponent(webSiteName);8057 if (slotName !== null && slotName !== undefined) {8058 url2 = url2 + '/slots/' + encodeURIComponent(slotName);8059 }8060 url2 = url2 + '/config/connectionstrings';8061 var queryParameters = [];8062 queryParameters.push('api-version=2014-06-01');8063 if (queryParameters.length > 0) {8064 url2 = url2 + '?' + queryParameters.join('&');8065 }8066 var baseUrl = this.client.baseUri;8067 // Trim '/' character from the end of baseUrl and beginning of url.8068 if (baseUrl[baseUrl.length - 1] === '/') {8069 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);8070 }8071 if (url2[0] === '/') {8072 url2 = url2.substring(1);8073 }8074 url2 = baseUrl + '/' + url2;8075 url2 = url2.replace(' ', '%20');8076 8077 // Create HTTP transport objects8078 var httpRequest = new WebResource();8079 httpRequest.method = 'PUT';8080 httpRequest.headers = {};8081 httpRequest.url = url2;8082 8083 // Set Headers8084 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';8085 8086 // Serialize Request8087 var requestContent = null;8088 var requestDoc = null;8089 8090 var webSiteUpdateConnectionStringsParametersValue = {};8091 requestDoc = webSiteUpdateConnectionStringsParametersValue;8092 8093 if (parameters.properties !== null && parameters.properties !== undefined) {8094 var propertiesArray = [];8095 for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.length; loweredIndex1 = loweredIndex1 + 1) {8096 var propertiesItem = parameters.properties[loweredIndex1];8097 var connStringInfoValue = {};8098 propertiesArray.push(connStringInfoValue);8099 8100 if (propertiesItem.connectionString !== null && propertiesItem.connectionString !== undefined) {8101 connStringInfoValue['connectionString'] = propertiesItem.connectionString;8102 }8103 8104 if (propertiesItem.name !== null && propertiesItem.name !== undefined) {8105 connStringInfoValue['name'] = propertiesItem.name;8106 }8107 8108 if (propertiesItem.type !== null && propertiesItem.type !== undefined) {8109 connStringInfoValue['type'] = propertiesItem.type !== null && propertiesItem.type !== undefined ? propertiesItem.type.toString() : 'MySql';8110 }8111 }8112 webSiteUpdateConnectionStringsParametersValue['properties'] = propertiesArray;8113 }8114 8115 if (parameters.id !== null && parameters.id !== undefined) {8116 webSiteUpdateConnectionStringsParametersValue['id'] = parameters.id;8117 }8118 8119 if (parameters.name !== null && parameters.name !== undefined) {8120 webSiteUpdateConnectionStringsParametersValue['name'] = parameters.name;8121 }8122 8123 webSiteUpdateConnectionStringsParametersValue['location'] = parameters.location;8124 8125 if (parameters.tags !== null && parameters.tags !== undefined) {8126 var tagsDictionary = {};8127 for (var tagsKey in parameters.tags) {8128 var tagsValue = parameters.tags[tagsKey];8129 tagsDictionary[tagsKey] = tagsValue;8130 }8131 webSiteUpdateConnectionStringsParametersValue['tags'] = tagsDictionary;8132 }8133 8134 if (parameters.type !== null && parameters.type !== undefined) {8135 webSiteUpdateConnectionStringsParametersValue['type'] = parameters.type;8136 }8137 8138 requestContent = JSON.stringify(requestDoc);8139 httpRequest.body = requestContent;8140 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');8141 // Send Request8142 return this.client.pipeline(httpRequest, function (err, response, body) {8143 if (err !== null && err !== undefined) {8144 return callback(err);8145 }8146 var statusCode = response.statusCode;8147 if (statusCode !== 200) {8148 var error = new Error(body);8149 error.statusCode = response.statusCode;8150 return callback(error);8151 }8152 8153 // Create Result8154 var result = null;8155 // Deserialize Response8156 if (statusCode === 200) {8157 var responseContent = body;8158 result = {};8159 var responseDoc = null;8160 if (responseContent) {8161 responseDoc = JSON.parse(responseContent);8162 }8163 8164 if (responseDoc !== null && responseDoc !== undefined) {8165 var resourceInstance = { properties: [], tags: {} };8166 result.resource = resourceInstance;8167 8168 var propertiesArray2 = responseDoc['properties'];8169 if (propertiesArray2 !== null && propertiesArray2 !== undefined) {8170 for (var loweredIndex2 = 0; loweredIndex2 < propertiesArray2.length; loweredIndex2 = loweredIndex2 + 1) {8171 var propertiesValue = propertiesArray2[loweredIndex2];8172 var connStringInfoInstance = {};8173 resourceInstance.properties.push(connStringInfoInstance);8174 8175 var connectionStringValue = propertiesValue['connectionString'];8176 if (connectionStringValue !== null && connectionStringValue !== undefined) {8177 var connectionStringInstance = connectionStringValue;8178 connStringInfoInstance.connectionString = connectionStringInstance;8179 }8180 8181 var nameValue = propertiesValue['name'];8182 if (nameValue !== null && nameValue !== undefined) {8183 var nameInstance = nameValue;8184 connStringInfoInstance.name = nameInstance;8185 }8186 8187 var typeValue = propertiesValue['type'];8188 if (typeValue !== null && typeValue !== undefined) {8189 var typeInstance = typeValue;8190 connStringInfoInstance.type = typeInstance;8191 }8192 }8193 }8194 8195 var idValue = responseDoc['id'];8196 if (idValue !== null && idValue !== undefined) {8197 var idInstance = idValue;8198 resourceInstance.id = idInstance;8199 }8200 8201 var nameValue2 = responseDoc['name'];8202 if (nameValue2 !== null && nameValue2 !== undefined) {8203 var nameInstance2 = nameValue2;8204 resourceInstance.name = nameInstance2;8205 }8206 8207 var locationValue = responseDoc['location'];8208 if (locationValue !== null && locationValue !== undefined) {8209 var locationInstance = locationValue;8210 resourceInstance.location = locationInstance;8211 }8212 8213 var tagsSequenceElement = responseDoc['tags'];8214 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {8215 for (var property in tagsSequenceElement) {8216 var tagsKey2 = property;8217 var tagsValue2 = tagsSequenceElement[property];8218 resourceInstance.tags[tagsKey2] = tagsValue2;8219 }8220 }8221 8222 var typeValue2 = responseDoc['type'];8223 if (typeValue2 !== null && typeValue2 !== undefined) {8224 var typeInstance2 = typeValue2;8225 resourceInstance.type = typeInstance2;8226 }8227 }8228 8229 }8230 result.statusCode = statusCode;8231 result.requestId = response.headers['x-ms-request-id'];8232 8233 return callback(null, result);8234 });8235 };8236 8237 /**8238 * You can retrieve the metadata for a web site by issuing an HTTP GET8239 * request, or update them by using HTTP PUT with a request body that8240 * contains the settings to be updated. (see8241 * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for8242 * more information)8243 * 8244 * @param {string} resourceGroupName The name of the resource group8245 * 8246 * @param {string} webSiteName The name of the website8247 * 8248 * @param {string} [slotName] The name of the slot of the website8249 * 8250 * @param {WebSiteNameValueParameters} parameters The Update Web Site8251 * metadata parameters8252 * 8253 * @param {array} parameters.properties The name value pair parameters for8254 * the web site.8255 * 8256 * @param {string} [parameters.id] Gets the ID of the resource.8257 * 8258 * @param {string} [parameters.name] The name of the resource.8259 * 8260 * @param {string} parameters.location Gets or sets the location of the8261 * resource.8262 * 8263 * @param {object} [parameters.tags] Gets or sets the tags attached to the8264 * resource.8265 * 8266 * @param {string} [parameters.type] The type of the resource8267 * 8268 * @param {function} callback8269 * 8270 * @returns {Stream} The response stream.8271 */8272 WebSiteOperations.prototype.updateMetadata = function(resourceGroupName, webSiteName, slotName, parameters, callback) {8273 if (callback === null || callback === undefined) {8274 throw new Error('callback cannot be null.');8275 }8276 // Validate8277 if (resourceGroupName === null || resourceGroupName === undefined) {8278 return callback(new Error('resourceGroupName cannot be null.'));8279 }8280 if (webSiteName === null || webSiteName === undefined) {8281 return callback(new Error('webSiteName cannot be null.'));8282 }8283 if (parameters === null || parameters === undefined) {8284 return callback(new Error('parameters cannot be null.'));8285 }8286 if (parameters.location === null || parameters.location === undefined) {8287 return callback(new Error('parameters.location cannot be null.'));8288 }8289 if (parameters.properties === null || parameters.properties === undefined) {8290 return callback(new Error('parameters.properties cannot be null.'));8291 }8292 8293 // Tracing8294 8295 // Construct URL8296 var url2 = '';8297 url2 = url2 + '/subscriptions/';8298 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {8299 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);8300 }8301 url2 = url2 + '/resourceGroups/';8302 url2 = url2 + encodeURIComponent(resourceGroupName);8303 url2 = url2 + '/providers/';8304 url2 = url2 + 'Microsoft.Web';8305 url2 = url2 + '/';8306 url2 = url2 + 'sites';8307 url2 = url2 + '/';8308 url2 = url2 + encodeURIComponent(webSiteName);8309 if (slotName !== null && slotName !== undefined) {8310 url2 = url2 + '/slots/' + encodeURIComponent(slotName);8311 }8312 url2 = url2 + '/config/metadata';8313 var queryParameters = [];8314 queryParameters.push('api-version=2014-06-01');8315 if (queryParameters.length > 0) {8316 url2 = url2 + '?' + queryParameters.join('&');8317 }8318 var baseUrl = this.client.baseUri;8319 // Trim '/' character from the end of baseUrl and beginning of url.8320 if (baseUrl[baseUrl.length - 1] === '/') {8321 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);8322 }8323 if (url2[0] === '/') {8324 url2 = url2.substring(1);8325 }8326 url2 = baseUrl + '/' + url2;8327 url2 = url2.replace(' ', '%20');8328 8329 // Create HTTP transport objects8330 var httpRequest = new WebResource();8331 httpRequest.method = 'PUT';8332 httpRequest.headers = {};8333 httpRequest.url = url2;8334 8335 // Set Headers8336 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';8337 8338 // Serialize Request8339 var requestContent = null;8340 var requestDoc = null;8341 8342 var webSiteNameValueParametersValue = {};8343 requestDoc = webSiteNameValueParametersValue;8344 8345 if (parameters.properties !== null && parameters.properties !== undefined) {8346 var propertiesArray = [];8347 for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.length; loweredIndex1 = loweredIndex1 + 1) {8348 var propertiesItem = parameters.properties[loweredIndex1];8349 var nameValuePairValue = {};8350 propertiesArray.push(nameValuePairValue);8351 8352 if (propertiesItem.name !== null && propertiesItem.name !== undefined) {8353 nameValuePairValue['name'] = propertiesItem.name;8354 }8355 8356 if (propertiesItem.value !== null && propertiesItem.value !== undefined) {8357 nameValuePairValue['value'] = propertiesItem.value;8358 }8359 }8360 webSiteNameValueParametersValue['properties'] = propertiesArray;8361 }8362 8363 if (parameters.id !== null && parameters.id !== undefined) {8364 webSiteNameValueParametersValue['id'] = parameters.id;8365 }8366 8367 if (parameters.name !== null && parameters.name !== undefined) {8368 webSiteNameValueParametersValue['name'] = parameters.name;8369 }8370 8371 webSiteNameValueParametersValue['location'] = parameters.location;8372 8373 if (parameters.tags !== null && parameters.tags !== undefined) {8374 var tagsDictionary = {};8375 for (var tagsKey in parameters.tags) {8376 var tagsValue = parameters.tags[tagsKey];8377 tagsDictionary[tagsKey] = tagsValue;8378 }8379 webSiteNameValueParametersValue['tags'] = tagsDictionary;8380 }8381 8382 if (parameters.type !== null && parameters.type !== undefined) {8383 webSiteNameValueParametersValue['type'] = parameters.type;8384 }8385 8386 requestContent = JSON.stringify(requestDoc);8387 httpRequest.body = requestContent;8388 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');8389 // Send Request8390 return this.client.pipeline(httpRequest, function (err, response, body) {8391 if (err !== null && err !== undefined) {8392 return callback(err);8393 }8394 var statusCode = response.statusCode;8395 if (statusCode !== 200) {8396 var error = new Error(body);8397 error.statusCode = response.statusCode;8398 return callback(error);8399 }8400 8401 // Create Result8402 var result = null;8403 // Deserialize Response8404 if (statusCode === 200) {8405 var responseContent = body;8406 result = {};8407 var responseDoc = null;8408 if (responseContent) {8409 responseDoc = JSON.parse(responseContent);8410 }8411 8412 if (responseDoc !== null && responseDoc !== undefined) {8413 var resourceInstance = { properties: [], tags: {} };8414 result.resource = resourceInstance;8415 8416 var propertiesArray2 = responseDoc['properties'];8417 if (propertiesArray2 !== null && propertiesArray2 !== undefined) {8418 for (var loweredIndex2 = 0; loweredIndex2 < propertiesArray2.length; loweredIndex2 = loweredIndex2 + 1) {8419 var propertiesValue = propertiesArray2[loweredIndex2];8420 var nameValuePairInstance = {};8421 resourceInstance.properties.push(nameValuePairInstance);8422 8423 var nameValue = propertiesValue['name'];8424 if (nameValue !== null && nameValue !== undefined) {8425 var nameInstance = nameValue;8426 nameValuePairInstance.name = nameInstance;8427 }8428 8429 var valueValue = propertiesValue['value'];8430 if (valueValue !== null && valueValue !== undefined) {8431 var valueInstance = valueValue;8432 nameValuePairInstance.value = valueInstance;8433 }8434 }8435 }8436 8437 var idValue = responseDoc['id'];8438 if (idValue !== null && idValue !== undefined) {8439 var idInstance = idValue;8440 resourceInstance.id = idInstance;8441 }8442 8443 var nameValue2 = responseDoc['name'];8444 if (nameValue2 !== null && nameValue2 !== undefined) {8445 var nameInstance2 = nameValue2;8446 resourceInstance.name = nameInstance2;8447 }8448 8449 var locationValue = responseDoc['location'];8450 if (locationValue !== null && locationValue !== undefined) {8451 var locationInstance = locationValue;8452 resourceInstance.location = locationInstance;8453 }8454 8455 var tagsSequenceElement = responseDoc['tags'];8456 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {8457 for (var property in tagsSequenceElement) {8458 var tagsKey2 = property;8459 var tagsValue2 = tagsSequenceElement[property];8460 resourceInstance.tags[tagsKey2] = tagsValue2;8461 }8462 }8463 8464 var typeValue = responseDoc['type'];8465 if (typeValue !== null && typeValue !== undefined) {8466 var typeInstance = typeValue;8467 resourceInstance.type = typeInstance;8468 }8469 }8470 8471 }8472 result.statusCode = statusCode;8473 result.requestId = response.headers['x-ms-request-id'];8474 8475 return callback(null, result);8476 });8477 };8478 8479 /**8480 * Link source control to website (do not forget to setup the token, and if8481 * needed token secret, for the specific source control type used).8482 * 8483 * @param {string} resourceGroupName The name of the resource group8484 * 8485 * @param {string} webSiteName The name of the web site8486 * 8487 * @param {string} [slotName] The name of the slot of the website8488 * 8489 * @param {SiteSourceControlUpdateParameters} parameters The update site8490 * source control parameters.8491 * 8492 * @param {SiteSourceControlProperties} parameters.properties Gets or sets8493 * the properties of the link site to source control.8494 * 8495 * @param {string} parameters.properties.repoUrl Gets or sets the repository8496 * url.8497 * 8498 * @param {string} [parameters.properties.branch] Gets or sets the branch (if8499 * required, will be master by default).8500 * 8501 * @param {boolean} [parameters.properties.isManualIntegration] Gets or sets8502 * true for repository that requires to be manually synced or false (by8503 * default) otherwise.8504 * 8505 * @param {boolean} [parameters.properties.deploymentRollbackEnabled] Gets or8506 * sets true to keep a repository for non-repository source control provider8507 * (like Dropbox) or false (by default) otherwise.8508 * 8509 * @param {boolean} [parameters.properties.isMercurial] Gets or sets true if8510 * repository is Mercurial or false (by default) otherwise.8511 * 8512 * @param {function} callback8513 * 8514 * @returns {Stream} The response stream.8515 */8516 WebSiteOperations.prototype.updateSiteSourceControl = function(resourceGroupName, webSiteName, slotName, parameters, callback) {8517 if (callback === null || callback === undefined) {8518 throw new Error('callback cannot be null.');8519 }8520 // Validate8521 if (resourceGroupName === null || resourceGroupName === undefined) {8522 return callback(new Error('resourceGroupName cannot be null.'));8523 }8524 if (webSiteName === null || webSiteName === undefined) {8525 return callback(new Error('webSiteName cannot be null.'));8526 }8527 if (parameters === null || parameters === undefined) {8528 return callback(new Error('parameters cannot be null.'));8529 }8530 if (parameters.properties === null || parameters.properties === undefined) {8531 return callback(new Error('parameters.properties cannot be null.'));8532 }8533 if (parameters.properties.repoUrl === null || parameters.properties.repoUrl === undefined) {8534 return callback(new Error('parameters.properties.repoUrl cannot be null.'));8535 }8536 8537 // Tracing8538 8539 // Construct URL8540 var url2 = '';8541 url2 = url2 + '/subscriptions/';8542 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {8543 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);8544 }8545 url2 = url2 + '/resourceGroups/';8546 url2 = url2 + encodeURIComponent(resourceGroupName);8547 url2 = url2 + '/providers/';8548 url2 = url2 + 'Microsoft.Web';8549 url2 = url2 + '/';8550 url2 = url2 + 'sites';8551 url2 = url2 + '/';8552 url2 = url2 + encodeURIComponent(webSiteName);8553 if (slotName !== null && slotName !== undefined) {8554 url2 = url2 + '/slots/' + encodeURIComponent(slotName);8555 }8556 url2 = url2 + '/sourcecontrols/web';8557 var queryParameters = [];8558 queryParameters.push('api-version=2014-06-01');8559 if (queryParameters.length > 0) {8560 url2 = url2 + '?' + queryParameters.join('&');8561 }8562 var baseUrl = this.client.baseUri;8563 // Trim '/' character from the end of baseUrl and beginning of url.8564 if (baseUrl[baseUrl.length - 1] === '/') {8565 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);8566 }8567 if (url2[0] === '/') {8568 url2 = url2.substring(1);8569 }8570 url2 = baseUrl + '/' + url2;8571 url2 = url2.replace(' ', '%20');8572 8573 // Create HTTP transport objects8574 var httpRequest = new WebResource();8575 httpRequest.method = 'PUT';8576 httpRequest.headers = {};8577 httpRequest.url = url2;8578 8579 // Set Headers8580 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';8581 8582 // Serialize Request8583 var requestContent = null;8584 var requestDoc = null;8585 8586 var siteSourceControlUpdateParametersValue = {};8587 requestDoc = siteSourceControlUpdateParametersValue;8588 8589 var propertiesValue = {};8590 siteSourceControlUpdateParametersValue['properties'] = propertiesValue;8591 8592 propertiesValue['repoUrl'] = parameters.properties.repoUrl;8593 8594 if (parameters.properties.branch !== null && parameters.properties.branch !== undefined) {8595 propertiesValue['branch'] = parameters.properties.branch;8596 }8597 8598 if (parameters.properties.isManualIntegration !== null && parameters.properties.isManualIntegration !== undefined) {8599 propertiesValue['isManualIntegration'] = parameters.properties.isManualIntegration;8600 }8601 8602 if (parameters.properties.deploymentRollbackEnabled !== null && parameters.properties.deploymentRollbackEnabled !== undefined) {8603 propertiesValue['deploymentRollbackEnabled'] = parameters.properties.deploymentRollbackEnabled;8604 }8605 8606 if (parameters.properties.isMercurial !== null && parameters.properties.isMercurial !== undefined) {8607 propertiesValue['isMercurial'] = parameters.properties.isMercurial;8608 }8609 8610 requestContent = JSON.stringify(requestDoc);8611 httpRequest.body = requestContent;8612 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');8613 // Send Request8614 return this.client.pipeline(httpRequest, function (err, response, body) {8615 if (err !== null && err !== undefined) {8616 return callback(err);8617 }8618 var statusCode = response.statusCode;8619 if (statusCode !== 200) {8620 var error = new Error(body);8621 error.statusCode = response.statusCode;8622 return callback(error);8623 }8624 8625 // Create Result8626 var result = null;8627 // Deserialize Response8628 if (statusCode === 200) {8629 var responseContent = body;8630 result = {};8631 var responseDoc = null;8632 if (responseContent) {8633 responseDoc = JSON.parse(responseContent);8634 }8635 8636 if (responseDoc !== null && responseDoc !== undefined) {8637 var siteSourceControlInstance = { tags: {} };8638 result.siteSourceControl = siteSourceControlInstance;8639 8640 var propertiesValue2 = responseDoc['properties'];8641 if (propertiesValue2 !== null && propertiesValue2 !== undefined) {8642 var propertiesInstance = {};8643 siteSourceControlInstance.properties = propertiesInstance;8644 8645 var repoUrlValue = propertiesValue2['repoUrl'];8646 if (repoUrlValue !== null && repoUrlValue !== undefined) {8647 var repoUrlInstance = repoUrlValue;8648 propertiesInstance.repoUrl = repoUrlInstance;8649 }8650 8651 var branchValue = propertiesValue2['branch'];8652 if (branchValue !== null && branchValue !== undefined) {8653 var branchInstance = branchValue;8654 propertiesInstance.branch = branchInstance;8655 }8656 8657 var isManualIntegrationValue = propertiesValue2['isManualIntegration'];8658 if (isManualIntegrationValue !== null && isManualIntegrationValue !== undefined) {8659 var isManualIntegrationInstance = isManualIntegrationValue;8660 propertiesInstance.isManualIntegration = isManualIntegrationInstance;8661 }8662 8663 var deploymentRollbackEnabledValue = propertiesValue2['deploymentRollbackEnabled'];8664 if (deploymentRollbackEnabledValue !== null && deploymentRollbackEnabledValue !== undefined) {8665 var deploymentRollbackEnabledInstance = deploymentRollbackEnabledValue;8666 propertiesInstance.deploymentRollbackEnabled = deploymentRollbackEnabledInstance;8667 }8668 8669 var isMercurialValue = propertiesValue2['isMercurial'];8670 if (isMercurialValue !== null && isMercurialValue !== undefined) {8671 var isMercurialInstance = isMercurialValue;8672 propertiesInstance.isMercurial = isMercurialInstance;8673 }8674 }8675 8676 var idValue = responseDoc['id'];8677 if (idValue !== null && idValue !== undefined) {8678 var idInstance = idValue;8679 siteSourceControlInstance.id = idInstance;8680 }8681 8682 var nameValue = responseDoc['name'];8683 if (nameValue !== null && nameValue !== undefined) {8684 var nameInstance = nameValue;8685 siteSourceControlInstance.name = nameInstance;8686 }8687 8688 var locationValue = responseDoc['location'];8689 if (locationValue !== null && locationValue !== undefined) {8690 var locationInstance = locationValue;8691 siteSourceControlInstance.location = locationInstance;8692 }8693 8694 var tagsSequenceElement = responseDoc['tags'];8695 if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {8696 for (var property in tagsSequenceElement) {8697 var tagsKey = property;8698 var tagsValue = tagsSequenceElement[property];8699 siteSourceControlInstance.tags[tagsKey] = tagsValue;8700 }8701 }8702 8703 var typeValue = responseDoc['type'];8704 if (typeValue !== null && typeValue !== undefined) {8705 var typeInstance = typeValue;8706 siteSourceControlInstance.type = typeInstance;8707 }8708 }8709 8710 }8711 result.statusCode = statusCode;8712 result.requestId = response.headers['x-ms-request-id'];8713 8714 return callback(null, result);8715 });8716 };8717 8718 /**8719 * Update list of app settings and connection strings which to be slot8720 * specific. E.g. settings in staging slots remain in staging after swap8721 * with production.8722 * 8723 * @param {string} resourceGroupName The name of the resource group8724 * 8725 * @param {string} webSiteName The name of the website8726 * 8727 * @param {SlotConfigNamesUpdateParameters} parameters The Update slot8728 * configs parameters8729 * 8730 * @param {SlotConfigNames} parameters.properties The name value pair8731 * parameters for the web site.8732 * 8733 * @param {array} [parameters.properties.connectionStringNames] One or more8734 * string elements that list the name of the connection string setting that8735 * will not be moved durig site swap. For example, if slot named staging has8736 * connection UsersDatabase that points to staging test database, it8737 * shouldn't be moved when swapped with production slot but should take the8738 * current value from production.8739 * 8740 * @param {array} [parameters.properties.appSettingNames] One or more string8741 * elements that list the name of the app setting that will not be moved8742 * durig site swap. For example, if slot named staging has setting8743 * EnableVerboseLogging=1, it shouldn't be moved when swapped with8744 * production slot but should take the current value from production.8745 * 8746 * @param {string} [parameters.id] Gets the ID of the resource.8747 * 8748 * @param {string} [parameters.name] The name of the resource.8749 * 8750 * @param {string} parameters.location Gets or sets the location of the8751 * resource.8752 * 8753 * @param {object} [parameters.tags] Gets or sets the tags attached to the8754 * resource.8755 * 8756 * @param {string} [parameters.type] The type of the resource8757 * 8758 * @param {function} callback8759 * 8760 * @returns {Stream} The response stream.8761 */8762 WebSiteOperations.prototype.updateSlotConfigNames = function(resourceGroupName, webSiteName, parameters, callback) {8763 if (callback === null || callback === undefined) {8764 throw new Error('callback cannot be null.');8765 }8766 // Validate8767 if (resourceGroupName === null || resourceGroupName === undefined) {8768 return callback(new Error('resourceGroupName cannot be null.'));8769 }8770 if (webSiteName === null || webSiteName === undefined) {8771 return callback(new Error('webSiteName cannot be null.'));8772 }8773 if (parameters === null || parameters === undefined) {8774 return callback(new Error('parameters cannot be null.'));8775 }8776 if (parameters.location === null || parameters.location === undefined) {8777 return callback(new Error('parameters.location cannot be null.'));8778 }8779 if (parameters.properties === null || parameters.properties === undefined) {8780 return callback(new Error('parameters.properties cannot be null.'));8781 }8782 8783 // Tracing8784 8785 // Construct URL8786 var url2 = '';8787 url2 = url2 + '/subscriptions/';8788 if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {8789 url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);8790 }8791 url2 = url2 + '/resourceGroups/';8792 url2 = url2 + encodeURIComponent(resourceGroupName);8793 url2 = url2 + '/providers/';8794 url2 = url2 + 'Microsoft.Web';8795 url2 = url2 + '/';8796 url2 = url2 + 'sites';8797 url2 = url2 + '/';8798 url2 = url2 + encodeURIComponent(webSiteName);8799 url2 = url2 + '/slotConfigNames';8800 var queryParameters = [];8801 queryParameters.push('api-version=2014-06-01');8802 if (queryParameters.length > 0) {8803 url2 = url2 + '?' + queryParameters.join('&');8804 }8805 var baseUrl = this.client.baseUri;8806 // Trim '/' character from the end of baseUrl and beginning of url.8807 if (baseUrl[baseUrl.length - 1] === '/') {8808 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);8809 }8810 if (url2[0] === '/') {8811 url2 = url2.substring(1);8812 }8813 url2 = baseUrl + '/' + url2;8814 url2 = url2.replace(' ', '%20');8815 8816 // Create HTTP transport objects8817 var httpRequest = new WebResource();8818 httpRequest.method = 'PUT';8819 httpRequest.headers = {};8820 httpRequest.url = url2;8821 8822 // Set Headers8823 httpRequest.headers['accept'] = 'application/json';8824 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';8825 8826 // Serialize Request8827 var requestContent = null;8828 var requestDoc = null;8829 8830 var slotConfigNamesUpdateParametersValue = {};8831 requestDoc = slotConfigNamesUpdateParametersValue;8832 8833 var propertiesValue = {};8834 slotConfigNamesUpdateParametersValue['properties'] = propertiesValue;8835 8836 if (parameters.properties.connectionStringNames !== null && parameters.properties.connectionStringNames !== undefined) {8837 var connectionStringNamesArray = [];8838 for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.connectionStringNames.length; loweredIndex1 = loweredIndex1 + 1) {8839 var connectionStringNamesItem = parameters.properties.connectionStringNames[loweredIndex1];8840 connectionStringNamesArray.push(connectionStringNamesItem);8841 }8842 propertiesValue['connectionStringNames'] = connectionStringNamesArray;8843 }8844 8845 if (parameters.properties.appSettingNames !== null && parameters.properties.appSettingNames !== undefined) {8846 var appSettingNamesArray = [];8847 for (var loweredIndex2 = 0; loweredIndex2 < parameters.properties.appSettingNames.length; loweredIndex2 = loweredIndex2 + 1) {8848 var appSettingNamesItem = parameters.properties.appSettingNames[loweredIndex2];8849 appSettingNamesArray.push(appSettingNamesItem);8850 }8851 propertiesValue['appSettingNames'] = appSettingNamesArray;8852 }8853 8854 if (parameters.id !== null && parameters.id !== undefined) {8855 slotConfigNamesUpdateParametersValue['id'] = parameters.id;8856 }8857 8858 if (parameters.name !== null && parameters.name !== undefined) {8859 slotConfigNamesUpdateParametersValue['name'] = parameters.name;8860 }8861 8862 slotConfigNamesUpdateParametersValue['location'] = parameters.location;8863 8864 if (parameters.tags !== null && parameters.tags !== undefined) {8865 var tagsDictionary = {};8866 for (var tagsKey in parameters.tags) {8867 var tagsValue = parameters.tags[tagsKey];8868 tagsDictionary[tagsKey] = tagsValue;8869 }8870 slotConfigNamesUpdateParametersValue['tags'] = tagsDictionary;8871 }8872 8873 if (parameters.type !== null && parameters.type !== undefined) {8874 slotConfigNamesUpdateParametersValue['type'] = parameters.type;8875 }8876 8877 requestContent = JSON.stringify(requestDoc);8878 httpRequest.body = requestContent;8879 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');8880 // Send Request8881 return this.client.pipeline(httpRequest, function (err, response, body) {8882 if (err !== null && err !== undefined) {8883 return callback(err);8884 }8885 var statusCode = response.statusCode;8886 if (statusCode !== 200) {8887 var error = new Error(body);8888 error.statusCode = response.statusCode;8889 return callback(error);8890 }8891 8892 // Create Result8893 var result = null;8894 // Deserialize Response8895 result = {};8896 result.statusCode = statusCode;8897 result.requestId = response.headers['x-ms-request-id'];8898 8899 return callback(null, result);8900 });8901 };8902 8903 return WebSiteOperations;
...
graphRbacManagementClient.js
Source:graphRbacManagementClient.js
1/* jshint latedef:false */2/* jshint forin:false */3/* jshint noempty:false */45// 6// Copyright (c) Microsoft and contributors. All rights reserved.7// 8// Licensed under the Apache License, Version 2.0 (the "License");9// you may not use this file except in compliance with the License.10// You may obtain a copy of the License at11// http://www.apache.org/licenses/LICENSE-2.012// 13// Unless required by applicable law or agreed to in writing, software14// distributed under the License is distributed on an "AS IS" BASIS,15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16// 17// See the License for the specific language governing permissions and18// limitations under the License.19// 2021// Warning: This code was generated by a tool.22// 23// Changes to this file may cause incorrect behavior and will be lost if the24// code is regenerated.2526'use strict';2728var util = require('util');29var azureCommon = require('azure-common');30var Service = azureCommon.Service;31var WebResource = azureCommon.WebResource;3233var GraphRbacManagementClient = ( /** @lends GraphRbacManagementClient */ function() {34 /**35 * @class36 * Initializes a new instance of the GraphRbacManagementClient class.37 * @constructor38 * 39 * @param {string} tenantID Gets or sets the tenant Id.40 * 41 * @param {SubscriptionCloudCredentials} credentials Gets subscription42 * credentials which uniquely identify Microsoft Azure subscription. The43 * subscription ID forms part of the URI for every service call.44 * 45 * @param {string} [credentials.subscriptionId]46 * 47 * @param {string} [baseUri] Gets the URI used as the base for all cloud48 * service requests.49 * 50 * @param {Array} filters51 */52 function GraphRbacManagementClient(tenantID, credentials, baseUri, filters) {53 if (tenantID === null || tenantID === undefined) {54 throw new Error('tenantID cannot be null.');55 }56 if (credentials === null || credentials === undefined) {57 throw new Error('credentials cannot be null.');58 }59 60 GraphRbacManagementClient['super_'].call(this, credentials, filters);61 62 this.tenantID = tenantID;63 this.credentials = credentials;64 this.baseUri = baseUri;65 if (this.baseUri === null || this.baseUri === undefined) {66 this.baseUri = 'https://graph.windows.net/';67 }68 if (this.apiVersion === null || this.apiVersion === undefined) {69 this.apiVersion = '1.42-previewInternal';70 }71 if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) {72 this.longRunningOperationInitialTimeout = -1;73 }74 if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) {75 this.longRunningOperationRetryTimeout = -1;76 }77 /**78 * Provides an instance of the79 * [ApplicationOperations](-ApplicationOperations.html) object.80 * @type {object}81 */82 this.application = new ApplicationOperations(this);83 /**84 * Provides an instance of the [GroupOperations](-GroupOperations.html)85 * object.86 * @type {object}87 */88 this.group = new GroupOperations(this);89 /**90 * Provides an instance of the [ObjectOperations](-ObjectOperations.html)91 * object.92 * @type {object}93 */94 this.objects = new ObjectOperations(this);95 /**96 * Provides an instance of the97 * [ServicePrincipalOperations](-ServicePrincipalOperations.html) object.98 * @type {object}99 */100 this.servicePrincipal = new ServicePrincipalOperations(this);101 /**102 * Provides an instance of the [UserOperations](-UserOperations.html)103 * object.104 * @type {object}105 */106 this.user = new UserOperations(this);107 }108 109 util.inherits(GraphRbacManagementClient, Service);110 111 112 return GraphRbacManagementClient;113})();114exports.GraphRbacManagementClient = GraphRbacManagementClient;115116var ApplicationOperations = ( /** @lends ApplicationOperations */ function() {117 /**118 * @class119 * Operations for working with applications in Azure Active Directory Graph120 * API. (see http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx121 * for more information)122 * __NOTE__: An instance of this class is automatically created for an123 * instance of the [GraphRbacManagementClient] {@link124 * GraphRbacManagementClient~GraphRbacManagementClient}.125 * See [application] {@link126 * GraphRbacManagementClient~GraphRbacManagementClient#application}.127 * Initializes a new instance of the ApplicationOperations class.128 * @constructor129 * 130 * @param {GraphRbacManagementClient} client Reference to the service client.131 */132 function ApplicationOperations(client) {133 this.client = client;134 }135 136 /**137 * Create a new application. (see138 * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more139 * information)140 * 141 * @param {ApplicationCreateParameters} parameters Parameters to create an142 * application.143 * 144 * @param {boolean} parameters.availableToOtherTenants Indicates if the145 * application will be available to other tenants146 * 147 * @param {string} parameters.displayName Application display name148 * 149 * @param {string} parameters.homepage Application homepage150 * 151 * @param {IEnumerable} parameters.identifierUris Application Uris152 * 153 * @param {IEnumerable} [parameters.replyUrls] Application reply Urls154 * 155 * @param {IEnumerable} [parameters.keyCredentials] Gets or sets the list of156 * KeyCredential objects157 * 158 * @param {IEnumerable} [parameters.passwordCredentials] Gets or sets the159 * list of PasswordCredential objects160 * 161 * @param {function} callback162 * 163 * @returns {Stream} The response stream.164 */165 ApplicationOperations.prototype.create = function(parameters, callback) {166 if (callback === null || callback === undefined) {167 throw new Error('callback cannot be null.');168 }169 // Validate170 if (parameters === null || parameters === undefined) {171 return callback(new Error('parameters cannot be null.'));172 }173 if (parameters.availableToOtherTenants === null || parameters.availableToOtherTenants === undefined) {174 return callback(new Error('parameters.availableToOtherTenants cannot be null.'));175 }176 if (parameters.displayName === null || parameters.displayName === undefined) {177 return callback(new Error('parameters.displayName cannot be null.'));178 }179 if (parameters.homepage === null || parameters.homepage === undefined) {180 return callback(new Error('parameters.homepage cannot be null.'));181 }182 if (parameters.identifierUris === null || parameters.identifierUris === undefined) {183 return callback(new Error('parameters.identifierUris cannot be null.'));184 }185 186 // Tracing187 188 // Construct URL189 var url2 = '';190 url2 = url2 + '/';191 url2 = url2 + encodeURIComponent(this.client.tenantID);192 url2 = url2 + '/applications';193 var queryParameters = [];194 queryParameters.push('api-version=1.42-previewInternal');195 if (queryParameters.length > 0) {196 url2 = url2 + '?' + queryParameters.join('&');197 }198 var baseUrl = this.client.baseUri;199 // Trim '/' character from the end of baseUrl and beginning of url.200 if (baseUrl[baseUrl.length - 1] === '/') {201 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);202 }203 if (url2[0] === '/') {204 url2 = url2.substring(1);205 }206 url2 = baseUrl + '/' + url2;207 url2 = url2.replace(' ', '%20');208 209 // Create HTTP transport objects210 var httpRequest = new WebResource();211 httpRequest.method = 'POST';212 httpRequest.headers = {};213 httpRequest.url = url2;214 215 // Set Headers216 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';217 218 // Serialize Request219 var requestContent = null;220 var requestDoc = null;221 222 var applicationCreateParametersValue = {};223 requestDoc = applicationCreateParametersValue;224 225 applicationCreateParametersValue['availableToOtherTenants'] = parameters.availableToOtherTenants;226 227 applicationCreateParametersValue['displayName'] = parameters.displayName;228 229 applicationCreateParametersValue['homepage'] = parameters.homepage;230 231 if (parameters.identifierUris !== null && parameters.identifierUris !== undefined) {232 var identifierUrisArray = [];233 for (var loweredIndex1 = 0; loweredIndex1 < parameters.identifierUris.length; loweredIndex1 = loweredIndex1 + 1) {234 var identifierUrisItem = parameters.identifierUris[loweredIndex1];235 identifierUrisArray.push(identifierUrisItem);236 }237 applicationCreateParametersValue['identifierUris'] = identifierUrisArray;238 }239 240 if (parameters.replyUrls !== null && parameters.replyUrls !== undefined) {241 var replyUrlsArray = [];242 for (var loweredIndex2 = 0; loweredIndex2 < parameters.replyUrls.length; loweredIndex2 = loweredIndex2 + 1) {243 var replyUrlsItem = parameters.replyUrls[loweredIndex2];244 replyUrlsArray.push(replyUrlsItem);245 }246 applicationCreateParametersValue['replyUrls'] = replyUrlsArray;247 }248 249 if (parameters.keyCredentials !== null && parameters.keyCredentials !== undefined) {250 var keyCredentialsArray = [];251 for (var loweredIndex3 = 0; loweredIndex3 < parameters.keyCredentials.length; loweredIndex3 = loweredIndex3 + 1) {252 var keyCredentialsItem = parameters.keyCredentials[loweredIndex3];253 var keyCredentialValue = {};254 keyCredentialsArray.push(keyCredentialValue);255 256 if (keyCredentialsItem.startDate !== null && keyCredentialsItem.startDate !== undefined) {257 keyCredentialValue['startDate'] = keyCredentialsItem.startDate.toISOString();258 }259 260 if (keyCredentialsItem.endDate !== null && keyCredentialsItem.endDate !== undefined) {261 keyCredentialValue['endDate'] = keyCredentialsItem.endDate.toISOString();262 }263 264 if (keyCredentialsItem.value !== null && keyCredentialsItem.value !== undefined) {265 keyCredentialValue['value'] = keyCredentialsItem.value;266 }267 268 if (keyCredentialsItem.keyId !== null && keyCredentialsItem.keyId !== undefined) {269 keyCredentialValue['keyId'] = keyCredentialsItem.keyId;270 }271 272 if (keyCredentialsItem.usage !== null && keyCredentialsItem.usage !== undefined) {273 keyCredentialValue['usage'] = keyCredentialsItem.usage;274 }275 276 if (keyCredentialsItem.type !== null && keyCredentialsItem.type !== undefined) {277 keyCredentialValue['type'] = keyCredentialsItem.type;278 }279 }280 applicationCreateParametersValue['keyCredentials'] = keyCredentialsArray;281 }282 283 if (parameters.passwordCredentials !== null && parameters.passwordCredentials !== undefined) {284 var passwordCredentialsArray = [];285 for (var loweredIndex4 = 0; loweredIndex4 < parameters.passwordCredentials.length; loweredIndex4 = loweredIndex4 + 1) {286 var passwordCredentialsItem = parameters.passwordCredentials[loweredIndex4];287 var passwordCredentialValue = {};288 passwordCredentialsArray.push(passwordCredentialValue);289 290 if (passwordCredentialsItem.startDate !== null && passwordCredentialsItem.startDate !== undefined) {291 passwordCredentialValue['startDate'] = passwordCredentialsItem.startDate.toISOString();292 }293 294 if (passwordCredentialsItem.endDate !== null && passwordCredentialsItem.endDate !== undefined) {295 passwordCredentialValue['endDate'] = passwordCredentialsItem.endDate.toISOString();296 }297 298 if (passwordCredentialsItem.keyId !== null && passwordCredentialsItem.keyId !== undefined) {299 passwordCredentialValue['keyId'] = passwordCredentialsItem.keyId;300 }301 302 if (passwordCredentialsItem.value !== null && passwordCredentialsItem.value !== undefined) {303 passwordCredentialValue['value'] = passwordCredentialsItem.value;304 }305 }306 applicationCreateParametersValue['passwordCredentials'] = passwordCredentialsArray;307 }308 309 requestContent = JSON.stringify(requestDoc);310 httpRequest.body = requestContent;311 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');312 // Send Request313 return this.client.pipeline(httpRequest, function (err, response, body) {314 if (err !== null && err !== undefined) {315 return callback(err);316 }317 var statusCode = response.statusCode;318 if (statusCode !== 201) {319 var error = new Error(body);320 error.statusCode = response.statusCode;321 return callback(error);322 }323 324 // Create Result325 var result = null;326 // Deserialize Response327 if (statusCode === 201) {328 var responseContent = body;329 result = {};330 var responseDoc = null;331 if (responseContent) {332 responseDoc = JSON.parse(responseContent);333 }334 335 if (responseDoc !== null && responseDoc !== undefined) {336 var applicationInstance = { appPermissions: [] };337 result.application = applicationInstance;338 339 var objectIdValue = responseDoc['objectId'];340 if (objectIdValue !== null && objectIdValue !== undefined) {341 var objectIdInstance = objectIdValue;342 applicationInstance.objectId = objectIdInstance;343 }344 345 var objectTypeValue = responseDoc['objectType'];346 if (objectTypeValue !== null && objectTypeValue !== undefined) {347 var objectTypeInstance = objectTypeValue;348 applicationInstance.objectType = objectTypeInstance;349 }350 351 var appIdValue = responseDoc['appId'];352 if (appIdValue !== null && appIdValue !== undefined) {353 var appIdInstance = appIdValue;354 applicationInstance.appId = appIdInstance;355 }356 357 var appPermissionsArray = responseDoc['appPermissions'];358 if (appPermissionsArray !== null && appPermissionsArray !== undefined) {359 for (var loweredIndex5 = 0; loweredIndex5 < appPermissionsArray.length; loweredIndex5 = loweredIndex5 + 1) {360 var appPermissionsValue = appPermissionsArray[loweredIndex5];361 applicationInstance.appPermissions.push(appPermissionsValue);362 }363 }364 365 var availableToOtherTenantsValue = responseDoc['availableToOtherTenants'];366 if (availableToOtherTenantsValue !== null && availableToOtherTenantsValue !== undefined) {367 var availableToOtherTenantsInstance = availableToOtherTenantsValue;368 applicationInstance.availableToOtherTenants = availableToOtherTenantsInstance;369 }370 }371 372 }373 result.statusCode = statusCode;374 result.requestId = response.headers['request-id'];375 376 return callback(null, result);377 });378 };379 380 /**381 * Delete an application. (see382 * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more383 * information)384 * 385 * @param {string} applicationObjectId Application object id386 * 387 * @param {function} callback388 * 389 * @returns {Stream} The response stream.390 */391 ApplicationOperations.prototype.deleteMethod = function(applicationObjectId, callback) {392 if (callback === null || callback === undefined) {393 throw new Error('callback cannot be null.');394 }395 // Validate396 if (applicationObjectId === null || applicationObjectId === undefined) {397 return callback(new Error('applicationObjectId cannot be null.'));398 }399 400 // Tracing401 402 // Construct URL403 var url2 = '';404 url2 = url2 + '/';405 url2 = url2 + encodeURIComponent(this.client.tenantID);406 url2 = url2 + '/applications/';407 url2 = url2 + applicationObjectId;408 var queryParameters = [];409 queryParameters.push('api-version=1.42-previewInternal');410 if (queryParameters.length > 0) {411 url2 = url2 + '?' + queryParameters.join('&');412 }413 var baseUrl = this.client.baseUri;414 // Trim '/' character from the end of baseUrl and beginning of url.415 if (baseUrl[baseUrl.length - 1] === '/') {416 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);417 }418 if (url2[0] === '/') {419 url2 = url2.substring(1);420 }421 url2 = baseUrl + '/' + url2;422 url2 = url2.replace(' ', '%20');423 424 // Create HTTP transport objects425 var httpRequest = new WebResource();426 httpRequest.method = 'DELETE';427 httpRequest.headers = {};428 httpRequest.url = url2;429 430 // Set Headers431 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';432 433 // Send Request434 return this.client.pipeline(httpRequest, function (err, response, body) {435 if (err !== null && err !== undefined) {436 return callback(err);437 }438 var statusCode = response.statusCode;439 if (statusCode !== 204) {440 var error = new Error(body);441 error.statusCode = response.statusCode;442 return callback(error);443 }444 445 // Create Result446 var result = null;447 // Deserialize Response448 result = {};449 result.statusCode = statusCode;450 result.requestId = response.headers['request-id'];451 452 return callback(null, result);453 });454 };455 456 /**457 * Get an application by object Id. (see458 * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more459 * information)460 * 461 * @param {string} applicationObjectId Application object id462 * 463 * @param {function} callback464 * 465 * @returns {Stream} The response stream.466 */467 ApplicationOperations.prototype.get = function(applicationObjectId, callback) {468 if (callback === null || callback === undefined) {469 throw new Error('callback cannot be null.');470 }471 // Validate472 if (applicationObjectId === null || applicationObjectId === undefined) {473 return callback(new Error('applicationObjectId cannot be null.'));474 }475 476 // Tracing477 478 // Construct URL479 var url2 = '';480 url2 = url2 + '/';481 url2 = url2 + encodeURIComponent(this.client.tenantID);482 url2 = url2 + '/applications/';483 url2 = url2 + applicationObjectId;484 var queryParameters = [];485 queryParameters.push('api-version=1.42-previewInternal');486 if (queryParameters.length > 0) {487 url2 = url2 + '?' + queryParameters.join('&');488 }489 var baseUrl = this.client.baseUri;490 // Trim '/' character from the end of baseUrl and beginning of url.491 if (baseUrl[baseUrl.length - 1] === '/') {492 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);493 }494 if (url2[0] === '/') {495 url2 = url2.substring(1);496 }497 url2 = baseUrl + '/' + url2;498 url2 = url2.replace(' ', '%20');499 500 // Create HTTP transport objects501 var httpRequest = new WebResource();502 httpRequest.method = 'GET';503 httpRequest.headers = {};504 httpRequest.url = url2;505 506 // Set Headers507 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';508 509 // Send Request510 return this.client.pipeline(httpRequest, function (err, response, body) {511 if (err !== null && err !== undefined) {512 return callback(err);513 }514 var statusCode = response.statusCode;515 if (statusCode !== 204) {516 var error = new Error(body);517 error.statusCode = response.statusCode;518 return callback(error);519 }520 521 // Create Result522 var result = null;523 // Deserialize Response524 if (statusCode === 204) {525 var responseContent = body;526 result = {};527 var responseDoc = null;528 if (responseContent) {529 responseDoc = JSON.parse(responseContent);530 }531 532 if (responseDoc !== null && responseDoc !== undefined) {533 var applicationInstance = { appPermissions: [] };534 result.application = applicationInstance;535 536 var objectIdValue = responseDoc['objectId'];537 if (objectIdValue !== null && objectIdValue !== undefined) {538 var objectIdInstance = objectIdValue;539 applicationInstance.objectId = objectIdInstance;540 }541 542 var objectTypeValue = responseDoc['objectType'];543 if (objectTypeValue !== null && objectTypeValue !== undefined) {544 var objectTypeInstance = objectTypeValue;545 applicationInstance.objectType = objectTypeInstance;546 }547 548 var appIdValue = responseDoc['appId'];549 if (appIdValue !== null && appIdValue !== undefined) {550 var appIdInstance = appIdValue;551 applicationInstance.appId = appIdInstance;552 }553 554 var appPermissionsArray = responseDoc['appPermissions'];555 if (appPermissionsArray !== null && appPermissionsArray !== undefined) {556 for (var loweredIndex1 = 0; loweredIndex1 < appPermissionsArray.length; loweredIndex1 = loweredIndex1 + 1) {557 var appPermissionsValue = appPermissionsArray[loweredIndex1];558 applicationInstance.appPermissions.push(appPermissionsValue);559 }560 }561 562 var availableToOtherTenantsValue = responseDoc['availableToOtherTenants'];563 if (availableToOtherTenantsValue !== null && availableToOtherTenantsValue !== undefined) {564 var availableToOtherTenantsInstance = availableToOtherTenantsValue;565 applicationInstance.availableToOtherTenants = availableToOtherTenantsInstance;566 }567 }568 569 }570 result.statusCode = statusCode;571 result.requestId = response.headers['request-id'];572 573 return callback(null, result);574 });575 };576 577 /**578 * Update existing application. (see579 * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more580 * information)581 * 582 * @param {string} applicationObjectId Application object id583 * 584 * @param {ApplicationCreateParameters} parameters Parameters to create an585 * application.586 * 587 * @param {boolean} parameters.availableToOtherTenants Indicates if the588 * application will be available to other tenants589 * 590 * @param {string} parameters.displayName Application display name591 * 592 * @param {string} parameters.homepage Application homepage593 * 594 * @param {IEnumerable} parameters.identifierUris Application Uris595 * 596 * @param {IEnumerable} [parameters.replyUrls] Application reply Urls597 * 598 * @param {IEnumerable} [parameters.keyCredentials] Gets or sets the list of599 * KeyCredential objects600 * 601 * @param {IEnumerable} [parameters.passwordCredentials] Gets or sets the602 * list of PasswordCredential objects603 * 604 * @param {function} callback605 * 606 * @returns {Stream} The response stream.607 */608 ApplicationOperations.prototype.update = function(applicationObjectId, parameters, callback) {609 if (callback === null || callback === undefined) {610 throw new Error('callback cannot be null.');611 }612 // Validate613 if (applicationObjectId === null || applicationObjectId === undefined) {614 return callback(new Error('applicationObjectId cannot be null.'));615 }616 if (parameters === null || parameters === undefined) {617 return callback(new Error('parameters cannot be null.'));618 }619 if (parameters.availableToOtherTenants === null || parameters.availableToOtherTenants === undefined) {620 return callback(new Error('parameters.availableToOtherTenants cannot be null.'));621 }622 if (parameters.displayName === null || parameters.displayName === undefined) {623 return callback(new Error('parameters.displayName cannot be null.'));624 }625 if (parameters.homepage === null || parameters.homepage === undefined) {626 return callback(new Error('parameters.homepage cannot be null.'));627 }628 if (parameters.identifierUris === null || parameters.identifierUris === undefined) {629 return callback(new Error('parameters.identifierUris cannot be null.'));630 }631 632 // Tracing633 634 // Construct URL635 var url2 = '';636 url2 = url2 + '/';637 url2 = url2 + encodeURIComponent(this.client.tenantID);638 url2 = url2 + '/applications/';639 url2 = url2 + applicationObjectId;640 var queryParameters = [];641 queryParameters.push('api-version=1.42-previewInternal');642 if (queryParameters.length > 0) {643 url2 = url2 + '?' + queryParameters.join('&');644 }645 var baseUrl = this.client.baseUri;646 // Trim '/' character from the end of baseUrl and beginning of url.647 if (baseUrl[baseUrl.length - 1] === '/') {648 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);649 }650 if (url2[0] === '/') {651 url2 = url2.substring(1);652 }653 url2 = baseUrl + '/' + url2;654 url2 = url2.replace(' ', '%20');655 656 // Create HTTP transport objects657 var httpRequest = new WebResource();658 httpRequest.method = 'PATCH';659 httpRequest.headers = {};660 httpRequest.url = url2;661 662 // Set Headers663 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';664 665 // Serialize Request666 var requestContent = null;667 var requestDoc = null;668 669 var applicationCreateParametersValue = {};670 requestDoc = applicationCreateParametersValue;671 672 applicationCreateParametersValue['availableToOtherTenants'] = parameters.availableToOtherTenants;673 674 applicationCreateParametersValue['displayName'] = parameters.displayName;675 676 applicationCreateParametersValue['homepage'] = parameters.homepage;677 678 if (parameters.identifierUris !== null && parameters.identifierUris !== undefined) {679 var identifierUrisArray = [];680 for (var loweredIndex1 = 0; loweredIndex1 < parameters.identifierUris.length; loweredIndex1 = loweredIndex1 + 1) {681 var identifierUrisItem = parameters.identifierUris[loweredIndex1];682 identifierUrisArray.push(identifierUrisItem);683 }684 applicationCreateParametersValue['identifierUris'] = identifierUrisArray;685 }686 687 if (parameters.replyUrls !== null && parameters.replyUrls !== undefined) {688 var replyUrlsArray = [];689 for (var loweredIndex2 = 0; loweredIndex2 < parameters.replyUrls.length; loweredIndex2 = loweredIndex2 + 1) {690 var replyUrlsItem = parameters.replyUrls[loweredIndex2];691 replyUrlsArray.push(replyUrlsItem);692 }693 applicationCreateParametersValue['replyUrls'] = replyUrlsArray;694 }695 696 if (parameters.keyCredentials !== null && parameters.keyCredentials !== undefined) {697 var keyCredentialsArray = [];698 for (var loweredIndex3 = 0; loweredIndex3 < parameters.keyCredentials.length; loweredIndex3 = loweredIndex3 + 1) {699 var keyCredentialsItem = parameters.keyCredentials[loweredIndex3];700 var keyCredentialValue = {};701 keyCredentialsArray.push(keyCredentialValue);702 703 if (keyCredentialsItem.startDate !== null && keyCredentialsItem.startDate !== undefined) {704 keyCredentialValue['startDate'] = keyCredentialsItem.startDate.toISOString();705 }706 707 if (keyCredentialsItem.endDate !== null && keyCredentialsItem.endDate !== undefined) {708 keyCredentialValue['endDate'] = keyCredentialsItem.endDate.toISOString();709 }710 711 if (keyCredentialsItem.value !== null && keyCredentialsItem.value !== undefined) {712 keyCredentialValue['value'] = keyCredentialsItem.value;713 }714 715 if (keyCredentialsItem.keyId !== null && keyCredentialsItem.keyId !== undefined) {716 keyCredentialValue['keyId'] = keyCredentialsItem.keyId;717 }718 719 if (keyCredentialsItem.usage !== null && keyCredentialsItem.usage !== undefined) {720 keyCredentialValue['usage'] = keyCredentialsItem.usage;721 }722 723 if (keyCredentialsItem.type !== null && keyCredentialsItem.type !== undefined) {724 keyCredentialValue['type'] = keyCredentialsItem.type;725 }726 }727 applicationCreateParametersValue['keyCredentials'] = keyCredentialsArray;728 }729 730 if (parameters.passwordCredentials !== null && parameters.passwordCredentials !== undefined) {731 var passwordCredentialsArray = [];732 for (var loweredIndex4 = 0; loweredIndex4 < parameters.passwordCredentials.length; loweredIndex4 = loweredIndex4 + 1) {733 var passwordCredentialsItem = parameters.passwordCredentials[loweredIndex4];734 var passwordCredentialValue = {};735 passwordCredentialsArray.push(passwordCredentialValue);736 737 if (passwordCredentialsItem.startDate !== null && passwordCredentialsItem.startDate !== undefined) {738 passwordCredentialValue['startDate'] = passwordCredentialsItem.startDate.toISOString();739 }740 741 if (passwordCredentialsItem.endDate !== null && passwordCredentialsItem.endDate !== undefined) {742 passwordCredentialValue['endDate'] = passwordCredentialsItem.endDate.toISOString();743 }744 745 if (passwordCredentialsItem.keyId !== null && passwordCredentialsItem.keyId !== undefined) {746 passwordCredentialValue['keyId'] = passwordCredentialsItem.keyId;747 }748 749 if (passwordCredentialsItem.value !== null && passwordCredentialsItem.value !== undefined) {750 passwordCredentialValue['value'] = passwordCredentialsItem.value;751 }752 }753 applicationCreateParametersValue['passwordCredentials'] = passwordCredentialsArray;754 }755 756 requestContent = JSON.stringify(requestDoc);757 httpRequest.body = requestContent;758 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');759 // Send Request760 return this.client.pipeline(httpRequest, function (err, response, body) {761 if (err !== null && err !== undefined) {762 return callback(err);763 }764 var statusCode = response.statusCode;765 if (statusCode !== 204) {766 var error = new Error(body);767 error.statusCode = response.statusCode;768 return callback(error);769 }770 771 // Create Result772 var result = null;773 // Deserialize Response774 result = {};775 result.statusCode = statusCode;776 result.requestId = response.headers['request-id'];777 778 return callback(null, result);779 });780 };781 782 return ApplicationOperations;783})();784785var GroupOperations = ( /** @lends GroupOperations */ function() {786 /**787 * @class788 * Operations for working with Groups in Azure Active Directory Graph API.789 * (see http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for790 * more information)791 * __NOTE__: An instance of this class is automatically created for an792 * instance of the [GraphRbacManagementClient] {@link793 * GraphRbacManagementClient~GraphRbacManagementClient}.794 * See [group] {@link795 * GraphRbacManagementClient~GraphRbacManagementClient#group}.796 * Initializes a new instance of the GroupOperations class.797 * @constructor798 * 799 * @param {GraphRbacManagementClient} client Reference to the service client.800 */801 function GroupOperations(client) {802 this.client = client;803 }804 805 /**806 * Add a memeber to a group. (see807 * http://msdn.microsoft.com/en-us/library/azure/dn151600.aspx for more808 * information)809 * 810 * @param {string} groupObjectId Group object id811 * 812 * @param {GroupAddMemberParameters} parameters Member Object Url as813 * https://graph.windows.net/contoso.onmicrosoft.com/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd814 * 815 * @param {string} parameters.memberUrl Group display name816 * 817 * @param {function} callback818 * 819 * @returns {Stream} The response stream.820 */821 GroupOperations.prototype.addMember = function(groupObjectId, parameters, callback) {822 if (callback === null || callback === undefined) {823 throw new Error('callback cannot be null.');824 }825 // Validate826 if (groupObjectId === null || groupObjectId === undefined) {827 return callback(new Error('groupObjectId cannot be null.'));828 }829 if (parameters === null || parameters === undefined) {830 return callback(new Error('parameters cannot be null.'));831 }832 if (parameters.memberUrl === null || parameters.memberUrl === undefined) {833 return callback(new Error('parameters.memberUrl cannot be null.'));834 }835 836 // Tracing837 838 // Construct URL839 var url2 = '';840 url2 = url2 + '/';841 url2 = url2 + encodeURIComponent(this.client.tenantID);842 url2 = url2 + '/groups/';843 url2 = url2 + groupObjectId;844 url2 = url2 + '/$links/members';845 var queryParameters = [];846 queryParameters.push('api-version=1.42-previewInternal');847 if (queryParameters.length > 0) {848 url2 = url2 + '?' + queryParameters.join('&');849 }850 var baseUrl = this.client.baseUri;851 // Trim '/' character from the end of baseUrl and beginning of url.852 if (baseUrl[baseUrl.length - 1] === '/') {853 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);854 }855 if (url2[0] === '/') {856 url2 = url2.substring(1);857 }858 url2 = baseUrl + '/' + url2;859 url2 = url2.replace(' ', '%20');860 861 // Create HTTP transport objects862 var httpRequest = new WebResource();863 httpRequest.method = 'POST';864 httpRequest.headers = {};865 httpRequest.url = url2;866 867 // Set Headers868 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';869 870 // Serialize Request871 var requestContent = null;872 var requestDoc = null;873 874 var groupAddMemberParametersValue = {};875 requestDoc = groupAddMemberParametersValue;876 877 groupAddMemberParametersValue['url'] = parameters.memberUrl;878 879 requestContent = JSON.stringify(requestDoc);880 httpRequest.body = requestContent;881 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');882 // Send Request883 return this.client.pipeline(httpRequest, function (err, response, body) {884 if (err !== null && err !== undefined) {885 return callback(err);886 }887 var statusCode = response.statusCode;888 if (statusCode !== 204) {889 var error = new Error(body);890 error.statusCode = response.statusCode;891 return callback(error);892 }893 894 // Create Result895 var result = null;896 // Deserialize Response897 result = {};898 result.statusCode = statusCode;899 result.requestId = response.headers['request-id'];900 901 return callback(null, result);902 });903 };904 905 /**906 * Create a group in the directory. (see907 * http://msdn.microsoft.com/en-us/library/azure/dn151614.aspx for more908 * information)909 * 910 * @param {GroupCreateParameters} parameters Parameters to create a group911 * 912 * @param {string} parameters.displayName Group display name913 * 914 * @param {boolean} parameters.mailEnabled Mail915 * 916 * @param {string} parameters.mailNickname Mail nick name917 * 918 * @param {boolean} parameters.securityEnabled Is security enabled919 * 920 * @param {function} callback921 * 922 * @returns {Stream} The response stream.923 */924 GroupOperations.prototype.create = function(parameters, callback) {925 if (callback === null || callback === undefined) {926 throw new Error('callback cannot be null.');927 }928 // Validate929 if (parameters === null || parameters === undefined) {930 return callback(new Error('parameters cannot be null.'));931 }932 if (parameters.displayName === null || parameters.displayName === undefined) {933 return callback(new Error('parameters.displayName cannot be null.'));934 }935 if (parameters.mailEnabled === null || parameters.mailEnabled === undefined) {936 return callback(new Error('parameters.mailEnabled cannot be null.'));937 }938 if (parameters.mailNickname === null || parameters.mailNickname === undefined) {939 return callback(new Error('parameters.mailNickname cannot be null.'));940 }941 if (parameters.securityEnabled === null || parameters.securityEnabled === undefined) {942 return callback(new Error('parameters.securityEnabled cannot be null.'));943 }944 945 // Tracing946 947 // Construct URL948 var url2 = '';949 url2 = url2 + '/';950 url2 = url2 + encodeURIComponent(this.client.tenantID);951 url2 = url2 + '/groups';952 var queryParameters = [];953 queryParameters.push('api-version=1.42-previewInternal');954 if (queryParameters.length > 0) {955 url2 = url2 + '?' + queryParameters.join('&');956 }957 var baseUrl = this.client.baseUri;958 // Trim '/' character from the end of baseUrl and beginning of url.959 if (baseUrl[baseUrl.length - 1] === '/') {960 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);961 }962 if (url2[0] === '/') {963 url2 = url2.substring(1);964 }965 url2 = baseUrl + '/' + url2;966 url2 = url2.replace(' ', '%20');967 968 // Create HTTP transport objects969 var httpRequest = new WebResource();970 httpRequest.method = 'POST';971 httpRequest.headers = {};972 httpRequest.url = url2;973 974 // Set Headers975 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';976 977 // Serialize Request978 var requestContent = null;979 var requestDoc = null;980 981 var groupCreateParametersValue = {};982 requestDoc = groupCreateParametersValue;983 984 groupCreateParametersValue['displayName'] = parameters.displayName;985 986 groupCreateParametersValue['mailEnabled'] = parameters.mailEnabled;987 988 groupCreateParametersValue['mailNickname'] = parameters.mailNickname;989 990 groupCreateParametersValue['securityEnabled'] = parameters.securityEnabled;991 992 requestContent = JSON.stringify(requestDoc);993 httpRequest.body = requestContent;994 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');995 // Send Request996 return this.client.pipeline(httpRequest, function (err, response, body) {997 if (err !== null && err !== undefined) {998 return callback(err);999 }1000 var statusCode = response.statusCode;1001 if (statusCode !== 201) {1002 var error = new Error(body);1003 error.statusCode = response.statusCode;1004 return callback(error);1005 }1006 1007 // Create Result1008 var result = null;1009 // Deserialize Response1010 if (statusCode === 201) {1011 var responseContent = body;1012 result = {};1013 var responseDoc = null;1014 if (responseContent) {1015 responseDoc = JSON.parse(responseContent);1016 }1017 1018 if (responseDoc !== null && responseDoc !== undefined) {1019 var groupInstance = {};1020 result.group = groupInstance;1021 1022 var objectIdValue = responseDoc['objectId'];1023 if (objectIdValue !== null && objectIdValue !== undefined) {1024 var objectIdInstance = objectIdValue;1025 groupInstance.objectId = objectIdInstance;1026 }1027 1028 var objectTypeValue = responseDoc['objectType'];1029 if (objectTypeValue !== null && objectTypeValue !== undefined) {1030 var objectTypeInstance = objectTypeValue;1031 groupInstance.objectType = objectTypeInstance;1032 }1033 1034 var displayNameValue = responseDoc['displayName'];1035 if (displayNameValue !== null && displayNameValue !== undefined) {1036 var displayNameInstance = displayNameValue;1037 groupInstance.displayName = displayNameInstance;1038 }1039 1040 var securityEnabledValue = responseDoc['securityEnabled'];1041 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {1042 var securityEnabledInstance = securityEnabledValue;1043 groupInstance.securityEnabled = securityEnabledInstance;1044 }1045 1046 var mailValue = responseDoc['mail'];1047 if (mailValue !== null && mailValue !== undefined) {1048 var mailInstance = mailValue;1049 groupInstance.mail = mailInstance;1050 }1051 }1052 1053 }1054 result.statusCode = statusCode;1055 result.requestId = response.headers['request-id'];1056 1057 return callback(null, result);1058 });1059 };1060 1061 /**1062 * Delete a group in the directory. (see1063 * http://msdn.microsoft.com/en-us/library/azure/dn151608.aspx for more1064 * information)1065 * 1066 * @param {string} groupObjectId Object id1067 * 1068 * @param {function} callback1069 * 1070 * @returns {Stream} The response stream.1071 */1072 GroupOperations.prototype.deleteMethod = function(groupObjectId, callback) {1073 if (callback === null || callback === undefined) {1074 throw new Error('callback cannot be null.');1075 }1076 // Validate1077 if (groupObjectId === null || groupObjectId === undefined) {1078 return callback(new Error('groupObjectId cannot be null.'));1079 }1080 1081 // Tracing1082 1083 // Construct URL1084 var url2 = '';1085 url2 = url2 + '/';1086 url2 = url2 + encodeURIComponent(this.client.tenantID);1087 url2 = url2 + '/groups/';1088 url2 = url2 + groupObjectId;1089 var queryParameters = [];1090 queryParameters.push('api-version=1.42-previewInternal');1091 if (queryParameters.length > 0) {1092 url2 = url2 + '?' + queryParameters.join('&');1093 }1094 var baseUrl = this.client.baseUri;1095 // Trim '/' character from the end of baseUrl and beginning of url.1096 if (baseUrl[baseUrl.length - 1] === '/') {1097 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1098 }1099 if (url2[0] === '/') {1100 url2 = url2.substring(1);1101 }1102 url2 = baseUrl + '/' + url2;1103 url2 = url2.replace(' ', '%20');1104 1105 // Create HTTP transport objects1106 var httpRequest = new WebResource();1107 httpRequest.method = 'DELETE';1108 httpRequest.headers = {};1109 httpRequest.url = url2;1110 1111 // Set Headers1112 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1113 1114 // Send Request1115 return this.client.pipeline(httpRequest, function (err, response, body) {1116 if (err !== null && err !== undefined) {1117 return callback(err);1118 }1119 var statusCode = response.statusCode;1120 if (statusCode !== 204) {1121 var error = new Error(body);1122 error.statusCode = response.statusCode;1123 return callback(error);1124 }1125 1126 // Create Result1127 var result = null;1128 // Deserialize Response1129 result = {};1130 result.statusCode = statusCode;1131 result.requestId = response.headers['request-id'];1132 1133 return callback(null, result);1134 });1135 };1136 1137 /**1138 * Gets group information from the directory.1139 * 1140 * @param {string} objectId User objectId to get group information.1141 * 1142 * @param {function} callback1143 * 1144 * @returns {Stream} The response stream.1145 */1146 GroupOperations.prototype.get = function(objectId, callback) {1147 if (callback === null || callback === undefined) {1148 throw new Error('callback cannot be null.');1149 }1150 // Validate1151 if (objectId === null || objectId === undefined) {1152 return callback(new Error('objectId cannot be null.'));1153 }1154 1155 // Tracing1156 1157 // Construct URL1158 var url2 = '';1159 url2 = url2 + '/';1160 url2 = url2 + encodeURIComponent(this.client.tenantID);1161 url2 = url2 + '/groups/';1162 url2 = url2 + objectId;1163 var queryParameters = [];1164 queryParameters.push('api-version=1.42-previewInternal');1165 if (queryParameters.length > 0) {1166 url2 = url2 + '?' + queryParameters.join('&');1167 }1168 var baseUrl = this.client.baseUri;1169 // Trim '/' character from the end of baseUrl and beginning of url.1170 if (baseUrl[baseUrl.length - 1] === '/') {1171 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1172 }1173 if (url2[0] === '/') {1174 url2 = url2.substring(1);1175 }1176 url2 = baseUrl + '/' + url2;1177 url2 = url2.replace(' ', '%20');1178 1179 // Create HTTP transport objects1180 var httpRequest = new WebResource();1181 httpRequest.method = 'GET';1182 httpRequest.headers = {};1183 httpRequest.url = url2;1184 1185 // Set Headers1186 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1187 1188 // Send Request1189 return this.client.pipeline(httpRequest, function (err, response, body) {1190 if (err !== null && err !== undefined) {1191 return callback(err);1192 }1193 var statusCode = response.statusCode;1194 if (statusCode !== 200) {1195 var error = new Error(body);1196 error.statusCode = response.statusCode;1197 return callback(error);1198 }1199 1200 // Create Result1201 var result = null;1202 // Deserialize Response1203 if (statusCode === 200) {1204 var responseContent = body;1205 result = {};1206 var responseDoc = null;1207 if (responseContent) {1208 responseDoc = JSON.parse(responseContent);1209 }1210 1211 if (responseDoc !== null && responseDoc !== undefined) {1212 var groupInstance = {};1213 result.group = groupInstance;1214 1215 var objectIdValue = responseDoc['objectId'];1216 if (objectIdValue !== null && objectIdValue !== undefined) {1217 var objectIdInstance = objectIdValue;1218 groupInstance.objectId = objectIdInstance;1219 }1220 1221 var objectTypeValue = responseDoc['objectType'];1222 if (objectTypeValue !== null && objectTypeValue !== undefined) {1223 var objectTypeInstance = objectTypeValue;1224 groupInstance.objectType = objectTypeInstance;1225 }1226 1227 var displayNameValue = responseDoc['displayName'];1228 if (displayNameValue !== null && displayNameValue !== undefined) {1229 var displayNameInstance = displayNameValue;1230 groupInstance.displayName = displayNameInstance;1231 }1232 1233 var securityEnabledValue = responseDoc['securityEnabled'];1234 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {1235 var securityEnabledInstance = securityEnabledValue;1236 groupInstance.securityEnabled = securityEnabledInstance;1237 }1238 1239 var mailValue = responseDoc['mail'];1240 if (mailValue !== null && mailValue !== undefined) {1241 var mailInstance = mailValue;1242 groupInstance.mail = mailInstance;1243 }1244 }1245 1246 }1247 result.statusCode = statusCode;1248 result.requestId = response.headers['request-id'];1249 1250 return callback(null, result);1251 });1252 };1253 1254 /**1255 * Gets the members of a group.1256 * 1257 * @param {string} objectId Group object Id who's members should be retrieved.1258 * 1259 * @param {function} callback1260 * 1261 * @returns {Stream} The response stream.1262 */1263 GroupOperations.prototype.getGroupMembers = function(objectId, callback) {1264 if (callback === null || callback === undefined) {1265 throw new Error('callback cannot be null.');1266 }1267 // Validate1268 if (objectId === null || objectId === undefined) {1269 return callback(new Error('objectId cannot be null.'));1270 }1271 1272 // Tracing1273 1274 // Construct URL1275 var url2 = '';1276 url2 = url2 + '/';1277 url2 = url2 + encodeURIComponent(this.client.tenantID);1278 url2 = url2 + '/groups/';1279 url2 = url2 + objectId;1280 url2 = url2 + '/members';1281 var queryParameters = [];1282 queryParameters.push('api-version=1.42-previewInternal');1283 if (queryParameters.length > 0) {1284 url2 = url2 + '?' + queryParameters.join('&');1285 }1286 var baseUrl = this.client.baseUri;1287 // Trim '/' character from the end of baseUrl and beginning of url.1288 if (baseUrl[baseUrl.length - 1] === '/') {1289 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1290 }1291 if (url2[0] === '/') {1292 url2 = url2.substring(1);1293 }1294 url2 = baseUrl + '/' + url2;1295 url2 = url2.replace(' ', '%20');1296 1297 // Create HTTP transport objects1298 var httpRequest = new WebResource();1299 httpRequest.method = 'GET';1300 httpRequest.headers = {};1301 httpRequest.url = url2;1302 1303 // Set Headers1304 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1305 1306 // Send Request1307 return this.client.pipeline(httpRequest, function (err, response, body) {1308 if (err !== null && err !== undefined) {1309 return callback(err);1310 }1311 var statusCode = response.statusCode;1312 if (statusCode !== 200) {1313 var error = new Error(body);1314 error.statusCode = response.statusCode;1315 return callback(error);1316 }1317 1318 // Create Result1319 var result = null;1320 // Deserialize Response1321 if (statusCode === 200) {1322 var responseContent = body;1323 result = { aADObject: [] };1324 var responseDoc = null;1325 if (responseContent) {1326 responseDoc = JSON.parse(responseContent);1327 }1328 1329 if (responseDoc !== null && responseDoc !== undefined) {1330 var valueArray = responseDoc['value'];1331 if (valueArray !== null && valueArray !== undefined) {1332 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {1333 var valueValue = valueArray[loweredIndex1];1334 var aADObjectInstance = {};1335 result.aADObject.push(aADObjectInstance);1336 1337 var objectIdValue = valueValue['objectId'];1338 if (objectIdValue !== null && objectIdValue !== undefined) {1339 var objectIdInstance = objectIdValue;1340 aADObjectInstance.objectId = objectIdInstance;1341 }1342 1343 var objectTypeValue = valueValue['objectType'];1344 if (objectTypeValue !== null && objectTypeValue !== undefined) {1345 var objectTypeInstance = objectTypeValue;1346 aADObjectInstance.objectType = objectTypeInstance;1347 }1348 1349 var displayNameValue = valueValue['displayName'];1350 if (displayNameValue !== null && displayNameValue !== undefined) {1351 var displayNameInstance = displayNameValue;1352 aADObjectInstance.displayName = displayNameInstance;1353 }1354 1355 var userPrincipalNameValue = valueValue['userPrincipalName'];1356 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {1357 var userPrincipalNameInstance = userPrincipalNameValue;1358 aADObjectInstance.userPrincipalName = userPrincipalNameInstance;1359 }1360 1361 var mailValue = valueValue['mail'];1362 if (mailValue !== null && mailValue !== undefined) {1363 var mailInstance = mailValue;1364 aADObjectInstance.mail = mailInstance;1365 }1366 1367 var mailEnabledValue = valueValue['mailEnabled'];1368 if (mailEnabledValue !== null && mailEnabledValue !== undefined) {1369 var mailEnabledInstance = mailEnabledValue;1370 aADObjectInstance.mailEnabled = mailEnabledInstance;1371 }1372 1373 var securityEnabledValue = valueValue['securityEnabled'];1374 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {1375 var securityEnabledInstance = securityEnabledValue;1376 aADObjectInstance.securityEnabled = securityEnabledInstance;1377 }1378 }1379 }1380 1381 var odatanextLinkValue = responseDoc['odata.nextLink'];1382 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {1383 var odatanextLinkInstance = odatanextLinkValue;1384 result.nextLink = odatanextLinkInstance;1385 }1386 }1387 1388 }1389 result.statusCode = statusCode;1390 result.requestId = response.headers['request-id'];1391 1392 return callback(null, result);1393 });1394 };1395 1396 /**1397 * Gets next set of members of a group.1398 * 1399 * @param {string} nextLink NextLink from the previous successful call to1400 * GetGroupMembers or GetGroupMembersNext.1401 * 1402 * @param {function} callback1403 * 1404 * @returns {Stream} The response stream.1405 */1406 GroupOperations.prototype.getGroupMembersNext = function(nextLink, callback) {1407 if (callback === null || callback === undefined) {1408 throw new Error('callback cannot be null.');1409 }1410 // Validate1411 if (nextLink === null || nextLink === undefined) {1412 return callback(new Error('nextLink cannot be null.'));1413 }1414 1415 // Tracing1416 1417 // Construct URL1418 var url2 = '';1419 url2 = url2 + '/';1420 url2 = url2 + encodeURIComponent(this.client.tenantID);1421 url2 = url2 + '/';1422 url2 = url2 + nextLink;1423 url2 = url2 + '&api-version=1.42-previewInternal';1424 var baseUrl = this.client.baseUri;1425 // Trim '/' character from the end of baseUrl and beginning of url.1426 if (baseUrl[baseUrl.length - 1] === '/') {1427 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1428 }1429 if (url2[0] === '/') {1430 url2 = url2.substring(1);1431 }1432 url2 = baseUrl + '/' + url2;1433 url2 = url2.replace(' ', '%20');1434 1435 // Create HTTP transport objects1436 var httpRequest = new WebResource();1437 httpRequest.method = 'GET';1438 httpRequest.headers = {};1439 httpRequest.url = url2;1440 1441 // Set Headers1442 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1443 1444 // Send Request1445 return this.client.pipeline(httpRequest, function (err, response, body) {1446 if (err !== null && err !== undefined) {1447 return callback(err);1448 }1449 var statusCode = response.statusCode;1450 if (statusCode !== 200) {1451 var error = new Error(body);1452 error.statusCode = response.statusCode;1453 return callback(error);1454 }1455 1456 // Create Result1457 var result = null;1458 // Deserialize Response1459 if (statusCode === 200) {1460 var responseContent = body;1461 result = { aADObject: [] };1462 var responseDoc = null;1463 if (responseContent) {1464 responseDoc = JSON.parse(responseContent);1465 }1466 1467 if (responseDoc !== null && responseDoc !== undefined) {1468 var valueArray = responseDoc['value'];1469 if (valueArray !== null && valueArray !== undefined) {1470 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {1471 var valueValue = valueArray[loweredIndex1];1472 var aADObjectInstance = {};1473 result.aADObject.push(aADObjectInstance);1474 1475 var objectIdValue = valueValue['objectId'];1476 if (objectIdValue !== null && objectIdValue !== undefined) {1477 var objectIdInstance = objectIdValue;1478 aADObjectInstance.objectId = objectIdInstance;1479 }1480 1481 var objectTypeValue = valueValue['objectType'];1482 if (objectTypeValue !== null && objectTypeValue !== undefined) {1483 var objectTypeInstance = objectTypeValue;1484 aADObjectInstance.objectType = objectTypeInstance;1485 }1486 1487 var displayNameValue = valueValue['displayName'];1488 if (displayNameValue !== null && displayNameValue !== undefined) {1489 var displayNameInstance = displayNameValue;1490 aADObjectInstance.displayName = displayNameInstance;1491 }1492 1493 var userPrincipalNameValue = valueValue['userPrincipalName'];1494 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {1495 var userPrincipalNameInstance = userPrincipalNameValue;1496 aADObjectInstance.userPrincipalName = userPrincipalNameInstance;1497 }1498 1499 var mailValue = valueValue['mail'];1500 if (mailValue !== null && mailValue !== undefined) {1501 var mailInstance = mailValue;1502 aADObjectInstance.mail = mailInstance;1503 }1504 1505 var mailEnabledValue = valueValue['mailEnabled'];1506 if (mailEnabledValue !== null && mailEnabledValue !== undefined) {1507 var mailEnabledInstance = mailEnabledValue;1508 aADObjectInstance.mailEnabled = mailEnabledInstance;1509 }1510 1511 var securityEnabledValue = valueValue['securityEnabled'];1512 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {1513 var securityEnabledInstance = securityEnabledValue;1514 aADObjectInstance.securityEnabled = securityEnabledInstance;1515 }1516 }1517 }1518 1519 var odatanextLinkValue = responseDoc['odata.nextLink'];1520 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {1521 var odatanextLinkInstance = odatanextLinkValue;1522 result.nextLink = odatanextLinkInstance;1523 }1524 }1525 1526 }1527 result.statusCode = statusCode;1528 result.requestId = response.headers['request-id'];1529 1530 return callback(null, result);1531 });1532 };1533 1534 /**1535 * Gets a collection that contains the Object IDs of the groups of which the1536 * group is a member.1537 * 1538 * @param {GroupGetMemberGroupsParameters} parameters Group filtering1539 * parameters.1540 * 1541 * @param {string} parameters.objectId Group object Id1542 * 1543 * @param {boolean} parameters.securityEnabledOnly If true only membership in1544 * security enabled groups should be checked. Otherwise membership in all1545 * groups should be checked1546 * 1547 * @param {function} callback1548 * 1549 * @returns {Stream} The response stream.1550 */1551 GroupOperations.prototype.getMemberGroups = function(parameters, callback) {1552 if (callback === null || callback === undefined) {1553 throw new Error('callback cannot be null.');1554 }1555 // Validate1556 if (parameters === null || parameters === undefined) {1557 return callback(new Error('parameters cannot be null.'));1558 }1559 if (parameters.objectId === null || parameters.objectId === undefined) {1560 return callback(new Error('parameters.objectId cannot be null.'));1561 }1562 if (parameters.securityEnabledOnly === null || parameters.securityEnabledOnly === undefined) {1563 return callback(new Error('parameters.securityEnabledOnly cannot be null.'));1564 }1565 1566 // Tracing1567 1568 // Construct URL1569 var url2 = '';1570 url2 = url2 + '/';1571 url2 = url2 + encodeURIComponent(this.client.tenantID);1572 url2 = url2 + '/groups/';1573 url2 = url2 + parameters.objectId;1574 url2 = url2 + '/getMemberGroups';1575 var queryParameters = [];1576 queryParameters.push('api-version=1.42-previewInternal');1577 if (queryParameters.length > 0) {1578 url2 = url2 + '?' + queryParameters.join('&');1579 }1580 var baseUrl = this.client.baseUri;1581 // Trim '/' character from the end of baseUrl and beginning of url.1582 if (baseUrl[baseUrl.length - 1] === '/') {1583 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1584 }1585 if (url2[0] === '/') {1586 url2 = url2.substring(1);1587 }1588 url2 = baseUrl + '/' + url2;1589 url2 = url2.replace(' ', '%20');1590 1591 // Create HTTP transport objects1592 var httpRequest = new WebResource();1593 httpRequest.method = 'POST';1594 httpRequest.headers = {};1595 httpRequest.url = url2;1596 1597 // Set Headers1598 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1599 1600 // Serialize Request1601 var requestContent = null;1602 var requestDoc = null;1603 1604 requestDoc = {};1605 requestDoc['securityEnabledOnly'] = parameters.securityEnabledOnly;1606 1607 requestContent = JSON.stringify(requestDoc);1608 httpRequest.body = requestContent;1609 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');1610 // Send Request1611 return this.client.pipeline(httpRequest, function (err, response, body) {1612 if (err !== null && err !== undefined) {1613 return callback(err);1614 }1615 var statusCode = response.statusCode;1616 if (statusCode !== 200) {1617 var error = new Error(body);1618 error.statusCode = response.statusCode;1619 return callback(error);1620 }1621 1622 // Create Result1623 var result = null;1624 // Deserialize Response1625 if (statusCode === 200) {1626 var responseContent = body;1627 result = { objectIds: [] };1628 var responseDoc = null;1629 if (responseContent) {1630 responseDoc = JSON.parse(responseContent);1631 }1632 1633 if (responseDoc !== null && responseDoc !== undefined) {1634 var valueArray = responseDoc['value'];1635 if (valueArray !== null && valueArray !== undefined) {1636 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {1637 var valueValue = valueArray[loweredIndex1];1638 result.objectIds.push(valueValue);1639 }1640 }1641 }1642 1643 }1644 result.statusCode = statusCode;1645 result.requestId = response.headers['request-id'];1646 1647 return callback(null, result);1648 });1649 };1650 1651 /**1652 * Gets list of groups for the current tenant.1653 * 1654 * @param {string} [mail] Email to filter results.1655 * 1656 * @param {string} [displayNameStartsWith] Display name to filter results.1657 * 1658 * @param {function} callback1659 * 1660 * @returns {Stream} The response stream.1661 */1662 GroupOperations.prototype.list = function(mail, displayNameStartsWith, callback) {1663 if (callback === null || callback === undefined) {1664 throw new Error('callback cannot be null.');1665 }1666 // Validate1667 1668 // Tracing1669 1670 // Construct URL1671 var url2 = '';1672 url2 = url2 + '/';1673 url2 = url2 + encodeURIComponent(this.client.tenantID);1674 url2 = url2 + '/groups';1675 var queryParameters = [];1676 var odataFilter = [];1677 if (mail !== null && mail !== undefined) {1678 odataFilter.push('mail eq \'' + encodeURIComponent(mail) + '\'');1679 }1680 if (odataFilter.length > 0) {1681 queryParameters.push('$filter=' + odataFilter.join(null));1682 }1683 var odataFilter2 = [];1684 if (displayNameStartsWith !== null && displayNameStartsWith !== undefined) {1685 odataFilter2.push('startswith(displayName,\'' + encodeURIComponent(displayNameStartsWith) + '\')');1686 }1687 if (odataFilter2.length > 0) {1688 queryParameters.push('$filter=' + odataFilter2.join(null));1689 }1690 queryParameters.push('api-version=1.42-previewInternal');1691 if (queryParameters.length > 0) {1692 url2 = url2 + '?' + queryParameters.join('&');1693 }1694 var baseUrl = this.client.baseUri;1695 // Trim '/' character from the end of baseUrl and beginning of url.1696 if (baseUrl[baseUrl.length - 1] === '/') {1697 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1698 }1699 if (url2[0] === '/') {1700 url2 = url2.substring(1);1701 }1702 url2 = baseUrl + '/' + url2;1703 url2 = url2.replace(' ', '%20');1704 1705 // Create HTTP transport objects1706 var httpRequest = new WebResource();1707 httpRequest.method = 'GET';1708 httpRequest.headers = {};1709 httpRequest.url = url2;1710 1711 // Set Headers1712 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1713 1714 // Send Request1715 return this.client.pipeline(httpRequest, function (err, response, body) {1716 if (err !== null && err !== undefined) {1717 return callback(err);1718 }1719 var statusCode = response.statusCode;1720 if (statusCode !== 200) {1721 var error = new Error(body);1722 error.statusCode = response.statusCode;1723 return callback(error);1724 }1725 1726 // Create Result1727 var result = null;1728 // Deserialize Response1729 if (statusCode === 200) {1730 var responseContent = body;1731 result = { groups: [] };1732 var responseDoc = null;1733 if (responseContent) {1734 responseDoc = JSON.parse(responseContent);1735 }1736 1737 if (responseDoc !== null && responseDoc !== undefined) {1738 var valueArray = responseDoc['value'];1739 if (valueArray !== null && valueArray !== undefined) {1740 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {1741 var valueValue = valueArray[loweredIndex1];1742 var groupInstance = {};1743 result.groups.push(groupInstance);1744 1745 var objectIdValue = valueValue['objectId'];1746 if (objectIdValue !== null && objectIdValue !== undefined) {1747 var objectIdInstance = objectIdValue;1748 groupInstance.objectId = objectIdInstance;1749 }1750 1751 var objectTypeValue = valueValue['objectType'];1752 if (objectTypeValue !== null && objectTypeValue !== undefined) {1753 var objectTypeInstance = objectTypeValue;1754 groupInstance.objectType = objectTypeInstance;1755 }1756 1757 var displayNameValue = valueValue['displayName'];1758 if (displayNameValue !== null && displayNameValue !== undefined) {1759 var displayNameInstance = displayNameValue;1760 groupInstance.displayName = displayNameInstance;1761 }1762 1763 var securityEnabledValue = valueValue['securityEnabled'];1764 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {1765 var securityEnabledInstance = securityEnabledValue;1766 groupInstance.securityEnabled = securityEnabledInstance;1767 }1768 1769 var mailValue = valueValue['mail'];1770 if (mailValue !== null && mailValue !== undefined) {1771 var mailInstance = mailValue;1772 groupInstance.mail = mailInstance;1773 }1774 }1775 }1776 1777 var odatanextLinkValue = responseDoc['odata.nextLink'];1778 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {1779 var odatanextLinkInstance = odatanextLinkValue;1780 result.nextLink = odatanextLinkInstance;1781 }1782 }1783 1784 }1785 result.statusCode = statusCode;1786 result.requestId = response.headers['request-id'];1787 1788 return callback(null, result);1789 });1790 };1791 1792 /**1793 * Gets list of groups for the current tenant.1794 * 1795 * @param {string} nextLink NextLink from the previous successful call to1796 * List operation.1797 * 1798 * @param {function} callback1799 * 1800 * @returns {Stream} The response stream.1801 */1802 GroupOperations.prototype.listNext = function(nextLink, callback) {1803 if (callback === null || callback === undefined) {1804 throw new Error('callback cannot be null.');1805 }1806 // Validate1807 if (nextLink === null || nextLink === undefined) {1808 return callback(new Error('nextLink cannot be null.'));1809 }1810 1811 // Tracing1812 1813 // Construct URL1814 var url2 = '';1815 url2 = url2 + '/';1816 url2 = url2 + encodeURIComponent(this.client.tenantID);1817 url2 = url2 + '/';1818 url2 = url2 + nextLink;1819 url2 = url2 + '&api-version=1.42-previewInternal';1820 var baseUrl = this.client.baseUri;1821 // Trim '/' character from the end of baseUrl and beginning of url.1822 if (baseUrl[baseUrl.length - 1] === '/') {1823 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1824 }1825 if (url2[0] === '/') {1826 url2 = url2.substring(1);1827 }1828 url2 = baseUrl + '/' + url2;1829 url2 = url2.replace(' ', '%20');1830 1831 // Create HTTP transport objects1832 var httpRequest = new WebResource();1833 httpRequest.method = 'GET';1834 httpRequest.headers = {};1835 httpRequest.url = url2;1836 1837 // Set Headers1838 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1839 1840 // Send Request1841 return this.client.pipeline(httpRequest, function (err, response, body) {1842 if (err !== null && err !== undefined) {1843 return callback(err);1844 }1845 var statusCode = response.statusCode;1846 if (statusCode !== 200) {1847 var error = new Error(body);1848 error.statusCode = response.statusCode;1849 return callback(error);1850 }1851 1852 // Create Result1853 var result = null;1854 // Deserialize Response1855 if (statusCode === 200) {1856 var responseContent = body;1857 result = { groups: [] };1858 var responseDoc = null;1859 if (responseContent) {1860 responseDoc = JSON.parse(responseContent);1861 }1862 1863 if (responseDoc !== null && responseDoc !== undefined) {1864 var valueArray = responseDoc['value'];1865 if (valueArray !== null && valueArray !== undefined) {1866 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {1867 var valueValue = valueArray[loweredIndex1];1868 var groupInstance = {};1869 result.groups.push(groupInstance);1870 1871 var objectIdValue = valueValue['objectId'];1872 if (objectIdValue !== null && objectIdValue !== undefined) {1873 var objectIdInstance = objectIdValue;1874 groupInstance.objectId = objectIdInstance;1875 }1876 1877 var objectTypeValue = valueValue['objectType'];1878 if (objectTypeValue !== null && objectTypeValue !== undefined) {1879 var objectTypeInstance = objectTypeValue;1880 groupInstance.objectType = objectTypeInstance;1881 }1882 1883 var displayNameValue = valueValue['displayName'];1884 if (displayNameValue !== null && displayNameValue !== undefined) {1885 var displayNameInstance = displayNameValue;1886 groupInstance.displayName = displayNameInstance;1887 }1888 1889 var securityEnabledValue = valueValue['securityEnabled'];1890 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {1891 var securityEnabledInstance = securityEnabledValue;1892 groupInstance.securityEnabled = securityEnabledInstance;1893 }1894 1895 var mailValue = valueValue['mail'];1896 if (mailValue !== null && mailValue !== undefined) {1897 var mailInstance = mailValue;1898 groupInstance.mail = mailInstance;1899 }1900 }1901 }1902 1903 var odatanextLinkValue = responseDoc['odata.nextLink'];1904 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {1905 var odatanextLinkInstance = odatanextLinkValue;1906 result.nextLink = odatanextLinkInstance;1907 }1908 }1909 1910 }1911 result.statusCode = statusCode;1912 result.requestId = response.headers['request-id'];1913 1914 return callback(null, result);1915 });1916 };1917 1918 /**1919 * Remove a memeber from a group (see1920 * http://msdn.microsoft.com/en-us/library/azure/dn151607.aspx for more1921 * information)1922 * 1923 * @param {string} groupObjectId Group object id1924 * 1925 * @param {string} memberObjectId Member Object id1926 * 1927 * @param {function} callback1928 * 1929 * @returns {Stream} The response stream.1930 */1931 GroupOperations.prototype.removeMember = function(groupObjectId, memberObjectId, callback) {1932 if (callback === null || callback === undefined) {1933 throw new Error('callback cannot be null.');1934 }1935 // Validate1936 if (groupObjectId === null || groupObjectId === undefined) {1937 return callback(new Error('groupObjectId cannot be null.'));1938 }1939 if (memberObjectId === null || memberObjectId === undefined) {1940 return callback(new Error('memberObjectId cannot be null.'));1941 }1942 1943 // Tracing1944 1945 // Construct URL1946 var url2 = '';1947 url2 = url2 + '/';1948 url2 = url2 + encodeURIComponent(this.client.tenantID);1949 url2 = url2 + '/groups/';1950 url2 = url2 + groupObjectId;1951 url2 = url2 + '/$links/members/';1952 url2 = url2 + memberObjectId;1953 var queryParameters = [];1954 queryParameters.push('api-version=1.42-previewInternal');1955 if (queryParameters.length > 0) {1956 url2 = url2 + '?' + queryParameters.join('&');1957 }1958 var baseUrl = this.client.baseUri;1959 // Trim '/' character from the end of baseUrl and beginning of url.1960 if (baseUrl[baseUrl.length - 1] === '/') {1961 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);1962 }1963 if (url2[0] === '/') {1964 url2 = url2.substring(1);1965 }1966 url2 = baseUrl + '/' + url2;1967 url2 = url2.replace(' ', '%20');1968 1969 // Create HTTP transport objects1970 var httpRequest = new WebResource();1971 httpRequest.method = 'DELETE';1972 httpRequest.headers = {};1973 httpRequest.url = url2;1974 1975 // Set Headers1976 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';1977 1978 // Send Request1979 return this.client.pipeline(httpRequest, function (err, response, body) {1980 if (err !== null && err !== undefined) {1981 return callback(err);1982 }1983 var statusCode = response.statusCode;1984 if (statusCode !== 204) {1985 var error = new Error(body);1986 error.statusCode = response.statusCode;1987 return callback(error);1988 }1989 1990 // Create Result1991 var result = null;1992 // Deserialize Response1993 result = {};1994 result.statusCode = statusCode;1995 result.requestId = response.headers['request-id'];1996 1997 return callback(null, result);1998 });1999 };2000 2001 return GroupOperations;2002})();20032004var ObjectOperations = ( /** @lends ObjectOperations */ function() {2005 /**2006 * @class2007 * Operations for working with Objects in Azure AD Graph API. (see2008 * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more2009 * information)2010 * __NOTE__: An instance of this class is automatically created for an2011 * instance of the [GraphRbacManagementClient] {@link2012 * GraphRbacManagementClient~GraphRbacManagementClient}.2013 * See [objects] {@link2014 * GraphRbacManagementClient~GraphRbacManagementClient#objects}.2015 * Initializes a new instance of the ObjectOperations class.2016 * @constructor2017 * 2018 * @param {GraphRbacManagementClient} client Reference to the service client.2019 */2020 function ObjectOperations(client) {2021 this.client = client;2022 }2023 2024 /**2025 * Gets AD group membership by provided AD object Ids2026 * 2027 * @param {GetObjectsParameters} parameters Objects filtering parameters.2028 * 2029 * @param {array} [parameters.ids] Requested object Ids2030 * 2031 * @param {array} [parameters.types] Requested object types2032 * 2033 * @param {function} callback2034 * 2035 * @returns {Stream} The response stream.2036 */2037 ObjectOperations.prototype.getObjectsByObjectIds = function(parameters, callback) {2038 if (callback === null || callback === undefined) {2039 throw new Error('callback cannot be null.');2040 }2041 // Validate2042 if (parameters === null || parameters === undefined) {2043 return callback(new Error('parameters cannot be null.'));2044 }2045 2046 // Tracing2047 2048 // Construct URL2049 var url2 = '';2050 url2 = url2 + '/';2051 url2 = url2 + encodeURIComponent(this.client.tenantID);2052 url2 = url2 + '/getObjectsByObjectIds';2053 var queryParameters = [];2054 queryParameters.push('api-version=1.42-previewInternal');2055 if (queryParameters.length > 0) {2056 url2 = url2 + '?' + queryParameters.join('&');2057 }2058 var baseUrl = this.client.baseUri;2059 // Trim '/' character from the end of baseUrl and beginning of url.2060 if (baseUrl[baseUrl.length - 1] === '/') {2061 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2062 }2063 if (url2[0] === '/') {2064 url2 = url2.substring(1);2065 }2066 url2 = baseUrl + '/' + url2;2067 url2 = url2.replace(' ', '%20');2068 2069 // Create HTTP transport objects2070 var httpRequest = new WebResource();2071 httpRequest.method = 'POST';2072 httpRequest.headers = {};2073 httpRequest.url = url2;2074 2075 // Set Headers2076 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2077 2078 // Serialize Request2079 var requestContent = null;2080 var requestDoc = null;2081 2082 var getObjectsParametersValue = {};2083 requestDoc = getObjectsParametersValue;2084 2085 if (parameters.ids !== null && parameters.ids !== undefined) {2086 var objectIdsArray = [];2087 for (var loweredIndex1 = 0; loweredIndex1 < parameters.ids.length; loweredIndex1 = loweredIndex1 + 1) {2088 var objectIdsItem = parameters.ids[loweredIndex1];2089 objectIdsArray.push(objectIdsItem);2090 }2091 getObjectsParametersValue['objectIds'] = objectIdsArray;2092 }2093 2094 if (parameters.types !== null && parameters.types !== undefined) {2095 var typesArray = [];2096 for (var loweredIndex2 = 0; loweredIndex2 < parameters.types.length; loweredIndex2 = loweredIndex2 + 1) {2097 var typesItem = parameters.types[loweredIndex2];2098 typesArray.push(typesItem);2099 }2100 getObjectsParametersValue['types'] = typesArray;2101 }2102 2103 requestContent = JSON.stringify(requestDoc);2104 httpRequest.body = requestContent;2105 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');2106 // Send Request2107 return this.client.pipeline(httpRequest, function (err, response, body) {2108 if (err !== null && err !== undefined) {2109 return callback(err);2110 }2111 var statusCode = response.statusCode;2112 if (statusCode !== 200) {2113 var error = new Error(body);2114 error.statusCode = response.statusCode;2115 return callback(error);2116 }2117 2118 // Create Result2119 var result = null;2120 // Deserialize Response2121 if (statusCode === 200) {2122 var responseContent = body;2123 result = { aADObject: [] };2124 var responseDoc = null;2125 if (responseContent) {2126 responseDoc = JSON.parse(responseContent);2127 }2128 2129 if (responseDoc !== null && responseDoc !== undefined) {2130 var valueArray = responseDoc['value'];2131 if (valueArray !== null && valueArray !== undefined) {2132 for (var loweredIndex3 = 0; loweredIndex3 < valueArray.length; loweredIndex3 = loweredIndex3 + 1) {2133 var valueValue = valueArray[loweredIndex3];2134 var aADObjectInstance = {};2135 result.aADObject.push(aADObjectInstance);2136 2137 var objectIdValue = valueValue['objectId'];2138 if (objectIdValue !== null && objectIdValue !== undefined) {2139 var objectIdInstance = objectIdValue;2140 aADObjectInstance.objectId = objectIdInstance;2141 }2142 2143 var objectTypeValue = valueValue['objectType'];2144 if (objectTypeValue !== null && objectTypeValue !== undefined) {2145 var objectTypeInstance = objectTypeValue;2146 aADObjectInstance.objectType = objectTypeInstance;2147 }2148 2149 var displayNameValue = valueValue['displayName'];2150 if (displayNameValue !== null && displayNameValue !== undefined) {2151 var displayNameInstance = displayNameValue;2152 aADObjectInstance.displayName = displayNameInstance;2153 }2154 2155 var userPrincipalNameValue = valueValue['userPrincipalName'];2156 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {2157 var userPrincipalNameInstance = userPrincipalNameValue;2158 aADObjectInstance.userPrincipalName = userPrincipalNameInstance;2159 }2160 2161 var mailValue = valueValue['mail'];2162 if (mailValue !== null && mailValue !== undefined) {2163 var mailInstance = mailValue;2164 aADObjectInstance.mail = mailInstance;2165 }2166 2167 var mailEnabledValue = valueValue['mailEnabled'];2168 if (mailEnabledValue !== null && mailEnabledValue !== undefined) {2169 var mailEnabledInstance = mailEnabledValue;2170 aADObjectInstance.mailEnabled = mailEnabledInstance;2171 }2172 2173 var securityEnabledValue = valueValue['securityEnabled'];2174 if (securityEnabledValue !== null && securityEnabledValue !== undefined) {2175 var securityEnabledInstance = securityEnabledValue;2176 aADObjectInstance.securityEnabled = securityEnabledInstance;2177 }2178 }2179 }2180 2181 var odatanextLinkValue = responseDoc['odata.nextLink'];2182 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {2183 var odatanextLinkInstance = odatanextLinkValue;2184 result.nextLink = odatanextLinkInstance;2185 }2186 }2187 2188 }2189 result.statusCode = statusCode;2190 result.requestId = response.headers['request-id'];2191 2192 return callback(null, result);2193 });2194 };2195 2196 return ObjectOperations;2197})();21982199var ServicePrincipalOperations = ( /** @lends ServicePrincipalOperations */ function() {2200 /**2201 * @class2202 * Operations for working with service principal in Azure Active Directory2203 * Graph API. (see2204 * http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for more2205 * information)2206 * __NOTE__: An instance of this class is automatically created for an2207 * instance of the [GraphRbacManagementClient] {@link2208 * GraphRbacManagementClient~GraphRbacManagementClient}.2209 * See [servicePrincipal] {@link2210 * GraphRbacManagementClient~GraphRbacManagementClient#servicePrincipal}.2211 * Initializes a new instance of the ServicePrincipalOperations class.2212 * @constructor2213 * 2214 * @param {GraphRbacManagementClient} client Reference to the service client.2215 */2216 function ServicePrincipalOperations(client) {2217 this.client = client;2218 }2219 2220 /**2221 * Creates a service principal in the directory.2222 * 2223 * @param {ServicePrincipalCreateParameters} parameters Parameters to create2224 * a service principal.2225 * 2226 * @param {string} parameters.appId Gets or sets application Id2227 * 2228 * @param {boolean} parameters.accountEnabled Specifies if the account is2229 * enabled2230 * 2231 * @param {function} callback2232 * 2233 * @returns {Stream} The response stream.2234 */2235 ServicePrincipalOperations.prototype.create = function(parameters, callback) {2236 if (callback === null || callback === undefined) {2237 throw new Error('callback cannot be null.');2238 }2239 // Validate2240 if (parameters === null || parameters === undefined) {2241 return callback(new Error('parameters cannot be null.'));2242 }2243 if (parameters.accountEnabled === null || parameters.accountEnabled === undefined) {2244 return callback(new Error('parameters.accountEnabled cannot be null.'));2245 }2246 if (parameters.appId === null || parameters.appId === undefined) {2247 return callback(new Error('parameters.appId cannot be null.'));2248 }2249 2250 // Tracing2251 2252 // Construct URL2253 var url2 = '';2254 url2 = url2 + '/';2255 url2 = url2 + encodeURIComponent(this.client.tenantID);2256 url2 = url2 + '/servicePrincipals';2257 var queryParameters = [];2258 queryParameters.push('api-version=1.42-previewInternal');2259 if (queryParameters.length > 0) {2260 url2 = url2 + '?' + queryParameters.join('&');2261 }2262 var baseUrl = this.client.baseUri;2263 // Trim '/' character from the end of baseUrl and beginning of url.2264 if (baseUrl[baseUrl.length - 1] === '/') {2265 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2266 }2267 if (url2[0] === '/') {2268 url2 = url2.substring(1);2269 }2270 url2 = baseUrl + '/' + url2;2271 url2 = url2.replace(' ', '%20');2272 2273 // Create HTTP transport objects2274 var httpRequest = new WebResource();2275 httpRequest.method = 'POST';2276 httpRequest.headers = {};2277 httpRequest.url = url2;2278 2279 // Set Headers2280 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2281 2282 // Serialize Request2283 var requestContent = null;2284 var requestDoc = null;2285 2286 var servicePrincipalCreateParametersValue = {};2287 requestDoc = servicePrincipalCreateParametersValue;2288 2289 servicePrincipalCreateParametersValue['appId'] = parameters.appId;2290 2291 servicePrincipalCreateParametersValue['accountEnabled'] = parameters.accountEnabled;2292 2293 requestContent = JSON.stringify(requestDoc);2294 httpRequest.body = requestContent;2295 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');2296 // Send Request2297 return this.client.pipeline(httpRequest, function (err, response, body) {2298 if (err !== null && err !== undefined) {2299 return callback(err);2300 }2301 var statusCode = response.statusCode;2302 if (statusCode !== 201) {2303 var error = new Error(body);2304 error.statusCode = response.statusCode;2305 return callback(error);2306 }2307 2308 // Create Result2309 var result = null;2310 // Deserialize Response2311 if (statusCode === 201) {2312 var responseContent = body;2313 result = {};2314 var responseDoc = null;2315 if (responseContent) {2316 responseDoc = JSON.parse(responseContent);2317 }2318 2319 if (responseDoc !== null && responseDoc !== undefined) {2320 var servicePrincipalInstance = { servicePrincipalNames: [] };2321 result.servicePrincipal = servicePrincipalInstance;2322 2323 var objectIdValue = responseDoc['objectId'];2324 if (objectIdValue !== null && objectIdValue !== undefined) {2325 var objectIdInstance = objectIdValue;2326 servicePrincipalInstance.objectId = objectIdInstance;2327 }2328 2329 var objectTypeValue = responseDoc['objectType'];2330 if (objectTypeValue !== null && objectTypeValue !== undefined) {2331 var objectTypeInstance = objectTypeValue;2332 servicePrincipalInstance.objectType = objectTypeInstance;2333 }2334 2335 var displayNameValue = responseDoc['displayName'];2336 if (displayNameValue !== null && displayNameValue !== undefined) {2337 var displayNameInstance = displayNameValue;2338 servicePrincipalInstance.displayName = displayNameInstance;2339 }2340 2341 var appIdValue = responseDoc['appId'];2342 if (appIdValue !== null && appIdValue !== undefined) {2343 var appIdInstance = appIdValue;2344 servicePrincipalInstance.appId = appIdInstance;2345 }2346 2347 var servicePrincipalNamesArray = responseDoc['servicePrincipalNames'];2348 if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {2349 for (var loweredIndex1 = 0; loweredIndex1 < servicePrincipalNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {2350 var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex1];2351 servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);2352 }2353 }2354 }2355 2356 }2357 result.statusCode = statusCode;2358 result.requestId = response.headers['request-id'];2359 2360 return callback(null, result);2361 });2362 };2363 2364 /**2365 * Deletes service principal from the directory.2366 * 2367 * @param {string} objectId Object id to delete service principal information.2368 * 2369 * @param {function} callback2370 * 2371 * @returns {Stream} The response stream.2372 */2373 ServicePrincipalOperations.prototype.deleteMethod = function(objectId, callback) {2374 if (callback === null || callback === undefined) {2375 throw new Error('callback cannot be null.');2376 }2377 // Validate2378 if (objectId === null || objectId === undefined) {2379 return callback(new Error('objectId cannot be null.'));2380 }2381 2382 // Tracing2383 2384 // Construct URL2385 var url2 = '';2386 url2 = url2 + '/';2387 url2 = url2 + encodeURIComponent(this.client.tenantID);2388 url2 = url2 + '/servicePrincipals/';2389 url2 = url2 + objectId;2390 var queryParameters = [];2391 queryParameters.push('api-version=1.42-previewInternal');2392 if (queryParameters.length > 0) {2393 url2 = url2 + '?' + queryParameters.join('&');2394 }2395 var baseUrl = this.client.baseUri;2396 // Trim '/' character from the end of baseUrl and beginning of url.2397 if (baseUrl[baseUrl.length - 1] === '/') {2398 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2399 }2400 if (url2[0] === '/') {2401 url2 = url2.substring(1);2402 }2403 url2 = baseUrl + '/' + url2;2404 url2 = url2.replace(' ', '%20');2405 2406 // Create HTTP transport objects2407 var httpRequest = new WebResource();2408 httpRequest.method = 'DELETE';2409 httpRequest.headers = {};2410 httpRequest.url = url2;2411 2412 // Set Headers2413 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2414 2415 // Send Request2416 return this.client.pipeline(httpRequest, function (err, response, body) {2417 if (err !== null && err !== undefined) {2418 return callback(err);2419 }2420 var statusCode = response.statusCode;2421 if (statusCode !== 204) {2422 var error = new Error(body);2423 error.statusCode = response.statusCode;2424 return callback(error);2425 }2426 2427 // Create Result2428 var result = null;2429 // Deserialize Response2430 result = {};2431 result.statusCode = statusCode;2432 result.requestId = response.headers['request-id'];2433 2434 return callback(null, result);2435 });2436 };2437 2438 /**2439 * Gets service principal information from the directory.2440 * 2441 * @param {string} objectId Object id to get service principal information.2442 * 2443 * @param {function} callback2444 * 2445 * @returns {Stream} The response stream.2446 */2447 ServicePrincipalOperations.prototype.get = function(objectId, callback) {2448 if (callback === null || callback === undefined) {2449 throw new Error('callback cannot be null.');2450 }2451 // Validate2452 if (objectId === null || objectId === undefined) {2453 return callback(new Error('objectId cannot be null.'));2454 }2455 2456 // Tracing2457 2458 // Construct URL2459 var url2 = '';2460 url2 = url2 + '/';2461 url2 = url2 + encodeURIComponent(this.client.tenantID);2462 url2 = url2 + '/servicePrincipals/';2463 url2 = url2 + objectId;2464 var queryParameters = [];2465 queryParameters.push('api-version=1.42-previewInternal');2466 if (queryParameters.length > 0) {2467 url2 = url2 + '?' + queryParameters.join('&');2468 }2469 var baseUrl = this.client.baseUri;2470 // Trim '/' character from the end of baseUrl and beginning of url.2471 if (baseUrl[baseUrl.length - 1] === '/') {2472 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2473 }2474 if (url2[0] === '/') {2475 url2 = url2.substring(1);2476 }2477 url2 = baseUrl + '/' + url2;2478 url2 = url2.replace(' ', '%20');2479 2480 // Create HTTP transport objects2481 var httpRequest = new WebResource();2482 httpRequest.method = 'GET';2483 httpRequest.headers = {};2484 httpRequest.url = url2;2485 2486 // Set Headers2487 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2488 2489 // Send Request2490 return this.client.pipeline(httpRequest, function (err, response, body) {2491 if (err !== null && err !== undefined) {2492 return callback(err);2493 }2494 var statusCode = response.statusCode;2495 if (statusCode !== 200) {2496 var error = new Error(body);2497 error.statusCode = response.statusCode;2498 return callback(error);2499 }2500 2501 // Create Result2502 var result = null;2503 // Deserialize Response2504 if (statusCode === 200) {2505 var responseContent = body;2506 result = {};2507 var responseDoc = null;2508 if (responseContent) {2509 responseDoc = JSON.parse(responseContent);2510 }2511 2512 if (responseDoc !== null && responseDoc !== undefined) {2513 var servicePrincipalInstance = { servicePrincipalNames: [] };2514 result.servicePrincipal = servicePrincipalInstance;2515 2516 var objectIdValue = responseDoc['objectId'];2517 if (objectIdValue !== null && objectIdValue !== undefined) {2518 var objectIdInstance = objectIdValue;2519 servicePrincipalInstance.objectId = objectIdInstance;2520 }2521 2522 var objectTypeValue = responseDoc['objectType'];2523 if (objectTypeValue !== null && objectTypeValue !== undefined) {2524 var objectTypeInstance = objectTypeValue;2525 servicePrincipalInstance.objectType = objectTypeInstance;2526 }2527 2528 var displayNameValue = responseDoc['displayName'];2529 if (displayNameValue !== null && displayNameValue !== undefined) {2530 var displayNameInstance = displayNameValue;2531 servicePrincipalInstance.displayName = displayNameInstance;2532 }2533 2534 var appIdValue = responseDoc['appId'];2535 if (appIdValue !== null && appIdValue !== undefined) {2536 var appIdInstance = appIdValue;2537 servicePrincipalInstance.appId = appIdInstance;2538 }2539 2540 var servicePrincipalNamesArray = responseDoc['servicePrincipalNames'];2541 if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {2542 for (var loweredIndex1 = 0; loweredIndex1 < servicePrincipalNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {2543 var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex1];2544 servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);2545 }2546 }2547 }2548 2549 }2550 result.statusCode = statusCode;2551 result.requestId = response.headers['request-id'];2552 2553 return callback(null, result);2554 });2555 };2556 2557 /**2558 * Gets service principal information from the directory.2559 * 2560 * @param {string} servicePrincipalName filter based on service principal name2561 * 2562 * @param {function} callback2563 * 2564 * @returns {Stream} The response stream.2565 */2566 ServicePrincipalOperations.prototype.getByServicePrincipalName = function(servicePrincipalName, callback) {2567 if (callback === null || callback === undefined) {2568 throw new Error('callback cannot be null.');2569 }2570 // Validate2571 if (servicePrincipalName === null || servicePrincipalName === undefined) {2572 return callback(new Error('servicePrincipalName cannot be null.'));2573 }2574 2575 // Tracing2576 2577 // Construct URL2578 var url2 = '';2579 url2 = url2 + '/';2580 url2 = url2 + encodeURIComponent(this.client.tenantID);2581 url2 = url2 + '/servicePrincipals';2582 var queryParameters = [];2583 var odataFilter = [];2584 odataFilter.push('servicePrincipalNames/any(c:c eq \'' + encodeURIComponent(servicePrincipalName) + '\')');2585 if (odataFilter.length > 0) {2586 queryParameters.push('$filter=' + odataFilter.join(null));2587 }2588 queryParameters.push('api-version=1.42-previewInternal');2589 if (queryParameters.length > 0) {2590 url2 = url2 + '?' + queryParameters.join('&');2591 }2592 var baseUrl = this.client.baseUri;2593 // Trim '/' character from the end of baseUrl and beginning of url.2594 if (baseUrl[baseUrl.length - 1] === '/') {2595 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2596 }2597 if (url2[0] === '/') {2598 url2 = url2.substring(1);2599 }2600 url2 = baseUrl + '/' + url2;2601 url2 = url2.replace(' ', '%20');2602 2603 // Create HTTP transport objects2604 var httpRequest = new WebResource();2605 httpRequest.method = 'GET';2606 httpRequest.headers = {};2607 httpRequest.url = url2;2608 2609 // Set Headers2610 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2611 2612 // Send Request2613 return this.client.pipeline(httpRequest, function (err, response, body) {2614 if (err !== null && err !== undefined) {2615 return callback(err);2616 }2617 var statusCode = response.statusCode;2618 if (statusCode !== 200) {2619 var error = new Error(body);2620 error.statusCode = response.statusCode;2621 return callback(error);2622 }2623 2624 // Create Result2625 var result = null;2626 // Deserialize Response2627 if (statusCode === 200) {2628 var responseContent = body;2629 result = { servicePrincipals: [] };2630 var responseDoc = null;2631 if (responseContent) {2632 responseDoc = JSON.parse(responseContent);2633 }2634 2635 if (responseDoc !== null && responseDoc !== undefined) {2636 var valueArray = responseDoc['value'];2637 if (valueArray !== null && valueArray !== undefined) {2638 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {2639 var valueValue = valueArray[loweredIndex1];2640 var servicePrincipalInstance = { servicePrincipalNames: [] };2641 result.servicePrincipals.push(servicePrincipalInstance);2642 2643 var objectIdValue = valueValue['objectId'];2644 if (objectIdValue !== null && objectIdValue !== undefined) {2645 var objectIdInstance = objectIdValue;2646 servicePrincipalInstance.objectId = objectIdInstance;2647 }2648 2649 var objectTypeValue = valueValue['objectType'];2650 if (objectTypeValue !== null && objectTypeValue !== undefined) {2651 var objectTypeInstance = objectTypeValue;2652 servicePrincipalInstance.objectType = objectTypeInstance;2653 }2654 2655 var displayNameValue = valueValue['displayName'];2656 if (displayNameValue !== null && displayNameValue !== undefined) {2657 var displayNameInstance = displayNameValue;2658 servicePrincipalInstance.displayName = displayNameInstance;2659 }2660 2661 var appIdValue = valueValue['appId'];2662 if (appIdValue !== null && appIdValue !== undefined) {2663 var appIdInstance = appIdValue;2664 servicePrincipalInstance.appId = appIdInstance;2665 }2666 2667 var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];2668 if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {2669 for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {2670 var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];2671 servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);2672 }2673 }2674 }2675 }2676 2677 var odatanextLinkValue = responseDoc['odata.nextLink'];2678 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {2679 var odatanextLinkInstance = odatanextLinkValue;2680 result.nextLink = odatanextLinkInstance;2681 }2682 }2683 2684 }2685 result.statusCode = statusCode;2686 result.requestId = response.headers['request-id'];2687 2688 return callback(null, result);2689 });2690 };2691 2692 /**2693 * Gets list of service principals from the current tenant.2694 * 2695 * @param {string} [displayNameStartsWith] Display name to filter results.2696 * 2697 * @param {function} callback2698 * 2699 * @returns {Stream} The response stream.2700 */2701 ServicePrincipalOperations.prototype.list = function(displayNameStartsWith, callback) {2702 if (callback === null || callback === undefined) {2703 throw new Error('callback cannot be null.');2704 }2705 // Validate2706 2707 // Tracing2708 2709 // Construct URL2710 var url2 = '';2711 url2 = url2 + '/';2712 url2 = url2 + encodeURIComponent(this.client.tenantID);2713 url2 = url2 + '/servicePrincipals';2714 var queryParameters = [];2715 var odataFilter = [];2716 if (displayNameStartsWith !== null && displayNameStartsWith !== undefined) {2717 odataFilter.push('startswith(displayName,\'' + encodeURIComponent(displayNameStartsWith) + '\')');2718 }2719 if (odataFilter.length > 0) {2720 queryParameters.push('$filter=' + odataFilter.join(null));2721 }2722 queryParameters.push('api-version=1.42-previewInternal');2723 if (queryParameters.length > 0) {2724 url2 = url2 + '?' + queryParameters.join('&');2725 }2726 var baseUrl = this.client.baseUri;2727 // Trim '/' character from the end of baseUrl and beginning of url.2728 if (baseUrl[baseUrl.length - 1] === '/') {2729 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2730 }2731 if (url2[0] === '/') {2732 url2 = url2.substring(1);2733 }2734 url2 = baseUrl + '/' + url2;2735 url2 = url2.replace(' ', '%20');2736 2737 // Create HTTP transport objects2738 var httpRequest = new WebResource();2739 httpRequest.method = 'GET';2740 httpRequest.headers = {};2741 httpRequest.url = url2;2742 2743 // Set Headers2744 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2745 2746 // Send Request2747 return this.client.pipeline(httpRequest, function (err, response, body) {2748 if (err !== null && err !== undefined) {2749 return callback(err);2750 }2751 var statusCode = response.statusCode;2752 if (statusCode !== 200) {2753 var error = new Error(body);2754 error.statusCode = response.statusCode;2755 return callback(error);2756 }2757 2758 // Create Result2759 var result = null;2760 // Deserialize Response2761 if (statusCode === 200) {2762 var responseContent = body;2763 result = { servicePrincipals: [] };2764 var responseDoc = null;2765 if (responseContent) {2766 responseDoc = JSON.parse(responseContent);2767 }2768 2769 if (responseDoc !== null && responseDoc !== undefined) {2770 var valueArray = responseDoc['value'];2771 if (valueArray !== null && valueArray !== undefined) {2772 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {2773 var valueValue = valueArray[loweredIndex1];2774 var servicePrincipalInstance = { servicePrincipalNames: [] };2775 result.servicePrincipals.push(servicePrincipalInstance);2776 2777 var objectIdValue = valueValue['objectId'];2778 if (objectIdValue !== null && objectIdValue !== undefined) {2779 var objectIdInstance = objectIdValue;2780 servicePrincipalInstance.objectId = objectIdInstance;2781 }2782 2783 var objectTypeValue = valueValue['objectType'];2784 if (objectTypeValue !== null && objectTypeValue !== undefined) {2785 var objectTypeInstance = objectTypeValue;2786 servicePrincipalInstance.objectType = objectTypeInstance;2787 }2788 2789 var displayNameValue = valueValue['displayName'];2790 if (displayNameValue !== null && displayNameValue !== undefined) {2791 var displayNameInstance = displayNameValue;2792 servicePrincipalInstance.displayName = displayNameInstance;2793 }2794 2795 var appIdValue = valueValue['appId'];2796 if (appIdValue !== null && appIdValue !== undefined) {2797 var appIdInstance = appIdValue;2798 servicePrincipalInstance.appId = appIdInstance;2799 }2800 2801 var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];2802 if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {2803 for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {2804 var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];2805 servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);2806 }2807 }2808 }2809 }2810 2811 var odatanextLinkValue = responseDoc['odata.nextLink'];2812 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {2813 var odatanextLinkInstance = odatanextLinkValue;2814 result.nextLink = odatanextLinkInstance;2815 }2816 }2817 2818 }2819 result.statusCode = statusCode;2820 result.requestId = response.headers['request-id'];2821 2822 return callback(null, result);2823 });2824 };2825 2826 /**2827 * Gets list of service principals for the current tenant.2828 * 2829 * @param {string} nextLink NextLink from the previous successful call to2830 * List operation.2831 * 2832 * @param {function} callback2833 * 2834 * @returns {Stream} The response stream.2835 */2836 ServicePrincipalOperations.prototype.listNext = function(nextLink, callback) {2837 if (callback === null || callback === undefined) {2838 throw new Error('callback cannot be null.');2839 }2840 // Validate2841 if (nextLink === null || nextLink === undefined) {2842 return callback(new Error('nextLink cannot be null.'));2843 }2844 2845 // Tracing2846 2847 // Construct URL2848 var url2 = '';2849 url2 = url2 + '/';2850 url2 = url2 + encodeURIComponent(this.client.tenantID);2851 url2 = url2 + '/';2852 url2 = url2 + nextLink;2853 url2 = url2 + '&api-version=1.42-previewInternal';2854 var baseUrl = this.client.baseUri;2855 // Trim '/' character from the end of baseUrl and beginning of url.2856 if (baseUrl[baseUrl.length - 1] === '/') {2857 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);2858 }2859 if (url2[0] === '/') {2860 url2 = url2.substring(1);2861 }2862 url2 = baseUrl + '/' + url2;2863 url2 = url2.replace(' ', '%20');2864 2865 // Create HTTP transport objects2866 var httpRequest = new WebResource();2867 httpRequest.method = 'GET';2868 httpRequest.headers = {};2869 httpRequest.url = url2;2870 2871 // Set Headers2872 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';2873 2874 // Send Request2875 return this.client.pipeline(httpRequest, function (err, response, body) {2876 if (err !== null && err !== undefined) {2877 return callback(err);2878 }2879 var statusCode = response.statusCode;2880 if (statusCode !== 200) {2881 var error = new Error(body);2882 error.statusCode = response.statusCode;2883 return callback(error);2884 }2885 2886 // Create Result2887 var result = null;2888 // Deserialize Response2889 if (statusCode === 200) {2890 var responseContent = body;2891 result = { servicePrincipals: [] };2892 var responseDoc = null;2893 if (responseContent) {2894 responseDoc = JSON.parse(responseContent);2895 }2896 2897 if (responseDoc !== null && responseDoc !== undefined) {2898 var valueArray = responseDoc['value'];2899 if (valueArray !== null && valueArray !== undefined) {2900 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {2901 var valueValue = valueArray[loweredIndex1];2902 var servicePrincipalInstance = { servicePrincipalNames: [] };2903 result.servicePrincipals.push(servicePrincipalInstance);2904 2905 var objectIdValue = valueValue['objectId'];2906 if (objectIdValue !== null && objectIdValue !== undefined) {2907 var objectIdInstance = objectIdValue;2908 servicePrincipalInstance.objectId = objectIdInstance;2909 }2910 2911 var objectTypeValue = valueValue['objectType'];2912 if (objectTypeValue !== null && objectTypeValue !== undefined) {2913 var objectTypeInstance = objectTypeValue;2914 servicePrincipalInstance.objectType = objectTypeInstance;2915 }2916 2917 var displayNameValue = valueValue['displayName'];2918 if (displayNameValue !== null && displayNameValue !== undefined) {2919 var displayNameInstance = displayNameValue;2920 servicePrincipalInstance.displayName = displayNameInstance;2921 }2922 2923 var appIdValue = valueValue['appId'];2924 if (appIdValue !== null && appIdValue !== undefined) {2925 var appIdInstance = appIdValue;2926 servicePrincipalInstance.appId = appIdInstance;2927 }2928 2929 var servicePrincipalNamesArray = valueValue['servicePrincipalNames'];2930 if (servicePrincipalNamesArray !== null && servicePrincipalNamesArray !== undefined) {2931 for (var loweredIndex2 = 0; loweredIndex2 < servicePrincipalNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {2932 var servicePrincipalNamesValue = servicePrincipalNamesArray[loweredIndex2];2933 servicePrincipalInstance.servicePrincipalNames.push(servicePrincipalNamesValue);2934 }2935 }2936 }2937 }2938 2939 var odatanextLinkValue = responseDoc['odata.nextLink'];2940 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {2941 var odatanextLinkInstance = odatanextLinkValue;2942 result.nextLink = odatanextLinkInstance;2943 }2944 }2945 2946 }2947 result.statusCode = statusCode;2948 result.requestId = response.headers['request-id'];2949 2950 return callback(null, result);2951 });2952 };2953 2954 return ServicePrincipalOperations;2955})();29562957var UserOperations = ( /** @lends UserOperations */ function() {2958 /**2959 * @class2960 * Operations for working with Users in Azure Active Directory Graph API.2961 * (see http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx for2962 * more information)2963 * __NOTE__: An instance of this class is automatically created for an2964 * instance of the [GraphRbacManagementClient] {@link2965 * GraphRbacManagementClient~GraphRbacManagementClient}.2966 * See [user] {@link2967 * GraphRbacManagementClient~GraphRbacManagementClient#user}.2968 * Initializes a new instance of the UserOperations class.2969 * @constructor2970 * 2971 * @param {GraphRbacManagementClient} client Reference to the service client.2972 */2973 function UserOperations(client) {2974 this.client = client;2975 }2976 2977 /**2978 * Create a new user. (see2979 * http://msdn.microsoft.com/en-us/library/azure/dn130117.aspx for more2980 * information)2981 * 2982 * @param {UserCreateParameters} parameters Parameters to create a user.2983 * 2984 * @param {string} parameters.userPrincipalName User Principal Name2985 * 2986 * @param {boolean} parameters.accountEnabled Enable the account2987 * 2988 * @param {string} parameters.displayName User display name2989 * 2990 * @param {string} parameters.mailNickname Mail nick name2991 * 2992 * @param {PasswordProfile} parameters.passwordProfileSettings Password2993 * Profile2994 * 2995 * @param {string} parameters.passwordProfileSettings.password Password2996 * 2997 * @param {boolean}2998 * [parameters.passwordProfileSettings.forceChangePasswordNextLogin] Force2999 * change password on next login3000 * 3001 * @param {function} callback3002 * 3003 * @returns {Stream} The response stream.3004 */3005 UserOperations.prototype.create = function(parameters, callback) {3006 if (callback === null || callback === undefined) {3007 throw new Error('callback cannot be null.');3008 }3009 // Validate3010 if (parameters === null || parameters === undefined) {3011 return callback(new Error('parameters cannot be null.'));3012 }3013 if (parameters.accountEnabled === null || parameters.accountEnabled === undefined) {3014 return callback(new Error('parameters.accountEnabled cannot be null.'));3015 }3016 if (parameters.displayName === null || parameters.displayName === undefined) {3017 return callback(new Error('parameters.displayName cannot be null.'));3018 }3019 if (parameters.mailNickname === null || parameters.mailNickname === undefined) {3020 return callback(new Error('parameters.mailNickname cannot be null.'));3021 }3022 if (parameters.passwordProfileSettings === null || parameters.passwordProfileSettings === undefined) {3023 return callback(new Error('parameters.passwordProfileSettings cannot be null.'));3024 }3025 if (parameters.passwordProfileSettings.password === null || parameters.passwordProfileSettings.password === undefined) {3026 return callback(new Error('parameters.passwordProfileSettings. cannot be null.'));3027 }3028 if (parameters.userPrincipalName === null || parameters.userPrincipalName === undefined) {3029 return callback(new Error('parameters.userPrincipalName cannot be null.'));3030 }3031 3032 // Tracing3033 3034 // Construct URL3035 var url2 = '';3036 url2 = url2 + '/';3037 url2 = url2 + encodeURIComponent(this.client.tenantID);3038 url2 = url2 + '/users';3039 var queryParameters = [];3040 queryParameters.push('api-version=1.42-previewInternal');3041 if (queryParameters.length > 0) {3042 url2 = url2 + '?' + queryParameters.join('&');3043 }3044 var baseUrl = this.client.baseUri;3045 // Trim '/' character from the end of baseUrl and beginning of url.3046 if (baseUrl[baseUrl.length - 1] === '/') {3047 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3048 }3049 if (url2[0] === '/') {3050 url2 = url2.substring(1);3051 }3052 url2 = baseUrl + '/' + url2;3053 url2 = url2.replace(' ', '%20');3054 3055 // Create HTTP transport objects3056 var httpRequest = new WebResource();3057 httpRequest.method = 'POST';3058 httpRequest.headers = {};3059 httpRequest.url = url2;3060 3061 // Set Headers3062 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3063 3064 // Serialize Request3065 var requestContent = null;3066 var requestDoc = null;3067 3068 var userCreateParametersValue = {};3069 requestDoc = userCreateParametersValue;3070 3071 userCreateParametersValue['userPrincipalName'] = parameters.userPrincipalName;3072 3073 userCreateParametersValue['accountEnabled'] = parameters.accountEnabled;3074 3075 userCreateParametersValue['displayName'] = parameters.displayName;3076 3077 userCreateParametersValue['mailNickname'] = parameters.mailNickname;3078 3079 var passwordProfileValue = {};3080 userCreateParametersValue['passwordProfile'] = passwordProfileValue;3081 3082 passwordProfileValue['password'] = parameters.passwordProfileSettings.password;3083 3084 if (parameters.passwordProfileSettings.forceChangePasswordNextLogin !== null && parameters.passwordProfileSettings.forceChangePasswordNextLogin !== undefined) {3085 passwordProfileValue['forceChangePasswordNextLogin'] = parameters.passwordProfileSettings.forceChangePasswordNextLogin;3086 }3087 3088 requestContent = JSON.stringify(requestDoc);3089 httpRequest.body = requestContent;3090 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');3091 // Send Request3092 return this.client.pipeline(httpRequest, function (err, response, body) {3093 if (err !== null && err !== undefined) {3094 return callback(err);3095 }3096 var statusCode = response.statusCode;3097 if (statusCode !== 201) {3098 var error = new Error(body);3099 error.statusCode = response.statusCode;3100 return callback(error);3101 }3102 3103 // Create Result3104 var result = null;3105 // Deserialize Response3106 if (statusCode === 201) {3107 var responseContent = body;3108 result = {};3109 var responseDoc = null;3110 if (responseContent) {3111 responseDoc = JSON.parse(responseContent);3112 }3113 3114 if (responseDoc !== null && responseDoc !== undefined) {3115 var userInstance = {};3116 result.user = userInstance;3117 3118 var objectIdValue = responseDoc['objectId'];3119 if (objectIdValue !== null && objectIdValue !== undefined) {3120 var objectIdInstance = objectIdValue;3121 userInstance.objectId = objectIdInstance;3122 }3123 3124 var objectTypeValue = responseDoc['objectType'];3125 if (objectTypeValue !== null && objectTypeValue !== undefined) {3126 var objectTypeInstance = objectTypeValue;3127 userInstance.objectType = objectTypeInstance;3128 }3129 3130 var userPrincipalNameValue = responseDoc['userPrincipalName'];3131 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {3132 var userPrincipalNameInstance = userPrincipalNameValue;3133 userInstance.userPrincipalName = userPrincipalNameInstance;3134 }3135 3136 var displayNameValue = responseDoc['displayName'];3137 if (displayNameValue !== null && displayNameValue !== undefined) {3138 var displayNameInstance = displayNameValue;3139 userInstance.displayName = displayNameInstance;3140 }3141 3142 var signInNameValue = responseDoc['signInName'];3143 if (signInNameValue !== null && signInNameValue !== undefined) {3144 var signInNameInstance = signInNameValue;3145 userInstance.signInName = signInNameInstance;3146 }3147 3148 var mailValue = responseDoc['mail'];3149 if (mailValue !== null && mailValue !== undefined) {3150 var mailInstance = mailValue;3151 userInstance.mail = mailInstance;3152 }3153 }3154 3155 }3156 result.statusCode = statusCode;3157 result.requestId = response.headers['request-id'];3158 3159 return callback(null, result);3160 });3161 };3162 3163 /**3164 * Delete a user. (see3165 * http://msdn.microsoft.com/en-us/library/azure/dn151676.aspx for more3166 * information)3167 * 3168 * @param {string} user user object id or user principal name3169 * 3170 * @param {function} callback3171 * 3172 * @returns {Stream} The response stream.3173 */3174 UserOperations.prototype.deleteMethod = function(user, callback) {3175 if (callback === null || callback === undefined) {3176 throw new Error('callback cannot be null.');3177 }3178 // Validate3179 if (user === null || user === undefined) {3180 return callback(new Error('user cannot be null.'));3181 }3182 3183 // Tracing3184 3185 // Construct URL3186 var url2 = '';3187 url2 = url2 + '/';3188 url2 = url2 + encodeURIComponent(this.client.tenantID);3189 url2 = url2 + '/users/';3190 url2 = url2 + user;3191 var queryParameters = [];3192 queryParameters.push('api-version=1.42-previewInternal');3193 if (queryParameters.length > 0) {3194 url2 = url2 + '?' + queryParameters.join('&');3195 }3196 var baseUrl = this.client.baseUri;3197 // Trim '/' character from the end of baseUrl and beginning of url.3198 if (baseUrl[baseUrl.length - 1] === '/') {3199 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3200 }3201 if (url2[0] === '/') {3202 url2 = url2.substring(1);3203 }3204 url2 = baseUrl + '/' + url2;3205 url2 = url2.replace(' ', '%20');3206 3207 // Create HTTP transport objects3208 var httpRequest = new WebResource();3209 httpRequest.method = 'DELETE';3210 httpRequest.headers = {};3211 httpRequest.url = url2;3212 3213 // Set Headers3214 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3215 3216 // Send Request3217 return this.client.pipeline(httpRequest, function (err, response, body) {3218 if (err !== null && err !== undefined) {3219 return callback(err);3220 }3221 var statusCode = response.statusCode;3222 if (statusCode !== 204) {3223 var error = new Error(body);3224 error.statusCode = response.statusCode;3225 return callback(error);3226 }3227 3228 // Create Result3229 var result = null;3230 // Deserialize Response3231 result = {};3232 result.statusCode = statusCode;3233 result.requestId = response.headers['request-id'];3234 3235 return callback(null, result);3236 });3237 };3238 3239 /**3240 * Gets user information from the directory. (see3241 * http://msdn.microsoft.com/en-us/library/azure/dn151678.aspx for more3242 * information)3243 * 3244 * @param {string} upnOrObjectId User object Id or user principal name to get3245 * user information.3246 * 3247 * @param {function} callback3248 * 3249 * @returns {Stream} The response stream.3250 */3251 UserOperations.prototype.get = function(upnOrObjectId, callback) {3252 if (callback === null || callback === undefined) {3253 throw new Error('callback cannot be null.');3254 }3255 // Validate3256 if (upnOrObjectId === null || upnOrObjectId === undefined) {3257 return callback(new Error('upnOrObjectId cannot be null.'));3258 }3259 3260 // Tracing3261 3262 // Construct URL3263 var url2 = '';3264 url2 = url2 + '/';3265 url2 = url2 + encodeURIComponent(this.client.tenantID);3266 url2 = url2 + '/users/';3267 url2 = url2 + upnOrObjectId;3268 var queryParameters = [];3269 queryParameters.push('api-version=1.42-previewInternal');3270 if (queryParameters.length > 0) {3271 url2 = url2 + '?' + queryParameters.join('&');3272 }3273 var baseUrl = this.client.baseUri;3274 // Trim '/' character from the end of baseUrl and beginning of url.3275 if (baseUrl[baseUrl.length - 1] === '/') {3276 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3277 }3278 if (url2[0] === '/') {3279 url2 = url2.substring(1);3280 }3281 url2 = baseUrl + '/' + url2;3282 url2 = url2.replace(' ', '%20');3283 3284 // Create HTTP transport objects3285 var httpRequest = new WebResource();3286 httpRequest.method = 'GET';3287 httpRequest.headers = {};3288 httpRequest.url = url2;3289 3290 // Set Headers3291 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3292 3293 // Send Request3294 return this.client.pipeline(httpRequest, function (err, response, body) {3295 if (err !== null && err !== undefined) {3296 return callback(err);3297 }3298 var statusCode = response.statusCode;3299 if (statusCode !== 200) {3300 var error = new Error(body);3301 error.statusCode = response.statusCode;3302 return callback(error);3303 }3304 3305 // Create Result3306 var result = null;3307 // Deserialize Response3308 if (statusCode === 200) {3309 var responseContent = body;3310 result = {};3311 var responseDoc = null;3312 if (responseContent) {3313 responseDoc = JSON.parse(responseContent);3314 }3315 3316 if (responseDoc !== null && responseDoc !== undefined) {3317 var userInstance = {};3318 result.user = userInstance;3319 3320 var objectIdValue = responseDoc['objectId'];3321 if (objectIdValue !== null && objectIdValue !== undefined) {3322 var objectIdInstance = objectIdValue;3323 userInstance.objectId = objectIdInstance;3324 }3325 3326 var objectTypeValue = responseDoc['objectType'];3327 if (objectTypeValue !== null && objectTypeValue !== undefined) {3328 var objectTypeInstance = objectTypeValue;3329 userInstance.objectType = objectTypeInstance;3330 }3331 3332 var userPrincipalNameValue = responseDoc['userPrincipalName'];3333 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {3334 var userPrincipalNameInstance = userPrincipalNameValue;3335 userInstance.userPrincipalName = userPrincipalNameInstance;3336 }3337 3338 var displayNameValue = responseDoc['displayName'];3339 if (displayNameValue !== null && displayNameValue !== undefined) {3340 var displayNameInstance = displayNameValue;3341 userInstance.displayName = displayNameInstance;3342 }3343 3344 var signInNameValue = responseDoc['signInName'];3345 if (signInNameValue !== null && signInNameValue !== undefined) {3346 var signInNameInstance = signInNameValue;3347 userInstance.signInName = signInNameInstance;3348 }3349 3350 var mailValue = responseDoc['mail'];3351 if (mailValue !== null && mailValue !== undefined) {3352 var mailInstance = mailValue;3353 userInstance.mail = mailInstance;3354 }3355 }3356 3357 }3358 result.statusCode = statusCode;3359 result.requestId = response.headers['request-id'];3360 3361 return callback(null, result);3362 });3363 };3364 3365 /**3366 * Gets user information from the directory.3367 * 3368 * @param {string} signInName filter based on sign in name3369 * 3370 * @param {function} callback3371 * 3372 * @returns {Stream} The response stream.3373 */3374 UserOperations.prototype.getBySignInName = function(signInName, callback) {3375 if (callback === null || callback === undefined) {3376 throw new Error('callback cannot be null.');3377 }3378 // Validate3379 if (signInName === null || signInName === undefined) {3380 return callback(new Error('signInName cannot be null.'));3381 }3382 3383 // Tracing3384 3385 // Construct URL3386 var url2 = '';3387 url2 = url2 + '/';3388 url2 = url2 + encodeURIComponent(this.client.tenantID);3389 url2 = url2 + '/users';3390 var queryParameters = [];3391 var odataFilter = [];3392 odataFilter.push('signInName eq \'' + encodeURIComponent(signInName) + '\'');3393 if (odataFilter.length > 0) {3394 queryParameters.push('$filter=' + odataFilter.join(null));3395 }3396 queryParameters.push('api-version=1.42-previewInternal');3397 if (queryParameters.length > 0) {3398 url2 = url2 + '?' + queryParameters.join('&');3399 }3400 var baseUrl = this.client.baseUri;3401 // Trim '/' character from the end of baseUrl and beginning of url.3402 if (baseUrl[baseUrl.length - 1] === '/') {3403 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3404 }3405 if (url2[0] === '/') {3406 url2 = url2.substring(1);3407 }3408 url2 = baseUrl + '/' + url2;3409 url2 = url2.replace(' ', '%20');3410 3411 // Create HTTP transport objects3412 var httpRequest = new WebResource();3413 httpRequest.method = 'GET';3414 httpRequest.headers = {};3415 httpRequest.url = url2;3416 3417 // Set Headers3418 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3419 3420 // Send Request3421 return this.client.pipeline(httpRequest, function (err, response, body) {3422 if (err !== null && err !== undefined) {3423 return callback(err);3424 }3425 var statusCode = response.statusCode;3426 if (statusCode !== 200) {3427 var error = new Error(body);3428 error.statusCode = response.statusCode;3429 return callback(error);3430 }3431 3432 // Create Result3433 var result = null;3434 // Deserialize Response3435 if (statusCode === 200) {3436 var responseContent = body;3437 result = { users: [] };3438 var responseDoc = null;3439 if (responseContent) {3440 responseDoc = JSON.parse(responseContent);3441 }3442 3443 if (responseDoc !== null && responseDoc !== undefined) {3444 var valueArray = responseDoc['value'];3445 if (valueArray !== null && valueArray !== undefined) {3446 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {3447 var valueValue = valueArray[loweredIndex1];3448 var userInstance = {};3449 result.users.push(userInstance);3450 3451 var objectIdValue = valueValue['objectId'];3452 if (objectIdValue !== null && objectIdValue !== undefined) {3453 var objectIdInstance = objectIdValue;3454 userInstance.objectId = objectIdInstance;3455 }3456 3457 var objectTypeValue = valueValue['objectType'];3458 if (objectTypeValue !== null && objectTypeValue !== undefined) {3459 var objectTypeInstance = objectTypeValue;3460 userInstance.objectType = objectTypeInstance;3461 }3462 3463 var userPrincipalNameValue = valueValue['userPrincipalName'];3464 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {3465 var userPrincipalNameInstance = userPrincipalNameValue;3466 userInstance.userPrincipalName = userPrincipalNameInstance;3467 }3468 3469 var displayNameValue = valueValue['displayName'];3470 if (displayNameValue !== null && displayNameValue !== undefined) {3471 var displayNameInstance = displayNameValue;3472 userInstance.displayName = displayNameInstance;3473 }3474 3475 var signInNameValue = valueValue['signInName'];3476 if (signInNameValue !== null && signInNameValue !== undefined) {3477 var signInNameInstance = signInNameValue;3478 userInstance.signInName = signInNameInstance;3479 }3480 3481 var mailValue = valueValue['mail'];3482 if (mailValue !== null && mailValue !== undefined) {3483 var mailInstance = mailValue;3484 userInstance.mail = mailInstance;3485 }3486 }3487 }3488 3489 var odatanextLinkValue = responseDoc['odata.nextLink'];3490 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {3491 var odatanextLinkInstance = odatanextLinkValue;3492 result.nextLink = odatanextLinkInstance;3493 }3494 }3495 3496 }3497 result.statusCode = statusCode;3498 result.requestId = response.headers['request-id'];3499 3500 return callback(null, result);3501 });3502 };3503 3504 /**3505 * Gets a collection that contains the Object IDs of the groups of which the3506 * user is a member.3507 * 3508 * @param {UserGetMemberGroupsParameters} parameters User filtering3509 * parameters.3510 * 3511 * @param {string} parameters.objectId User object Id3512 * 3513 * @param {boolean} parameters.securityEnabledOnly If true only membership in3514 * security enabled groups should be checked. Otherwise membership in all3515 * groups should be checked3516 * 3517 * @param {function} callback3518 * 3519 * @returns {Stream} The response stream.3520 */3521 UserOperations.prototype.getMemberGroups = function(parameters, callback) {3522 if (callback === null || callback === undefined) {3523 throw new Error('callback cannot be null.');3524 }3525 // Validate3526 if (parameters === null || parameters === undefined) {3527 return callback(new Error('parameters cannot be null.'));3528 }3529 if (parameters.objectId === null || parameters.objectId === undefined) {3530 return callback(new Error('parameters.objectId cannot be null.'));3531 }3532 if (parameters.securityEnabledOnly === null || parameters.securityEnabledOnly === undefined) {3533 return callback(new Error('parameters.securityEnabledOnly cannot be null.'));3534 }3535 3536 // Tracing3537 3538 // Construct URL3539 var url2 = '';3540 url2 = url2 + '/';3541 url2 = url2 + encodeURIComponent(this.client.tenantID);3542 url2 = url2 + '/users/';3543 url2 = url2 + parameters.objectId;3544 url2 = url2 + '/getMemberGroups';3545 var queryParameters = [];3546 queryParameters.push('api-version=1.42-previewInternal');3547 if (queryParameters.length > 0) {3548 url2 = url2 + '?' + queryParameters.join('&');3549 }3550 var baseUrl = this.client.baseUri;3551 // Trim '/' character from the end of baseUrl and beginning of url.3552 if (baseUrl[baseUrl.length - 1] === '/') {3553 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3554 }3555 if (url2[0] === '/') {3556 url2 = url2.substring(1);3557 }3558 url2 = baseUrl + '/' + url2;3559 url2 = url2.replace(' ', '%20');3560 3561 // Create HTTP transport objects3562 var httpRequest = new WebResource();3563 httpRequest.method = 'POST';3564 httpRequest.headers = {};3565 httpRequest.url = url2;3566 3567 // Set Headers3568 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3569 3570 // Serialize Request3571 var requestContent = null;3572 var requestDoc = null;3573 3574 requestDoc = {};3575 requestDoc['securityEnabledOnly'] = parameters.securityEnabledOnly;3576 3577 requestContent = JSON.stringify(requestDoc);3578 httpRequest.body = requestContent;3579 httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');3580 // Send Request3581 return this.client.pipeline(httpRequest, function (err, response, body) {3582 if (err !== null && err !== undefined) {3583 return callback(err);3584 }3585 var statusCode = response.statusCode;3586 if (statusCode !== 200) {3587 var error = new Error(body);3588 error.statusCode = response.statusCode;3589 return callback(error);3590 }3591 3592 // Create Result3593 var result = null;3594 // Deserialize Response3595 if (statusCode === 200) {3596 var responseContent = body;3597 result = { objectIds: [] };3598 var responseDoc = null;3599 if (responseContent) {3600 responseDoc = JSON.parse(responseContent);3601 }3602 3603 if (responseDoc !== null && responseDoc !== undefined) {3604 var valueArray = responseDoc['value'];3605 if (valueArray !== null && valueArray !== undefined) {3606 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {3607 var valueValue = valueArray[loweredIndex1];3608 result.objectIds.push(valueValue);3609 }3610 }3611 }3612 3613 }3614 result.statusCode = statusCode;3615 result.requestId = response.headers['request-id'];3616 3617 return callback(null, result);3618 });3619 };3620 3621 /**3622 * Gets list of users for the current tenant.3623 * 3624 * @param {string} [mail] Email to filter results.3625 * 3626 * @param {string} [displayNameStartsWith] Display name to filter results.3627 * 3628 * @param {function} callback3629 * 3630 * @returns {Stream} The response stream.3631 */3632 UserOperations.prototype.list = function(mail, displayNameStartsWith, callback) {3633 if (callback === null || callback === undefined) {3634 throw new Error('callback cannot be null.');3635 }3636 // Validate3637 3638 // Tracing3639 3640 // Construct URL3641 var url2 = '';3642 url2 = url2 + '/';3643 url2 = url2 + encodeURIComponent(this.client.tenantID);3644 url2 = url2 + '/users';3645 var queryParameters = [];3646 var odataFilter = [];3647 if (mail !== null && mail !== undefined) {3648 odataFilter.push('mail eq \'' + encodeURIComponent(mail) + '\'');3649 }3650 if (odataFilter.length > 0) {3651 queryParameters.push('$filter=' + odataFilter.join(null));3652 }3653 var odataFilter2 = [];3654 if (displayNameStartsWith !== null && displayNameStartsWith !== undefined) {3655 odataFilter2.push('startswith(displayName,\'' + encodeURIComponent(displayNameStartsWith) + '\')');3656 }3657 if (odataFilter2.length > 0) {3658 queryParameters.push('$filter=' + odataFilter2.join(null));3659 }3660 queryParameters.push('api-version=1.42-previewInternal');3661 if (queryParameters.length > 0) {3662 url2 = url2 + '?' + queryParameters.join('&');3663 }3664 var baseUrl = this.client.baseUri;3665 // Trim '/' character from the end of baseUrl and beginning of url.3666 if (baseUrl[baseUrl.length - 1] === '/') {3667 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3668 }3669 if (url2[0] === '/') {3670 url2 = url2.substring(1);3671 }3672 url2 = baseUrl + '/' + url2;3673 url2 = url2.replace(' ', '%20');3674 3675 // Create HTTP transport objects3676 var httpRequest = new WebResource();3677 httpRequest.method = 'GET';3678 httpRequest.headers = {};3679 httpRequest.url = url2;3680 3681 // Set Headers3682 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3683 3684 // Send Request3685 return this.client.pipeline(httpRequest, function (err, response, body) {3686 if (err !== null && err !== undefined) {3687 return callback(err);3688 }3689 var statusCode = response.statusCode;3690 if (statusCode !== 200) {3691 var error = new Error(body);3692 error.statusCode = response.statusCode;3693 return callback(error);3694 }3695 3696 // Create Result3697 var result = null;3698 // Deserialize Response3699 if (statusCode === 200) {3700 var responseContent = body;3701 result = { users: [] };3702 var responseDoc = null;3703 if (responseContent) {3704 responseDoc = JSON.parse(responseContent);3705 }3706 3707 if (responseDoc !== null && responseDoc !== undefined) {3708 var valueArray = responseDoc['value'];3709 if (valueArray !== null && valueArray !== undefined) {3710 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {3711 var valueValue = valueArray[loweredIndex1];3712 var userInstance = {};3713 result.users.push(userInstance);3714 3715 var objectIdValue = valueValue['objectId'];3716 if (objectIdValue !== null && objectIdValue !== undefined) {3717 var objectIdInstance = objectIdValue;3718 userInstance.objectId = objectIdInstance;3719 }3720 3721 var objectTypeValue = valueValue['objectType'];3722 if (objectTypeValue !== null && objectTypeValue !== undefined) {3723 var objectTypeInstance = objectTypeValue;3724 userInstance.objectType = objectTypeInstance;3725 }3726 3727 var userPrincipalNameValue = valueValue['userPrincipalName'];3728 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {3729 var userPrincipalNameInstance = userPrincipalNameValue;3730 userInstance.userPrincipalName = userPrincipalNameInstance;3731 }3732 3733 var displayNameValue = valueValue['displayName'];3734 if (displayNameValue !== null && displayNameValue !== undefined) {3735 var displayNameInstance = displayNameValue;3736 userInstance.displayName = displayNameInstance;3737 }3738 3739 var signInNameValue = valueValue['signInName'];3740 if (signInNameValue !== null && signInNameValue !== undefined) {3741 var signInNameInstance = signInNameValue;3742 userInstance.signInName = signInNameInstance;3743 }3744 3745 var mailValue = valueValue['mail'];3746 if (mailValue !== null && mailValue !== undefined) {3747 var mailInstance = mailValue;3748 userInstance.mail = mailInstance;3749 }3750 }3751 }3752 3753 var odatanextLinkValue = responseDoc['odata.nextLink'];3754 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {3755 var odatanextLinkInstance = odatanextLinkValue;3756 result.nextLink = odatanextLinkInstance;3757 }3758 }3759 3760 }3761 result.statusCode = statusCode;3762 result.requestId = response.headers['request-id'];3763 3764 return callback(null, result);3765 });3766 };3767 3768 /**3769 * Gets list of users for the current tenant.3770 * 3771 * @param {string} nextLink NextLink from the previous successful call to3772 * List operation.3773 * 3774 * @param {function} callback3775 * 3776 * @returns {Stream} The response stream.3777 */3778 UserOperations.prototype.listNext = function(nextLink, callback) {3779 if (callback === null || callback === undefined) {3780 throw new Error('callback cannot be null.');3781 }3782 // Validate3783 if (nextLink === null || nextLink === undefined) {3784 return callback(new Error('nextLink cannot be null.'));3785 }3786 3787 // Tracing3788 3789 // Construct URL3790 var url2 = '';3791 url2 = url2 + '/';3792 url2 = url2 + encodeURIComponent(this.client.tenantID);3793 url2 = url2 + '/';3794 url2 = url2 + nextLink;3795 url2 = url2 + '&api-version=1.42-previewInternal';3796 var baseUrl = this.client.baseUri;3797 // Trim '/' character from the end of baseUrl and beginning of url.3798 if (baseUrl[baseUrl.length - 1] === '/') {3799 baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);3800 }3801 if (url2[0] === '/') {3802 url2 = url2.substring(1);3803 }3804 url2 = baseUrl + '/' + url2;3805 url2 = url2.replace(' ', '%20');3806 3807 // Create HTTP transport objects3808 var httpRequest = new WebResource();3809 httpRequest.method = 'GET';3810 httpRequest.headers = {};3811 httpRequest.url = url2;3812 3813 // Set Headers3814 httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';3815 3816 // Send Request3817 return this.client.pipeline(httpRequest, function (err, response, body) {3818 if (err !== null && err !== undefined) {3819 return callback(err);3820 }3821 var statusCode = response.statusCode;3822 if (statusCode !== 200) {3823 var error = new Error(body);3824 error.statusCode = response.statusCode;3825 return callback(error);3826 }3827 3828 // Create Result3829 var result = null;3830 // Deserialize Response3831 if (statusCode === 200) {3832 var responseContent = body;3833 result = { users: [] };3834 var responseDoc = null;3835 if (responseContent) {3836 responseDoc = JSON.parse(responseContent);3837 }3838 3839 if (responseDoc !== null && responseDoc !== undefined) {3840 var valueArray = responseDoc['value'];3841 if (valueArray !== null && valueArray !== undefined) {3842 for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {3843 var valueValue = valueArray[loweredIndex1];3844 var userInstance = {};3845 result.users.push(userInstance);3846 3847 var objectIdValue = valueValue['objectId'];3848 if (objectIdValue !== null && objectIdValue !== undefined) {3849 var objectIdInstance = objectIdValue;3850 userInstance.objectId = objectIdInstance;3851 }3852 3853 var objectTypeValue = valueValue['objectType'];3854 if (objectTypeValue !== null && objectTypeValue !== undefined) {3855 var objectTypeInstance = objectTypeValue;3856 userInstance.objectType = objectTypeInstance;3857 }3858 3859 var userPrincipalNameValue = valueValue['userPrincipalName'];3860 if (userPrincipalNameValue !== null && userPrincipalNameValue !== undefined) {3861 var userPrincipalNameInstance = userPrincipalNameValue;3862 userInstance.userPrincipalName = userPrincipalNameInstance;3863 }3864 3865 var displayNameValue = valueValue['displayName'];3866 if (displayNameValue !== null && displayNameValue !== undefined) {3867 var displayNameInstance = displayNameValue;3868 userInstance.displayName = displayNameInstance;3869 }3870 3871 var signInNameValue = valueValue['signInName'];3872 if (signInNameValue !== null && signInNameValue !== undefined) {3873 var signInNameInstance = signInNameValue;3874 userInstance.signInName = signInNameInstance;3875 }3876 3877 var mailValue = valueValue['mail'];3878 if (mailValue !== null && mailValue !== undefined) {3879 var mailInstance = mailValue;3880 userInstance.mail = mailInstance;3881 }3882 }3883 }3884 3885 var odatanextLinkValue = responseDoc['odata.nextLink'];3886 if (odatanextLinkValue !== null && odatanextLinkValue !== undefined) {3887 var odatanextLinkInstance = odatanextLinkValue;3888 result.nextLink = odatanextLinkInstance;3889 }3890 }3891 3892 }3893 result.statusCode = statusCode;3894 result.requestId = response.headers['request-id'];3895 3896 return callback(null, result);3897 });3898 };3899 3900 return UserOperations;
...
Using AI Code Generation
1const { url2 } = require('pact-foundation/pact');2const { url } = require('pact-foundation/pact');3console.log(url2());4console.log(url());5const { url2 } = require('pact-foundation/pact');6const { url } = require('pact-foundation/pact');7console.log(url2());8console.log(url());9const { url2 } = require('pact-foundation/pact');10const { url } = require('pact-foundation/pact');11console.log(url2());12console.log(url());13const { url2 } = require('pact-foundation/pact');14const { url } = require('pact-foundation/pact');15console.log(url2());16console.log(url());17const { url2 } = require('pact-foundation/pact');18const { url } = require('pact-foundation/pact');19console.log(url2());20console.log(url());21const { url2 } = require('pact-foundation/pact');22const { url } = require('pact-foundation/pact');
Using AI Code Generation
1const { url2 } = require('pact-foundation-pact-node');2const url = url2('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer/latest');3console.log(url);4const { url3 } = require('pact-foundation-pact-node');5const url = url3('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer/latest');6console.log(url);7const { url4 } = require('pact-foundation-pact-node');8const url = url4('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer/latest');9console.log(url);10const { url5 } = require('pact-foundation-pact-node');11const url = url5('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer/latest');12console.log(url);13const { url6 } = require('pact-foundation-pact-node');14const url = url6('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer/latest');15console.log(url);16const { url7 } = require('pact-foundation-pact-node');17const url = url7('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer/latest');18console.log(url);19const { url8 } = require('pact-foundation-pact-node');20const url = url8('pact-broker', 9292, '/pacts/provider/My%20Provider/consumer/My%20Consumer
Using AI Code Generation
1const url2 = require('pact-foundation/pact-node/src/url').url2;2console.log(url);3const url2 = require('pact-foundation/pact-node/src/url').url2;4console.log(url);5const url2 = require('pact-foundation/pact-node/src/url').url2;6console.log(url);7const url2 = require('pact-foundation/pact-node/src/url').url2;8console.log(url);9const url2 = require('pact-foundation/pact-node/src/url').url2;10console.log(url);11const url2 = require('pact-foundation/pact-node/src/url').url2;12console.log(url);13const url2 = require('pact-foundation/pact-node/src/url').url2;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!