/* jshint latedef:false */
/* jshint forin:false */
/* jshint noempty:false */

// 
// Copyright (c) Microsoft and contributors.  All rights reserved.
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
// 

// Warning: This code was generated by a tool.
// 
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

'use strict';

var util = require('util');
var _ = require('underscore');
var azureCommon = require('azure-common');
var xml = azureCommon.xml2js;
var js2xml = azureCommon.js2xml;
var Service = azureCommon.Service;
var WebResource = azureCommon.WebResource;

var WebSiteManagementClient = ( /** @lends WebSiteManagementClient */ function() {
  /**
   * @class
   * The Web Sites Management API provides a RESTful set of web services that
   * interact with the Windows Azure Web Sites service to manage your web
   * sites. The API has entities that capture the relationship between an end
   * user and Windows Azure Web Sites service.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166981.aspx for
   * more information)
   * Initializes a new instance of the WebSiteManagementClient class.
   * @constructor
   * 
   * @param {SubscriptionCloudCredentials} credentials Gets subscription
   * credentials which uniquely identify Microsoft Azure subscription. The
   * subscription ID forms part of the URI for every service call.
   * 
   * @param {string} [credentials.subscriptionId]
   * 
   * @param {string} [baseUri] Gets the URI used as the base for all cloud
   * service requests.
   * 
   * @param {Array} filters
   */
  function WebSiteManagementClient(credentials, baseUri, filters) {
    if (credentials === null || credentials === undefined) {
      throw new Error('credentials cannot be null.');
    }
    
    WebSiteManagementClient['super_'].call(this, credentials, filters);
    
    this.credentials = credentials;
    this.baseUri = baseUri;
    if (this.baseUri === null || this.baseUri === undefined) {
      this.baseUri = 'https://management.core.windows.net';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2014-04-01';
    }
    if (this.longRunningOperationInitialTimeout === null || this.longRunningOperationInitialTimeout === undefined) {
      this.longRunningOperationInitialTimeout = -1;
    }
    if (this.longRunningOperationRetryTimeout === null || this.longRunningOperationRetryTimeout === undefined) {
      this.longRunningOperationRetryTimeout = -1;
    }
    /**
     * Provides an instance of the
     * [WebHostingPlanOperations](-WebHostingPlanOperations.html) object.
     * @type {object}
     */
    this.webHostingPlans = new WebHostingPlanOperations(this);
    /**
     * Provides an instance of the [WebSiteOperations](-WebSiteOperations.html)
     * object.
     * @type {object}
     */
    this.webSites = new WebSiteOperations(this);
    /**
     * Provides an instance of the
     * [WebSpaceOperations](-WebSpaceOperations.html) object.
     * @type {object}
     */
    this.webSpaces = new WebSpaceOperations(this);
  }
  
  util.inherits(WebSiteManagementClient, Service);
  
  /**
   * The Get Operation Status operation returns the status of the specified
   * operation. After calling a long-running operation, you can call Get
   * Operation Status to determine whether the operation has succeeded,
   * failed, timed out, or is still in progress.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the webspace for the website
   * where the operation was targeted.
   * 
   * @param {string} siteName The name of the site where the operation was
   * targeted.
   * 
   * @param {string} operationId The operation ID for the operation you wish to
   * track. The operation ID is returned in the ID field in the body of the
   * response for long-running operations.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteManagementClient.prototype.getOperationStatus = function(webSpaceName, siteName, operationId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (siteName === null || siteName === undefined) {
      return callback(new Error('siteName cannot be null.'));
    }
    if (operationId === null || operationId === undefined) {
      return callback(new Error('operationId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(siteName);
    url2 = url2 + '/operations/';
    url2 = url2 + encodeURIComponent(operationId);
    var baseUrl = this.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { errors: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var operationElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (operationElement !== null && operationElement !== undefined) {
            var createdTimeElement = js2xml.getElement(responseDoc, operationElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
              var createdTimeInstance = new Date(createdTimeElement);
              result.createdTime = createdTimeInstance;
            }
            
            var errorsSequenceElement = js2xml.getElement(responseDoc, operationElement, 'ERRORS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (errorsSequenceElement !== null && errorsSequenceElement !== undefined) {
              var isNil = false;
              var nilAttribute = js2xml.getAttribute(responseDoc, errorsSequenceElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute !== null && nilAttribute !== undefined) {
                isNil = nilAttribute === 'true';
              }
              if (isNil === false) {
                for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, errorsSequenceElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                  var errorsElement = js2xml.getElements(responseDoc, errorsSequenceElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                  var errorInstance = { parameters: [] };
                  result.errors.push(errorInstance);
                  
                  var codeElement = js2xml.getElement(responseDoc, errorsElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (codeElement !== null && codeElement !== undefined) {
                    var isNil2 = false;
                    var nilAttribute2 = js2xml.getAttribute(responseDoc, codeElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                      isNil2 = nilAttribute2 === 'true';
                    }
                    if (isNil2 === false) {
                      var codeInstance = codeElement;
                      errorInstance.code = codeInstance;
                    }
                  }
                  
                  var messageElement = js2xml.getElement(responseDoc, errorsElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (messageElement !== null && messageElement !== undefined) {
                    var isNil3 = false;
                    var nilAttribute3 = js2xml.getAttribute(responseDoc, messageElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute3 !== null && nilAttribute3 !== undefined) {
                      isNil3 = nilAttribute3 === 'true';
                    }
                    if (isNil3 === false) {
                      var messageInstance = messageElement;
                      errorInstance.message = messageInstance;
                    }
                  }
                  
                  var extendedCodeElement = js2xml.getElement(responseDoc, errorsElement, 'EXTENDEDCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (extendedCodeElement !== null && extendedCodeElement !== undefined) {
                    var isNil4 = false;
                    var nilAttribute4 = js2xml.getAttribute(responseDoc, extendedCodeElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute4 !== null && nilAttribute4 !== undefined) {
                      isNil4 = nilAttribute4 === 'true';
                    }
                    if (isNil4 === false) {
                      var extendedCodeInstance = extendedCodeElement;
                      errorInstance.extendedCode = extendedCodeInstance;
                    }
                  }
                  
                  var messageTemplateElement = js2xml.getElement(responseDoc, errorsElement, 'MESSAGETEMPLATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (messageTemplateElement !== null && messageTemplateElement !== undefined) {
                    var isNil5 = false;
                    var nilAttribute5 = js2xml.getAttribute(responseDoc, messageTemplateElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute5 !== null && nilAttribute5 !== undefined) {
                      isNil5 = nilAttribute5 === 'true';
                    }
                    if (isNil5 === false) {
                      var messageTemplateInstance = messageTemplateElement;
                      errorInstance.messageTemplate = messageTemplateInstance;
                    }
                  }
                  
                  var parametersSequenceElement = js2xml.getElement(responseDoc, errorsElement, 'PARAMETERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (parametersSequenceElement !== null && parametersSequenceElement !== undefined) {
                    var isNil6 = false;
                    var nilAttribute6 = js2xml.getAttribute(responseDoc, parametersSequenceElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute6 !== null && nilAttribute6 !== undefined) {
                      isNil6 = nilAttribute6 === 'true';
                    }
                    if (isNil6 === false) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, parametersSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex2 = loweredIndex2 + 1) {
                        var parametersElement = js2xml.getElements(responseDoc, parametersSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex2];
                        errorInstance.parameters.push(parametersElement);
                      }
                    } else {
                      errorInstance.parameters = null;
                    }
                  }
                  
                  var innerErrorsElement = js2xml.getElement(responseDoc, errorsElement, 'INNERERRORS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (innerErrorsElement !== null && innerErrorsElement !== undefined) {
                    var isNil7 = false;
                    var nilAttribute7 = js2xml.getAttribute(responseDoc, innerErrorsElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute7 !== null && nilAttribute7 !== undefined) {
                      isNil7 = nilAttribute7 === 'true';
                    }
                    if (isNil7 === false) {
                      var innerErrorsInstance = innerErrorsElement;
                      errorInstance.innerErrors = innerErrorsInstance;
                    }
                  }
                }
              } else {
                result.errors = null;
              }
            }
            
            var expirationTimeElement = js2xml.getElement(responseDoc, operationElement, 'EXPIRATIONTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (expirationTimeElement !== null && expirationTimeElement !== undefined && expirationTimeElement.length !== 0) {
              var expirationTimeInstance = new Date(expirationTimeElement);
              result.expirationTime = expirationTimeInstance;
            }
            
            var geoMasterOperationIdElement = js2xml.getElement(responseDoc, operationElement, 'GEOMASTEROPERATIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (geoMasterOperationIdElement !== null && geoMasterOperationIdElement !== undefined) {
              var isNil8 = false;
              var nilAttribute8 = js2xml.getAttribute(responseDoc, geoMasterOperationIdElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute8 !== null && nilAttribute8 !== undefined) {
                isNil8 = nilAttribute8 === 'true';
              }
              if (isNil8 === false) {
                var geoMasterOperationIdInstance = geoMasterOperationIdElement;
                result.geoMasterOperationId = geoMasterOperationIdInstance;
              }
            }
            
            var idElement = js2xml.getElement(responseDoc, operationElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (idElement !== null && idElement !== undefined) {
              var isNil9 = false;
              var nilAttribute9 = js2xml.getAttribute(responseDoc, idElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute9 !== null && nilAttribute9 !== undefined) {
                isNil9 = nilAttribute9 === 'true';
              }
              if (isNil9 === false) {
                var idInstance = idElement;
                result.operationId = idInstance;
              }
            }
            
            var modifiedTimeElement = js2xml.getElement(responseDoc, operationElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
              var modifiedTimeInstance = new Date(modifiedTimeElement);
              result.modifiedTime = modifiedTimeInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, operationElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var isNil10 = false;
              var nilAttribute10 = js2xml.getAttribute(responseDoc, nameElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute10 !== null && nilAttribute10 !== undefined) {
                isNil10 = nilAttribute10 === 'true';
              }
              if (isNil10 === false) {
                var nameInstance = nameElement;
                result.name = nameInstance;
              }
            }
            
            var statusElement = js2xml.getElement(responseDoc, operationElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Register your subscription to use Azure Web Sites.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteManagementClient.prototype.registerSubscription = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.credentials.subscriptionId);
    }
    url2 = url2 + '/services';
    var queryParameters = [];
    queryParameters.push('service=website');
    queryParameters.push('action=register');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Unregister your subscription to use Azure Web Sites.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteManagementClient.prototype.unregisterSubscription = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.credentials.subscriptionId);
    }
    url2 = url2 + '/services';
    var queryParameters = [];
    queryParameters.push('service=website');
    queryParameters.push('action=unregister');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return WebSiteManagementClient;
})();
exports.WebSiteManagementClient = WebSiteManagementClient;

var WebHostingPlanOperations = ( /** @lends WebHostingPlanOperations */ function() {
  /**
   * @class
   * Operations for managing web hosting plans beneath your subscription.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [WebSiteManagementClient] {@link
   * WebSiteManagementClient~WebSiteManagementClient}.
   * See [webHostingPlans] {@link
   * WebSiteManagementClient~WebSiteManagementClient#webHostingPlans}.
   * Initializes a new instance of the WebHostingPlanOperations class.
   * @constructor
   * 
   * @param {WebSiteManagementClient} client Reference to the service client.
   */
  function WebHostingPlanOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a new Web Hosting Plan.  (see
   * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
   * for more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {WebHostingPlanCreateParameters} parameters Web Hosting Plan
   * Parameters.
   * 
   * @param {string} parameters.name Name of the Web hosting plan.
   * 
   * @param {number} [parameters.numberOfWorkers] The requested number of
   * workers.
   * 
   * @param {SkuOptions} [parameters.sKU] SKU of the Web hosting plan.
   * 
   * @param {WorkerSizeOptions} [parameters.workerSize] The worker size.
   * Possible values are Small, Medium, and Large. For JSON, the equivalents
   * are 0 = Small, 1 = Medium, and 2 = Large.
   * 
   * @param {string} [parameters.adminSiteName] The admin site. The admin site
   * is used to deploy site extensions or contents shared by all site in the
   * plan.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.create = function(webSpaceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/ServerFarms';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var serverFarmElement = js2xml.createElement('ServerFarm', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, serverFarmElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(serverFarmElement, nameElement);
    
    if (parameters.numberOfWorkers !== null && parameters.numberOfWorkers !== undefined) {
      var numberOfWorkersElement = js2xml.createElement('NumberOfWorkers', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(numberOfWorkersElement, parameters.numberOfWorkers.toString());
      js2xml.addChildElement(serverFarmElement, numberOfWorkersElement);
    }
    
    if (parameters.sKU !== null && parameters.sKU !== undefined) {
      var sKUElement = js2xml.createElement('SKU', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(sKUElement, parameters.sKU !== null && parameters.sKU !== undefined ? parameters.sKU.toString() : 'Free');
      js2xml.addChildElement(serverFarmElement, sKUElement);
    }
    
    if (parameters.workerSize !== null && parameters.workerSize !== undefined) {
      var workerSizeElement = js2xml.createElement('WorkerSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(workerSizeElement, parameters.workerSize !== null && parameters.workerSize !== undefined ? parameters.workerSize.toString() : 'Small');
      js2xml.addChildElement(serverFarmElement, workerSizeElement);
    }
    
    if (parameters.adminSiteName !== null && parameters.adminSiteName !== undefined) {
      var adminSiteNameElement = js2xml.createElement('AdminSiteName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(adminSiteNameElement, parameters.adminSiteName);
      js2xml.addChildElement(serverFarmElement, adminSiteNameElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var serverFarmElement2 = js2xml.getElement(responseDoc, responseDoc, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (serverFarmElement2 !== null && serverFarmElement2 !== undefined) {
            var webHostingPlanInstance = {};
            result.webHostingPlan = webHostingPlanInstance;
            
            var nameElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance = nameElement2;
              webHostingPlanInstance.name = nameInstance;
            }
            
            var numberOfWorkersElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'NUMBEROFWORKERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (numberOfWorkersElement2 !== null && numberOfWorkersElement2 !== undefined && numberOfWorkersElement2.length !== 0) {
              var numberOfWorkersInstance = parseInt(numberOfWorkersElement2, 10);
              webHostingPlanInstance.numberOfWorkers = numberOfWorkersInstance;
            }
            
            var sKUElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sKUElement2 !== null && sKUElement2 !== undefined && sKUElement2.length !== 0) {
              var sKUInstance = sKUElement2;
              webHostingPlanInstance.sKU = sKUInstance;
            }
            
            var workerSizeElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'WORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (workerSizeElement2 !== null && workerSizeElement2 !== undefined && workerSizeElement2.length !== 0) {
              var workerSizeInstance = workerSizeElement2;
              webHostingPlanInstance.workerSize = workerSizeInstance;
            }
            
            var adminSiteNameElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'ADMINSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adminSiteNameElement2 !== null && adminSiteNameElement2 !== undefined) {
              var adminSiteNameInstance = adminSiteNameElement2;
              webHostingPlanInstance.adminSiteName = adminSiteNameInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes a Web Hosting Plan  (see
   * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
   * for more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webHostingPlanName The name of the web hosting plan.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.deleteMethod = function(webSpaceName, webHostingPlanName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webHostingPlanName === null || webHostingPlanName === undefined) {
      return callback(new Error('webHostingPlanName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/ServerFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets details of an existing Web Hosting Plan  (see
   * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
   * for more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webHostingPlanName The name of the web hosting plan.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.get = function(webSpaceName, webHostingPlanName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webHostingPlanName === null || webHostingPlanName === undefined) {
      return callback(new Error('webHostingPlanName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/serverFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var serverFarmElement = js2xml.getElement(responseDoc, responseDoc, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (serverFarmElement !== null && serverFarmElement !== undefined) {
            var webHostingPlanInstance = {};
            result.webHostingPlan = webHostingPlanInstance;
            
            var nameElement = js2xml.getElement(responseDoc, serverFarmElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              webHostingPlanInstance.name = nameInstance;
            }
            
            var numberOfWorkersElement = js2xml.getElement(responseDoc, serverFarmElement, 'NUMBEROFWORKERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (numberOfWorkersElement !== null && numberOfWorkersElement !== undefined && numberOfWorkersElement.length !== 0) {
              var numberOfWorkersInstance = parseInt(numberOfWorkersElement, 10);
              webHostingPlanInstance.numberOfWorkers = numberOfWorkersInstance;
            }
            
            var sKUElement = js2xml.getElement(responseDoc, serverFarmElement, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sKUElement !== null && sKUElement !== undefined && sKUElement.length !== 0) {
              var sKUInstance = sKUElement;
              webHostingPlanInstance.sKU = sKUInstance;
            }
            
            var workerSizeElement = js2xml.getElement(responseDoc, serverFarmElement, 'WORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (workerSizeElement !== null && workerSizeElement !== undefined && workerSizeElement.length !== 0) {
              var workerSizeInstance = workerSizeElement;
              webHostingPlanInstance.workerSize = workerSizeInstance;
            }
            
            var adminSiteNameElement = js2xml.getElement(responseDoc, serverFarmElement, 'ADMINSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adminSiteNameElement !== null && adminSiteNameElement !== undefined) {
              var adminSiteNameInstance = adminSiteNameElement;
              webHostingPlanInstance.adminSiteName = adminSiteNameInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve historical usage metrics for a site by issuing an HTTP
   * GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166964.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webHostingPlanName The name of the web hosting plan.
   * 
   * @param {WebHostingPlanGetHistoricalUsageMetricsParameters} parameters
   * Parameters supplied to the Get Historical Usage Metrics Web hosting plan
   * operation.
   * 
   * @param {array} [parameters.metricNames] Specifies a comma-separated list
   * of the names of the metrics to return. If the names parameter is not
   * specified, then all available metrics are returned.
   * 
   * @param {date} [parameters.startTime] The starting time of the metrics to
   * return. If this parameter is not specified, the beginning of the current
   * hour is used.
   * 
   * @param {date} [parameters.endTime] The ending time of the metrics to
   * return. If this parameter is not specified, the current time is used.
   * 
   * @param {string} [parameters.timeGrain] The grain at which the metrics are
   * returned. Supported values are PT1M (minute), PT1H (hour), P1D (day).
   * 
   * @param {boolean} [parameters.includeInstanceBreakdown] Flag which
   * specifies if the metrics for each machine instance should be included.
   * For sites that run on more than one machine this could be useful to
   * identify a bad machine.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.getHistoricalUsageMetrics = function(webSpaceName, webHostingPlanName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webHostingPlanName === null || webHostingPlanName === undefined) {
      return callback(new Error('webHostingPlanName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/serverFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    url2 = url2 + '/metrics';
    var queryParameters = [];
    if (parameters.metricNames !== null && parameters.metricNames !== undefined && parameters.metricNames.length > 0) {
      queryParameters.push('names=' + encodeURIComponent(parameters.metricNames.join(',')));
    }
    if (parameters.startTime !== null && parameters.startTime !== undefined) {
      queryParameters.push('StartTime=' + encodeURIComponent(parameters.startTime.toISOString()));
    }
    if (parameters.endTime !== null && parameters.endTime !== undefined) {
      queryParameters.push('EndTime=' + encodeURIComponent(parameters.endTime.toISOString()));
    }
    if (parameters.timeGrain !== null && parameters.timeGrain !== undefined) {
      queryParameters.push('timeGrain=' + encodeURIComponent(parameters.timeGrain));
    }
    if (parameters.includeInstanceBreakdown !== null && parameters.includeInstanceBreakdown !== undefined) {
      queryParameters.push('details=' + encodeURIComponent(parameters.includeInstanceBreakdown.toString()));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { usageMetrics: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var metricResponsesElement = js2xml.getElement(responseDoc, responseDoc, 'METRICRESPONSES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (metricResponsesElement !== null && metricResponsesElement !== undefined) {
            if (metricResponsesElement !== null && metricResponsesElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, metricResponsesElement, 'METRICRESPONSE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var usageMetricsElement = js2xml.getElements(responseDoc, metricResponsesElement, 'METRICRESPONSE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var metricResponseInstance = {};
                result.usageMetrics.push(metricResponseInstance);
                
                var codeElement = js2xml.getElement(responseDoc, usageMetricsElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (codeElement !== null && codeElement !== undefined) {
                  var codeInstance = codeElement;
                  metricResponseInstance.code = codeInstance;
                }
                
                var dataElement = js2xml.getElement(responseDoc, usageMetricsElement, 'DATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dataElement !== null && dataElement !== undefined) {
                  var dataInstance = { values: [] };
                  metricResponseInstance.data = dataInstance;
                  
                  var displayNameElement = js2xml.getElement(responseDoc, dataElement, 'DISPLAYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (displayNameElement !== null && displayNameElement !== undefined) {
                    var displayNameInstance = displayNameElement;
                    dataInstance.displayName = displayNameInstance;
                  }
                  
                  var endTimeElement = js2xml.getElement(responseDoc, dataElement, 'ENDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (endTimeElement !== null && endTimeElement !== undefined && endTimeElement.length !== 0) {
                    var endTimeInstance = new Date(endTimeElement);
                    dataInstance.endTime = endTimeInstance;
                  }
                  
                  var nameElement = js2xml.getElement(responseDoc, dataElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement !== null && nameElement !== undefined) {
                    var nameInstance = nameElement;
                    dataInstance.name = nameInstance;
                  }
                  
                  var primaryAggregationTypeElement = js2xml.getElement(responseDoc, dataElement, 'PRIMARYAGGREGATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (primaryAggregationTypeElement !== null && primaryAggregationTypeElement !== undefined) {
                    var primaryAggregationTypeInstance = primaryAggregationTypeElement;
                    dataInstance.primaryAggregationType = primaryAggregationTypeInstance;
                  }
                  
                  var startTimeElement = js2xml.getElement(responseDoc, dataElement, 'STARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (startTimeElement !== null && startTimeElement !== undefined && startTimeElement.length !== 0) {
                    var startTimeInstance = new Date(startTimeElement);
                    dataInstance.startTime = startTimeInstance;
                  }
                  
                  var timeGrainElement = js2xml.getElement(responseDoc, dataElement, 'TIMEGRAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (timeGrainElement !== null && timeGrainElement !== undefined) {
                    var timeGrainInstance = timeGrainElement;
                    dataInstance.timeGrain = timeGrainInstance;
                  }
                  
                  var unitElement = js2xml.getElement(responseDoc, dataElement, 'UNIT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (unitElement !== null && unitElement !== undefined) {
                    var unitInstance = unitElement;
                    dataInstance.unit = unitInstance;
                  }
                  
                  var valuesSequenceElement = js2xml.getElement(responseDoc, dataElement, 'VALUES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (valuesSequenceElement !== null && valuesSequenceElement !== undefined) {
                    for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, valuesSequenceElement, 'METRICSAMPLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                      var valuesElement = js2xml.getElements(responseDoc, valuesSequenceElement, 'METRICSAMPLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                      var metricSampleInstance = {};
                      dataInstance.values.push(metricSampleInstance);
                      
                      var countElement = js2xml.getElement(responseDoc, valuesElement, 'COUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (countElement !== null && countElement !== undefined && countElement.length !== 0) {
                        var countInstance = parseInt(countElement, 10);
                        metricSampleInstance.count = countInstance;
                      }
                      
                      var maximumElement = js2xml.getElement(responseDoc, valuesElement, 'MAXIMUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (maximumElement !== null && maximumElement !== undefined) {
                        var isNil = false;
                        var nilAttribute = js2xml.getAttribute(responseDoc, maximumElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                        if (nilAttribute !== null && nilAttribute !== undefined) {
                          isNil = nilAttribute === 'true';
                        }
                        if (isNil === false) {
                          var maximumInstance = maximumElement;
                          metricSampleInstance.maximum = maximumInstance;
                        }
                      }
                      
                      var minimumElement = js2xml.getElement(responseDoc, valuesElement, 'MINIMUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (minimumElement !== null && minimumElement !== undefined) {
                        var isNil2 = false;
                        var nilAttribute2 = js2xml.getAttribute(responseDoc, minimumElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                        if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                          isNil2 = nilAttribute2 === 'true';
                        }
                        if (isNil2 === false) {
                          var minimumInstance = minimumElement;
                          metricSampleInstance.minimum = minimumInstance;
                        }
                      }
                      
                      var timeCreatedElement = js2xml.getElement(responseDoc, valuesElement, 'TIMECREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (timeCreatedElement !== null && timeCreatedElement !== undefined && timeCreatedElement.length !== 0) {
                        var timeCreatedInstance = new Date(timeCreatedElement);
                        metricSampleInstance.timeCreated = timeCreatedInstance;
                      }
                      
                      var totalElement = js2xml.getElement(responseDoc, valuesElement, 'TOTAL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (totalElement !== null && totalElement !== undefined) {
                        var totalInstance = totalElement;
                        metricSampleInstance.total = totalInstance;
                      }
                      
                      var instanceNameElement = js2xml.getElement(responseDoc, valuesElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (instanceNameElement !== null && instanceNameElement !== undefined) {
                        var instanceNameInstance = instanceNameElement;
                        metricSampleInstance.instanceName = instanceNameInstance;
                      }
                    }
                  }
                }
                
                var messageElement = js2xml.getElement(responseDoc, usageMetricsElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (messageElement !== null && messageElement !== undefined) {
                  var messageInstance = messageElement;
                  metricResponseInstance.message = messageInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can list the web spaces under the current subscription by issuing a
   * GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166961.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.list = function(webSpaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/serverFarms';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { webHostingPlans: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var serverFarmsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'SERVERFARMS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (serverFarmsSequenceElement !== null && serverFarmsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, serverFarmsSequenceElement, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var serverFarmsElement = js2xml.getElements(responseDoc, serverFarmsSequenceElement, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var serverFarmInstance = {};
              result.webHostingPlans.push(serverFarmInstance);
              
              var nameElement = js2xml.getElement(responseDoc, serverFarmsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                serverFarmInstance.name = nameInstance;
              }
              
              var numberOfWorkersElement = js2xml.getElement(responseDoc, serverFarmsElement, 'NUMBEROFWORKERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (numberOfWorkersElement !== null && numberOfWorkersElement !== undefined && numberOfWorkersElement.length !== 0) {
                var numberOfWorkersInstance = parseInt(numberOfWorkersElement, 10);
                serverFarmInstance.numberOfWorkers = numberOfWorkersInstance;
              }
              
              var sKUElement = js2xml.getElement(responseDoc, serverFarmsElement, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sKUElement !== null && sKUElement !== undefined && sKUElement.length !== 0) {
                var sKUInstance = sKUElement;
                serverFarmInstance.sKU = sKUInstance;
              }
              
              var workerSizeElement = js2xml.getElement(responseDoc, serverFarmsElement, 'WORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (workerSizeElement !== null && workerSizeElement !== undefined && workerSizeElement.length !== 0) {
                var workerSizeInstance = workerSizeElement;
                serverFarmInstance.workerSize = workerSizeInstance;
              }
              
              var adminSiteNameElement = js2xml.getElement(responseDoc, serverFarmsElement, 'ADMINSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (adminSiteNameElement !== null && adminSiteNameElement !== undefined) {
                var adminSiteNameInstance = adminSiteNameElement;
                serverFarmInstance.adminSiteName = adminSiteNameInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates an existing Web Hosting Plan.  (see
   * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
   * for more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webHostingPlanName The name of the web hosting plan.
   * 
   * @param {WebHostingPlanUpdateParameters} parameters Parameters supplied to
   * the Update Web Hosting Plan operation.
   * 
   * @param {number} [parameters.numberOfWorkers] The requested number of
   * workers.
   * 
   * @param {SkuOptions} [parameters.sKU] SKU of the Web hosting plan.
   * 
   * @param {WorkerSizeOptions} [parameters.workerSize] The worker size.
   * Possible values are Small, Medium, and Large. For JSON, the equivalents
   * are 0 = Small, 1 = Medium, and 2 = Large.
   * 
   * @param {string} [parameters.adminSiteName] The admin site. The admin site
   * is used to deploy site extensions or contents shared by all site in the
   * plan.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.update = function(webSpaceName, webHostingPlanName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webHostingPlanName === null || webHostingPlanName === undefined) {
      return callback(new Error('webHostingPlanName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/ServerFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var serverFarmElement = js2xml.createElement('ServerFarm', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, serverFarmElement);
    
    if (parameters.numberOfWorkers !== null && parameters.numberOfWorkers !== undefined) {
      var numberOfWorkersElement = js2xml.createElement('NumberOfWorkers', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(numberOfWorkersElement, parameters.numberOfWorkers.toString());
      js2xml.addChildElement(serverFarmElement, numberOfWorkersElement);
    }
    
    if (parameters.sKU !== null && parameters.sKU !== undefined) {
      var sKUElement = js2xml.createElement('SKU', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(sKUElement, parameters.sKU !== null && parameters.sKU !== undefined ? parameters.sKU.toString() : 'Free');
      js2xml.addChildElement(serverFarmElement, sKUElement);
    }
    
    if (parameters.workerSize !== null && parameters.workerSize !== undefined) {
      var workerSizeElement = js2xml.createElement('WorkerSize', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(workerSizeElement, parameters.workerSize !== null && parameters.workerSize !== undefined ? parameters.workerSize.toString() : 'Small');
      js2xml.addChildElement(serverFarmElement, workerSizeElement);
    }
    
    if (parameters.adminSiteName !== null && parameters.adminSiteName !== undefined) {
      var adminSiteNameElement = js2xml.createElement('AdminSiteName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(adminSiteNameElement, parameters.adminSiteName);
      js2xml.addChildElement(serverFarmElement, adminSiteNameElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var serverFarmElement2 = js2xml.getElement(responseDoc, responseDoc, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (serverFarmElement2 !== null && serverFarmElement2 !== undefined) {
            var webHostingPlanInstance = {};
            result.webHostingPlan = webHostingPlanInstance;
            
            var nameElement = js2xml.getElement(responseDoc, serverFarmElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              webHostingPlanInstance.name = nameInstance;
            }
            
            var numberOfWorkersElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'NUMBEROFWORKERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (numberOfWorkersElement2 !== null && numberOfWorkersElement2 !== undefined && numberOfWorkersElement2.length !== 0) {
              var numberOfWorkersInstance = parseInt(numberOfWorkersElement2, 10);
              webHostingPlanInstance.numberOfWorkers = numberOfWorkersInstance;
            }
            
            var sKUElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sKUElement2 !== null && sKUElement2 !== undefined && sKUElement2.length !== 0) {
              var sKUInstance = sKUElement2;
              webHostingPlanInstance.sKU = sKUInstance;
            }
            
            var workerSizeElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'WORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (workerSizeElement2 !== null && workerSizeElement2 !== undefined && workerSizeElement2.length !== 0) {
              var workerSizeInstance = workerSizeElement2;
              webHostingPlanInstance.workerSize = workerSizeInstance;
            }
            
            var adminSiteNameElement2 = js2xml.getElement(responseDoc, serverFarmElement2, 'ADMINSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adminSiteNameElement2 !== null && adminSiteNameElement2 !== undefined) {
              var adminSiteNameInstance = adminSiteNameElement2;
              webHostingPlanInstance.adminSiteName = adminSiteNameInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return WebHostingPlanOperations;
})();

var WebSiteOperations = ( /** @lends WebSiteOperations */ function() {
  /**
   * @class
   * Operations for managing the web sites in a web space.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166981.aspx for
   * more information)
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [WebSiteManagementClient] {@link
   * WebSiteManagementClient~WebSiteManagementClient}.
   * See [webSites] {@link
   * WebSiteManagementClient~WebSiteManagementClient#webSites}.
   * Initializes a new instance of the WebSiteOperations class.
   * @constructor
   * 
   * @param {WebSiteManagementClient} client Reference to the service client.
   */
  function WebSiteOperations(client) {
    this.client = client;
  }
  
  /**
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} targetSwapSlot The name of the target slot to be swapped
   * with.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.applySlotConfiguration = function(webSpaceName, webSiteName, targetSwapSlot, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (targetSwapSlot === null || targetSwapSlot === undefined) {
      return callback(new Error('targetSwapSlot cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/applySlotConfig';
    var queryParameters = [];
    queryParameters.push('targetSwapSlot=' + encodeURIComponent(targetSwapSlot));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['accept'] = 'application/json';
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Backups a site on-demand.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {BackupRequest} backupRequest A backup specification.
   * 
   * @param {BackupSchedule} [backupRequest.backupSchedule] The backup schedule
   * structure - valid only when setting up a schedule. Should be Null for
   * on-demand backups.
   * 
   * @param {number} [backupRequest.backupSchedule.frequencyInterval] The
   * frequency of backups.
   * 
   * @param {FrequencyUnit} [backupRequest.backupSchedule.frequencyUnit] Units
   * for FrequencyInterval - e.g. Day or Hour
   * 
   * @param {boolean} [backupRequest.backupSchedule.keepAtLeastOneBackup]
   * Retention policy deletes backups after predefined number of days. If this
   * is true, there will be always at least one backup left. regardless of the
   * policy. If false, all backups can be deleted.
   * 
   * @param {date} [backupRequest.backupSchedule.lastExecutionTime] The last
   * time when this schedule started a backup, Null if didn't start anything
   * yet.
   * 
   * @param {number} [backupRequest.backupSchedule.retentionPeriodInDays]
   * Backups older N days (N defined by this value) will be automatically
   * deleted.
   * 
   * @param {date} [backupRequest.backupSchedule.startTime] When this schedule
   * should start backing up the site. Null means immediately.
   * 
   * @param {IEnumerable} [backupRequest.databases] Database settings for
   * backup.
   * 
   * @param {boolean} [backupRequest.enabled] Valid only for a backup schedule
   * (can be Null for on-demand backups). True if enabled; false if disabled
   * (no backups will be performed).
   * 
   * @param {string} [backupRequest.name] The name of this backup - will be
   * used for generating a blob name.
   * 
   * @param {string} [backupRequest.storageAccountUrl] SAS URL for a container
   * in a storage account. E.g.
   * 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=abcdefABCDEFabcdef0123456789
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.backup = function(webSpaceName, webSiteName, backupRequest, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (backupRequest === null || backupRequest === undefined) {
      return callback(new Error('backupRequest cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/backup';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var backupRequestElement = js2xml.createElement('BackupRequest', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, backupRequestElement);
    
    if (backupRequest.backupSchedule !== null && backupRequest.backupSchedule !== undefined) {
      var backupScheduleElement = js2xml.createElement('BackupSchedule', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(backupRequestElement, backupScheduleElement);
      
      if (backupRequest.backupSchedule.frequencyInterval !== null && backupRequest.backupSchedule.frequencyInterval !== undefined) {
        var frequencyIntervalElement = js2xml.createElement('FrequencyInterval', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(frequencyIntervalElement, backupRequest.backupSchedule.frequencyInterval.toString());
        js2xml.addChildElement(backupScheduleElement, frequencyIntervalElement);
      }
      
      if (backupRequest.backupSchedule.frequencyUnit !== null && backupRequest.backupSchedule.frequencyUnit !== undefined) {
        var frequencyUnitElement = js2xml.createElement('FrequencyUnit', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(frequencyUnitElement, backupRequest.backupSchedule.frequencyUnit !== null && backupRequest.backupSchedule.frequencyUnit !== undefined ? backupRequest.backupSchedule.frequencyUnit.toString() : 'Day');
        js2xml.addChildElement(backupScheduleElement, frequencyUnitElement);
      }
      
      if (backupRequest.backupSchedule.keepAtLeastOneBackup !== null && backupRequest.backupSchedule.keepAtLeastOneBackup !== undefined) {
        var keepAtLeastOneBackupElement = js2xml.createElement('KeepAtLeastOneBackup', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(keepAtLeastOneBackupElement, backupRequest.backupSchedule.keepAtLeastOneBackup.toString());
        js2xml.addChildElement(backupScheduleElement, keepAtLeastOneBackupElement);
      }
      
      if (backupRequest.backupSchedule.lastExecutionTime !== null && backupRequest.backupSchedule.lastExecutionTime !== undefined) {
        var lastExecutionTimeElement = js2xml.createElement('LastExecutionTime', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(lastExecutionTimeElement, backupRequest.backupSchedule.lastExecutionTime.toISOString());
        js2xml.addChildElement(backupScheduleElement, lastExecutionTimeElement);
      }
      
      if (backupRequest.backupSchedule.retentionPeriodInDays !== null && backupRequest.backupSchedule.retentionPeriodInDays !== undefined) {
        var retentionPeriodInDaysElement = js2xml.createElement('RetentionPeriodInDays', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(retentionPeriodInDaysElement, backupRequest.backupSchedule.retentionPeriodInDays.toString());
        js2xml.addChildElement(backupScheduleElement, retentionPeriodInDaysElement);
      }
      
      if (backupRequest.backupSchedule.startTime !== null && backupRequest.backupSchedule.startTime !== undefined) {
        var startTimeElement = js2xml.createElement('StartTime', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(startTimeElement, backupRequest.backupSchedule.startTime.toISOString());
        js2xml.addChildElement(backupScheduleElement, startTimeElement);
      }
    }
    
    if (backupRequest.databases !== null && backupRequest.databases !== undefined) {
      var databasesSequenceElement = js2xml.createElement('Databases', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < backupRequest.databases.length; loweredIndex1 = loweredIndex1 + 1) {
        var databasesItem = backupRequest.databases[loweredIndex1];
        var databaseBackupSettingElement = js2xml.createElement('DatabaseBackupSetting', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(databasesSequenceElement, databaseBackupSettingElement);
        
        if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
          var connectionStringElement = js2xml.createElement('ConnectionString', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringElement, databasesItem.connectionString);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringElement);
        }
        
        if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
          var connectionStringNameElement = js2xml.createElement('ConnectionStringName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringNameElement, databasesItem.connectionStringName);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringNameElement);
        }
        
        if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
          var databaseTypeElement = js2xml.createElement('DatabaseType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(databaseTypeElement, databasesItem.databaseType);
          js2xml.addChildElement(databaseBackupSettingElement, databaseTypeElement);
        }
        
        if (databasesItem.name !== null && databasesItem.name !== undefined) {
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, databasesItem.name);
          js2xml.addChildElement(databaseBackupSettingElement, nameElement);
        }
      }
      js2xml.addChildElement(backupRequestElement, databasesSequenceElement);
    }
    
    if (backupRequest.enabled !== null && backupRequest.enabled !== undefined) {
      var enabledElement = js2xml.createElement('Enabled', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(enabledElement, backupRequest.enabled.toString());
      js2xml.addChildElement(backupRequestElement, enabledElement);
    }
    
    if (backupRequest.name !== null && backupRequest.name !== undefined) {
      var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement2, backupRequest.name);
      js2xml.addChildElement(backupRequestElement, nameElement2);
    }
    
    if (backupRequest.storageAccountUrl !== null && backupRequest.storageAccountUrl !== undefined) {
      var storageAccountUrlElement = js2xml.createElement('StorageAccountUrl', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(storageAccountUrlElement, backupRequest.storageAccountUrl);
      js2xml.addChildElement(backupRequestElement, storageAccountUrlElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var backupItemElement = js2xml.getElement(responseDoc, responseDoc, 'BACKUPITEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (backupItemElement !== null && backupItemElement !== undefined) {
            var backupItemInstance = { databases: [] };
            result.backupItem = backupItemInstance;
            
            var storageAccountUrlElement2 = js2xml.getElement(responseDoc, backupItemElement, 'STORAGEACCOUNTURL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (storageAccountUrlElement2 !== null && storageAccountUrlElement2 !== undefined) {
              var storageAccountUrlInstance = storageAccountUrlElement2;
              backupItemInstance.storageAccountUrl = storageAccountUrlInstance;
            }
            
            var blobNameElement = js2xml.getElement(responseDoc, backupItemElement, 'BLOBNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (blobNameElement !== null && blobNameElement !== undefined) {
              var blobNameInstance = blobNameElement;
              backupItemInstance.blobName = blobNameInstance;
            }
            
            var nameElement3 = js2xml.getElement(responseDoc, backupItemElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement3 !== null && nameElement3 !== undefined) {
              var nameInstance = nameElement3;
              backupItemInstance.name = nameInstance;
            }
            
            var statusElement = js2xml.getElement(responseDoc, backupItemElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              backupItemInstance.status = statusInstance;
            }
            
            var sizeInBytesElement = js2xml.getElement(responseDoc, backupItemElement, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sizeInBytesElement !== null && sizeInBytesElement !== undefined && sizeInBytesElement.length !== 0) {
              var sizeInBytesInstance = parseInt(sizeInBytesElement, 10);
              backupItemInstance.sizeInBytes = sizeInBytesInstance;
            }
            
            var createdElement = js2xml.getElement(responseDoc, backupItemElement, 'CREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (createdElement !== null && createdElement !== undefined && createdElement.length !== 0) {
              var createdInstance = new Date(createdElement);
              backupItemInstance.created = createdInstance;
            }
            
            var logElement = js2xml.getElement(responseDoc, backupItemElement, 'LOG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (logElement !== null && logElement !== undefined) {
              var logInstance = logElement;
              backupItemInstance.log = logInstance;
            }
            
            var databasesSequenceElement2 = js2xml.getElement(responseDoc, backupItemElement, 'DATABASES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (databasesSequenceElement2 !== null && databasesSequenceElement2 !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, databasesSequenceElement2, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                var databasesElement = js2xml.getElements(responseDoc, databasesSequenceElement2, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                var databaseBackupSettingInstance = {};
                backupItemInstance.databases.push(databaseBackupSettingInstance);
                
                var connectionStringElement2 = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (connectionStringElement2 !== null && connectionStringElement2 !== undefined) {
                  var connectionStringInstance = connectionStringElement2;
                  databaseBackupSettingInstance.connectionString = connectionStringInstance;
                }
                
                var connectionStringNameElement2 = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (connectionStringNameElement2 !== null && connectionStringNameElement2 !== undefined) {
                  var connectionStringNameInstance = connectionStringNameElement2;
                  databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                }
                
                var databaseTypeElement2 = js2xml.getElement(responseDoc, databasesElement, 'DATABASETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (databaseTypeElement2 !== null && databaseTypeElement2 !== undefined) {
                  var databaseTypeInstance = databaseTypeElement2;
                  databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                }
                
                var nameElement4 = js2xml.getElement(responseDoc, databasesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement4 !== null && nameElement4 !== undefined) {
                  var nameInstance2 = nameElement4;
                  databaseBackupSettingInstance.name = nameInstance2;
                }
              }
            }
            
            var scheduledElement = js2xml.getElement(responseDoc, backupItemElement, 'SCHEDULED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (scheduledElement !== null && scheduledElement !== undefined && scheduledElement.length !== 0) {
              var scheduledInstance = scheduledElement === 'true';
              backupItemInstance.scheduled = scheduledInstance;
            }
            
            var lastRestoreTimeStampElement = js2xml.getElement(responseDoc, backupItemElement, 'LASTRESTORETIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lastRestoreTimeStampElement !== null && lastRestoreTimeStampElement !== undefined && lastRestoreTimeStampElement.length !== 0) {
              var lastRestoreTimeStampInstance = new Date(lastRestoreTimeStampElement);
              backupItemInstance.lastRestoreTimeStamp = lastRestoreTimeStampInstance;
            }
            
            var finishedTimeStampElement = js2xml.getElement(responseDoc, backupItemElement, 'FINISHEDTIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (finishedTimeStampElement !== null && finishedTimeStampElement !== undefined && finishedTimeStampElement.length !== 0) {
              var finishedTimeStampInstance = new Date(finishedTimeStampElement);
              backupItemInstance.finishedTimeStamp = finishedTimeStampInstance;
            }
            
            var correlationIdElement = js2xml.getElement(responseDoc, backupItemElement, 'CORRELATIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (correlationIdElement !== null && correlationIdElement !== undefined) {
              var correlationIdInstance = correlationIdElement;
              backupItemInstance.correlationId = correlationIdInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can swap a web site from one slot to another slot.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} sourceSlotName The name of the first web site slot to swap
   * (source).
   * 
   * @param {string} targetSlotName The name of the second web site slot to
   * swap with (target).
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.beginSwappingSlots = function(webSpaceName, webSiteName, sourceSlotName, targetSlotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (sourceSlotName === null || sourceSlotName === undefined) {
      return callback(new Error('sourceSlotName cannot be null.'));
    }
    if (targetSlotName === null || targetSlotName === undefined) {
      return callback(new Error('targetSlotName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '(';
    url2 = url2 + encodeURIComponent(sourceSlotName);
    url2 = url2 + ')/slots';
    var queryParameters = [];
    queryParameters.push('Command=swap');
    queryParameters.push('targetSlot=' + encodeURIComponent(targetSlotName));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 202) {
        var responseContent = body;
        result = { errors: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var operationElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (operationElement !== null && operationElement !== undefined) {
            var createdTimeElement = js2xml.getElement(responseDoc, operationElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
              var createdTimeInstance = new Date(createdTimeElement);
              result.createdTime = createdTimeInstance;
            }
            
            var errorsSequenceElement = js2xml.getElement(responseDoc, operationElement, 'ERRORS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (errorsSequenceElement !== null && errorsSequenceElement !== undefined) {
              var isNil = false;
              var nilAttribute = js2xml.getAttribute(responseDoc, errorsSequenceElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute !== null && nilAttribute !== undefined) {
                isNil = nilAttribute === 'true';
              }
              if (isNil === false) {
                for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, errorsSequenceElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                  var errorsElement = js2xml.getElements(responseDoc, errorsSequenceElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                  var errorInstance = { parameters: [] };
                  result.errors.push(errorInstance);
                  
                  var codeElement = js2xml.getElement(responseDoc, errorsElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (codeElement !== null && codeElement !== undefined) {
                    var isNil2 = false;
                    var nilAttribute2 = js2xml.getAttribute(responseDoc, codeElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                      isNil2 = nilAttribute2 === 'true';
                    }
                    if (isNil2 === false) {
                      var codeInstance = codeElement;
                      errorInstance.code = codeInstance;
                    }
                  }
                  
                  var messageElement = js2xml.getElement(responseDoc, errorsElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (messageElement !== null && messageElement !== undefined) {
                    var isNil3 = false;
                    var nilAttribute3 = js2xml.getAttribute(responseDoc, messageElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute3 !== null && nilAttribute3 !== undefined) {
                      isNil3 = nilAttribute3 === 'true';
                    }
                    if (isNil3 === false) {
                      var messageInstance = messageElement;
                      errorInstance.message = messageInstance;
                    }
                  }
                  
                  var extendedCodeElement = js2xml.getElement(responseDoc, errorsElement, 'EXTENDEDCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (extendedCodeElement !== null && extendedCodeElement !== undefined) {
                    var isNil4 = false;
                    var nilAttribute4 = js2xml.getAttribute(responseDoc, extendedCodeElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute4 !== null && nilAttribute4 !== undefined) {
                      isNil4 = nilAttribute4 === 'true';
                    }
                    if (isNil4 === false) {
                      var extendedCodeInstance = extendedCodeElement;
                      errorInstance.extendedCode = extendedCodeInstance;
                    }
                  }
                  
                  var messageTemplateElement = js2xml.getElement(responseDoc, errorsElement, 'MESSAGETEMPLATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (messageTemplateElement !== null && messageTemplateElement !== undefined) {
                    var isNil5 = false;
                    var nilAttribute5 = js2xml.getAttribute(responseDoc, messageTemplateElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute5 !== null && nilAttribute5 !== undefined) {
                      isNil5 = nilAttribute5 === 'true';
                    }
                    if (isNil5 === false) {
                      var messageTemplateInstance = messageTemplateElement;
                      errorInstance.messageTemplate = messageTemplateInstance;
                    }
                  }
                  
                  var parametersSequenceElement = js2xml.getElement(responseDoc, errorsElement, 'PARAMETERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (parametersSequenceElement !== null && parametersSequenceElement !== undefined) {
                    var isNil6 = false;
                    var nilAttribute6 = js2xml.getAttribute(responseDoc, parametersSequenceElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute6 !== null && nilAttribute6 !== undefined) {
                      isNil6 = nilAttribute6 === 'true';
                    }
                    if (isNil6 === false) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, parametersSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex2 = loweredIndex2 + 1) {
                        var parametersElement = js2xml.getElements(responseDoc, parametersSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex2];
                        errorInstance.parameters.push(parametersElement);
                      }
                    } else {
                      errorInstance.parameters = null;
                    }
                  }
                  
                  var innerErrorsElement = js2xml.getElement(responseDoc, errorsElement, 'INNERERRORS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (innerErrorsElement !== null && innerErrorsElement !== undefined) {
                    var isNil7 = false;
                    var nilAttribute7 = js2xml.getAttribute(responseDoc, innerErrorsElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute7 !== null && nilAttribute7 !== undefined) {
                      isNil7 = nilAttribute7 === 'true';
                    }
                    if (isNil7 === false) {
                      var innerErrorsInstance = innerErrorsElement;
                      errorInstance.innerErrors = innerErrorsInstance;
                    }
                  }
                }
              } else {
                result.errors = null;
              }
            }
            
            var expirationTimeElement = js2xml.getElement(responseDoc, operationElement, 'EXPIRATIONTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (expirationTimeElement !== null && expirationTimeElement !== undefined && expirationTimeElement.length !== 0) {
              var expirationTimeInstance = new Date(expirationTimeElement);
              result.expirationTime = expirationTimeInstance;
            }
            
            var geoMasterOperationIdElement = js2xml.getElement(responseDoc, operationElement, 'GEOMASTEROPERATIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (geoMasterOperationIdElement !== null && geoMasterOperationIdElement !== undefined) {
              var isNil8 = false;
              var nilAttribute8 = js2xml.getAttribute(responseDoc, geoMasterOperationIdElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute8 !== null && nilAttribute8 !== undefined) {
                isNil8 = nilAttribute8 === 'true';
              }
              if (isNil8 === false) {
                var geoMasterOperationIdInstance = geoMasterOperationIdElement;
                result.geoMasterOperationId = geoMasterOperationIdInstance;
              }
            }
            
            var idElement = js2xml.getElement(responseDoc, operationElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (idElement !== null && idElement !== undefined) {
              var isNil9 = false;
              var nilAttribute9 = js2xml.getAttribute(responseDoc, idElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute9 !== null && nilAttribute9 !== undefined) {
                isNil9 = nilAttribute9 === 'true';
              }
              if (isNil9 === false) {
                var idInstance = idElement;
                result.operationId = idInstance;
              }
            }
            
            var modifiedTimeElement = js2xml.getElement(responseDoc, operationElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
              var modifiedTimeInstance = new Date(modifiedTimeElement);
              result.modifiedTime = modifiedTimeInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, operationElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var isNil10 = false;
              var nilAttribute10 = js2xml.getAttribute(responseDoc, nameElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute10 !== null && nilAttribute10 !== undefined) {
                isNil10 = nilAttribute10 === 'true';
              }
              if (isNil10 === false) {
                var nameInstance = nameElement;
                result.name = nameInstance;
              }
            }
            
            var statusElement = js2xml.getElement(responseDoc, operationElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can create a web site by using a POST request that includes the name
   * of the web site and other information in the request body.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166986.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {WebSiteCreateParameters} parameters Parameters supplied to the
   * Create Web Site operation.
   * 
   * @param {string} parameters.name The name of the web site. This should
   * match the host name in the default domain.
   * 
   * @param {string} parameters.serverFarm The name of the Server Farm (Web
   * Hosting Plan) associated with this web site. This is a required value.
   * Server Farm must already exist.
   * 
   * @param {WebSpaceDetails} [parameters.webSpace] Information about the web
   * space to create.
   * 
   * @param {string} [parameters.webSpace.geoRegion] The geographical region of
   * the web space that will be created.
   * 
   * @param {string} [parameters.webSpace.name] The name of the web space.
   * 
   * @param {string} [parameters.webSpace.plan] The web space plan. This value
   * must be VirtualDedicatedPlan.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.create = function(webSpaceName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.name === null || parameters.name === undefined) {
      return callback(new Error('parameters.name cannot be null.'));
    }
    if (parameters.serverFarm === null || parameters.serverFarm === undefined) {
      return callback(new Error('parameters.serverFarm cannot be null.'));
    }
    if (parameters.webSpace !== null && parameters.webSpace !== undefined) {
      if (parameters.webSpace.geoRegion === null || parameters.webSpace.geoRegion === undefined) {
        return callback(new Error('parameters.webSpace. cannot be null.'));
      }
      if (parameters.webSpace.name === null || parameters.webSpace.name === undefined) {
        return callback(new Error('parameters.webSpace. cannot be null.'));
      }
      if (parameters.webSpace.plan === null || parameters.webSpace.plan === undefined) {
        return callback(new Error('parameters.webSpace. cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var siteElement = js2xml.createElement('Site', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, siteElement);
    
    var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(nameElement, parameters.name);
    js2xml.addChildElement(siteElement, nameElement);
    
    var serverFarmElement = js2xml.createElement('ServerFarm', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(serverFarmElement, parameters.serverFarm);
    js2xml.addChildElement(siteElement, serverFarmElement);
    
    if (parameters.webSpace !== null && parameters.webSpace !== undefined) {
      var webSpaceToCreateElement = js2xml.createElement('WebSpaceToCreate', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(siteElement, webSpaceToCreateElement);
      
      var geoRegionElement = js2xml.createElement('GeoRegion', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(geoRegionElement, parameters.webSpace.geoRegion);
      js2xml.addChildElement(webSpaceToCreateElement, geoRegionElement);
      
      var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement2, parameters.webSpace.name);
      js2xml.addChildElement(webSpaceToCreateElement, nameElement2);
      
      var planElement = js2xml.createElement('Plan', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(planElement, parameters.webSpace.plan);
      js2xml.addChildElement(webSpaceToCreateElement, planElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 201) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var siteElement2 = js2xml.getElement(responseDoc, responseDoc, 'SITE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (siteElement2 !== null && siteElement2 !== undefined) {
            var webSiteInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [] };
            result.webSite = webSiteInstance;
            
            var adminEnabledElement = js2xml.getElement(responseDoc, siteElement2, 'ADMINENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adminEnabledElement !== null && adminEnabledElement !== undefined && adminEnabledElement.length !== 0) {
              var adminEnabledInstance = adminEnabledElement === 'true';
              webSiteInstance.adminEnabled = adminEnabledInstance;
            }
            
            var availabilityStateElement = js2xml.getElement(responseDoc, siteElement2, 'AVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (availabilityStateElement !== null && availabilityStateElement !== undefined && availabilityStateElement.length !== 0) {
              var availabilityStateInstance = availabilityStateElement;
              webSiteInstance.availabilityState = availabilityStateInstance;
            }
            
            var sKUElement = js2xml.getElement(responseDoc, siteElement2, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sKUElement !== null && sKUElement !== undefined && sKUElement.length !== 0) {
              var sKUInstance = sKUElement;
              webSiteInstance.sku = sKUInstance;
            }
            
            var enabledElement = js2xml.getElement(responseDoc, siteElement2, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
              var enabledInstance = enabledElement === 'true';
              webSiteInstance.enabled = enabledInstance;
            }
            
            var enabledHostNamesSequenceElement = js2xml.getElement(responseDoc, siteElement2, 'ENABLEDHOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledHostNamesSequenceElement !== null && enabledHostNamesSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex1 = loweredIndex1 + 1) {
                var enabledHostNamesElement = js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex1];
                webSiteInstance.enabledHostNames.push(enabledHostNamesElement);
              }
            }
            
            var hostNameSslStatesSequenceElement = js2xml.getElement(responseDoc, siteElement2, 'HOSTNAMESSLSTATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostNameSslStatesSequenceElement !== null && hostNameSslStatesSequenceElement !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                var hostNameSslStatesElement = js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                var hostNameSslStateInstance = {};
                webSiteInstance.hostNameSslStates.push(hostNameSslStateInstance);
                
                var nameElement3 = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement3 !== null && nameElement3 !== undefined) {
                  var nameInstance = nameElement3;
                  hostNameSslStateInstance.name = nameInstance;
                }
                
                var sslStateElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'SSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sslStateElement !== null && sslStateElement !== undefined && sslStateElement.length !== 0) {
                  var sslStateInstance = sslStateElement;
                  hostNameSslStateInstance.sslState = sslStateInstance;
                }
                
                var thumbprintElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintElement !== null && thumbprintElement !== undefined) {
                  var isNil = false;
                  var nilAttribute = js2xml.getAttribute(responseDoc, thumbprintElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                  if (nilAttribute !== null && nilAttribute !== undefined) {
                    isNil = nilAttribute === 'true';
                  }
                  if (isNil === false) {
                    var thumbprintInstance = thumbprintElement;
                    hostNameSslStateInstance.thumbprint = thumbprintInstance;
                  }
                }
                
                var virtualIPElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (virtualIPElement !== null && virtualIPElement !== undefined) {
                  var isNil2 = false;
                  var nilAttribute2 = js2xml.getAttribute(responseDoc, virtualIPElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                  if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                    isNil2 = nilAttribute2 === 'true';
                  }
                  if (isNil2 === false) {
                    var virtualIPInstance = virtualIPElement;
                    hostNameSslStateInstance.virtualIP = virtualIPInstance;
                  }
                }
              }
            }
            
            var hostNamesSequenceElement = js2xml.getElement(responseDoc, siteElement2, 'HOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostNamesSequenceElement !== null && hostNamesSequenceElement !== undefined) {
              for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, hostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex3 = loweredIndex3 + 1) {
                var hostNamesElement = js2xml.getElements(responseDoc, hostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex3];
                webSiteInstance.hostNames.push(hostNamesElement);
              }
            }
            
            var lastModifiedTimeUtcElement = js2xml.getElement(responseDoc, siteElement2, 'LASTMODIFIEDTIMEUTC', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lastModifiedTimeUtcElement !== null && lastModifiedTimeUtcElement !== undefined && lastModifiedTimeUtcElement.length !== 0) {
              var lastModifiedTimeUtcInstance = new Date(lastModifiedTimeUtcElement);
              webSiteInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;
            }
            
            var nameElement4 = js2xml.getElement(responseDoc, siteElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement4 !== null && nameElement4 !== undefined) {
              var nameInstance2 = nameElement4;
              webSiteInstance.name = nameInstance2;
            }
            
            var repositorySiteNameElement = js2xml.getElement(responseDoc, siteElement2, 'REPOSITORYSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (repositorySiteNameElement !== null && repositorySiteNameElement !== undefined) {
              var repositorySiteNameInstance = repositorySiteNameElement;
              webSiteInstance.repositorySiteName = repositorySiteNameInstance;
            }
            
            var runtimeAvailabilityStateElement = js2xml.getElement(responseDoc, siteElement2, 'RUNTIMEAVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (runtimeAvailabilityStateElement !== null && runtimeAvailabilityStateElement !== undefined && runtimeAvailabilityStateElement.length !== 0) {
              var runtimeAvailabilityStateInstance = runtimeAvailabilityStateElement;
              webSiteInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;
            }
            
            var selfLinkElement = js2xml.getElement(responseDoc, siteElement2, 'SELFLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (selfLinkElement !== null && selfLinkElement !== undefined) {
              var selfLinkInstance = selfLinkElement;
              webSiteInstance.uri = selfLinkInstance;
            }
            
            var serverFarmElement2 = js2xml.getElement(responseDoc, siteElement2, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (serverFarmElement2 !== null && serverFarmElement2 !== undefined) {
              var serverFarmInstance = serverFarmElement2;
              webSiteInstance.serverFarm = serverFarmInstance;
            }
            
            var sitePropertiesElement = js2xml.getElement(responseDoc, siteElement2, 'SITEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sitePropertiesElement !== null && sitePropertiesElement !== undefined) {
              var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };
              webSiteInstance.siteProperties = sitePropertiesInstance;
              
              var appSettingsSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'APPSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
                for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                  var appSettingsElement = js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                  var appSettingsKey = js2xml.getElement(responseDoc, appSettingsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var appSettingsValue = js2xml.getElement(responseDoc, appSettingsElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
                }
              }
              
              var metadataSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'METADATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                  var metadataElement = js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                  var metadataKey = js2xml.getElement(responseDoc, metadataElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var metadataValue = js2xml.getElement(responseDoc, metadataElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.metadata[metadataKey] = metadataValue;
                }
              }
              
              var propertiesSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'PROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {
                for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                  var propertiesElement = js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                  var propertiesKey = js2xml.getElement(responseDoc, propertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var propertiesValue = js2xml.getElement(responseDoc, propertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.properties[propertiesKey] = propertiesValue;
                }
              }
            }
            
            var stateElement = js2xml.getElement(responseDoc, siteElement2, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (stateElement !== null && stateElement !== undefined) {
              var stateInstance = stateElement;
              webSiteInstance.state = stateInstance;
            }
            
            var usageStateElement = js2xml.getElement(responseDoc, siteElement2, 'USAGESTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (usageStateElement !== null && usageStateElement !== undefined && usageStateElement.length !== 0) {
              var usageStateInstance = usageStateElement;
              webSiteInstance.usageState = usageStateInstance;
            }
            
            var webSpaceElement = js2xml.getElement(responseDoc, siteElement2, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (webSpaceElement !== null && webSpaceElement !== undefined) {
              var webSpaceInstance = webSpaceElement;
              webSiteInstance.webSpace = webSpaceInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Creates an association to a hybrid connection for a web site.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} siteName The name of the web site.
   * 
   * @param {HybridConnectionCreateParameters} parameters Parameters supplied
   * to the Create Hybrid Connection operation.
   * 
   * @param {string} parameters.biztalkUri The resource uri of the biztalk
   * service. This field can be left empty; Without it the Azure Portal will
   * not be able to display the biztalk service for this connection properly.
   * 
   * @param {string} parameters.entityConnectionString The biztalk application
   * connection string for this connection
   * 
   * @param {string} parameters.entityName The unique name for this connection
   * 
   * @param {string} parameters.hostname The hostname of the target on-premise
   * resource
   * 
   * @param {number} parameters.port The port of the target on-premise resource
   * 
   * @param {string} parameters.resourceConnectionString Reserved for future
   * use. The connection string for the resource. This field can be left empty.
   * 
   * @param {string} parameters.resourceType Reserved for future use. The type
   * of resource to be connected. This field can be left empty.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.createHybridConnection = function(webSpaceName, siteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (siteName === null || siteName === undefined) {
      return callback(new Error('siteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.biztalkUri === null || parameters.biztalkUri === undefined) {
      return callback(new Error('parameters.biztalkUri cannot be null.'));
    }
    if (parameters.entityConnectionString === null || parameters.entityConnectionString === undefined) {
      return callback(new Error('parameters.entityConnectionString cannot be null.'));
    }
    if (parameters.entityName === null || parameters.entityName === undefined) {
      return callback(new Error('parameters.entityName cannot be null.'));
    }
    if (parameters.hostname === null || parameters.hostname === undefined) {
      return callback(new Error('parameters.hostname cannot be null.'));
    }
    if (parameters.port === null || parameters.port === undefined) {
      return callback(new Error('parameters.port cannot be null.'));
    }
    if (parameters.resourceConnectionString === null || parameters.resourceConnectionString === undefined) {
      return callback(new Error('parameters.resourceConnectionString cannot be null.'));
    }
    if (parameters.resourceType === null || parameters.resourceType === undefined) {
      return callback(new Error('parameters.resourceType cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(siteName);
    url2 = url2 + '/hybridconnection';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var relayServiceConnectionEntityElement = js2xml.createElement('RelayServiceConnectionEntity', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, relayServiceConnectionEntityElement);
    
    var biztalkUriElement = js2xml.createElement('BiztalkUri', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(biztalkUriElement, parameters.biztalkUri);
    js2xml.addChildElement(relayServiceConnectionEntityElement, biztalkUriElement);
    
    var entityConnectionStringElement = js2xml.createElement('EntityConnectionString', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(entityConnectionStringElement, parameters.entityConnectionString);
    js2xml.addChildElement(relayServiceConnectionEntityElement, entityConnectionStringElement);
    
    var entityNameElement = js2xml.createElement('EntityName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(entityNameElement, parameters.entityName);
    js2xml.addChildElement(relayServiceConnectionEntityElement, entityNameElement);
    
    var hostnameElement = js2xml.createElement('Hostname', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(hostnameElement, parameters.hostname);
    js2xml.addChildElement(relayServiceConnectionEntityElement, hostnameElement);
    
    var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(portElement, parameters.port.toString());
    js2xml.addChildElement(relayServiceConnectionEntityElement, portElement);
    
    var resourceConnectionStringElement = js2xml.createElement('ResourceConnectionString', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(resourceConnectionStringElement, parameters.resourceConnectionString);
    js2xml.addChildElement(relayServiceConnectionEntityElement, resourceConnectionStringElement);
    
    var resourceTypeElement = js2xml.createElement('ResourceType', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(resourceTypeElement, parameters.resourceType);
    js2xml.addChildElement(relayServiceConnectionEntityElement, resourceTypeElement);
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var relayServiceConnectionEntityElement2 = js2xml.getElement(responseDoc, responseDoc, 'RELAYSERVICECONNECTIONENTITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (relayServiceConnectionEntityElement2 !== null && relayServiceConnectionEntityElement2 !== undefined) {
            var hybridConnectionInstance = {};
            result.hybridConnection = hybridConnectionInstance;
            
            var entityNameElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'ENTITYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (entityNameElement2 !== null && entityNameElement2 !== undefined) {
              var entityNameInstance = entityNameElement2;
              hybridConnectionInstance.entityName = entityNameInstance;
            }
            
            var entityConnectionStringElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'ENTITYCONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (entityConnectionStringElement2 !== null && entityConnectionStringElement2 !== undefined) {
              var entityConnectionStringInstance = entityConnectionStringElement2;
              hybridConnectionInstance.entityConnectionString = entityConnectionStringInstance;
            }
            
            var resourceTypeElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'RESOURCETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (resourceTypeElement2 !== null && resourceTypeElement2 !== undefined) {
              var resourceTypeInstance = resourceTypeElement2;
              hybridConnectionInstance.resourceType = resourceTypeInstance;
            }
            
            var resourceConnectionStringElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'RESOURCECONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (resourceConnectionStringElement2 !== null && resourceConnectionStringElement2 !== undefined) {
              var resourceConnectionStringInstance = resourceConnectionStringElement2;
              hybridConnectionInstance.resourceConnectionString = resourceConnectionStringInstance;
            }
            
            var hostnameElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostnameElement2 !== null && hostnameElement2 !== undefined) {
              var hostnameInstance = hostnameElement2;
              hybridConnectionInstance.hostname = hostnameInstance;
            }
            
            var portElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (portElement2 !== null && portElement2 !== undefined && portElement2.length !== 0) {
              var portInstance = parseInt(portElement2, 10);
              hybridConnectionInstance.port = portInstance;
            }
            
            var biztalkUriElement2 = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement2, 'BIZTALKURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (biztalkUriElement2 !== null && biztalkUriElement2 !== undefined) {
              var biztalkUriInstance = biztalkUriElement2;
              hybridConnectionInstance.biztalkUri = biztalkUriInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * A web site repository is essentially a Git repository that you can use to
   * manage your web site content. By using Git source control tools, you can
   * push or pull version-controlled changes to your site. This API executes a
   * repository create operation.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.createRepository = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/repository';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can delete a web site by issuing an HTTP DELETE request. If the web
   * site being deleted is the only site remaining in a server farm, you can
   * optionally delete the server farm as well by using the
   * deleteEmptyServerFarm parameter.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn236430.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {WebSiteDeleteParameters} parameters Parameters supplied to the
   * Delete Web Site operation.
   * 
   * @param {boolean} parameters.deleteEmptyServerFarm Indicates if the server
   * farm should be deleted. You can delete the server farm if the web site
   * being deleted is the last web site in a server farm.
   * 
   * @param {boolean} parameters.deleteMetrics Indicates if the metrics for the
   * web site should be deleted.
   * 
   * @param {boolean} parameters.deleteAllSlots Indicates if all slots for the
   * web site should be deleted.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.deleteMethod = function(webSpaceName, webSiteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.deleteAllSlots === null || parameters.deleteAllSlots === undefined) {
      return callback(new Error('parameters.deleteAllSlots cannot be null.'));
    }
    if (parameters.deleteEmptyServerFarm === null || parameters.deleteEmptyServerFarm === undefined) {
      return callback(new Error('parameters.deleteEmptyServerFarm cannot be null.'));
    }
    if (parameters.deleteMetrics === null || parameters.deleteMetrics === undefined) {
      return callback(new Error('parameters.deleteMetrics cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    var queryParameters = [];
    queryParameters.push('deleteEmptyServerFarm=' + encodeURIComponent(parameters.deleteEmptyServerFarm.toString()));
    queryParameters.push('deleteMetrics=' + encodeURIComponent(parameters.deleteMetrics.toString()));
    queryParameters.push('deleteAllSlots=' + encodeURIComponent(parameters.deleteAllSlots.toString()));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes a hybrid connection on a specific site.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} hybridConnectionName The name of the hybrid connection
   * entity
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.deleteHybridConnection = function(webSpaceName, webSiteName, hybridConnectionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (hybridConnectionName === null || hybridConnectionName === undefined) {
      return callback(new Error('hybridConnectionName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/hybridconnection/';
    url2 = url2 + encodeURIComponent(hybridConnectionName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * A web site repository is essentially a Git repository that you can use to
   * manage your web site content. By using Git source control tools, you can
   * push or pull version-controlled changes to your site. This API executes a
   * repository delete operation.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.deleteRepository = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/repository';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 204) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 204) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var anyURIElement = js2xml.getElement(responseDoc, responseDoc, 'ANYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/');
          if (anyURIElement !== null && anyURIElement !== undefined) {
            result.uri = anyURIElement;
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Scans a backup in a storage account and returns database information etc.
   * Should be called before calling Restore to discover what parameters are
   * needed for the restore operation.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {RestoreRequest} restoreRequest A restore request.
   * 
   * @param {boolean} [restoreRequest.adjustConnectionStrings] If the restore
   * operation also restores a database along with the website and the
   * database is on a different server than when the original site h
   * 
   * @param {string} [restoreRequest.blobName] The blob name where the backup
   * is stored. E.g. mysite1_20140203.zip
   * 
   * @param {IEnumerable} [restoreRequest.databases] Database settings for
   * backup.
   * 
   * @param {boolean} [restoreRequest.ignoreConflictingHostNames] When
   * restoring a site, custom domains might conflict with other site in the
   * same datacenter. If this value is true, such hostnames will be ignored
   * during restore. If this is false, the restore operation will fail on such
   * conflict.
   * 
   * @param {boolean} [restoreRequest.overwrite] True if the restore operation
   * will be used for overwrite an existing site; false otherwise.
   * 
   * @param {string} [restoreRequest.storageAccountUrl] SAS URL for a container
   * in a storage account. E.g.
   * 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=abcdefABCDEFabcdef0123456789
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.discover = function(webSpaceName, webSiteName, restoreRequest, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (restoreRequest === null || restoreRequest === undefined) {
      return callback(new Error('restoreRequest cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/restore/discover';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var restoreRequestElement = js2xml.createElement('RestoreRequest', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, restoreRequestElement);
    
    if (restoreRequest.adjustConnectionStrings !== null && restoreRequest.adjustConnectionStrings !== undefined) {
      var adjustConnectionStringsElement = js2xml.createElement('AdjustConnectionStrings', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(adjustConnectionStringsElement, restoreRequest.adjustConnectionStrings.toString());
      js2xml.addChildElement(restoreRequestElement, adjustConnectionStringsElement);
    }
    
    if (restoreRequest.blobName !== null && restoreRequest.blobName !== undefined) {
      var blobNameElement = js2xml.createElement('BlobName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(blobNameElement, restoreRequest.blobName);
      js2xml.addChildElement(restoreRequestElement, blobNameElement);
    }
    
    if (restoreRequest.databases !== null && restoreRequest.databases !== undefined) {
      var databasesSequenceElement = js2xml.createElement('Databases', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < restoreRequest.databases.length; loweredIndex1 = loweredIndex1 + 1) {
        var databasesItem = restoreRequest.databases[loweredIndex1];
        var databaseBackupSettingElement = js2xml.createElement('DatabaseBackupSetting', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(databasesSequenceElement, databaseBackupSettingElement);
        
        if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
          var connectionStringElement = js2xml.createElement('ConnectionString', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringElement, databasesItem.connectionString);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringElement);
        }
        
        if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
          var connectionStringNameElement = js2xml.createElement('ConnectionStringName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringNameElement, databasesItem.connectionStringName);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringNameElement);
        }
        
        if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
          var databaseTypeElement = js2xml.createElement('DatabaseType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(databaseTypeElement, databasesItem.databaseType);
          js2xml.addChildElement(databaseBackupSettingElement, databaseTypeElement);
        }
        
        if (databasesItem.name !== null && databasesItem.name !== undefined) {
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, databasesItem.name);
          js2xml.addChildElement(databaseBackupSettingElement, nameElement);
        }
      }
      js2xml.addChildElement(restoreRequestElement, databasesSequenceElement);
    }
    
    if (restoreRequest.ignoreConflictingHostNames !== null && restoreRequest.ignoreConflictingHostNames !== undefined) {
      var ignoreConflictingHostNamesElement = js2xml.createElement('IgnoreConflictingHostNames', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(ignoreConflictingHostNamesElement, restoreRequest.ignoreConflictingHostNames.toString());
      js2xml.addChildElement(restoreRequestElement, ignoreConflictingHostNamesElement);
    }
    
    if (restoreRequest.overwrite !== null && restoreRequest.overwrite !== undefined) {
      var overwriteElement = js2xml.createElement('Overwrite', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(overwriteElement, restoreRequest.overwrite.toString());
      js2xml.addChildElement(restoreRequestElement, overwriteElement);
    }
    
    if (restoreRequest.storageAccountUrl !== null && restoreRequest.storageAccountUrl !== undefined) {
      var storageAccountUrlElement = js2xml.createElement('StorageAccountUrl', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(storageAccountUrlElement, restoreRequest.storageAccountUrl);
      js2xml.addChildElement(restoreRequestElement, storageAccountUrlElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { databases: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var restoreRequestElement2 = js2xml.getElement(responseDoc, responseDoc, 'RESTOREREQUEST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (restoreRequestElement2 !== null && restoreRequestElement2 !== undefined) {
            var storageAccountUrlElement2 = js2xml.getElement(responseDoc, restoreRequestElement2, 'STORAGEACCOUNTURL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (storageAccountUrlElement2 !== null && storageAccountUrlElement2 !== undefined) {
              var storageAccountUrlInstance = storageAccountUrlElement2;
              result.storageAccountUrl = storageAccountUrlInstance;
            }
            
            var blobNameElement2 = js2xml.getElement(responseDoc, restoreRequestElement2, 'BLOBNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (blobNameElement2 !== null && blobNameElement2 !== undefined) {
              var blobNameInstance = blobNameElement2;
              result.blobName = blobNameInstance;
            }
            
            var overwriteElement2 = js2xml.getElement(responseDoc, restoreRequestElement2, 'OVERWRITE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (overwriteElement2 !== null && overwriteElement2 !== undefined && overwriteElement2.length !== 0) {
              var overwriteInstance = overwriteElement2 === 'true';
              result.overwrite = overwriteInstance;
            }
            
            var databasesSequenceElement2 = js2xml.getElement(responseDoc, restoreRequestElement2, 'DATABASES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (databasesSequenceElement2 !== null && databasesSequenceElement2 !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, databasesSequenceElement2, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                var databasesElement = js2xml.getElements(responseDoc, databasesSequenceElement2, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                var databaseBackupSettingInstance = {};
                result.databases.push(databaseBackupSettingInstance);
                
                var connectionStringElement2 = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (connectionStringElement2 !== null && connectionStringElement2 !== undefined) {
                  var connectionStringInstance = connectionStringElement2;
                  databaseBackupSettingInstance.connectionString = connectionStringInstance;
                }
                
                var connectionStringNameElement2 = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (connectionStringNameElement2 !== null && connectionStringNameElement2 !== undefined) {
                  var connectionStringNameInstance = connectionStringNameElement2;
                  databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                }
                
                var databaseTypeElement2 = js2xml.getElement(responseDoc, databasesElement, 'DATABASETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (databaseTypeElement2 !== null && databaseTypeElement2 !== undefined) {
                  var databaseTypeInstance = databaseTypeElement2;
                  databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                }
                
                var nameElement2 = js2xml.getElement(responseDoc, databasesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement2 !== null && nameElement2 !== undefined) {
                  var nameInstance = nameElement2;
                  databaseBackupSettingInstance.name = nameInstance;
                }
              }
            }
            
            var ignoreConflictingHostNamesElement2 = js2xml.getElement(responseDoc, restoreRequestElement2, 'IGNORECONFLICTINGHOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (ignoreConflictingHostNamesElement2 !== null && ignoreConflictingHostNamesElement2 !== undefined && ignoreConflictingHostNamesElement2.length !== 0) {
              var ignoreConflictingHostNamesInstance = ignoreConflictingHostNamesElement2 === 'true';
              result.ignoreConflictingHostNames = ignoreConflictingHostNamesInstance;
            }
            
            var adjustConnectionStringsElement2 = js2xml.getElement(responseDoc, restoreRequestElement2, 'ADJUSTCONNECTIONSTRINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adjustConnectionStringsElement2 !== null && adjustConnectionStringsElement2 !== undefined && adjustConnectionStringsElement2.length !== 0) {
              var adjustConnectionStringsInstance = adjustConnectionStringsElement2 === 'true';
              result.adjustConnectionStrings = adjustConnectionStringsInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can generate a new random password for publishing a site by issuing an
   * HTTP POST request. Tip: If you want to verify that the publish password
   * has changed, issue an HTTP GET on /publishxml before calling
   * /newpassword. In the publish XML, note the hash value in the userPWD
   * attribute. After calling /newpassword, call /publishxml again. You can
   * then compare the new value of userPWD in the Publish XML with the one you
   * noted earlier.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn236428.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.generatePassword = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/newpassword';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve details for a web site by issuing an HTTP GET request.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn167007.aspx
   * for more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {WebSiteGetParameters} [parametersOrCallback] Parameters supplied
   * to the Get Web Site Operation.
   * 
   * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list
   * of the names of any additional parameters to return.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.get = function(webSpaceName, webSiteName, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    var queryParameters = [];
    if (parameters !== null && parameters !== undefined && parameters.propertiesToInclude !== null && parameters.propertiesToInclude !== undefined && parameters.propertiesToInclude.length > 0) {
      queryParameters.push('propertiesToInclude=' + encodeURIComponent(parameters.propertiesToInclude.join(',')));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var siteElement = js2xml.getElement(responseDoc, responseDoc, 'SITE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (siteElement !== null && siteElement !== undefined) {
            var webSiteInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [] };
            result.webSite = webSiteInstance;
            
            var adminEnabledElement = js2xml.getElement(responseDoc, siteElement, 'ADMINENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adminEnabledElement !== null && adminEnabledElement !== undefined && adminEnabledElement.length !== 0) {
              var adminEnabledInstance = adminEnabledElement === 'true';
              webSiteInstance.adminEnabled = adminEnabledInstance;
            }
            
            var availabilityStateElement = js2xml.getElement(responseDoc, siteElement, 'AVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (availabilityStateElement !== null && availabilityStateElement !== undefined && availabilityStateElement.length !== 0) {
              var availabilityStateInstance = availabilityStateElement;
              webSiteInstance.availabilityState = availabilityStateInstance;
            }
            
            var sKUElement = js2xml.getElement(responseDoc, siteElement, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sKUElement !== null && sKUElement !== undefined && sKUElement.length !== 0) {
              var sKUInstance = sKUElement;
              webSiteInstance.sku = sKUInstance;
            }
            
            var enabledElement = js2xml.getElement(responseDoc, siteElement, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
              var enabledInstance = enabledElement === 'true';
              webSiteInstance.enabled = enabledInstance;
            }
            
            var enabledHostNamesSequenceElement = js2xml.getElement(responseDoc, siteElement, 'ENABLEDHOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledHostNamesSequenceElement !== null && enabledHostNamesSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex1 = loweredIndex1 + 1) {
                var enabledHostNamesElement = js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex1];
                webSiteInstance.enabledHostNames.push(enabledHostNamesElement);
              }
            }
            
            var hostNameSslStatesSequenceElement = js2xml.getElement(responseDoc, siteElement, 'HOSTNAMESSLSTATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostNameSslStatesSequenceElement !== null && hostNameSslStatesSequenceElement !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                var hostNameSslStatesElement = js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                var hostNameSslStateInstance = {};
                webSiteInstance.hostNameSslStates.push(hostNameSslStateInstance);
                
                var nameElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  hostNameSslStateInstance.name = nameInstance;
                }
                
                var sslStateElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'SSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sslStateElement !== null && sslStateElement !== undefined && sslStateElement.length !== 0) {
                  var sslStateInstance = sslStateElement;
                  hostNameSslStateInstance.sslState = sslStateInstance;
                }
                
                var thumbprintElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintElement !== null && thumbprintElement !== undefined) {
                  var isNil = false;
                  var nilAttribute = js2xml.getAttribute(responseDoc, thumbprintElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                  if (nilAttribute !== null && nilAttribute !== undefined) {
                    isNil = nilAttribute === 'true';
                  }
                  if (isNil === false) {
                    var thumbprintInstance = thumbprintElement;
                    hostNameSslStateInstance.thumbprint = thumbprintInstance;
                  }
                }
                
                var virtualIPElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (virtualIPElement !== null && virtualIPElement !== undefined) {
                  var isNil2 = false;
                  var nilAttribute2 = js2xml.getAttribute(responseDoc, virtualIPElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                  if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                    isNil2 = nilAttribute2 === 'true';
                  }
                  if (isNil2 === false) {
                    var virtualIPInstance = virtualIPElement;
                    hostNameSslStateInstance.virtualIP = virtualIPInstance;
                  }
                }
              }
            }
            
            var hostNamesSequenceElement = js2xml.getElement(responseDoc, siteElement, 'HOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostNamesSequenceElement !== null && hostNamesSequenceElement !== undefined) {
              for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, hostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex3 = loweredIndex3 + 1) {
                var hostNamesElement = js2xml.getElements(responseDoc, hostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex3];
                webSiteInstance.hostNames.push(hostNamesElement);
              }
            }
            
            var lastModifiedTimeUtcElement = js2xml.getElement(responseDoc, siteElement, 'LASTMODIFIEDTIMEUTC', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lastModifiedTimeUtcElement !== null && lastModifiedTimeUtcElement !== undefined && lastModifiedTimeUtcElement.length !== 0) {
              var lastModifiedTimeUtcInstance = new Date(lastModifiedTimeUtcElement);
              webSiteInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;
            }
            
            var nameElement2 = js2xml.getElement(responseDoc, siteElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance2 = nameElement2;
              webSiteInstance.name = nameInstance2;
            }
            
            var repositorySiteNameElement = js2xml.getElement(responseDoc, siteElement, 'REPOSITORYSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (repositorySiteNameElement !== null && repositorySiteNameElement !== undefined) {
              var repositorySiteNameInstance = repositorySiteNameElement;
              webSiteInstance.repositorySiteName = repositorySiteNameInstance;
            }
            
            var runtimeAvailabilityStateElement = js2xml.getElement(responseDoc, siteElement, 'RUNTIMEAVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (runtimeAvailabilityStateElement !== null && runtimeAvailabilityStateElement !== undefined && runtimeAvailabilityStateElement.length !== 0) {
              var runtimeAvailabilityStateInstance = runtimeAvailabilityStateElement;
              webSiteInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;
            }
            
            var selfLinkElement = js2xml.getElement(responseDoc, siteElement, 'SELFLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (selfLinkElement !== null && selfLinkElement !== undefined) {
              var selfLinkInstance = selfLinkElement;
              webSiteInstance.uri = selfLinkInstance;
            }
            
            var serverFarmElement = js2xml.getElement(responseDoc, siteElement, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (serverFarmElement !== null && serverFarmElement !== undefined) {
              var serverFarmInstance = serverFarmElement;
              webSiteInstance.serverFarm = serverFarmInstance;
            }
            
            var sitePropertiesElement = js2xml.getElement(responseDoc, siteElement, 'SITEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sitePropertiesElement !== null && sitePropertiesElement !== undefined) {
              var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };
              webSiteInstance.siteProperties = sitePropertiesInstance;
              
              var appSettingsSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'APPSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
                for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex4 = loweredIndex4 + 1) {
                  var appSettingsElement = js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex4];
                  var appSettingsKey = js2xml.getElement(responseDoc, appSettingsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var appSettingsValue = js2xml.getElement(responseDoc, appSettingsElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
                }
              }
              
              var metadataSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'METADATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
                for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                  var metadataElement = js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                  var metadataKey = js2xml.getElement(responseDoc, metadataElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var metadataValue = js2xml.getElement(responseDoc, metadataElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.metadata[metadataKey] = metadataValue;
                }
              }
              
              var propertiesSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'PROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {
                for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                  var propertiesElement = js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                  var propertiesKey = js2xml.getElement(responseDoc, propertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var propertiesValue = js2xml.getElement(responseDoc, propertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.properties[propertiesKey] = propertiesValue;
                }
              }
            }
            
            var stateElement = js2xml.getElement(responseDoc, siteElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (stateElement !== null && stateElement !== undefined) {
              var stateInstance = stateElement;
              webSiteInstance.state = stateInstance;
            }
            
            var usageStateElement = js2xml.getElement(responseDoc, siteElement, 'USAGESTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (usageStateElement !== null && usageStateElement !== undefined && usageStateElement.length !== 0) {
              var usageStateInstance = usageStateElement;
              webSiteInstance.usageState = usageStateInstance;
            }
            
            var webSpaceElement = js2xml.getElement(responseDoc, siteElement, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (webSpaceElement !== null && webSpaceElement !== undefined) {
              var webSpaceInstance = webSpaceElement;
              webSiteInstance.webSpace = webSpaceInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a schedule configuration for site backups.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getBackupConfiguration = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/backup/config';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { databases: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var backupRequestElement = js2xml.getElement(responseDoc, responseDoc, 'BACKUPREQUEST', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (backupRequestElement !== null && backupRequestElement !== undefined) {
            var enabledElement = js2xml.getElement(responseDoc, backupRequestElement, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
              var enabledInstance = enabledElement === 'true';
              result.enabled = enabledInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, backupRequestElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var backupScheduleElement = js2xml.getElement(responseDoc, backupRequestElement, 'BACKUPSCHEDULE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (backupScheduleElement !== null && backupScheduleElement !== undefined) {
              var backupScheduleInstance = {};
              result.backupSchedule = backupScheduleInstance;
              
              var frequencyIntervalElement = js2xml.getElement(responseDoc, backupScheduleElement, 'FREQUENCYINTERVAL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (frequencyIntervalElement !== null && frequencyIntervalElement !== undefined && frequencyIntervalElement.length !== 0) {
                var frequencyIntervalInstance = parseInt(frequencyIntervalElement, 10);
                backupScheduleInstance.frequencyInterval = frequencyIntervalInstance;
              }
              
              var frequencyUnitElement = js2xml.getElement(responseDoc, backupScheduleElement, 'FREQUENCYUNIT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (frequencyUnitElement !== null && frequencyUnitElement !== undefined && frequencyUnitElement.length !== 0) {
                var frequencyUnitInstance = frequencyUnitElement;
                backupScheduleInstance.frequencyUnit = frequencyUnitInstance;
              }
              
              var keepAtLeastOneBackupElement = js2xml.getElement(responseDoc, backupScheduleElement, 'KEEPATLEASTONEBACKUP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (keepAtLeastOneBackupElement !== null && keepAtLeastOneBackupElement !== undefined && keepAtLeastOneBackupElement.length !== 0) {
                var keepAtLeastOneBackupInstance = keepAtLeastOneBackupElement === 'true';
                backupScheduleInstance.keepAtLeastOneBackup = keepAtLeastOneBackupInstance;
              }
              
              var lastExecutionTimeElement = js2xml.getElement(responseDoc, backupScheduleElement, 'LASTEXECUTIONTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (lastExecutionTimeElement !== null && lastExecutionTimeElement !== undefined && lastExecutionTimeElement.length !== 0) {
                var lastExecutionTimeInstance = new Date(lastExecutionTimeElement);
                backupScheduleInstance.lastExecutionTime = lastExecutionTimeInstance;
              }
              
              var retentionPeriodInDaysElement = js2xml.getElement(responseDoc, backupScheduleElement, 'RETENTIONPERIODINDAYS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (retentionPeriodInDaysElement !== null && retentionPeriodInDaysElement !== undefined && retentionPeriodInDaysElement.length !== 0) {
                var retentionPeriodInDaysInstance = parseInt(retentionPeriodInDaysElement, 10);
                backupScheduleInstance.retentionPeriodInDays = retentionPeriodInDaysInstance;
              }
              
              var startTimeElement = js2xml.getElement(responseDoc, backupScheduleElement, 'STARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (startTimeElement !== null && startTimeElement !== undefined && startTimeElement.length !== 0) {
                var startTimeInstance = new Date(startTimeElement);
                backupScheduleInstance.startTime = startTimeInstance;
              }
            }
            
            var databasesSequenceElement = js2xml.getElement(responseDoc, backupRequestElement, 'DATABASES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (databasesSequenceElement !== null && databasesSequenceElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, databasesSequenceElement, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var databasesElement = js2xml.getElements(responseDoc, databasesSequenceElement, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var databaseBackupSettingInstance = {};
                result.databases.push(databaseBackupSettingInstance);
                
                var connectionStringElement = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (connectionStringElement !== null && connectionStringElement !== undefined) {
                  var connectionStringInstance = connectionStringElement;
                  databaseBackupSettingInstance.connectionString = connectionStringInstance;
                }
                
                var connectionStringNameElement = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (connectionStringNameElement !== null && connectionStringNameElement !== undefined) {
                  var connectionStringNameInstance = connectionStringNameElement;
                  databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                }
                
                var databaseTypeElement = js2xml.getElement(responseDoc, databasesElement, 'DATABASETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (databaseTypeElement !== null && databaseTypeElement !== undefined) {
                  var databaseTypeInstance = databaseTypeElement;
                  databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                }
                
                var nameElement2 = js2xml.getElement(responseDoc, databasesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement2 !== null && nameElement2 !== undefined) {
                  var nameInstance2 = nameElement2;
                  databaseBackupSettingInstance.name = nameInstance2;
                }
              }
            }
            
            var storageAccountUrlElement = js2xml.getElement(responseDoc, backupRequestElement, 'STORAGEACCOUNTURL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (storageAccountUrlElement !== null && storageAccountUrlElement !== undefined) {
              var storageAccountUrlInstance = storageAccountUrlElement;
              result.storageAccountUrl = storageAccountUrlInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve the config settings for a web site by issuing an HTTP GET
   * request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getConfiguration = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/config';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['accept'] = 'application/json';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { appSettings: {}, connectionStrings: [], defaultDocuments: [], handlerMappings: [], metadata: {}, routingRules: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var appSettingsSequenceElement = responseDoc['AppSettings'];
          if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < appSettingsSequenceElement.length; loweredIndex1 = loweredIndex1 + 1) {
              var appSettingsElement = appSettingsSequenceElement[loweredIndex1];
              var appSettingsKey = appSettingsElement['Name'];
              var appSettingsValue = appSettingsElement['Value'];
              result.appSettings[appSettingsKey] = appSettingsValue;
            }
          }
          
          var connectionStringsArray = responseDoc['ConnectionStrings'];
          if (connectionStringsArray !== null && connectionStringsArray !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < connectionStringsArray.length; loweredIndex2 = loweredIndex2 + 1) {
              var connectionStringsValue = connectionStringsArray[loweredIndex2];
              var connectionStringInfoInstance = {};
              result.connectionStrings.push(connectionStringInfoInstance);
              
              var connectionStringValue = connectionStringsValue['ConnectionString'];
              if (connectionStringValue !== null && connectionStringValue !== undefined) {
                var connectionStringInstance = connectionStringValue;
                connectionStringInfoInstance.connectionString = connectionStringInstance;
              }
              
              var nameValue = connectionStringsValue['Name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                connectionStringInfoInstance.name = nameInstance;
              }
              
              var typeValue = connectionStringsValue['Type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                connectionStringInfoInstance.type = typeInstance;
              }
            }
          }
          
          var defaultDocumentsArray = responseDoc['DefaultDocuments'];
          if (defaultDocumentsArray !== null && defaultDocumentsArray !== undefined) {
            for (var loweredIndex3 = 0; loweredIndex3 < defaultDocumentsArray.length; loweredIndex3 = loweredIndex3 + 1) {
              var defaultDocumentsValue = defaultDocumentsArray[loweredIndex3];
              result.defaultDocuments.push(defaultDocumentsValue);
            }
          }
          
          var detailedErrorLoggingEnabledValue = responseDoc['DetailedErrorLoggingEnabled'];
          if (detailedErrorLoggingEnabledValue !== null && detailedErrorLoggingEnabledValue !== undefined) {
            var detailedErrorLoggingEnabledInstance = detailedErrorLoggingEnabledValue;
            result.detailedErrorLoggingEnabled = detailedErrorLoggingEnabledInstance;
          }
          
          var documentRootValue = responseDoc['DocumentRoot'];
          if (documentRootValue !== null && documentRootValue !== undefined) {
            var documentRootInstance = documentRootValue;
            result.documentRoot = documentRootInstance;
          }
          
          var handlerMappingsArray = responseDoc['HandlerMappings'];
          if (handlerMappingsArray !== null && handlerMappingsArray !== undefined) {
            for (var loweredIndex4 = 0; loweredIndex4 < handlerMappingsArray.length; loweredIndex4 = loweredIndex4 + 1) {
              var handlerMappingsValue = handlerMappingsArray[loweredIndex4];
              var handlerMappingInstance = {};
              result.handlerMappings.push(handlerMappingInstance);
              
              var argumentsValue = handlerMappingsValue['Arguments'];
              if (argumentsValue !== null && argumentsValue !== undefined) {
                var argumentsInstance = argumentsValue;
                handlerMappingInstance.arguments = argumentsInstance;
              }
              
              var extensionValue = handlerMappingsValue['Extension'];
              if (extensionValue !== null && extensionValue !== undefined) {
                var extensionInstance = extensionValue;
                handlerMappingInstance.extension = extensionInstance;
              }
              
              var scriptProcessorValue = handlerMappingsValue['ScriptProcessor'];
              if (scriptProcessorValue !== null && scriptProcessorValue !== undefined) {
                var scriptProcessorInstance = scriptProcessorValue;
                handlerMappingInstance.scriptProcessor = scriptProcessorInstance;
              }
            }
          }
          
          var httpLoggingEnabledValue = responseDoc['HttpLoggingEnabled'];
          if (httpLoggingEnabledValue !== null && httpLoggingEnabledValue !== undefined) {
            var httpLoggingEnabledInstance = httpLoggingEnabledValue;
            result.httpLoggingEnabled = httpLoggingEnabledInstance;
          }
          
          var logsDirectorySizeLimitValue = responseDoc['LogsDirectorySizeLimit'];
          if (logsDirectorySizeLimitValue !== null && logsDirectorySizeLimitValue !== undefined) {
            var logsDirectorySizeLimitInstance = logsDirectorySizeLimitValue;
            result.logsDirectorySizeLimit = logsDirectorySizeLimitInstance;
          }
          
          var managedPipelineModeValue = responseDoc['ManagedPipelineMode'];
          if (managedPipelineModeValue !== null && managedPipelineModeValue !== undefined) {
            var managedPipelineModeInstance = managedPipelineModeValue;
            result.managedPipelineMode = managedPipelineModeInstance;
          }
          
          var metadataSequenceElement = responseDoc['Metadata'];
          if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
            for (var loweredIndex5 = 0; loweredIndex5 < metadataSequenceElement.length; loweredIndex5 = loweredIndex5 + 1) {
              var metadataElement = metadataSequenceElement[loweredIndex5];
              var metadataKey = metadataElement['Name'];
              var metadataValue = metadataElement['Value'];
              result.metadata[metadataKey] = metadataValue;
            }
          }
          
          var netFrameworkVersionValue = responseDoc['NetFrameworkVersion'];
          if (netFrameworkVersionValue !== null && netFrameworkVersionValue !== undefined) {
            var netFrameworkVersionInstance = netFrameworkVersionValue;
            result.netFrameworkVersion = netFrameworkVersionInstance;
          }
          
          var numberOfWorkersValue = responseDoc['NumberOfWorkers'];
          if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {
            var numberOfWorkersInstance = numberOfWorkersValue;
            result.numberOfWorkers = numberOfWorkersInstance;
          }
          
          var phpVersionValue = responseDoc['PhpVersion'];
          if (phpVersionValue !== null && phpVersionValue !== undefined) {
            var phpVersionInstance = phpVersionValue;
            result.phpVersion = phpVersionInstance;
          }
          
          var publishingPasswordValue = responseDoc['PublishingPassword'];
          if (publishingPasswordValue !== null && publishingPasswordValue !== undefined) {
            var publishingPasswordInstance = publishingPasswordValue;
            result.publishingPassword = publishingPasswordInstance;
          }
          
          var publishingUsernameValue = responseDoc['PublishingUsername'];
          if (publishingUsernameValue !== null && publishingUsernameValue !== undefined) {
            var publishingUsernameInstance = publishingUsernameValue;
            result.publishingUserName = publishingUsernameInstance;
          }
          
          var remoteDebuggingEnabledValue = responseDoc['RemoteDebuggingEnabled'];
          if (remoteDebuggingEnabledValue !== null && remoteDebuggingEnabledValue !== undefined) {
            var remoteDebuggingEnabledInstance = remoteDebuggingEnabledValue;
            result.remoteDebuggingEnabled = remoteDebuggingEnabledInstance;
          }
          
          var remoteDebuggingVersionValue = responseDoc['RemoteDebuggingVersion'];
          if (remoteDebuggingVersionValue !== null && remoteDebuggingVersionValue !== undefined) {
            var remoteDebuggingVersionInstance = remoteDebuggingVersionValue;
            result.remoteDebuggingVersion = remoteDebuggingVersionInstance;
          }
          
          var requestTracingEnabledValue = responseDoc['RequestTracingEnabled'];
          if (requestTracingEnabledValue !== null && requestTracingEnabledValue !== undefined) {
            var requestTracingEnabledInstance = requestTracingEnabledValue;
            result.requestTracingEnabled = requestTracingEnabledInstance;
          }
          
          var requestTracingExpirationTimeValue = responseDoc['RequestTracingExpirationTime'];
          if (requestTracingExpirationTimeValue !== null && requestTracingExpirationTimeValue !== undefined) {
            var requestTracingExpirationTimeInstance = requestTracingExpirationTimeValue;
            result.requestTracingExpirationTime = requestTracingExpirationTimeInstance;
          }
          
          var scmTypeValue = responseDoc['ScmType'];
          if (scmTypeValue !== null && scmTypeValue !== undefined) {
            var scmTypeInstance = scmTypeValue;
            result.scmType = scmTypeInstance;
          }
          
          var use32BitWorkerProcessValue = responseDoc['Use32BitWorkerProcess'];
          if (use32BitWorkerProcessValue !== null && use32BitWorkerProcessValue !== undefined) {
            var use32BitWorkerProcessInstance = use32BitWorkerProcessValue;
            result.use32BitWorkerProcess = use32BitWorkerProcessInstance;
          }
          
          var webSocketsEnabledValue = responseDoc['WebSocketsEnabled'];
          if (webSocketsEnabledValue !== null && webSocketsEnabledValue !== undefined) {
            var webSocketsEnabledInstance = webSocketsEnabledValue;
            result.webSocketsEnabled = webSocketsEnabledInstance;
          }
          
          var alwaysOnValue = responseDoc['AlwaysOn'];
          if (alwaysOnValue !== null && alwaysOnValue !== undefined) {
            var alwaysOnInstance = alwaysOnValue;
            result.alwaysOn = alwaysOnInstance;
          }
          
          var routingRulesArray = responseDoc['RoutingRules'];
          if (routingRulesArray !== null && routingRulesArray !== undefined) {
            for (var loweredIndex6 = 0; loweredIndex6 < routingRulesArray.length; loweredIndex6 = loweredIndex6 + 1) {
              var routingRulesValue = routingRulesArray[loweredIndex6];
              var typeName = routingRulesValue['__type'];
              if (typeName === 'RampUpRule:http://schemas.microsoft.com/windowsazure') {
                var rampUpRuleInstance = {};
                
                var actionHostNameValue = routingRulesValue['ActionHostName'];
                if (actionHostNameValue !== null && actionHostNameValue !== undefined) {
                  var actionHostNameInstance = actionHostNameValue;
                  rampUpRuleInstance.actionHostName = actionHostNameInstance;
                }
                
                var reroutePercentageValue = routingRulesValue['ReroutePercentage'];
                if (reroutePercentageValue !== null && reroutePercentageValue !== undefined) {
                  var reroutePercentageInstance = reroutePercentageValue;
                  rampUpRuleInstance.reroutePercentage = reroutePercentageInstance;
                }
                
                var changeStepValue = routingRulesValue['ChangeStep'];
                if (changeStepValue !== null && changeStepValue !== undefined) {
                  var changeStepInstance = changeStepValue;
                  rampUpRuleInstance.changeStep = changeStepInstance;
                }
                
                var changeIntervalInMinutesValue = routingRulesValue['ChangeIntervalInMinutes'];
                if (changeIntervalInMinutesValue !== null && changeIntervalInMinutesValue !== undefined) {
                  var changeIntervalInMinutesInstance = changeIntervalInMinutesValue;
                  rampUpRuleInstance.changeIntervalInMinutes = changeIntervalInMinutesInstance;
                }
                
                var minReroutePercentageValue = routingRulesValue['MinReroutePercentage'];
                if (minReroutePercentageValue !== null && minReroutePercentageValue !== undefined) {
                  var minReroutePercentageInstance = minReroutePercentageValue;
                  rampUpRuleInstance.minReroutePercentage = minReroutePercentageInstance;
                }
                
                var maxReroutePercentageValue = routingRulesValue['MaxReroutePercentage'];
                if (maxReroutePercentageValue !== null && maxReroutePercentageValue !== undefined) {
                  var maxReroutePercentageInstance = maxReroutePercentageValue;
                  rampUpRuleInstance.maxReroutePercentage = maxReroutePercentageInstance;
                }
                
                var changeDecisionCallbackUrlValue = routingRulesValue['ChangeDecisionCallbackUrl'];
                if (changeDecisionCallbackUrlValue !== null && changeDecisionCallbackUrlValue !== undefined) {
                  var changeDecisionCallbackUrlInstance = changeDecisionCallbackUrlValue;
                  rampUpRuleInstance.changeDecisionCallbackUrl = changeDecisionCallbackUrlInstance;
                }
                
                var nameValue2 = routingRulesValue['Name'];
                if (nameValue2 !== null && nameValue2 !== undefined) {
                  var nameInstance2 = nameValue2;
                  rampUpRuleInstance.name = nameInstance2;
                }
                result.routingRules.push(rampUpRuleInstance);
              }
            }
          }
          
          var javaVersionValue = responseDoc['JavaVersion'];
          if (javaVersionValue !== null && javaVersionValue !== undefined) {
            var javaVersionInstance = javaVersionValue;
            result.javaVersion = javaVersionInstance;
          }
          
          var javaContainerValue = responseDoc['JavaContainer'];
          if (javaContainerValue !== null && javaContainerValue !== undefined) {
            var javaContainerInstance = javaContainerValue;
            result.javaContainer = javaContainerInstance;
          }
          
          var javaContainerVersionValue = responseDoc['JavaContainerVersion'];
          if (javaContainerVersionValue !== null && javaContainerVersionValue !== undefined) {
            var javaContainerVersionInstance = javaContainerVersionValue;
            result.javaContainerVersion = javaContainerVersionInstance;
          }
          
          var autoSwapSlotNameValue = responseDoc['AutoSwapSlotName'];
          if (autoSwapSlotNameValue !== null && autoSwapSlotNameValue !== undefined) {
            var autoSwapSlotNameInstance = autoSwapSlotNameValue;
            result.autoSwapSlotName = autoSwapSlotNameInstance;
          }
          
          var siteAuthEnabledValue = responseDoc['SiteAuthEnabled'];
          if (siteAuthEnabledValue !== null && siteAuthEnabledValue !== undefined) {
            var siteAuthEnabledInstance = siteAuthEnabledValue;
            result.siteAuthEnabled = siteAuthEnabledInstance;
          }
          
          var siteAuthSettingsValue = responseDoc['SiteAuthSettings'];
          if (siteAuthSettingsValue !== null && siteAuthSettingsValue !== undefined) {
            var siteAuthSettingsInstance = {};
            result.siteAuthSettings = siteAuthSettingsInstance;
            
            var aADClientIdValue = siteAuthSettingsValue['AADClientId'];
            if (aADClientIdValue !== null && aADClientIdValue !== undefined) {
              var aADClientIdInstance = aADClientIdValue;
              siteAuthSettingsInstance.aADClientId = aADClientIdInstance;
            }
            
            var openIdIssuerValue = siteAuthSettingsValue['OpenIdIssuer'];
            if (openIdIssuerValue !== null && openIdIssuerValue !== undefined) {
              var openIdIssuerInstance = openIdIssuerValue;
              siteAuthSettingsInstance.openIdIssuer = openIdIssuerInstance;
            }
          }
          
          var limitsValue = responseDoc['limits'];
          if (limitsValue !== null && limitsValue !== undefined) {
            var limitsInstance = {};
            result.limits = limitsInstance;
            
            var maxPercentageCpuValue = limitsValue['maxPercentageCpu'];
            if (maxPercentageCpuValue !== null && maxPercentageCpuValue !== undefined) {
              var maxPercentageCpuInstance = maxPercentageCpuValue;
              limitsInstance.maxPercentageCpu = maxPercentageCpuInstance;
            }
            
            var maxMemoryInMbValue = limitsValue['maxMemoryInMb'];
            if (maxMemoryInMbValue !== null && maxMemoryInMbValue !== undefined) {
              var maxMemoryInMbInstance = maxMemoryInMbValue;
              limitsInstance.maxMemoryInMb = maxMemoryInMbInstance;
            }
            
            var maxDiskSizeInMbValue = limitsValue['maxDiskSizeInMb'];
            if (maxDiskSizeInMbValue !== null && maxDiskSizeInMbValue !== undefined) {
              var maxDiskSizeInMbInstance = maxDiskSizeInMbValue;
              limitsInstance.maxDiskSizeInMb = maxDiskSizeInMbInstance;
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve historical usage metrics for a site by issuing an HTTP
   * GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166964.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {WebSiteGetHistoricalUsageMetricsParameters} parameters Parameters
   * supplied to the Get Historical Usage Metrics Web Site operation.
   * 
   * @param {array} [parameters.metricNames] Specifies a comma-separated list
   * of the names of the metrics to return. If the names parameter is not
   * specified, then all available metrics are returned.
   * 
   * @param {date} [parameters.startTime] The starting time of the metrics to
   * return. If this parameter is not specified, the beginning of the current
   * hour is used.
   * 
   * @param {date} [parameters.endTime] The ending time of the metrics to
   * return. If this parameter is not specified, the current time is used.
   * 
   * @param {string} [parameters.timeGrain] The grain at which the metrics are
   * returned. Supported values are PT1M (minute), PT1H (hour), P1D (day).
   * 
   * @param {boolean} [parameters.includeInstanceBreakdown] Flag which
   * specifies if the metrics for each machine instance should be included.
   * For sites that run on more than one machine this could be useful to
   * identify a bad machine.
   * 
   * @param {boolean} [parameters.slotView] Flag which specifies if the metrics
   * returned should reflect slot swaps. Let's take for example following
   * case: if production slot has hostname www.contos.com and take traffic for
   * 12 hours and later is swapped with staging slot. Getting metrics with
   * SlotView=false will reflect the swap - e.g. there will be a increase on
   * the staging slot metrics after it goes to production.If SlotView=true is
   * used it will show the metrics for the www.contoso.com regardless which
   * slot was serving at the moment.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getHistoricalUsageMetrics = function(webSpaceName, webSiteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/metrics';
    var queryParameters = [];
    if (parameters.metricNames !== null && parameters.metricNames !== undefined && parameters.metricNames.length > 0) {
      queryParameters.push('names=' + encodeURIComponent(parameters.metricNames.join(',')));
    }
    if (parameters.startTime !== null && parameters.startTime !== undefined) {
      queryParameters.push('StartTime=' + encodeURIComponent(parameters.startTime.toISOString()));
    }
    if (parameters.endTime !== null && parameters.endTime !== undefined) {
      queryParameters.push('EndTime=' + encodeURIComponent(parameters.endTime.toISOString()));
    }
    if (parameters.timeGrain !== null && parameters.timeGrain !== undefined) {
      queryParameters.push('timeGrain=' + encodeURIComponent(parameters.timeGrain));
    }
    if (parameters.includeInstanceBreakdown !== null && parameters.includeInstanceBreakdown !== undefined) {
      queryParameters.push('details=' + encodeURIComponent(parameters.includeInstanceBreakdown.toString()));
    }
    if (parameters.slotView !== null && parameters.slotView !== undefined) {
      queryParameters.push('slotView=' + encodeURIComponent(parameters.slotView.toString()));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { usageMetrics: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var metricResponsesElement = js2xml.getElement(responseDoc, responseDoc, 'METRICRESPONSES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (metricResponsesElement !== null && metricResponsesElement !== undefined) {
            if (metricResponsesElement !== null && metricResponsesElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, metricResponsesElement, 'METRICRESPONSE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var usageMetricsElement = js2xml.getElements(responseDoc, metricResponsesElement, 'METRICRESPONSE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var metricResponseInstance = {};
                result.usageMetrics.push(metricResponseInstance);
                
                var codeElement = js2xml.getElement(responseDoc, usageMetricsElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (codeElement !== null && codeElement !== undefined) {
                  var codeInstance = codeElement;
                  metricResponseInstance.code = codeInstance;
                }
                
                var dataElement = js2xml.getElement(responseDoc, usageMetricsElement, 'DATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (dataElement !== null && dataElement !== undefined) {
                  var dataInstance = { values: [] };
                  metricResponseInstance.data = dataInstance;
                  
                  var displayNameElement = js2xml.getElement(responseDoc, dataElement, 'DISPLAYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (displayNameElement !== null && displayNameElement !== undefined) {
                    var displayNameInstance = displayNameElement;
                    dataInstance.displayName = displayNameInstance;
                  }
                  
                  var endTimeElement = js2xml.getElement(responseDoc, dataElement, 'ENDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (endTimeElement !== null && endTimeElement !== undefined && endTimeElement.length !== 0) {
                    var endTimeInstance = new Date(endTimeElement);
                    dataInstance.endTime = endTimeInstance;
                  }
                  
                  var nameElement = js2xml.getElement(responseDoc, dataElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement !== null && nameElement !== undefined) {
                    var nameInstance = nameElement;
                    dataInstance.name = nameInstance;
                  }
                  
                  var primaryAggregationTypeElement = js2xml.getElement(responseDoc, dataElement, 'PRIMARYAGGREGATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (primaryAggregationTypeElement !== null && primaryAggregationTypeElement !== undefined) {
                    var primaryAggregationTypeInstance = primaryAggregationTypeElement;
                    dataInstance.primaryAggregationType = primaryAggregationTypeInstance;
                  }
                  
                  var startTimeElement = js2xml.getElement(responseDoc, dataElement, 'STARTTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (startTimeElement !== null && startTimeElement !== undefined && startTimeElement.length !== 0) {
                    var startTimeInstance = new Date(startTimeElement);
                    dataInstance.startTime = startTimeInstance;
                  }
                  
                  var timeGrainElement = js2xml.getElement(responseDoc, dataElement, 'TIMEGRAIN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (timeGrainElement !== null && timeGrainElement !== undefined) {
                    var timeGrainInstance = timeGrainElement;
                    dataInstance.timeGrain = timeGrainInstance;
                  }
                  
                  var unitElement = js2xml.getElement(responseDoc, dataElement, 'UNIT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (unitElement !== null && unitElement !== undefined) {
                    var unitInstance = unitElement;
                    dataInstance.unit = unitInstance;
                  }
                  
                  var valuesSequenceElement = js2xml.getElement(responseDoc, dataElement, 'VALUES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (valuesSequenceElement !== null && valuesSequenceElement !== undefined) {
                    for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, valuesSequenceElement, 'METRICSAMPLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                      var valuesElement = js2xml.getElements(responseDoc, valuesSequenceElement, 'METRICSAMPLE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                      var metricSampleInstance = {};
                      dataInstance.values.push(metricSampleInstance);
                      
                      var countElement = js2xml.getElement(responseDoc, valuesElement, 'COUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (countElement !== null && countElement !== undefined && countElement.length !== 0) {
                        var countInstance = parseInt(countElement, 10);
                        metricSampleInstance.count = countInstance;
                      }
                      
                      var maximumElement = js2xml.getElement(responseDoc, valuesElement, 'MAXIMUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (maximumElement !== null && maximumElement !== undefined) {
                        var isNil = false;
                        var nilAttribute = js2xml.getAttribute(responseDoc, maximumElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                        if (nilAttribute !== null && nilAttribute !== undefined) {
                          isNil = nilAttribute === 'true';
                        }
                        if (isNil === false) {
                          var maximumInstance = maximumElement;
                          metricSampleInstance.maximum = maximumInstance;
                        }
                      }
                      
                      var minimumElement = js2xml.getElement(responseDoc, valuesElement, 'MINIMUM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (minimumElement !== null && minimumElement !== undefined) {
                        var isNil2 = false;
                        var nilAttribute2 = js2xml.getAttribute(responseDoc, minimumElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                        if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                          isNil2 = nilAttribute2 === 'true';
                        }
                        if (isNil2 === false) {
                          var minimumInstance = minimumElement;
                          metricSampleInstance.minimum = minimumInstance;
                        }
                      }
                      
                      var timeCreatedElement = js2xml.getElement(responseDoc, valuesElement, 'TIMECREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (timeCreatedElement !== null && timeCreatedElement !== undefined && timeCreatedElement.length !== 0) {
                        var timeCreatedInstance = new Date(timeCreatedElement);
                        metricSampleInstance.timeCreated = timeCreatedInstance;
                      }
                      
                      var totalElement = js2xml.getElement(responseDoc, valuesElement, 'TOTAL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (totalElement !== null && totalElement !== undefined) {
                        var totalInstance = totalElement;
                        metricSampleInstance.total = totalInstance;
                      }
                      
                      var instanceNameElement = js2xml.getElement(responseDoc, valuesElement, 'INSTANCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                      if (instanceNameElement !== null && instanceNameElement !== undefined) {
                        var instanceNameInstance = instanceNameElement;
                        metricSampleInstance.instanceName = instanceNameInstance;
                      }
                    }
                  }
                }
                
                var messageElement = js2xml.getElement(responseDoc, usageMetricsElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (messageElement !== null && messageElement !== undefined) {
                  var messageInstance = messageElement;
                  metricResponseInstance.message = messageInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Retrieves a particular hybrid connection that belongs to a specific site.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} hybridConnectionName The name of the hybrid connection
   * entity
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getHybridConnection = function(webSpaceName, webSiteName, hybridConnectionName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (hybridConnectionName === null || hybridConnectionName === undefined) {
      return callback(new Error('hybridConnectionName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/hybridconnection/';
    url2 = url2 + encodeURIComponent(hybridConnectionName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var relayServiceConnectionEntityElement = js2xml.getElement(responseDoc, responseDoc, 'RELAYSERVICECONNECTIONENTITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (relayServiceConnectionEntityElement !== null && relayServiceConnectionEntityElement !== undefined) {
            var hybridConnectionInstance = {};
            result.hybridConnection = hybridConnectionInstance;
            
            var entityNameElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'ENTITYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (entityNameElement !== null && entityNameElement !== undefined) {
              var entityNameInstance = entityNameElement;
              hybridConnectionInstance.entityName = entityNameInstance;
            }
            
            var entityConnectionStringElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'ENTITYCONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (entityConnectionStringElement !== null && entityConnectionStringElement !== undefined) {
              var entityConnectionStringInstance = entityConnectionStringElement;
              hybridConnectionInstance.entityConnectionString = entityConnectionStringInstance;
            }
            
            var resourceTypeElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'RESOURCETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (resourceTypeElement !== null && resourceTypeElement !== undefined) {
              var resourceTypeInstance = resourceTypeElement;
              hybridConnectionInstance.resourceType = resourceTypeInstance;
            }
            
            var resourceConnectionStringElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'RESOURCECONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (resourceConnectionStringElement !== null && resourceConnectionStringElement !== undefined) {
              var resourceConnectionStringInstance = resourceConnectionStringElement;
              hybridConnectionInstance.resourceConnectionString = resourceConnectionStringInstance;
            }
            
            var hostnameElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostnameElement !== null && hostnameElement !== undefined) {
              var hostnameInstance = hostnameElement;
              hybridConnectionInstance.hostname = hostnameInstance;
            }
            
            var portElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
              var portInstance = parseInt(portElement, 10);
              hybridConnectionInstance.port = portInstance;
            }
            
            var biztalkUriElement = js2xml.getElement(responseDoc, relayServiceConnectionEntityElement, 'BIZTALKURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (biztalkUriElement !== null && biztalkUriElement !== undefined) {
              var biztalkUriInstance = biztalkUriElement;
              hybridConnectionInstance.biztalkUri = biztalkUriInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve the list of active instances by ids for a web site by
   * issuing an HTTP GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166981.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getInstanceIds = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/instanceids';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { instanceIds: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var arrayOfstringSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'ARRAYOFSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS');
          if (arrayOfstringSequenceElement !== null && arrayOfstringSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, arrayOfstringSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex1 = loweredIndex1 + 1) {
              var arrayOfstringElement = js2xml.getElements(responseDoc, arrayOfstringSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex1];
              result.instanceIds.push(arrayOfstringElement);
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve the publish settings information for a web site by
   * issuing an HTTP GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166996.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getPublishProfile = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/publishxml';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { publishProfiles: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var publishDataElement = js2xml.getElement(responseDoc, responseDoc, 'PUBLISHDATA', '');
          if (publishDataElement !== null && publishDataElement !== undefined) {
            if (publishDataElement !== null && publishDataElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, publishDataElement, 'PUBLISHPROFILE', '').length; loweredIndex1 = loweredIndex1 + 1) {
                var publishProfilesElement = js2xml.getElements(responseDoc, publishDataElement, 'PUBLISHPROFILE', '')[loweredIndex1];
                var publishProfileInstance = { databases: [] };
                result.publishProfiles.push(publishProfileInstance);
                
                var profileNameAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'PROFILENAME', '');
                if (profileNameAttribute !== null && profileNameAttribute !== undefined) {
                  publishProfileInstance.profileName = profileNameAttribute;
                }
                
                var publishMethodAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'PUBLISHMETHOD', '');
                if (publishMethodAttribute !== null && publishMethodAttribute !== undefined) {
                  publishProfileInstance.publishMethod = publishMethodAttribute;
                }
                
                var publishUrlAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'PUBLISHURL', '');
                if (publishUrlAttribute !== null && publishUrlAttribute !== undefined) {
                  publishProfileInstance.publishUrl = publishUrlAttribute;
                }
                
                var msdeploySiteAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'MSDEPLOYSITE', '');
                if (msdeploySiteAttribute !== null && msdeploySiteAttribute !== undefined) {
                  publishProfileInstance.mSDeploySite = msdeploySiteAttribute;
                }
                
                var ftpPassiveModeAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'FTPPASSIVEMODE', '');
                if (ftpPassiveModeAttribute !== null && ftpPassiveModeAttribute !== undefined && (ftpPassiveModeAttribute === null || ftpPassiveModeAttribute === undefined || ftpPassiveModeAttribute.length === 0) === false) {
                  publishProfileInstance.ftpPassiveMode = ftpPassiveModeAttribute === 'true';
                }
                
                var userNameAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'USERNAME', '');
                if (userNameAttribute !== null && userNameAttribute !== undefined) {
                  publishProfileInstance.userName = userNameAttribute;
                }
                
                var userPWDAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'USERPWD', '');
                if (userPWDAttribute !== null && userPWDAttribute !== undefined) {
                  publishProfileInstance.userPassword = userPWDAttribute;
                }
                
                var destinationAppUrlAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'DESTINATIONAPPURL', '');
                if (destinationAppUrlAttribute !== null && destinationAppUrlAttribute !== undefined) {
                  publishProfileInstance.destinationAppUri = destinationAppUrlAttribute;
                }
                
                var sQLServerDBConnectionStringAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'SQLSERVERDBCONNECTIONSTRING', '');
                if (sQLServerDBConnectionStringAttribute !== null && sQLServerDBConnectionStringAttribute !== undefined) {
                  publishProfileInstance.sqlServerConnectionString = sQLServerDBConnectionStringAttribute;
                }
                
                var mySQLDBConnectionStringAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'MYSQLDBCONNECTIONSTRING', '');
                if (mySQLDBConnectionStringAttribute !== null && mySQLDBConnectionStringAttribute !== undefined) {
                  publishProfileInstance.mySqlConnectionString = mySQLDBConnectionStringAttribute;
                }
                
                var hostingProviderForumLinkAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'HOSTINGPROVIDERFORUMLINK', '');
                if (hostingProviderForumLinkAttribute !== null && hostingProviderForumLinkAttribute !== undefined) {
                  publishProfileInstance.hostingProviderForumUri = hostingProviderForumLinkAttribute;
                }
                
                var controlPanelLinkAttribute = js2xml.getAttribute(responseDoc, publishProfilesElement, 'CONTROLPANELLINK', '');
                if (controlPanelLinkAttribute !== null && controlPanelLinkAttribute !== undefined) {
                  publishProfileInstance.controlPanelUri = controlPanelLinkAttribute;
                }
                
                var databasesSequenceElement = js2xml.getElement(responseDoc, publishProfilesElement, 'DATABASES', '');
                if (databasesSequenceElement !== null && databasesSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, databasesSequenceElement, 'ADD', '').length; loweredIndex2 = loweredIndex2 + 1) {
                    var databasesElement = js2xml.getElements(responseDoc, databasesSequenceElement, 'ADD', '')[loweredIndex2];
                    var addInstance = {};
                    publishProfileInstance.databases.push(addInstance);
                    
                    var nameAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'NAME', '');
                    if (nameAttribute !== null && nameAttribute !== undefined) {
                      addInstance.name = nameAttribute;
                    }
                    
                    var connectionStringAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'CONNECTIONSTRING', '');
                    if (connectionStringAttribute !== null && connectionStringAttribute !== undefined) {
                      addInstance.connectionString = connectionStringAttribute;
                    }
                    
                    var providerNameAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'PROVIDERNAME', '');
                    if (providerNameAttribute !== null && providerNameAttribute !== undefined) {
                      addInstance.providerName = providerNameAttribute;
                    }
                    
                    var typeAttribute = js2xml.getAttribute(responseDoc, databasesElement, 'TYPE', '');
                    if (typeAttribute !== null && typeAttribute !== undefined) {
                      addInstance.type = typeAttribute;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * A web site repository is essentially a Git repository that you can use to
   * manage your web site content. By using Git source control tools, you can
   * push or pull version-controlled changes to your site. This API executes a
   * repository get operation.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getRepository = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/repository';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var anyURIElement = js2xml.getElement(responseDoc, responseDoc, 'ANYURI', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/');
          if (anyURIElement !== null && anyURIElement !== undefined) {
            result.uri = anyURIElement;
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getSlotConfigNames = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/slotConfigNames';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['accept'] = 'application/json';
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { appSettingNames: [], connectionStringNames: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var appSettingNamesArray = responseDoc['AppSettingNames'];
          if (appSettingNamesArray !== null && appSettingNamesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < appSettingNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var appSettingNamesValue = appSettingNamesArray[loweredIndex1];
              result.appSettingNames.push(appSettingNamesValue);
            }
          }
          
          var connectionStringNamesArray = responseDoc['ConnectionStringNames'];
          if (connectionStringNamesArray !== null && connectionStringNamesArray !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < connectionStringNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
              var connectionStringNamesValue = connectionStringNamesArray[loweredIndex2];
              result.connectionStringNames.push(connectionStringNamesValue);
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve current usage metrics for a site by issuing an HTTP GET
   * request. The metrics returned include CPU Time, Data In, Data Out, Local
   * Bytes Read, Local Bytes Written, Network Bytes Read, Network Bytes
   * Written, WP Stop Requests, Memory Usage, CPU Time - Minute Limit, and
   * File System Storage.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166991.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getUsageMetrics = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/usages';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { usageMetrics: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var usagesElement = js2xml.getElement(responseDoc, responseDoc, 'USAGES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (usagesElement !== null && usagesElement !== undefined) {
            if (usagesElement !== null && usagesElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, usagesElement, 'USAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var usageMetricsElement = js2xml.getElements(responseDoc, usagesElement, 'USAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var usageInstance = {};
                result.usageMetrics.push(usageInstance);
                
                var computeModeElement = js2xml.getElement(responseDoc, usageMetricsElement, 'COMPUTEMODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (computeModeElement !== null && computeModeElement !== undefined && computeModeElement.length !== 0) {
                  var computeModeInstance = computeModeElement;
                  usageInstance.computeMode = computeModeInstance;
                }
                
                var currentValueElement = js2xml.getElement(responseDoc, usageMetricsElement, 'CURRENTVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (currentValueElement !== null && currentValueElement !== undefined) {
                  var currentValueInstance = currentValueElement;
                  usageInstance.currentValue = currentValueInstance;
                }
                
                var displayNameElement = js2xml.getElement(responseDoc, usageMetricsElement, 'DISPLAYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (displayNameElement !== null && displayNameElement !== undefined) {
                  var displayNameInstance = displayNameElement;
                  usageInstance.displayName = displayNameInstance;
                }
                
                var limitElement = js2xml.getElement(responseDoc, usageMetricsElement, 'LIMIT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (limitElement !== null && limitElement !== undefined) {
                  var limitInstance = limitElement;
                  usageInstance.limit = limitInstance;
                }
                
                var nameElement = js2xml.getElement(responseDoc, usageMetricsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  usageInstance.name = nameInstance;
                }
                
                var nextResetTimeElement = js2xml.getElement(responseDoc, usageMetricsElement, 'NEXTRESETTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nextResetTimeElement !== null && nextResetTimeElement !== undefined && nextResetTimeElement.length !== 0) {
                  var nextResetTimeInstance = new Date(nextResetTimeElement);
                  usageInstance.nextResetTime = nextResetTimeInstance;
                }
                
                var resourceNameElement = js2xml.getElement(responseDoc, usageMetricsElement, 'RESOURCENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (resourceNameElement !== null && resourceNameElement !== undefined) {
                  var resourceNameInstance = resourceNameElement;
                  usageInstance.resourceName = resourceNameInstance;
                }
                
                var siteModeElement = js2xml.getElement(responseDoc, usageMetricsElement, 'SITEMODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (siteModeElement !== null && siteModeElement !== undefined && siteModeElement.length !== 0) {
                  var siteModeInstance = siteModeElement;
                  usageInstance.siteMode = siteModeInstance;
                }
                
                var unitElement = js2xml.getElement(responseDoc, usageMetricsElement, 'UNIT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (unitElement !== null && unitElement !== undefined) {
                  var unitInstance = unitElement;
                  usageInstance.unit = unitInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Determines if a host name is available.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.isHostnameAvailable = function(webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces';
    var queryParameters = [];
    queryParameters.push('ishostnameavailable=' + encodeURIComponent(webSiteName));
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var booleanElement = js2xml.getElement(responseDoc, responseDoc, 'BOOLEAN', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/');
          if (booleanElement !== null && booleanElement !== undefined && booleanElement.length !== 0) {
            var booleanInstance = booleanElement === 'true';
            result.isAvailable = booleanInstance;
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Returns list of all backups which are tracked by the system.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.listBackups = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/restore';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { backupItems: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var backupItemsElement = js2xml.getElement(responseDoc, responseDoc, 'BACKUPITEMS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (backupItemsElement !== null && backupItemsElement !== undefined) {
            if (backupItemsElement !== null && backupItemsElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, backupItemsElement, 'BACKUPITEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
                var backupItemsElement2 = js2xml.getElements(responseDoc, backupItemsElement, 'BACKUPITEM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
                var backupItemInstance = { databases: [] };
                result.backupItems.push(backupItemInstance);
                
                var storageAccountUrlElement = js2xml.getElement(responseDoc, backupItemsElement2, 'STORAGEACCOUNTURL', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (storageAccountUrlElement !== null && storageAccountUrlElement !== undefined) {
                  var storageAccountUrlInstance = storageAccountUrlElement;
                  backupItemInstance.storageAccountUrl = storageAccountUrlInstance;
                }
                
                var blobNameElement = js2xml.getElement(responseDoc, backupItemsElement2, 'BLOBNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (blobNameElement !== null && blobNameElement !== undefined) {
                  var blobNameInstance = blobNameElement;
                  backupItemInstance.blobName = blobNameInstance;
                }
                
                var nameElement = js2xml.getElement(responseDoc, backupItemsElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  backupItemInstance.name = nameInstance;
                }
                
                var statusElement = js2xml.getElement(responseDoc, backupItemsElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
                  var statusInstance = statusElement;
                  backupItemInstance.status = statusInstance;
                }
                
                var sizeInBytesElement = js2xml.getElement(responseDoc, backupItemsElement2, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sizeInBytesElement !== null && sizeInBytesElement !== undefined && sizeInBytesElement.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement, 10);
                  backupItemInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var createdElement = js2xml.getElement(responseDoc, backupItemsElement2, 'CREATED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (createdElement !== null && createdElement !== undefined && createdElement.length !== 0) {
                  var createdInstance = new Date(createdElement);
                  backupItemInstance.created = createdInstance;
                }
                
                var logElement = js2xml.getElement(responseDoc, backupItemsElement2, 'LOG', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (logElement !== null && logElement !== undefined) {
                  var logInstance = logElement;
                  backupItemInstance.log = logInstance;
                }
                
                var databasesSequenceElement = js2xml.getElement(responseDoc, backupItemsElement2, 'DATABASES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (databasesSequenceElement !== null && databasesSequenceElement !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, databasesSequenceElement, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex2 = loweredIndex2 + 1) {
                    var databasesElement = js2xml.getElements(responseDoc, databasesSequenceElement, 'DATABASEBACKUPSETTING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex2];
                    var databaseBackupSettingInstance = {};
                    backupItemInstance.databases.push(databaseBackupSettingInstance);
                    
                    var connectionStringElement = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (connectionStringElement !== null && connectionStringElement !== undefined) {
                      var connectionStringInstance = connectionStringElement;
                      databaseBackupSettingInstance.connectionString = connectionStringInstance;
                    }
                    
                    var connectionStringNameElement = js2xml.getElement(responseDoc, databasesElement, 'CONNECTIONSTRINGNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (connectionStringNameElement !== null && connectionStringNameElement !== undefined) {
                      var connectionStringNameInstance = connectionStringNameElement;
                      databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                    }
                    
                    var databaseTypeElement = js2xml.getElement(responseDoc, databasesElement, 'DATABASETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (databaseTypeElement !== null && databaseTypeElement !== undefined) {
                      var databaseTypeInstance = databaseTypeElement;
                      databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                    }
                    
                    var nameElement2 = js2xml.getElement(responseDoc, databasesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    if (nameElement2 !== null && nameElement2 !== undefined) {
                      var nameInstance2 = nameElement2;
                      databaseBackupSettingInstance.name = nameInstance2;
                    }
                  }
                }
                
                var scheduledElement = js2xml.getElement(responseDoc, backupItemsElement2, 'SCHEDULED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (scheduledElement !== null && scheduledElement !== undefined && scheduledElement.length !== 0) {
                  var scheduledInstance = scheduledElement === 'true';
                  backupItemInstance.scheduled = scheduledInstance;
                }
                
                var lastRestoreTimeStampElement = js2xml.getElement(responseDoc, backupItemsElement2, 'LASTRESTORETIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (lastRestoreTimeStampElement !== null && lastRestoreTimeStampElement !== undefined && lastRestoreTimeStampElement.length !== 0) {
                  var lastRestoreTimeStampInstance = new Date(lastRestoreTimeStampElement);
                  backupItemInstance.lastRestoreTimeStamp = lastRestoreTimeStampInstance;
                }
                
                var finishedTimeStampElement = js2xml.getElement(responseDoc, backupItemsElement2, 'FINISHEDTIMESTAMP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (finishedTimeStampElement !== null && finishedTimeStampElement !== undefined && finishedTimeStampElement.length !== 0) {
                  var finishedTimeStampInstance = new Date(finishedTimeStampElement);
                  backupItemInstance.finishedTimeStamp = finishedTimeStampInstance;
                }
                
                var correlationIdElement = js2xml.getElement(responseDoc, backupItemsElement2, 'CORRELATIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (correlationIdElement !== null && correlationIdElement !== undefined) {
                  var correlationIdInstance = correlationIdElement;
                  backupItemInstance.correlationId = correlationIdInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Retrieves a list of all hybrid connections on a specific web site.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.listHybridConnections = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/hybridconnection';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { hybridConnections: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var arrayOfRelayServiceConnectionEntitySequenceElement = js2xml.getElement(responseDoc, responseDoc, 'ARRAYOFRELAYSERVICECONNECTIONENTITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (arrayOfRelayServiceConnectionEntitySequenceElement !== null && arrayOfRelayServiceConnectionEntitySequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, arrayOfRelayServiceConnectionEntitySequenceElement, 'RELAYSERVICECONNECTIONENTITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var arrayOfRelayServiceConnectionEntityElement = js2xml.getElements(responseDoc, arrayOfRelayServiceConnectionEntitySequenceElement, 'RELAYSERVICECONNECTIONENTITY', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var relayServiceConnectionEntityInstance = {};
              result.hybridConnections.push(relayServiceConnectionEntityInstance);
              
              var entityNameElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'ENTITYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (entityNameElement !== null && entityNameElement !== undefined) {
                var entityNameInstance = entityNameElement;
                relayServiceConnectionEntityInstance.entityName = entityNameInstance;
              }
              
              var entityConnectionStringElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'ENTITYCONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (entityConnectionStringElement !== null && entityConnectionStringElement !== undefined) {
                var entityConnectionStringInstance = entityConnectionStringElement;
                relayServiceConnectionEntityInstance.entityConnectionString = entityConnectionStringInstance;
              }
              
              var resourceTypeElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'RESOURCETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (resourceTypeElement !== null && resourceTypeElement !== undefined) {
                var resourceTypeInstance = resourceTypeElement;
                relayServiceConnectionEntityInstance.resourceType = resourceTypeInstance;
              }
              
              var resourceConnectionStringElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'RESOURCECONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (resourceConnectionStringElement !== null && resourceConnectionStringElement !== undefined) {
                var resourceConnectionStringInstance = resourceConnectionStringElement;
                relayServiceConnectionEntityInstance.resourceConnectionString = resourceConnectionStringInstance;
              }
              
              var hostnameElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'HOSTNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostnameElement !== null && hostnameElement !== undefined) {
                var hostnameInstance = hostnameElement;
                relayServiceConnectionEntityInstance.hostname = hostnameInstance;
              }
              
              var portElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'PORT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (portElement !== null && portElement !== undefined && portElement.length !== 0) {
                var portInstance = parseInt(portElement, 10);
                relayServiceConnectionEntityInstance.port = portInstance;
              }
              
              var biztalkUriElement = js2xml.getElement(responseDoc, arrayOfRelayServiceConnectionEntityElement, 'BIZTALKURI', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (biztalkUriElement !== null && biztalkUriElement !== undefined) {
                var biztalkUriInstance = biztalkUriElement;
                relayServiceConnectionEntityInstance.biztalkUri = biztalkUriInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.resetSlotConfiguration = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/resetSlotConfig';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['accept'] = 'application/json';
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can restart a web site by issuing an HTTP POST request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn236425.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.restart = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/restart';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Restores a site to either a new site or existing site (Overwrite flag has
   * to be set to true for that).
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {RestoreRequest} restoreRequest A restore request.
   * 
   * @param {boolean} [restoreRequest.adjustConnectionStrings] If the restore
   * operation also restores a database along with the website and the
   * database is on a different server than when the original site h
   * 
   * @param {string} [restoreRequest.blobName] The blob name where the backup
   * is stored. E.g. mysite1_20140203.zip
   * 
   * @param {IEnumerable} [restoreRequest.databases] Database settings for
   * backup.
   * 
   * @param {boolean} [restoreRequest.ignoreConflictingHostNames] When
   * restoring a site, custom domains might conflict with other site in the
   * same datacenter. If this value is true, such hostnames will be ignored
   * during restore. If this is false, the restore operation will fail on such
   * conflict.
   * 
   * @param {boolean} [restoreRequest.overwrite] True if the restore operation
   * will be used for overwrite an existing site; false otherwise.
   * 
   * @param {string} [restoreRequest.storageAccountUrl] SAS URL for a container
   * in a storage account. E.g.
   * 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=abcdefABCDEFabcdef0123456789
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.restore = function(webSpaceName, webSiteName, restoreRequest, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (restoreRequest === null || restoreRequest === undefined) {
      return callback(new Error('restoreRequest cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/restore';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var restoreRequestElement = js2xml.createElement('RestoreRequest', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, restoreRequestElement);
    
    if (restoreRequest.adjustConnectionStrings !== null && restoreRequest.adjustConnectionStrings !== undefined) {
      var adjustConnectionStringsElement = js2xml.createElement('AdjustConnectionStrings', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(adjustConnectionStringsElement, restoreRequest.adjustConnectionStrings.toString());
      js2xml.addChildElement(restoreRequestElement, adjustConnectionStringsElement);
    }
    
    if (restoreRequest.blobName !== null && restoreRequest.blobName !== undefined) {
      var blobNameElement = js2xml.createElement('BlobName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(blobNameElement, restoreRequest.blobName);
      js2xml.addChildElement(restoreRequestElement, blobNameElement);
    }
    
    if (restoreRequest.databases !== null && restoreRequest.databases !== undefined) {
      var databasesSequenceElement = js2xml.createElement('Databases', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < restoreRequest.databases.length; loweredIndex1 = loweredIndex1 + 1) {
        var databasesItem = restoreRequest.databases[loweredIndex1];
        var databaseBackupSettingElement = js2xml.createElement('DatabaseBackupSetting', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(databasesSequenceElement, databaseBackupSettingElement);
        
        if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
          var connectionStringElement = js2xml.createElement('ConnectionString', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringElement, databasesItem.connectionString);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringElement);
        }
        
        if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
          var connectionStringNameElement = js2xml.createElement('ConnectionStringName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringNameElement, databasesItem.connectionStringName);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringNameElement);
        }
        
        if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
          var databaseTypeElement = js2xml.createElement('DatabaseType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(databaseTypeElement, databasesItem.databaseType);
          js2xml.addChildElement(databaseBackupSettingElement, databaseTypeElement);
        }
        
        if (databasesItem.name !== null && databasesItem.name !== undefined) {
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, databasesItem.name);
          js2xml.addChildElement(databaseBackupSettingElement, nameElement);
        }
      }
      js2xml.addChildElement(restoreRequestElement, databasesSequenceElement);
    }
    
    if (restoreRequest.ignoreConflictingHostNames !== null && restoreRequest.ignoreConflictingHostNames !== undefined) {
      var ignoreConflictingHostNamesElement = js2xml.createElement('IgnoreConflictingHostNames', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(ignoreConflictingHostNamesElement, restoreRequest.ignoreConflictingHostNames.toString());
      js2xml.addChildElement(restoreRequestElement, ignoreConflictingHostNamesElement);
    }
    
    if (restoreRequest.overwrite !== null && restoreRequest.overwrite !== undefined) {
      var overwriteElement = js2xml.createElement('Overwrite', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(overwriteElement, restoreRequest.overwrite.toString());
      js2xml.addChildElement(restoreRequestElement, overwriteElement);
    }
    
    if (restoreRequest.storageAccountUrl !== null && restoreRequest.storageAccountUrl !== undefined) {
      var storageAccountUrlElement = js2xml.createElement('StorageAccountUrl', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(storageAccountUrlElement, restoreRequest.storageAccountUrl);
      js2xml.addChildElement(restoreRequestElement, storageAccountUrlElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var restoreResponseElement = js2xml.getElement(responseDoc, responseDoc, 'RESTORERESPONSE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (restoreResponseElement !== null && restoreResponseElement !== undefined) {
            var operationIdElement = js2xml.getElement(responseDoc, restoreResponseElement, 'OPERATIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (operationIdElement !== null && operationIdElement !== undefined) {
              var operationIdInstance = operationIdElement;
              result.operationId = operationIdInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can swap a web site from one slot to another slot.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} sourceSlotName The name of the first web site slot to swap
   * (source).
   * 
   * @param {string} targetSlotName The name of the second web site slot to
   * swap with (target).
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.swapSlots = function(webSpaceName, webSiteName, sourceSlotName, targetSlotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    var client2 = this.client;
    
    return client2.webSites.beginSwappingSlots(webSpaceName, webSiteName, sourceSlotName, targetSlotName, function (err, result) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      if (result.status === 'Succeeded') {
        return callback(null, result);
      }
      var delayInSeconds = 30;
      if (client2.longRunningOperationInitialTimeout >= 0) {
        delayInSeconds = client2.longRunningOperationInitialTimeout;
      }
      
      var pollOperation = function () {
        setTimeout(function () {
          return client2.getOperationStatus(webSpaceName, webSiteName, result.operationId, function (err2, result2) {
            if (err2 !== null && err2 !== undefined) {
              return callback(err2);
            } else {
              if (result2.status !== 'InProgress') {
                if (result2.status !== 'Succeeded') {
                  if (result2.errors !== null && result2.errors !== undefined && result2.errors.length > 0) {
                    var ex = new Error(result2.errors[0].code + ' : ' + result2.errors[0].message);
                    ex.error = new Error();
                    ex.error.code = result2.errors[0].code;
                    ex.error.message = result2.errors[0].message;
                    return callback(ex);
                  } else {
                    var ex = new Error('');
                    return callback(ex);
                  }
                }
                
                return callback(null, result2);
              } else {
                delayInSeconds = 30;
                if (client2.longRunningOperationRetryTimeout >= 0) {
                  delayInSeconds = client2.longRunningOperationRetryTimeout;
                }
                pollOperation();
              }
            }
          });
        }, delayInSeconds * 1000);
      };
      
      pollOperation();
    });
  };
  
  /**
   * A web site repository is essentially a Git repository that you can use to
   * manage your web site content. By using Git source control tools, you can
   * push or pull version-controlled changes to your site. This API executes a
   * repository sync operation.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.syncRepository = function(webSpaceName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/repository';
    var queryParameters = [];
    queryParameters.push('action=sync');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Length'] = '0';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can update the settings for a web site by using the HTTP PUT method
   * and by specifying the settings in the request body.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn167005.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {WebSiteUpdateParameters} parameters Parameters supplied to the
   * Update Web Site operation.
   * 
   * @param {array} [parameters.hostNameSslStates] SSL states of host names
   * bound to the web site.
   * 
   * @param {array} [parameters.hostNames] An array of strings that contains
   * the public host names for the web site, including custom domains.
   * Important: When you add a custom domain in a PUT operation, be sure to
   * include every host name that you want for the web site. To delete a
   * custom domain name in a PUT operation, include all of the host names for
   * the web site that you want to keep, but leave out the one that you want
   * to delete.
   * 
   * @param {string} [parameters.serverFarm] String specifying the Server Farm
   * (Web Hosting Plan) where to place the site. Server Farm must exist.
   * 
   * @param {string} [parameters.state] A string that describes the state of
   * the web site. Possible values include Stopped, Running, or QuotaExceeded.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.update = function(webSpaceName, webSiteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.hostNameSslStates !== null && parameters.hostNameSslStates !== undefined) {
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.hostNameSslStates.length; loweredIndex1 = loweredIndex1 + 1) {
        var hostNameSslStatesParameterItem = parameters.hostNameSslStates[loweredIndex1];
        if (hostNameSslStatesParameterItem.name === null || hostNameSslStatesParameterItem.name === undefined) {
          return callback(new Error('parameters.hostNameSslStates. cannot be null.'));
        }
        if (hostNameSslStatesParameterItem.sslState === null || hostNameSslStatesParameterItem.sslState === undefined) {
          return callback(new Error('parameters.hostNameSslStates. cannot be null.'));
        }
        if (hostNameSslStatesParameterItem.toUpdate === null || hostNameSslStatesParameterItem.toUpdate === undefined) {
          return callback(new Error('parameters.hostNameSslStates. cannot be null.'));
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var siteElement = js2xml.createElement('Site', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, siteElement);
    
    if (parameters.hostNameSslStates !== null && parameters.hostNameSslStates !== undefined) {
      var hostNameSslStatesSequenceElement = js2xml.createElement('HostNameSslStates', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.hostNameSslStates.length; loweredIndex2 = loweredIndex2 + 1) {
        var hostNameSslStatesItem = parameters.hostNameSslStates[loweredIndex2];
        var webSiteHostNameSslStateElement = js2xml.createElement('WebSiteHostNameSslState', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(hostNameSslStatesSequenceElement, webSiteHostNameSslStateElement);
        
        var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(nameElement, hostNameSslStatesItem.name);
        js2xml.addChildElement(webSiteHostNameSslStateElement, nameElement);
        
        var sslStateElement = js2xml.createElement('SslState', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(sslStateElement, hostNameSslStatesItem.sslState !== null && hostNameSslStatesItem.sslState !== undefined ? hostNameSslStatesItem.sslState.toString() : 'Disabled');
        js2xml.addChildElement(webSiteHostNameSslStateElement, sslStateElement);
        
        if (hostNameSslStatesItem.thumbprint !== null && hostNameSslStatesItem.thumbprint !== undefined) {
          var thumbprintElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(thumbprintElement, hostNameSslStatesItem.thumbprint);
          js2xml.addChildElement(webSiteHostNameSslStateElement, thumbprintElement);
        }
        else if (hostNameSslStatesItem.thumbprint !== undefined) {
          var emptyElement = js2xml.createElement('Thumbprint', 'http://schemas.microsoft.com/windowsazure');
          var nilAttribute = js2xml.createAttribute('nil', 'http://www.w3.org/2001/XMLSchema-instance');
          js2xml.setAttributeValue(nilAttribute, 'true');
          js2xml.addAttribute(emptyElement, nilAttribute);
          js2xml.addChildElement(webSiteHostNameSslStateElement, emptyElement);
        }
        
        var toUpdateElement = js2xml.createElement('ToUpdate', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(toUpdateElement, 'true');
        js2xml.addChildElement(webSiteHostNameSslStateElement, toUpdateElement);
      }
      js2xml.addChildElement(siteElement, hostNameSslStatesSequenceElement);
    }
    
    if (parameters.hostNames !== null && parameters.hostNames !== undefined) {
      var hostNamesSequenceElement = js2xml.createElement('HostNames', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex3 = 0; loweredIndex3 < parameters.hostNames.length; loweredIndex3 = loweredIndex3 + 1) {
        var hostNamesItem = parameters.hostNames[loweredIndex3];
        var hostNamesItemElement = js2xml.createElement('string', 'http://schemas.microsoft.com/2003/10/Serialization/Arrays');
        js2xml.setElementValue(hostNamesItemElement, hostNamesItem);
        js2xml.addChildElement(hostNamesSequenceElement, hostNamesItemElement);
      }
      js2xml.addChildElement(siteElement, hostNamesSequenceElement);
    }
    
    if (parameters.serverFarm !== null && parameters.serverFarm !== undefined) {
      var serverFarmElement = js2xml.createElement('ServerFarm', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(serverFarmElement, parameters.serverFarm);
      js2xml.addChildElement(siteElement, serverFarmElement);
    }
    
    if (parameters.state !== null && parameters.state !== undefined) {
      var stateElement = js2xml.createElement('State', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(stateElement, parameters.state);
      js2xml.addChildElement(siteElement, stateElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var siteElement2 = js2xml.getElement(responseDoc, responseDoc, 'SITE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (siteElement2 !== null && siteElement2 !== undefined) {
            var webSiteInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [] };
            result.webSite = webSiteInstance;
            
            var adminEnabledElement = js2xml.getElement(responseDoc, siteElement2, 'ADMINENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (adminEnabledElement !== null && adminEnabledElement !== undefined && adminEnabledElement.length !== 0) {
              var adminEnabledInstance = adminEnabledElement === 'true';
              webSiteInstance.adminEnabled = adminEnabledInstance;
            }
            
            var availabilityStateElement = js2xml.getElement(responseDoc, siteElement2, 'AVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (availabilityStateElement !== null && availabilityStateElement !== undefined && availabilityStateElement.length !== 0) {
              var availabilityStateInstance = availabilityStateElement;
              webSiteInstance.availabilityState = availabilityStateInstance;
            }
            
            var sKUElement = js2xml.getElement(responseDoc, siteElement2, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sKUElement !== null && sKUElement !== undefined && sKUElement.length !== 0) {
              var sKUInstance = sKUElement;
              webSiteInstance.sku = sKUInstance;
            }
            
            var enabledElement = js2xml.getElement(responseDoc, siteElement2, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
              var enabledInstance = enabledElement === 'true';
              webSiteInstance.enabled = enabledInstance;
            }
            
            var enabledHostNamesSequenceElement = js2xml.getElement(responseDoc, siteElement2, 'ENABLEDHOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (enabledHostNamesSequenceElement !== null && enabledHostNamesSequenceElement !== undefined) {
              for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex4 = loweredIndex4 + 1) {
                var enabledHostNamesElement = js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex4];
                webSiteInstance.enabledHostNames.push(enabledHostNamesElement);
              }
            }
            
            var hostNameSslStatesSequenceElement2 = js2xml.getElement(responseDoc, siteElement2, 'HOSTNAMESSLSTATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostNameSslStatesSequenceElement2 !== null && hostNameSslStatesSequenceElement2 !== undefined) {
              for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement2, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                var hostNameSslStatesElement = js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement2, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                var hostNameSslStateInstance = {};
                webSiteInstance.hostNameSslStates.push(hostNameSslStateInstance);
                
                var nameElement2 = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (nameElement2 !== null && nameElement2 !== undefined) {
                  var nameInstance = nameElement2;
                  hostNameSslStateInstance.name = nameInstance;
                }
                
                var sslStateElement2 = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'SSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (sslStateElement2 !== null && sslStateElement2 !== undefined && sslStateElement2.length !== 0) {
                  var sslStateInstance = sslStateElement2;
                  hostNameSslStateInstance.sslState = sslStateInstance;
                }
                
                var thumbprintElement2 = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (thumbprintElement2 !== null && thumbprintElement2 !== undefined) {
                  var isNil = false;
                  var nilAttribute2 = js2xml.getAttribute(responseDoc, thumbprintElement2, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                  if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                    isNil = nilAttribute2 === 'true';
                  }
                  if (isNil === false) {
                    var thumbprintInstance = thumbprintElement2;
                    hostNameSslStateInstance.thumbprint = thumbprintInstance;
                  }
                }
                
                var virtualIPElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (virtualIPElement !== null && virtualIPElement !== undefined) {
                  var isNil2 = false;
                  var nilAttribute3 = js2xml.getAttribute(responseDoc, virtualIPElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                  if (nilAttribute3 !== null && nilAttribute3 !== undefined) {
                    isNil2 = nilAttribute3 === 'true';
                  }
                  if (isNil2 === false) {
                    var virtualIPInstance = virtualIPElement;
                    hostNameSslStateInstance.virtualIP = virtualIPInstance;
                  }
                }
              }
            }
            
            var hostNamesSequenceElement2 = js2xml.getElement(responseDoc, siteElement2, 'HOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (hostNamesSequenceElement2 !== null && hostNamesSequenceElement2 !== undefined) {
              for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, hostNamesSequenceElement2, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex6 = loweredIndex6 + 1) {
                var hostNamesElement = js2xml.getElements(responseDoc, hostNamesSequenceElement2, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex6];
                webSiteInstance.hostNames.push(hostNamesElement);
              }
            }
            
            var lastModifiedTimeUtcElement = js2xml.getElement(responseDoc, siteElement2, 'LASTMODIFIEDTIMEUTC', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (lastModifiedTimeUtcElement !== null && lastModifiedTimeUtcElement !== undefined && lastModifiedTimeUtcElement.length !== 0) {
              var lastModifiedTimeUtcInstance = new Date(lastModifiedTimeUtcElement);
              webSiteInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;
            }
            
            var nameElement3 = js2xml.getElement(responseDoc, siteElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement3 !== null && nameElement3 !== undefined) {
              var nameInstance2 = nameElement3;
              webSiteInstance.name = nameInstance2;
            }
            
            var repositorySiteNameElement = js2xml.getElement(responseDoc, siteElement2, 'REPOSITORYSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (repositorySiteNameElement !== null && repositorySiteNameElement !== undefined) {
              var repositorySiteNameInstance = repositorySiteNameElement;
              webSiteInstance.repositorySiteName = repositorySiteNameInstance;
            }
            
            var runtimeAvailabilityStateElement = js2xml.getElement(responseDoc, siteElement2, 'RUNTIMEAVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (runtimeAvailabilityStateElement !== null && runtimeAvailabilityStateElement !== undefined && runtimeAvailabilityStateElement.length !== 0) {
              var runtimeAvailabilityStateInstance = runtimeAvailabilityStateElement;
              webSiteInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;
            }
            
            var selfLinkElement = js2xml.getElement(responseDoc, siteElement2, 'SELFLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (selfLinkElement !== null && selfLinkElement !== undefined) {
              var selfLinkInstance = selfLinkElement;
              webSiteInstance.uri = selfLinkInstance;
            }
            
            var serverFarmElement2 = js2xml.getElement(responseDoc, siteElement2, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (serverFarmElement2 !== null && serverFarmElement2 !== undefined) {
              var serverFarmInstance = serverFarmElement2;
              webSiteInstance.serverFarm = serverFarmInstance;
            }
            
            var sitePropertiesElement = js2xml.getElement(responseDoc, siteElement2, 'SITEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (sitePropertiesElement !== null && sitePropertiesElement !== undefined) {
              var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };
              webSiteInstance.siteProperties = sitePropertiesInstance;
              
              var appSettingsSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'APPSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
                for (var loweredIndex7 = 0; loweredIndex7 < js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex7 = loweredIndex7 + 1) {
                  var appSettingsElement = js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex7];
                  var appSettingsKey = js2xml.getElement(responseDoc, appSettingsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var appSettingsValue = js2xml.getElement(responseDoc, appSettingsElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
                }
              }
              
              var metadataSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'METADATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
                for (var loweredIndex8 = 0; loweredIndex8 < js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex8 = loweredIndex8 + 1) {
                  var metadataElement = js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex8];
                  var metadataKey = js2xml.getElement(responseDoc, metadataElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var metadataValue = js2xml.getElement(responseDoc, metadataElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.metadata[metadataKey] = metadataValue;
                }
              }
              
              var propertiesSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'PROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {
                for (var loweredIndex9 = 0; loweredIndex9 < js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex9 = loweredIndex9 + 1) {
                  var propertiesElement = js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex9];
                  var propertiesKey = js2xml.getElement(responseDoc, propertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  var propertiesValue = js2xml.getElement(responseDoc, propertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  sitePropertiesInstance.properties[propertiesKey] = propertiesValue;
                }
              }
            }
            
            var stateElement2 = js2xml.getElement(responseDoc, siteElement2, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (stateElement2 !== null && stateElement2 !== undefined) {
              var stateInstance = stateElement2;
              webSiteInstance.state = stateInstance;
            }
            
            var usageStateElement = js2xml.getElement(responseDoc, siteElement2, 'USAGESTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (usageStateElement !== null && usageStateElement !== undefined && usageStateElement.length !== 0) {
              var usageStateInstance = usageStateElement;
              webSiteInstance.usageState = usageStateInstance;
            }
            
            var webSpaceElement = js2xml.getElement(responseDoc, siteElement2, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (webSpaceElement !== null && webSpaceElement !== undefined) {
              var webSpaceInstance = webSpaceElement;
              webSiteInstance.webSpace = webSpaceInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates a backup schedule for a site.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {BackupRequest} backupRequest A backup schedule specification.
   * 
   * @param {BackupSchedule} [backupRequest.backupSchedule] The backup schedule
   * structure - valid only when setting up a schedule. Should be Null for
   * on-demand backups.
   * 
   * @param {number} [backupRequest.backupSchedule.frequencyInterval] The
   * frequency of backups.
   * 
   * @param {FrequencyUnit} [backupRequest.backupSchedule.frequencyUnit] Units
   * for FrequencyInterval - e.g. Day or Hour
   * 
   * @param {boolean} [backupRequest.backupSchedule.keepAtLeastOneBackup]
   * Retention policy deletes backups after predefined number of days. If this
   * is true, there will be always at least one backup left. regardless of the
   * policy. If false, all backups can be deleted.
   * 
   * @param {date} [backupRequest.backupSchedule.lastExecutionTime] The last
   * time when this schedule started a backup, Null if didn't start anything
   * yet.
   * 
   * @param {number} [backupRequest.backupSchedule.retentionPeriodInDays]
   * Backups older N days (N defined by this value) will be automatically
   * deleted.
   * 
   * @param {date} [backupRequest.backupSchedule.startTime] When this schedule
   * should start backing up the site. Null means immediately.
   * 
   * @param {IEnumerable} [backupRequest.databases] Database settings for
   * backup.
   * 
   * @param {boolean} [backupRequest.enabled] Valid only for a backup schedule
   * (can be Null for on-demand backups). True if enabled; false if disabled
   * (no backups will be performed).
   * 
   * @param {string} [backupRequest.name] The name of this backup - will be
   * used for generating a blob name.
   * 
   * @param {string} [backupRequest.storageAccountUrl] SAS URL for a container
   * in a storage account. E.g.
   * 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=abcdefABCDEFabcdef0123456789
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateBackupConfiguration = function(webSpaceName, webSiteName, backupRequest, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (backupRequest === null || backupRequest === undefined) {
      return callback(new Error('backupRequest cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/backup/config';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var backupRequestElement = js2xml.createElement('BackupRequest', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, backupRequestElement);
    
    if (backupRequest.backupSchedule !== null && backupRequest.backupSchedule !== undefined) {
      var backupScheduleElement = js2xml.createElement('BackupSchedule', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(backupRequestElement, backupScheduleElement);
      
      if (backupRequest.backupSchedule.frequencyInterval !== null && backupRequest.backupSchedule.frequencyInterval !== undefined) {
        var frequencyIntervalElement = js2xml.createElement('FrequencyInterval', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(frequencyIntervalElement, backupRequest.backupSchedule.frequencyInterval.toString());
        js2xml.addChildElement(backupScheduleElement, frequencyIntervalElement);
      }
      
      if (backupRequest.backupSchedule.frequencyUnit !== null && backupRequest.backupSchedule.frequencyUnit !== undefined) {
        var frequencyUnitElement = js2xml.createElement('FrequencyUnit', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(frequencyUnitElement, backupRequest.backupSchedule.frequencyUnit !== null && backupRequest.backupSchedule.frequencyUnit !== undefined ? backupRequest.backupSchedule.frequencyUnit.toString() : 'Day');
        js2xml.addChildElement(backupScheduleElement, frequencyUnitElement);
      }
      
      if (backupRequest.backupSchedule.keepAtLeastOneBackup !== null && backupRequest.backupSchedule.keepAtLeastOneBackup !== undefined) {
        var keepAtLeastOneBackupElement = js2xml.createElement('KeepAtLeastOneBackup', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(keepAtLeastOneBackupElement, backupRequest.backupSchedule.keepAtLeastOneBackup.toString());
        js2xml.addChildElement(backupScheduleElement, keepAtLeastOneBackupElement);
      }
      
      if (backupRequest.backupSchedule.lastExecutionTime !== null && backupRequest.backupSchedule.lastExecutionTime !== undefined) {
        var lastExecutionTimeElement = js2xml.createElement('LastExecutionTime', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(lastExecutionTimeElement, backupRequest.backupSchedule.lastExecutionTime.toISOString());
        js2xml.addChildElement(backupScheduleElement, lastExecutionTimeElement);
      }
      
      if (backupRequest.backupSchedule.retentionPeriodInDays !== null && backupRequest.backupSchedule.retentionPeriodInDays !== undefined) {
        var retentionPeriodInDaysElement = js2xml.createElement('RetentionPeriodInDays', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(retentionPeriodInDaysElement, backupRequest.backupSchedule.retentionPeriodInDays.toString());
        js2xml.addChildElement(backupScheduleElement, retentionPeriodInDaysElement);
      }
      
      if (backupRequest.backupSchedule.startTime !== null && backupRequest.backupSchedule.startTime !== undefined) {
        var startTimeElement = js2xml.createElement('StartTime', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(startTimeElement, backupRequest.backupSchedule.startTime.toISOString());
        js2xml.addChildElement(backupScheduleElement, startTimeElement);
      }
    }
    
    if (backupRequest.databases !== null && backupRequest.databases !== undefined) {
      var databasesSequenceElement = js2xml.createElement('Databases', 'http://schemas.microsoft.com/windowsazure');
      for (var loweredIndex1 = 0; loweredIndex1 < backupRequest.databases.length; loweredIndex1 = loweredIndex1 + 1) {
        var databasesItem = backupRequest.databases[loweredIndex1];
        var databaseBackupSettingElement = js2xml.createElement('DatabaseBackupSetting', 'http://schemas.microsoft.com/windowsazure');
        js2xml.addChildElement(databasesSequenceElement, databaseBackupSettingElement);
        
        if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
          var connectionStringElement = js2xml.createElement('ConnectionString', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringElement, databasesItem.connectionString);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringElement);
        }
        
        if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
          var connectionStringNameElement = js2xml.createElement('ConnectionStringName', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(connectionStringNameElement, databasesItem.connectionStringName);
          js2xml.addChildElement(databaseBackupSettingElement, connectionStringNameElement);
        }
        
        if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
          var databaseTypeElement = js2xml.createElement('DatabaseType', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(databaseTypeElement, databasesItem.databaseType);
          js2xml.addChildElement(databaseBackupSettingElement, databaseTypeElement);
        }
        
        if (databasesItem.name !== null && databasesItem.name !== undefined) {
          var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
          js2xml.setElementValue(nameElement, databasesItem.name);
          js2xml.addChildElement(databaseBackupSettingElement, nameElement);
        }
      }
      js2xml.addChildElement(backupRequestElement, databasesSequenceElement);
    }
    
    if (backupRequest.enabled !== null && backupRequest.enabled !== undefined) {
      var enabledElement = js2xml.createElement('Enabled', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(enabledElement, backupRequest.enabled.toString());
      js2xml.addChildElement(backupRequestElement, enabledElement);
    }
    
    if (backupRequest.name !== null && backupRequest.name !== undefined) {
      var nameElement2 = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(nameElement2, backupRequest.name);
      js2xml.addChildElement(backupRequestElement, nameElement2);
    }
    
    if (backupRequest.storageAccountUrl !== null && backupRequest.storageAccountUrl !== undefined) {
      var storageAccountUrlElement = js2xml.createElement('StorageAccountUrl', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(storageAccountUrlElement, backupRequest.storageAccountUrl);
      js2xml.addChildElement(backupRequestElement, storageAccountUrlElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can update the config settings for a web site by issuing an HTTP PUT
   * with a request body containing the updated settings.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {WebSiteUpdateConfigurationParameters} parameters Parameters
   * supplied to the Update Configuration Web Site operation.
   * 
   * @param {object} [parameters.appSettings] A set of name/value pairs that
   * contain application settings for a web site.
   * 
   * @param {array} [parameters.connectionStrings] The connection strings for
   * database and other external resources.
   * 
   * @param {array} [parameters.defaultDocuments] One or more string elements
   * that list, in order of preference, the name of the file that a web site
   * returns when the web site's domain name is requested by itself. For
   * example, if the default document for http://contoso.com is default.htm,
   * the page http://www.contoso.com/default.htm is returned when the browser
   * is pointed to http://www.contoso.com.
   * 
   * @param {boolean} [parameters.detailedErrorLoggingEnabled] Indicates if
   * detailed error logging is enabled.
   * 
   * @param {string} [parameters.documentRoot] The document root.
   * 
   * @param {array} [parameters.handlerMappings] Specifies custom executable
   * programs for handling requests for specific file name extensions.
   * 
   * @param {boolean} [parameters.httpLoggingEnabled] Indicates if HTTP error
   * logging is enabled.
   * 
   * @param {number} [parameters.logsDirectorySizeLimit] The size limit of the
   * logs directory.
   * 
   * @param {ManagedPipelineMode} [parameters.managedPipelineMode] The managed
   * pipeline mode.
   * 
   * @param {object} [parameters.metadata] Name/value pairs for source control
   * or other information.
   * 
   * @param {string} [parameters.netFrameworkVersion] The .NET Framework
   * version. Supported values are v2.0 and v4.0.
   * 
   * @param {number} [parameters.numberOfWorkers] The number of web workers
   * allotted to the web site. If the web site mode is Free, this value is 1.
   * If the web site mode is Shared, this value can range from 1 through 6. If
   * the web site mode is Standard, this value can range from 1 through 10.
   * 
   * @param {string} [parameters.phpVersion] The web site PHP version.
   * Supported values are an empty string (an empty string disables PHP), 5.3,
   * and 5.4.
   * 
   * @param {boolean} [parameters.remoteDebuggingEnabled] Indicates if remote
   * debugging is enabled.
   * 
   * @param {string} [parameters.remoteDebuggingVersion] The remote debugging
   * version.
   * 
   * @param {boolean} [parameters.requestTracingEnabled] Indicates if request
   * tracing is enabled.
   * 
   * @param {date} [parameters.requestTracingExpirationTime] Time remaining
   * until request tracing expires.
   * 
   * @param {string} [parameters.scmType] The source control method that the
   * web site is using (for example, Local Git). If deployment from source
   * control has not been set up for the web site, this value is None.
   * 
   * @param {boolean} [parameters.use32BitWorkerProcess] Indicates if 32-bit
   * mode is enabled.
   * 
   * @param {boolean} [parameters.webSocketsEnabled] Indicates if Web Sockets
   * are enabled.
   * 
   * @param {boolean} [parameters.alwaysOn] Indicates if site's Always On
   * feature enabled.
   * 
   * @param {array} [parameters.routingRules] List of routing rules for the
   * website.
   * 
   * @param {string} [parameters.javaVersion] The web site JDK version.
   * Supported values are an empty string (an empty string disables Java),
   * 1.7.0_51
   * 
   * @param {string} [parameters.javaContainer] The web site Java Container.
   * Supported values are TOMCAT, JETTY
   * 
   * @param {string} [parameters.javaContainerVersion] The web site Java
   * Container Version. Supported values are 7.0.50 if Java Container is
   * TOMCAT and 9.1.0.20131115 if Java Container is JETTY
   * 
   * @param {string} [parameters.autoSwapSlotName] Sets the slot name to swap
   * with after successful deployment.
   * 
   * @param {boolean} [parameters.siteAuthEnabled] Gets or sets a value
   * indicating whether the site's Authentication / Authorization feature is
   * enabled.
   * 
   * @param {SiteAuthSettings} [parameters.siteAuthSettings] Gets or sets the
   * Authentication / Authorization settings of a web site.
   * 
   * @param {string} [parameters.siteAuthSettings.aADClientId] Gets or sets the
   * OpenID Connection client_id value for the web site.
   * 
   * @param {string} [parameters.siteAuthSettings.openIdIssuer] Gets or sets
   * the OpenID Connect issuer URL value for the web site.
   * 
   * @param {SiteLimits} [parameters.limits] The per site limits.
   * 
   * @param {number} [parameters.limits.maxPercentageCpu] The name of the pair.
   * 
   * @param {number} [parameters.limits.maxMemoryInMb] Maximum memory allowed
   * in MB
   * 
   * @param {number} [parameters.limits.maxDiskSizeInMb] Maximum disk size
   * allowed in MB
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateConfiguration = function(webSpaceName, webSiteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/config';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Accept'] = 'application/json';
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteUpdateConfigurationParametersValue = {};
    requestDoc = webSiteUpdateConfigurationParametersValue;
    
    if (parameters.appSettings !== null && parameters.appSettings !== undefined) {
      var appSettingsDictionary = [];
      for (var appSettingsKey in parameters.appSettings) {
        var appSettingsValue = parameters.appSettings[appSettingsKey];
        var appSettingsItemObject = {};
        appSettingsItemObject['Name'] = appSettingsKey;
        appSettingsItemObject['Value'] = appSettingsValue;
        appSettingsDictionary.push(appSettingsItemObject);
      }
      webSiteUpdateConfigurationParametersValue['AppSettings'] = appSettingsDictionary;
    }
    
    if (parameters.connectionStrings !== null && parameters.connectionStrings !== undefined) {
      var connectionStringsArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.connectionStrings.length; loweredIndex1 = loweredIndex1 + 1) {
        var connectionStringsItem = parameters.connectionStrings[loweredIndex1];
        var connectionStringInfoValue = {};
        connectionStringsArray.push(connectionStringInfoValue);
        
        if (connectionStringsItem.connectionString !== null && connectionStringsItem.connectionString !== undefined) {
          connectionStringInfoValue['ConnectionString'] = connectionStringsItem.connectionString;
        }
        
        if (connectionStringsItem.name !== null && connectionStringsItem.name !== undefined) {
          connectionStringInfoValue['Name'] = connectionStringsItem.name;
        }
        
        if (connectionStringsItem.type !== null && connectionStringsItem.type !== undefined) {
          connectionStringInfoValue['Type'] = connectionStringsItem.type;
        }
      }
      webSiteUpdateConfigurationParametersValue['ConnectionStrings'] = connectionStringsArray;
    }
    
    if (parameters.defaultDocuments !== null && parameters.defaultDocuments !== undefined) {
      var defaultDocumentsArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.defaultDocuments.length; loweredIndex2 = loweredIndex2 + 1) {
        var defaultDocumentsItem = parameters.defaultDocuments[loweredIndex2];
        defaultDocumentsArray.push(defaultDocumentsItem);
      }
      webSiteUpdateConfigurationParametersValue['DefaultDocuments'] = defaultDocumentsArray;
    }
    
    if (parameters.detailedErrorLoggingEnabled !== null && parameters.detailedErrorLoggingEnabled !== undefined) {
      webSiteUpdateConfigurationParametersValue['DetailedErrorLoggingEnabled'] = parameters.detailedErrorLoggingEnabled;
    }
    
    if (parameters.documentRoot !== null && parameters.documentRoot !== undefined) {
      webSiteUpdateConfigurationParametersValue['DocumentRoot'] = parameters.documentRoot;
    }
    
    if (parameters.handlerMappings !== null && parameters.handlerMappings !== undefined) {
      var handlerMappingsArray = [];
      for (var loweredIndex3 = 0; loweredIndex3 < parameters.handlerMappings.length; loweredIndex3 = loweredIndex3 + 1) {
        var handlerMappingsItem = parameters.handlerMappings[loweredIndex3];
        var handlerMappingValue = {};
        handlerMappingsArray.push(handlerMappingValue);
        
        if (handlerMappingsItem.arguments !== null && handlerMappingsItem.arguments !== undefined) {
          handlerMappingValue['Arguments'] = handlerMappingsItem.arguments;
        }
        
        if (handlerMappingsItem.extension !== null && handlerMappingsItem.extension !== undefined) {
          handlerMappingValue['Extension'] = handlerMappingsItem.extension;
        }
        
        if (handlerMappingsItem.scriptProcessor !== null && handlerMappingsItem.scriptProcessor !== undefined) {
          handlerMappingValue['ScriptProcessor'] = handlerMappingsItem.scriptProcessor;
        }
      }
      webSiteUpdateConfigurationParametersValue['HandlerMappings'] = handlerMappingsArray;
    }
    
    if (parameters.httpLoggingEnabled !== null && parameters.httpLoggingEnabled !== undefined) {
      webSiteUpdateConfigurationParametersValue['HttpLoggingEnabled'] = parameters.httpLoggingEnabled;
    }
    
    if (parameters.logsDirectorySizeLimit !== null && parameters.logsDirectorySizeLimit !== undefined) {
      webSiteUpdateConfigurationParametersValue['LogsDirectorySizeLimit'] = parameters.logsDirectorySizeLimit;
    }
    
    if (parameters.managedPipelineMode !== null && parameters.managedPipelineMode !== undefined) {
      webSiteUpdateConfigurationParametersValue['ManagedPipelineMode'] = parameters.managedPipelineMode;
    }
    
    if (parameters.metadata !== null && parameters.metadata !== undefined) {
      var metadataDictionary = [];
      for (var metadataKey in parameters.metadata) {
        var metadataValue = parameters.metadata[metadataKey];
        var metadataItemObject = {};
        metadataItemObject['Name'] = metadataKey;
        metadataItemObject['Value'] = metadataValue;
        metadataDictionary.push(metadataItemObject);
      }
      webSiteUpdateConfigurationParametersValue['Metadata'] = metadataDictionary;
    }
    
    if (parameters.netFrameworkVersion !== null && parameters.netFrameworkVersion !== undefined) {
      webSiteUpdateConfigurationParametersValue['NetFrameworkVersion'] = parameters.netFrameworkVersion;
    }
    
    if (parameters.numberOfWorkers !== null && parameters.numberOfWorkers !== undefined) {
      webSiteUpdateConfigurationParametersValue['NumberOfWorkers'] = parameters.numberOfWorkers;
    }
    
    if (parameters.phpVersion !== null && parameters.phpVersion !== undefined) {
      webSiteUpdateConfigurationParametersValue['PhpVersion'] = parameters.phpVersion;
    }
    
    if (parameters.remoteDebuggingEnabled !== null && parameters.remoteDebuggingEnabled !== undefined) {
      webSiteUpdateConfigurationParametersValue['RemoteDebuggingEnabled'] = parameters.remoteDebuggingEnabled;
    }
    
    if (parameters.remoteDebuggingVersion !== null && parameters.remoteDebuggingVersion !== undefined) {
      webSiteUpdateConfigurationParametersValue['RemoteDebuggingVersion'] = parameters.remoteDebuggingVersion;
    }
    
    if (parameters.requestTracingEnabled !== null && parameters.requestTracingEnabled !== undefined) {
      webSiteUpdateConfigurationParametersValue['RequestTracingEnabled'] = parameters.requestTracingEnabled;
    }
    
    if (parameters.requestTracingExpirationTime !== null && parameters.requestTracingExpirationTime !== undefined) {
      webSiteUpdateConfigurationParametersValue['RequestTracingExpirationTime'] = parameters.requestTracingExpirationTime;
    }
    
    if (parameters.scmType !== null && parameters.scmType !== undefined) {
      webSiteUpdateConfigurationParametersValue['ScmType'] = parameters.scmType;
    }
    
    if (parameters.use32BitWorkerProcess !== null && parameters.use32BitWorkerProcess !== undefined) {
      webSiteUpdateConfigurationParametersValue['Use32BitWorkerProcess'] = parameters.use32BitWorkerProcess;
    }
    
    if (parameters.webSocketsEnabled !== null && parameters.webSocketsEnabled !== undefined) {
      webSiteUpdateConfigurationParametersValue['WebSocketsEnabled'] = parameters.webSocketsEnabled;
    }
    
    if (parameters.alwaysOn !== null && parameters.alwaysOn !== undefined) {
      webSiteUpdateConfigurationParametersValue['AlwaysOn'] = parameters.alwaysOn;
    }
    
    if (parameters.routingRules !== null && parameters.routingRules !== undefined) {
      var routingRulesArray = [];
      for (var loweredIndex4 = 0; loweredIndex4 < parameters.routingRules.length; loweredIndex4 = loweredIndex4 + 1) {
        var routingRulesItem = parameters.routingRules[loweredIndex4];
        var routingRuleValue = {};
        routingRulesArray.push(routingRuleValue);
        if (routingRulesItem.type === 'RampUpRule:http://schemas.microsoft.com/windowsazure') {
          routingRuleValue['__type'] = 'RampUpRule:http://schemas.microsoft.com/windowsazure';
          var derived = routingRulesItem;
          
          if (derived.actionHostName !== null && derived.actionHostName !== undefined) {
            routingRuleValue['ActionHostName'] = derived.actionHostName;
          }
          
          if (derived.reroutePercentage !== null && derived.reroutePercentage !== undefined) {
            routingRuleValue['ReroutePercentage'] = derived.reroutePercentage;
          }
          
          if (derived.changeStep !== null && derived.changeStep !== undefined) {
            routingRuleValue['ChangeStep'] = derived.changeStep;
          }
          
          if (derived.changeIntervalInMinutes !== null && derived.changeIntervalInMinutes !== undefined) {
            routingRuleValue['ChangeIntervalInMinutes'] = derived.changeIntervalInMinutes;
          }
          
          if (derived.minReroutePercentage !== null && derived.minReroutePercentage !== undefined) {
            routingRuleValue['MinReroutePercentage'] = derived.minReroutePercentage;
          }
          
          if (derived.maxReroutePercentage !== null && derived.maxReroutePercentage !== undefined) {
            routingRuleValue['MaxReroutePercentage'] = derived.maxReroutePercentage;
          }
          
          if (derived.changeDecisionCallbackUrl !== null && derived.changeDecisionCallbackUrl !== undefined) {
            routingRuleValue['ChangeDecisionCallbackUrl'] = derived.changeDecisionCallbackUrl;
          }
          
          if (derived.name !== null && derived.name !== undefined) {
            routingRuleValue['Name'] = derived.name;
          }
        }
      }
      webSiteUpdateConfigurationParametersValue['RoutingRules'] = routingRulesArray;
    }
    
    if (parameters.javaVersion !== null && parameters.javaVersion !== undefined) {
      webSiteUpdateConfigurationParametersValue['JavaVersion'] = parameters.javaVersion;
    }
    
    if (parameters.javaContainer !== null && parameters.javaContainer !== undefined) {
      webSiteUpdateConfigurationParametersValue['JavaContainer'] = parameters.javaContainer;
    }
    
    if (parameters.javaContainerVersion !== null && parameters.javaContainerVersion !== undefined) {
      webSiteUpdateConfigurationParametersValue['JavaContainerVersion'] = parameters.javaContainerVersion;
    }
    
    if (parameters.autoSwapSlotName !== null && parameters.autoSwapSlotName !== undefined) {
      webSiteUpdateConfigurationParametersValue['AutoSwapSlotName'] = parameters.autoSwapSlotName;
    }
    
    if (parameters.siteAuthEnabled !== null && parameters.siteAuthEnabled !== undefined) {
      webSiteUpdateConfigurationParametersValue['SiteAuthEnabled'] = parameters.siteAuthEnabled;
    }
    
    if (parameters.siteAuthSettings !== null && parameters.siteAuthSettings !== undefined) {
      var siteAuthSettingsValue = {};
      webSiteUpdateConfigurationParametersValue['SiteAuthSettings'] = siteAuthSettingsValue;
      
      if (parameters.siteAuthSettings.aADClientId !== null && parameters.siteAuthSettings.aADClientId !== undefined) {
        siteAuthSettingsValue['AADClientId'] = parameters.siteAuthSettings.aADClientId;
      }
      
      if (parameters.siteAuthSettings.openIdIssuer !== null && parameters.siteAuthSettings.openIdIssuer !== undefined) {
        siteAuthSettingsValue['OpenIdIssuer'] = parameters.siteAuthSettings.openIdIssuer;
      }
    }
    
    if (parameters.limits !== null && parameters.limits !== undefined) {
      var limitsValue = {};
      webSiteUpdateConfigurationParametersValue['limits'] = limitsValue;
      
      if (parameters.limits.maxPercentageCpu !== null && parameters.limits.maxPercentageCpu !== undefined) {
        limitsValue['maxPercentageCpu'] = parameters.limits.maxPercentageCpu;
      }
      
      if (parameters.limits.maxMemoryInMb !== null && parameters.limits.maxMemoryInMb !== undefined) {
        limitsValue['maxMemoryInMb'] = parameters.limits.maxMemoryInMb;
      }
      
      if (parameters.limits.maxDiskSizeInMb !== null && parameters.limits.maxDiskSizeInMb !== undefined) {
        limitsValue['maxDiskSizeInMb'] = parameters.limits.maxDiskSizeInMb;
      }
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates an association to a hybrid connection for a web site.
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} siteName The name of the web site.
   * 
   * @param {HybridConnectionUpdateParameters} parameters Parameters supplied
   * to the Create Hybrid Connection operation.
   * 
   * @param {string} [parameters.biztalkUri] The resource uri of the biztalk
   * service. This field can be left empty; Without it the Azure Portal will
   * not be able to display the biztalk service for this connection properly.
   * 
   * @param {string} [parameters.entityConnectionString] The biztalk
   * application connection string for this connection
   * 
   * @param {string} parameters.entityName The unique name for this connection
   * 
   * @param {string} [parameters.hostname] The hostname of the target
   * on-premise resource
   * 
   * @param {number} [parameters.port] The port of the target on-premise
   * resource
   * 
   * @param {string} [parameters.resourceConnectionString] Reserved for future
   * use. The connection string for the resource. This field can be left empty.
   * 
   * @param {string} [parameters.resourceType] Reserved for future use. The
   * type of resource to be connected. This field can be left empty.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateHybridConnection = function(webSpaceName, siteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (siteName === null || siteName === undefined) {
      return callback(new Error('siteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.entityName === null || parameters.entityName === undefined) {
      return callback(new Error('parameters.entityName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(siteName);
    url2 = url2 + '/hybridconnection';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var relayServiceConnectionEntityElement = js2xml.createElement('RelayServiceConnectionEntity', 'http://schemas.microsoft.com/windowsazure');
    js2xml.addChildElement(requestDoc, relayServiceConnectionEntityElement);
    
    if (parameters.biztalkUri !== null && parameters.biztalkUri !== undefined) {
      var biztalkUriElement = js2xml.createElement('BiztalkUri', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(biztalkUriElement, parameters.biztalkUri);
      js2xml.addChildElement(relayServiceConnectionEntityElement, biztalkUriElement);
    }
    
    if (parameters.entityConnectionString !== null && parameters.entityConnectionString !== undefined) {
      var entityConnectionStringElement = js2xml.createElement('EntityConnectionString', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(entityConnectionStringElement, parameters.entityConnectionString);
      js2xml.addChildElement(relayServiceConnectionEntityElement, entityConnectionStringElement);
    }
    
    var entityNameElement = js2xml.createElement('EntityName', 'http://schemas.microsoft.com/windowsazure');
    js2xml.setElementValue(entityNameElement, parameters.entityName);
    js2xml.addChildElement(relayServiceConnectionEntityElement, entityNameElement);
    
    if (parameters.hostname !== null && parameters.hostname !== undefined) {
      var hostnameElement = js2xml.createElement('Hostname', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(hostnameElement, parameters.hostname);
      js2xml.addChildElement(relayServiceConnectionEntityElement, hostnameElement);
    }
    
    if (parameters.port !== null && parameters.port !== undefined) {
      var portElement = js2xml.createElement('Port', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(portElement, parameters.port.toString());
      js2xml.addChildElement(relayServiceConnectionEntityElement, portElement);
    }
    
    if (parameters.resourceConnectionString !== null && parameters.resourceConnectionString !== undefined) {
      var resourceConnectionStringElement = js2xml.createElement('ResourceConnectionString', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(resourceConnectionStringElement, parameters.resourceConnectionString);
      js2xml.addChildElement(relayServiceConnectionEntityElement, resourceConnectionStringElement);
    }
    
    if (parameters.resourceType !== null && parameters.resourceType !== undefined) {
      var resourceTypeElement = js2xml.createElement('ResourceType', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(resourceTypeElement, parameters.resourceType);
      js2xml.addChildElement(relayServiceConnectionEntityElement, resourceTypeElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {SlotConfigNamesUpdate} parameters The parameters.
   * 
   * @param {array} [parameters.connectionStringNames] One or more string
   * elements that list the name of the connection string setting that will
   * not be moved durig site swap. For example, if slot named staging has
   * connection UsersDatabase that points to staging test database, it
   * shouldn't be moved when swapped with production slot but should take the
   * current value from production.
   * 
   * @param {array} [parameters.appSettingNames] One or more string elements
   * that list the name of the app setting that will not be moved durig site
   * swap. For example, if slot named staging has setting
   * EnableVerboseLogging=1, it shouldn't be moved when swapped with
   * production slot but should take the current value from production.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateSlotConfigNames = function(webSpaceName, webSiteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/slotConfigNames';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['accept'] = 'application/json';
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var slotConfigNamesUpdateValue = {};
    requestDoc = slotConfigNamesUpdateValue;
    
    if (parameters.connectionStringNames !== null && parameters.connectionStringNames !== undefined) {
      var connectionStringNamesArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.connectionStringNames.length; loweredIndex1 = loweredIndex1 + 1) {
        var connectionStringNamesItem = parameters.connectionStringNames[loweredIndex1];
        connectionStringNamesArray.push(connectionStringNamesItem);
      }
      slotConfigNamesUpdateValue['ConnectionStringNames'] = connectionStringNamesArray;
    }
    
    if (parameters.appSettingNames !== null && parameters.appSettingNames !== undefined) {
      var appSettingNamesArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.appSettingNames.length; loweredIndex2 = loweredIndex2 + 1) {
        var appSettingNamesItem = parameters.appSettingNames[loweredIndex2];
        appSettingNamesArray.push(appSettingNamesItem);
      }
      slotConfigNamesUpdateValue['AppSettingNames'] = appSettingNamesArray;
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return WebSiteOperations;
})();

var WebSpaceOperations = ( /** @lends WebSpaceOperations */ function() {
  /**
   * @class
   * Operations for managing web spaces beneath your subscription.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [WebSiteManagementClient] {@link
   * WebSiteManagementClient~WebSiteManagementClient}.
   * See [webSpaces] {@link
   * WebSiteManagementClient~WebSiteManagementClient#webSpaces}.
   * Initializes a new instance of the WebSpaceOperations class.
   * @constructor
   * 
   * @param {WebSiteManagementClient} client Reference to the service client.
   */
  function WebSpaceOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a source control user with permissions to publish to this web
   * space.
   * 
   * @param {string} username The user name.
   * 
   * @param {string} password The user password.
   * 
   * @param {WebSpacesCreatePublishingUserParameters} [parametersOrCallback]
   * Parameters supplied to the Create Publishing User operation.
   * 
   * @param {string} [parametersOrCallback.name] The publishing user name.
   * 
   * @param {string} [parametersOrCallback.publishingPassword] The publishing
   * user password.
   * 
   * @param {string} [parametersOrCallback.publishingUserName] The publishing
   * user username.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.createPublishingUser = function(username, password, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (username === null || username === undefined) {
      return callback(new Error('username cannot be null.'));
    }
    if (password === null || password === undefined) {
      return callback(new Error('password cannot be null.'));
    }
    if (parameters !== null && parameters !== undefined) {
      if (parameters.publishingPassword === null || parameters.publishingPassword === undefined) {
        return callback(new Error('parameters.publishingPassword cannot be null.'));
      }
      if (parameters.publishingUserName === null || parameters.publishingUserName === undefined) {
        return callback(new Error('parameters.publishingUserName cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces';
    var queryParameters = [];
    queryParameters.push('properties=publishingCredentials');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    if (parameters !== null && parameters !== undefined) {
      var userElement = js2xml.createElement('User', 'http://schemas.microsoft.com/windowsazure');
      js2xml.addChildElement(requestDoc, userElement);
      
      if (parameters.name !== null && parameters.name !== undefined) {
        var nameElement = js2xml.createElement('Name', 'http://schemas.microsoft.com/windowsazure');
        js2xml.setElementValue(nameElement, parameters.name);
        js2xml.addChildElement(userElement, nameElement);
      }
      
      var publishingPasswordElement = js2xml.createElement('PublishingPassword', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishingPasswordElement, parameters.publishingPassword);
      js2xml.addChildElement(userElement, publishingPasswordElement);
      
      var publishingUserNameElement = js2xml.createElement('PublishingUserName', 'http://schemas.microsoft.com/windowsazure');
      js2xml.setElementValue(publishingUserNameElement, parameters.publishingUserName);
      js2xml.addChildElement(userElement, publishingUserNameElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200 || statusCode === 201) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var userElement2 = js2xml.getElement(responseDoc, responseDoc, 'USER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (userElement2 !== null && userElement2 !== undefined) {
            var nameElement2 = js2xml.getElement(responseDoc, userElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement2 !== null && nameElement2 !== undefined) {
              var nameInstance = nameElement2;
              result.name = nameInstance;
            }
            
            var publishingPasswordElement2 = js2xml.getElement(responseDoc, userElement2, 'PUBLISHINGPASSWORD', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishingPasswordElement2 !== null && publishingPasswordElement2 !== undefined) {
              var publishingPasswordInstance = publishingPasswordElement2;
              result.publishingPassword = publishingPasswordInstance;
            }
            
            var publishingUserNameElement2 = js2xml.getElement(responseDoc, userElement2, 'PUBLISHINGUSERNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (publishingUserNameElement2 !== null && publishingUserNameElement2 !== undefined) {
              var publishingUserNameInstance = publishingUserNameElement2;
              result.publishingUserName = publishingUserNameInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve details for a specified web space name by issuing an HTTP
   * GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn167017.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.get = function(webSpaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var webSpaceElement = js2xml.getElement(responseDoc, responseDoc, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (webSpaceElement !== null && webSpaceElement !== undefined) {
            var availabilityStateElement = js2xml.getElement(responseDoc, webSpaceElement, 'AVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (availabilityStateElement !== null && availabilityStateElement !== undefined && availabilityStateElement.length !== 0) {
              var availabilityStateInstance = availabilityStateElement;
              result.availabilityState = availabilityStateInstance;
            }
            
            var currentNumberOfWorkersElement = js2xml.getElement(responseDoc, webSpaceElement, 'CURRENTNUMBEROFWORKERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (currentNumberOfWorkersElement !== null && currentNumberOfWorkersElement !== undefined && currentNumberOfWorkersElement.length !== 0) {
              var isNil = false;
              var nilAttribute = js2xml.getAttribute(responseDoc, currentNumberOfWorkersElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute !== null && nilAttribute !== undefined) {
                isNil = nilAttribute === 'true';
              }
              if (isNil === false) {
                var currentNumberOfWorkersInstance = parseInt(currentNumberOfWorkersElement, 10);
                result.currentNumberOfWorkers = currentNumberOfWorkersInstance;
              }
            }
            
            var currentWorkerSizeElement = js2xml.getElement(responseDoc, webSpaceElement, 'CURRENTWORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (currentWorkerSizeElement !== null && currentWorkerSizeElement !== undefined && currentWorkerSizeElement.length !== 0) {
              var isNil2 = false;
              var nilAttribute2 = js2xml.getAttribute(responseDoc, currentWorkerSizeElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
              if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                isNil2 = nilAttribute2 === 'true';
              }
              if (isNil2 === false) {
                var currentWorkerSizeInstance = currentWorkerSizeElement;
                result.currentWorkerSize = currentWorkerSizeInstance;
              }
            }
            
            var geoLocationElement = js2xml.getElement(responseDoc, webSpaceElement, 'GEOLOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (geoLocationElement !== null && geoLocationElement !== undefined) {
              var geoLocationInstance = geoLocationElement;
              result.geoLocation = geoLocationInstance;
            }
            
            var geoRegionElement = js2xml.getElement(responseDoc, webSpaceElement, 'GEOREGION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (geoRegionElement !== null && geoRegionElement !== undefined) {
              var geoRegionInstance = geoRegionElement;
              result.geoRegion = geoRegionInstance;
            }
            
            var nameElement = js2xml.getElement(responseDoc, webSpaceElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (nameElement !== null && nameElement !== undefined) {
              var nameInstance = nameElement;
              result.name = nameInstance;
            }
            
            var planElement = js2xml.getElement(responseDoc, webSpaceElement, 'PLAN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (planElement !== null && planElement !== undefined) {
              var planInstance = planElement;
              result.plan = planInstance;
            }
            
            var statusElement = js2xml.getElement(responseDoc, webSpaceElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
            
            var subscriptionElement = js2xml.getElement(responseDoc, webSpaceElement, 'SUBSCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (subscriptionElement !== null && subscriptionElement !== undefined) {
              var subscriptionInstance = subscriptionElement;
              result.subscription = subscriptionInstance;
            }
            
            var workerSizeElement = js2xml.getElement(responseDoc, webSpaceElement, 'WORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (workerSizeElement !== null && workerSizeElement !== undefined && workerSizeElement.length !== 0) {
              var workerSizeInstance = workerSizeElement;
              result.workerSize = workerSizeInstance;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get the DNS Suffix for this subscription.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.getDnsSuffix = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces';
    var queryParameters = [];
    queryParameters.push('properties=dnssuffix');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var stringElement = js2xml.getElement(responseDoc, responseDoc, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/');
          if (stringElement !== null && stringElement !== undefined) {
            result.dnsSuffix = stringElement;
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can list the web spaces under the current subscription by issuing a
   * GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166961.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { webSpaces: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var webSpacesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'WEBSPACES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (webSpacesSequenceElement !== null && webSpacesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, webSpacesSequenceElement, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var webSpacesElement = js2xml.getElements(responseDoc, webSpacesSequenceElement, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var webSpaceInstance = {};
              result.webSpaces.push(webSpaceInstance);
              
              var availabilityStateElement = js2xml.getElement(responseDoc, webSpacesElement, 'AVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (availabilityStateElement !== null && availabilityStateElement !== undefined && availabilityStateElement.length !== 0) {
                var availabilityStateInstance = availabilityStateElement;
                webSpaceInstance.availabilityState = availabilityStateInstance;
              }
              
              var currentNumberOfWorkersElement = js2xml.getElement(responseDoc, webSpacesElement, 'CURRENTNUMBEROFWORKERS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (currentNumberOfWorkersElement !== null && currentNumberOfWorkersElement !== undefined && currentNumberOfWorkersElement.length !== 0) {
                var isNil = false;
                var nilAttribute = js2xml.getAttribute(responseDoc, currentNumberOfWorkersElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                if (nilAttribute !== null && nilAttribute !== undefined) {
                  isNil = nilAttribute === 'true';
                }
                if (isNil === false) {
                  var currentNumberOfWorkersInstance = parseInt(currentNumberOfWorkersElement, 10);
                  webSpaceInstance.currentNumberOfWorkers = currentNumberOfWorkersInstance;
                }
              }
              
              var currentWorkerSizeElement = js2xml.getElement(responseDoc, webSpacesElement, 'CURRENTWORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (currentWorkerSizeElement !== null && currentWorkerSizeElement !== undefined && currentWorkerSizeElement.length !== 0) {
                var isNil2 = false;
                var nilAttribute2 = js2xml.getAttribute(responseDoc, currentWorkerSizeElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                  isNil2 = nilAttribute2 === 'true';
                }
                if (isNil2 === false) {
                  var currentWorkerSizeInstance = currentWorkerSizeElement;
                  webSpaceInstance.currentWorkerSize = currentWorkerSizeInstance;
                }
              }
              
              var geoLocationElement = js2xml.getElement(responseDoc, webSpacesElement, 'GEOLOCATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (geoLocationElement !== null && geoLocationElement !== undefined) {
                var geoLocationInstance = geoLocationElement;
                webSpaceInstance.geoLocation = geoLocationInstance;
              }
              
              var geoRegionElement = js2xml.getElement(responseDoc, webSpacesElement, 'GEOREGION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (geoRegionElement !== null && geoRegionElement !== undefined) {
                var geoRegionInstance = geoRegionElement;
                webSpaceInstance.geoRegion = geoRegionInstance;
              }
              
              var nameElement = js2xml.getElement(responseDoc, webSpacesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                webSpaceInstance.name = nameInstance;
              }
              
              var planElement = js2xml.getElement(responseDoc, webSpacesElement, 'PLAN', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (planElement !== null && planElement !== undefined) {
                var planInstance = planElement;
                webSpaceInstance.plan = planInstance;
              }
              
              var statusElement = js2xml.getElement(responseDoc, webSpacesElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
                var statusInstance = statusElement;
                webSpaceInstance.status = statusInstance;
              }
              
              var subscriptionElement = js2xml.getElement(responseDoc, webSpacesElement, 'SUBSCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (subscriptionElement !== null && subscriptionElement !== undefined) {
                var subscriptionInstance = subscriptionElement;
                webSpaceInstance.subscription = subscriptionInstance;
              }
              
              var workerSizeElement = js2xml.getElement(responseDoc, webSpacesElement, 'WORKERSIZE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (workerSizeElement !== null && workerSizeElement !== undefined && workerSizeElement.length !== 0) {
                var workerSizeInstance = workerSizeElement;
                webSpaceInstance.workerSize = workerSizeInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get the available geo regions for this web space.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.listGeoRegions = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces';
    var queryParameters = [];
    queryParameters.push('properties=georegions');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { geoRegions: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var geoRegionsSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'GEOREGIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (geoRegionsSequenceElement !== null && geoRegionsSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, geoRegionsSequenceElement, 'GEOREGION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var geoRegionsElement = js2xml.getElements(responseDoc, geoRegionsSequenceElement, 'GEOREGION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var geoRegionInstance = {};
              result.geoRegions.push(geoRegionInstance);
              
              var descriptionElement = js2xml.getElement(responseDoc, geoRegionsElement, 'DESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (descriptionElement !== null && descriptionElement !== undefined) {
                var descriptionInstance = descriptionElement;
                geoRegionInstance.description = descriptionInstance;
              }
              
              var nameElement = js2xml.getElement(responseDoc, geoRegionsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement !== null && nameElement !== undefined) {
                var nameInstance = nameElement;
                geoRegionInstance.name = nameInstance;
              }
              
              var sortOrderElement = js2xml.getElement(responseDoc, geoRegionsElement, 'SORTORDER', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sortOrderElement !== null && sortOrderElement !== undefined && sortOrderElement.length !== 0) {
                var isNil = false;
                var nilAttribute = js2xml.getAttribute(responseDoc, sortOrderElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                if (nilAttribute !== null && nilAttribute !== undefined) {
                  isNil = nilAttribute === 'true';
                }
                if (isNil === false) {
                  var sortOrderInstance = parseInt(sortOrderElement, 10);
                  geoRegionInstance.sortOrder = sortOrderInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get the source control users allowed to publish to this web space.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.listPublishingUsers = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces';
    var queryParameters = [];
    queryParameters.push('properties=publishingUsers');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { users: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var arrayOfstringSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'ARRAYOFSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS');
          if (arrayOfstringSequenceElement !== null && arrayOfstringSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, arrayOfstringSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex1 = loweredIndex1 + 1) {
              var arrayOfstringElement = js2xml.getElements(responseDoc, arrayOfstringSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex1];
              var stringInstance = {};
              result.users.push(stringInstance);
              
              var stringInstance2 = arrayOfstringElement;
              stringInstance.name = stringInstance2;
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve a list of all web sites in a web space by issuing an HTTP
   * GET request.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn236429.aspx for
   * more information)
   * 
   * @param {string} webSpaceName The name of the web space.
   * 
   * @param {WebSiteListParameters} [parametersOrCallback] Additional
   * parameters.
   * 
   * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list
   * of the names of any additional parameters to return.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSpaceOperations.prototype.listWebSites = function(webSpaceName, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (webSpaceName === null || webSpaceName === undefined) {
      return callback(new Error('webSpaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/WebSpaces/';
    url2 = url2 + encodeURIComponent(webSpaceName);
    url2 = url2 + '/sites';
    var queryParameters = [];
    if (parameters !== null && parameters !== undefined && parameters.propertiesToInclude !== null && parameters.propertiesToInclude !== undefined && parameters.propertiesToInclude.length > 0) {
      queryParameters.push('propertiesToInclude=' + encodeURIComponent(parameters.propertiesToInclude.join(',')));
    }
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2014-04-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { webSites: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var sitesSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'SITES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (sitesSequenceElement !== null && sitesSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, sitesSequenceElement, 'SITE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex1 = loweredIndex1 + 1) {
              var sitesElement = js2xml.getElements(responseDoc, sitesSequenceElement, 'SITE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex1];
              var siteInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [] };
              result.webSites.push(siteInstance);
              
              var adminEnabledElement = js2xml.getElement(responseDoc, sitesElement, 'ADMINENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (adminEnabledElement !== null && adminEnabledElement !== undefined && adminEnabledElement.length !== 0) {
                var adminEnabledInstance = adminEnabledElement === 'true';
                siteInstance.adminEnabled = adminEnabledInstance;
              }
              
              var availabilityStateElement = js2xml.getElement(responseDoc, sitesElement, 'AVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (availabilityStateElement !== null && availabilityStateElement !== undefined && availabilityStateElement.length !== 0) {
                var availabilityStateInstance = availabilityStateElement;
                siteInstance.availabilityState = availabilityStateInstance;
              }
              
              var sKUElement = js2xml.getElement(responseDoc, sitesElement, 'SKU', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sKUElement !== null && sKUElement !== undefined && sKUElement.length !== 0) {
                var sKUInstance = sKUElement;
                siteInstance.sku = sKUInstance;
              }
              
              var enabledElement = js2xml.getElement(responseDoc, sitesElement, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
                var enabledInstance = enabledElement === 'true';
                siteInstance.enabled = enabledInstance;
              }
              
              var enabledHostNamesSequenceElement = js2xml.getElement(responseDoc, sitesElement, 'ENABLEDHOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (enabledHostNamesSequenceElement !== null && enabledHostNamesSequenceElement !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex2 = loweredIndex2 + 1) {
                  var enabledHostNamesElement = js2xml.getElements(responseDoc, enabledHostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex2];
                  siteInstance.enabledHostNames.push(enabledHostNamesElement);
                }
              }
              
              var hostNameSslStatesSequenceElement = js2xml.getElement(responseDoc, sitesElement, 'HOSTNAMESSLSTATES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostNameSslStatesSequenceElement !== null && hostNameSslStatesSequenceElement !== undefined) {
                for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex3 = loweredIndex3 + 1) {
                  var hostNameSslStatesElement = js2xml.getElements(responseDoc, hostNameSslStatesSequenceElement, 'HOSTNAMESSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex3];
                  var hostNameSslStateInstance = {};
                  siteInstance.hostNameSslStates.push(hostNameSslStateInstance);
                  
                  var nameElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (nameElement !== null && nameElement !== undefined) {
                    var nameInstance = nameElement;
                    hostNameSslStateInstance.name = nameInstance;
                  }
                  
                  var sslStateElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'SSLSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (sslStateElement !== null && sslStateElement !== undefined && sslStateElement.length !== 0) {
                    var sslStateInstance = sslStateElement;
                    hostNameSslStateInstance.sslState = sslStateInstance;
                  }
                  
                  var thumbprintElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'THUMBPRINT', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (thumbprintElement !== null && thumbprintElement !== undefined) {
                    var isNil = false;
                    var nilAttribute = js2xml.getAttribute(responseDoc, thumbprintElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute !== null && nilAttribute !== undefined) {
                      isNil = nilAttribute === 'true';
                    }
                    if (isNil === false) {
                      var thumbprintInstance = thumbprintElement;
                      hostNameSslStateInstance.thumbprint = thumbprintInstance;
                    }
                  }
                  
                  var virtualIPElement = js2xml.getElement(responseDoc, hostNameSslStatesElement, 'VIRTUALIP', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                  if (virtualIPElement !== null && virtualIPElement !== undefined) {
                    var isNil2 = false;
                    var nilAttribute2 = js2xml.getAttribute(responseDoc, virtualIPElement, 'NIL', 'HTTP://WWW.W3.ORG/2001/XMLSCHEMA-INSTANCE');
                    if (nilAttribute2 !== null && nilAttribute2 !== undefined) {
                      isNil2 = nilAttribute2 === 'true';
                    }
                    if (isNil2 === false) {
                      var virtualIPInstance = virtualIPElement;
                      hostNameSslStateInstance.virtualIP = virtualIPInstance;
                    }
                  }
                }
              }
              
              var hostNamesSequenceElement = js2xml.getElement(responseDoc, sitesElement, 'HOSTNAMES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (hostNamesSequenceElement !== null && hostNamesSequenceElement !== undefined) {
                for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, hostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS').length; loweredIndex4 = loweredIndex4 + 1) {
                  var hostNamesElement = js2xml.getElements(responseDoc, hostNamesSequenceElement, 'STRING', 'HTTP://SCHEMAS.MICROSOFT.COM/2003/10/SERIALIZATION/ARRAYS')[loweredIndex4];
                  siteInstance.hostNames.push(hostNamesElement);
                }
              }
              
              var lastModifiedTimeUtcElement = js2xml.getElement(responseDoc, sitesElement, 'LASTMODIFIEDTIMEUTC', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (lastModifiedTimeUtcElement !== null && lastModifiedTimeUtcElement !== undefined && lastModifiedTimeUtcElement.length !== 0) {
                var lastModifiedTimeUtcInstance = new Date(lastModifiedTimeUtcElement);
                siteInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;
              }
              
              var nameElement2 = js2xml.getElement(responseDoc, sitesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (nameElement2 !== null && nameElement2 !== undefined) {
                var nameInstance2 = nameElement2;
                siteInstance.name = nameInstance2;
              }
              
              var repositorySiteNameElement = js2xml.getElement(responseDoc, sitesElement, 'REPOSITORYSITENAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (repositorySiteNameElement !== null && repositorySiteNameElement !== undefined) {
                var repositorySiteNameInstance = repositorySiteNameElement;
                siteInstance.repositorySiteName = repositorySiteNameInstance;
              }
              
              var runtimeAvailabilityStateElement = js2xml.getElement(responseDoc, sitesElement, 'RUNTIMEAVAILABILITYSTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (runtimeAvailabilityStateElement !== null && runtimeAvailabilityStateElement !== undefined && runtimeAvailabilityStateElement.length !== 0) {
                var runtimeAvailabilityStateInstance = runtimeAvailabilityStateElement;
                siteInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;
              }
              
              var selfLinkElement = js2xml.getElement(responseDoc, sitesElement, 'SELFLINK', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (selfLinkElement !== null && selfLinkElement !== undefined) {
                var selfLinkInstance = selfLinkElement;
                siteInstance.uri = selfLinkInstance;
              }
              
              var serverFarmElement = js2xml.getElement(responseDoc, sitesElement, 'SERVERFARM', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (serverFarmElement !== null && serverFarmElement !== undefined) {
                var serverFarmInstance = serverFarmElement;
                siteInstance.serverFarm = serverFarmInstance;
              }
              
              var sitePropertiesElement = js2xml.getElement(responseDoc, sitesElement, 'SITEPROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (sitePropertiesElement !== null && sitePropertiesElement !== undefined) {
                var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };
                siteInstance.siteProperties = sitePropertiesInstance;
                
                var appSettingsSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'APPSETTINGS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
                  for (var loweredIndex5 = 0; loweredIndex5 < js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex5 = loweredIndex5 + 1) {
                    var appSettingsElement = js2xml.getElements(responseDoc, appSettingsSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex5];
                    var appSettingsKey = js2xml.getElement(responseDoc, appSettingsElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    var appSettingsValue = js2xml.getElement(responseDoc, appSettingsElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
                  }
                }
                
                var metadataSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'METADATA', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
                  for (var loweredIndex6 = 0; loweredIndex6 < js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex6 = loweredIndex6 + 1) {
                    var metadataElement = js2xml.getElements(responseDoc, metadataSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex6];
                    var metadataKey = js2xml.getElement(responseDoc, metadataElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    var metadataValue = js2xml.getElement(responseDoc, metadataElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    sitePropertiesInstance.metadata[metadataKey] = metadataValue;
                  }
                }
                
                var propertiesSequenceElement = js2xml.getElement(responseDoc, sitePropertiesElement, 'PROPERTIES', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {
                  for (var loweredIndex7 = 0; loweredIndex7 < js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE').length; loweredIndex7 = loweredIndex7 + 1) {
                    var propertiesElement = js2xml.getElements(responseDoc, propertiesSequenceElement, 'NAMEVALUEPAIR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE')[loweredIndex7];
                    var propertiesKey = js2xml.getElement(responseDoc, propertiesElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    var propertiesValue = js2xml.getElement(responseDoc, propertiesElement, 'VALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
                    sitePropertiesInstance.properties[propertiesKey] = propertiesValue;
                  }
                }
              }
              
              var stateElement = js2xml.getElement(responseDoc, sitesElement, 'STATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (stateElement !== null && stateElement !== undefined) {
                var stateInstance = stateElement;
                siteInstance.state = stateInstance;
              }
              
              var usageStateElement = js2xml.getElement(responseDoc, sitesElement, 'USAGESTATE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (usageStateElement !== null && usageStateElement !== undefined && usageStateElement.length !== 0) {
                var usageStateInstance = usageStateElement;
                siteInstance.usageState = usageStateInstance;
              }
              
              var webSpaceElement = js2xml.getElement(responseDoc, sitesElement, 'WEBSPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (webSpaceElement !== null && webSpaceElement !== undefined) {
                var webSpaceInstance = webSpaceElement;
                siteInstance.webSpace = webSpaceInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return WebSpaceOperations;
})();
