/* 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 Windows Azure Web Sites management API provides a RESTful set of web
   * services that interact with Windows Azure Web Sites service to manage
   * your web sites. The API has entities that capture the relationship
   * between an end user and the 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.azure.com';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2014-06-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
     * [SourceControlOperations](-SourceControlOperations.html) object.
     * @type {object}
     */
    this.sourceControls = new SourceControlOperations(this);
    /**
     * 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);
  }
  
  util.inherits(WebSiteManagementClient, Service);
  
  
  return WebSiteManagementClient;
})();
exports.WebSiteManagementClient = WebSiteManagementClient;

var SourceControlOperations = ( /** @lends SourceControlOperations */ function() {
  /**
   * @class
   * User source controls operations
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [WebSiteManagementClient] {@link
   * WebSiteManagementClient~WebSiteManagementClient}.
   * See [sourceControls] {@link
   * WebSiteManagementClient~WebSiteManagementClient#sourceControls}.
   * Initializes a new instance of the SourceControlOperations class.
   * @constructor
   * 
   * @param {WebSiteManagementClient} client Reference to the service client.
   */
  function SourceControlOperations(client) {
    this.client = client;
  }
  
  /**
   * Get user source control
   * 
   * @param {string} name The name of the source control (GitHub, Bitbucket,
   * CodePlex or Dropbox)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  SourceControlOperations.prototype.get = function(name, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (name === null || name === undefined) {
      return callback(new Error('name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/SourceControls/';
    url2 = url2 + encodeURIComponent(name);
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var sourceControlInstance = { tags: {} };
          result.sourceControl = sourceControlInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            sourceControlInstance.properties = propertiesInstance;
            
            var tokenValue = propertiesValue['token'];
            if (tokenValue !== null && tokenValue !== undefined) {
              var tokenInstance = tokenValue;
              propertiesInstance.token = tokenInstance;
            }
            
            var tokenSecretValue = propertiesValue['tokenSecret'];
            if (tokenSecretValue !== null && tokenSecretValue !== undefined) {
              var tokenSecretInstance = tokenSecretValue;
              propertiesInstance.tokenSecret = tokenSecretInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            sourceControlInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            sourceControlInstance.name = nameInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            sourceControlInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              sourceControlInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            sourceControlInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * List source controls for user.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  SourceControlOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/SourceControls';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 = { sourceControls: [] };
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var propertiesInstance = { tags: {} };
              result.sourceControls.push(propertiesInstance);
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance2 = {};
                propertiesInstance.properties = propertiesInstance2;
                
                var tokenValue = propertiesValue['token'];
                if (tokenValue !== null && tokenValue !== undefined) {
                  var tokenInstance = tokenValue;
                  propertiesInstance2.token = tokenInstance;
                }
                
                var tokenSecretValue = propertiesValue['tokenSecret'];
                if (tokenSecretValue !== null && tokenSecretValue !== undefined) {
                  var tokenSecretInstance = tokenSecretValue;
                  propertiesInstance2.tokenSecret = tokenSecretInstance;
                }
              }
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                propertiesInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                propertiesInstance.name = nameInstance;
              }
              
              var locationValue = valueValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                propertiesInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = valueValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property in tagsSequenceElement) {
                  var tagsKey = property;
                  var tagsValue = tagsSequenceElement[property];
                  propertiesInstance.tags[tagsKey] = tagsValue;
                }
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                propertiesInstance.type = typeInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Update source control for user.
   * 
   * @param {string} name The name of the source control (can be: GitHub,
   * Bitbucket, CodePlex, Dropbox)
   * 
   * @param {SourceControlUpdateParameters} parameters Parameters supplied to
   * the Update Source Control operation.
   * 
   * @param {SourceControlProperties} parameters.properties Gets or sets the
   * properties of the source control.
   * 
   * @param {string} [parameters.properties.token] Gets or sets the token.
   * 
   * @param {string} [parameters.properties.tokenSecret] Gets or sets the token
   * secret.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  SourceControlOperations.prototype.update = function(name, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (name === null || name === undefined) {
      return callback(new Error('name cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/SourceControls/';
    url2 = url2 + encodeURIComponent(name);
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var sourceControlUpdateParametersValue = {};
    requestDoc = sourceControlUpdateParametersValue;
    
    var propertiesValue = {};
    sourceControlUpdateParametersValue['properties'] = propertiesValue;
    
    if (parameters.properties.token !== null && parameters.properties.token !== undefined) {
      propertiesValue['token'] = parameters.properties.token;
    }
    
    if (parameters.properties.tokenSecret !== null && parameters.properties.tokenSecret !== undefined) {
      propertiesValue['tokenSecret'] = parameters.properties.tokenSecret;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        var sourceControlValue = responseDoc['SourceControl'];
        if (sourceControlValue !== null && sourceControlValue !== undefined) {
          var sourceControlInstance = {};
          
          var sourceControlInstance2 = { tags: {} };
          result.sourceControl = sourceControlInstance2;
          
          var propertiesValue2 = sourceControlValue['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var propertiesInstance = {};
            sourceControlInstance2.properties = propertiesInstance;
            
            var tokenValue = propertiesValue2['token'];
            if (tokenValue !== null && tokenValue !== undefined) {
              var tokenInstance = tokenValue;
              propertiesInstance.token = tokenInstance;
            }
            
            var tokenSecretValue = propertiesValue2['tokenSecret'];
            if (tokenSecretValue !== null && tokenSecretValue !== undefined) {
              var tokenSecretInstance = tokenSecretValue;
              propertiesInstance.tokenSecret = tokenSecretInstance;
            }
          }
          
          var idValue = sourceControlValue['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            sourceControlInstance2.id = idInstance;
          }
          
          var nameValue = sourceControlValue['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            sourceControlInstance2.name = nameInstance;
          }
          
          var locationValue = sourceControlValue['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            sourceControlInstance2.location = locationInstance;
          }
          
          var tagsSequenceElement = sourceControlValue['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              sourceControlInstance2.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = sourceControlValue['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            sourceControlInstance2.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return SourceControlOperations;
})();

var WebHostingPlanOperations = ( /** @lends WebHostingPlanOperations */ function() {
  /**
   * @class
   * Operations for managing the Web Hosting Plans in a resource group. Web
   * hosting plans (WHPs) represent a set of features and capacity that you
   * can share across your web sites. Web hosting plans support the 4 Azure
   * Web Sites pricing tiers (Free, Shared, Basic, and Standard) where each
   * tier has its own capabilities and capacity. Sites in the same
   * subscription, resource group, and geographic location can share a web
   * hosting plan. All the sites sharing a web hosting plan can leverage all
   * the capabilities and features defined by the web hosting plan tier. All
   * web sites associated with a given web hosting plan run on the resources
   * defined by the web hosting plan.  (see
   * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
   * for more information)
   * __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 or updates an existing one.  (see
   * http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
   * for more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {WebHostingPlanCreateOrUpdateParameters} parameters Parameters
   * supplied to the Create Server Farm operation.
   * 
   * @param {WebHostingPlan} parameters.webHostingPlan Gets or sets information
   * about a Web Hosting Plan being created of updated.
   * 
   * @param {WebHostingPlanProperties} [parameters.webHostingPlan.properties]
   * Represents the properties of the Web Hosting Plan.
   * 
   * @param {SkuOptions} [parameters.webHostingPlan.properties.sku] The Web
   * Hosting Plan SKU.
   * 
   * @param {number} [parameters.webHostingPlan.properties.numberOfWorkers] The
   * instance count, which is the number of virtual machines dedicated to the
   * Web Hosting Plan. Supported values are positive integers.
   * 
   * @param {WorkerSizeOptions}
   * [parameters.webHostingPlan.properties.workerSize] The instance size.
   * Possible values are Small, Medium, or Large.
   * 
   * @param {string} [parameters.webHostingPlan.properties.adminSiteName] The
   * admin site. The admin site is used to deploy site extensions or contents
   * shared by all site in the plan.
   * 
   * @param {string} [parameters.webHostingPlan.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.webHostingPlan.name] The name of the resource.
   * 
   * @param {string} parameters.webHostingPlan.location Gets or sets the
   * location of the resource.
   * 
   * @param {object} [parameters.webHostingPlan.tags] Gets or sets the tags
   * attached to the resource.
   * 
   * @param {string} [parameters.webHostingPlan.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.createOrUpdate = function(resourceGroupName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.webHostingPlan === null || parameters.webHostingPlan === undefined) {
      return callback(new Error('parameters.webHostingPlan cannot be null.'));
    }
    if (parameters.webHostingPlan.location === null || parameters.webHostingPlan.location === undefined) {
      return callback(new Error('parameters.webHostingPlan.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/serverFarms/';
    if (parameters.webHostingPlan.name !== null && parameters.webHostingPlan.name !== undefined) {
      url2 = url2 + encodeURIComponent(parameters.webHostingPlan.name);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webHostingPlanCreateOrUpdateParametersValue = {};
    requestDoc = webHostingPlanCreateOrUpdateParametersValue;
    
    if (parameters.webHostingPlan.properties !== null && parameters.webHostingPlan.properties !== undefined) {
      var propertiesValue = {};
      webHostingPlanCreateOrUpdateParametersValue['properties'] = propertiesValue;
      
      if (parameters.webHostingPlan.properties.sku !== null && parameters.webHostingPlan.properties.sku !== undefined) {
        propertiesValue['sku'] = parameters.webHostingPlan.properties.sku !== null && parameters.webHostingPlan.properties.sku !== undefined ? parameters.webHostingPlan.properties.sku.toString() : 'Free';
      }
      
      if (parameters.webHostingPlan.properties.numberOfWorkers !== null && parameters.webHostingPlan.properties.numberOfWorkers !== undefined) {
        propertiesValue['numberOfWorkers'] = parameters.webHostingPlan.properties.numberOfWorkers;
      }
      
      if (parameters.webHostingPlan.properties.workerSize !== null && parameters.webHostingPlan.properties.workerSize !== undefined) {
        propertiesValue['workerSize'] = parameters.webHostingPlan.properties.workerSize !== null && parameters.webHostingPlan.properties.workerSize !== undefined ? parameters.webHostingPlan.properties.workerSize.toString() : 'Small';
      }
      
      if (parameters.webHostingPlan.properties.adminSiteName !== null && parameters.webHostingPlan.properties.adminSiteName !== undefined) {
        propertiesValue['adminSiteName'] = parameters.webHostingPlan.properties.adminSiteName;
      }
    }
    
    if (parameters.webHostingPlan.id !== null && parameters.webHostingPlan.id !== undefined) {
      webHostingPlanCreateOrUpdateParametersValue['id'] = parameters.webHostingPlan.id;
    }
    
    if (parameters.webHostingPlan.name !== null && parameters.webHostingPlan.name !== undefined) {
      webHostingPlanCreateOrUpdateParametersValue['name'] = parameters.webHostingPlan.name;
    }
    
    webHostingPlanCreateOrUpdateParametersValue['location'] = parameters.webHostingPlan.location;
    
    if (parameters.webHostingPlan.tags !== null && parameters.webHostingPlan.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.webHostingPlan.tags) {
        var tagsValue = parameters.webHostingPlan.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webHostingPlanCreateOrUpdateParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.webHostingPlan.type !== null && parameters.webHostingPlan.type !== undefined) {
      webHostingPlanCreateOrUpdateParametersValue['type'] = parameters.webHostingPlan.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        var serverFarmValue = responseDoc['ServerFarm'];
        if (serverFarmValue !== null && serverFarmValue !== undefined) {
          var serverFarmInstance = {};
          
          var webHostingPlanInstance = { tags: {} };
          result.webHostingPlan = webHostingPlanInstance;
          
          var propertiesValue2 = serverFarmValue['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var propertiesInstance = {};
            webHostingPlanInstance.properties = propertiesInstance;
            
            var skuValue = propertiesValue2['sku'];
            if (skuValue !== null && skuValue !== undefined) {
              var skuInstance = skuValue;
              propertiesInstance.sku = skuInstance;
            }
            
            var numberOfWorkersValue = propertiesValue2['numberOfWorkers'];
            if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {
              var numberOfWorkersInstance = numberOfWorkersValue;
              propertiesInstance.numberOfWorkers = numberOfWorkersInstance;
            }
            
            var workerSizeValue = propertiesValue2['workerSize'];
            if (workerSizeValue !== null && workerSizeValue !== undefined) {
              var workerSizeInstance = workerSizeValue;
              propertiesInstance.workerSize = workerSizeInstance;
            }
            
            var adminSiteNameValue = propertiesValue2['adminSiteName'];
            if (adminSiteNameValue !== null && adminSiteNameValue !== undefined) {
              var adminSiteNameInstance = adminSiteNameValue;
              propertiesInstance.adminSiteName = adminSiteNameInstance;
            }
          }
          
          var idValue = serverFarmValue['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            webHostingPlanInstance.id = idInstance;
          }
          
          var nameValue = serverFarmValue['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            webHostingPlanInstance.name = nameInstance;
          }
          
          var locationValue = serverFarmValue['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            webHostingPlanInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = serverFarmValue['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              webHostingPlanInstance.tags[tagsKey2] = tagsValue2;
            }
          }
          
          var typeValue = serverFarmValue['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            webHostingPlanInstance.type = typeInstance;
          }
        }
        
      }
      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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webHostingPlanName The name of the Web Hosting Plan to
   * delete.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.deleteMethod = function(resourceGroupName, webHostingPlanName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webHostingPlanName === null || webHostingPlanName === undefined) {
      return callback(new Error('webHostingPlanName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/serverFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webHostingPlanName The name of the Web Hosting Plan.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.get = function(resourceGroupName, webHostingPlanName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webHostingPlanName === null || webHostingPlanName === undefined) {
      return callback(new Error('webHostingPlanName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/serverFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var webHostingPlanInstance = { tags: {} };
          result.webHostingPlan = webHostingPlanInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            webHostingPlanInstance.properties = propertiesInstance;
            
            var skuValue = propertiesValue['sku'];
            if (skuValue !== null && skuValue !== undefined) {
              var skuInstance = skuValue;
              propertiesInstance.sku = skuInstance;
            }
            
            var numberOfWorkersValue = propertiesValue['numberOfWorkers'];
            if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {
              var numberOfWorkersInstance = numberOfWorkersValue;
              propertiesInstance.numberOfWorkers = numberOfWorkersInstance;
            }
            
            var workerSizeValue = propertiesValue['workerSize'];
            if (workerSizeValue !== null && workerSizeValue !== undefined) {
              var workerSizeInstance = workerSizeValue;
              propertiesInstance.workerSize = workerSizeInstance;
            }
            
            var adminSiteNameValue = propertiesValue['adminSiteName'];
            if (adminSiteNameValue !== null && adminSiteNameValue !== undefined) {
              var adminSiteNameInstance = adminSiteNameValue;
              propertiesInstance.adminSiteName = adminSiteNameInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            webHostingPlanInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            webHostingPlanInstance.name = nameInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            webHostingPlanInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              webHostingPlanInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            webHostingPlanInstance.type = typeInstance;
          }
        }
        
      }
      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} resourceGroupName The name of the resource group.
   * 
   * @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(resourceGroupName, webHostingPlanName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/serverFarms/';
    url2 = url2 + encodeURIComponent(webHostingPlanName);
    url2 = url2 + '/metrics';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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-06-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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var propertiesArray = responseDoc['properties'];
          if (propertiesArray !== null && propertiesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var propertiesValue = propertiesArray[loweredIndex1];
              var historicalUsageMetricInstance = {};
              result.usageMetrics.push(historicalUsageMetricInstance);
              
              var codeValue = propertiesValue['code'];
              if (codeValue !== null && codeValue !== undefined) {
                var codeInstance = codeValue;
                historicalUsageMetricInstance.code = codeInstance;
              }
              
              var dataValue = propertiesValue['data'];
              if (dataValue !== null && dataValue !== undefined) {
                var dataInstance = { values: [] };
                historicalUsageMetricInstance.data = dataInstance;
                
                var displayNameValue = dataValue['displayName'];
                if (displayNameValue !== null && displayNameValue !== undefined) {
                  var displayNameInstance = displayNameValue;
                  dataInstance.displayName = displayNameInstance;
                }
                
                var endTimeValue = dataValue['EndTime'];
                if (endTimeValue !== null && endTimeValue !== undefined) {
                  var endTimeInstance = endTimeValue;
                  dataInstance.endTime = endTimeInstance;
                }
                
                var nameValue = dataValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  dataInstance.name = nameInstance;
                }
                
                var primaryAggregationTypeValue = dataValue['primaryAggregationType'];
                if (primaryAggregationTypeValue !== null && primaryAggregationTypeValue !== undefined) {
                  var primaryAggregationTypeInstance = primaryAggregationTypeValue;
                  dataInstance.primaryAggregationType = primaryAggregationTypeInstance;
                }
                
                var startTimeValue = dataValue['startTime'];
                if (startTimeValue !== null && startTimeValue !== undefined) {
                  var startTimeInstance = startTimeValue;
                  dataInstance.startTime = startTimeInstance;
                }
                
                var timeGrainValue = dataValue['timeGrain'];
                if (timeGrainValue !== null && timeGrainValue !== undefined) {
                  var timeGrainInstance = timeGrainValue;
                  dataInstance.timeGrain = timeGrainInstance;
                }
                
                var unitValue = dataValue['unit'];
                if (unitValue !== null && unitValue !== undefined) {
                  var unitInstance = unitValue;
                  dataInstance.unit = unitInstance;
                }
                
                var valuesArray = dataValue['values'];
                if (valuesArray !== null && valuesArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < valuesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var valuesValue = valuesArray[loweredIndex2];
                    var metricSampleInstance = {};
                    dataInstance.values.push(metricSampleInstance);
                    
                    var countValue = valuesValue['count'];
                    if (countValue !== null && countValue !== undefined) {
                      var countInstance = countValue;
                      metricSampleInstance.count = countInstance;
                    }
                    
                    var maximumValue = valuesValue['maximum'];
                    if (maximumValue !== null && maximumValue !== undefined) {
                      var maximumInstance = maximumValue;
                      metricSampleInstance.maximum = maximumInstance;
                    }
                    
                    var minimumValue = valuesValue['minimum'];
                    if (minimumValue !== null && minimumValue !== undefined) {
                      var minimumInstance = minimumValue;
                      metricSampleInstance.minimum = minimumInstance;
                    }
                    
                    var timeCreatedValue = valuesValue['timeCreated'];
                    if (timeCreatedValue !== null && timeCreatedValue !== undefined) {
                      var timeCreatedInstance = timeCreatedValue;
                      metricSampleInstance.timeCreated = timeCreatedInstance;
                    }
                    
                    var totalValue = valuesValue['total'];
                    if (totalValue !== null && totalValue !== undefined) {
                      var totalInstance = totalValue;
                      metricSampleInstance.total = totalInstance;
                    }
                    
                    var instanceNameValue = valuesValue['instanceName'];
                    if (instanceNameValue !== null && instanceNameValue !== undefined) {
                      var instanceNameInstance = instanceNameValue;
                      metricSampleInstance.instanceName = instanceNameInstance;
                    }
                  }
                }
              }
              
              var messageValue = propertiesValue['message'];
              if (messageValue !== null && messageValue !== undefined) {
                var messageInstance = messageValue;
                historicalUsageMetricInstance.message = messageInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets all Web Hosting Plans in a current subscription and Resource Group.
   * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn194277.aspx
   * for more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebHostingPlanOperations.prototype.list = function(resourceGroupName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/serverFarms';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var webHostingPlanInstance = { tags: {} };
              result.webHostingPlans.push(webHostingPlanInstance);
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = {};
                webHostingPlanInstance.properties = propertiesInstance;
                
                var skuValue = propertiesValue['sku'];
                if (skuValue !== null && skuValue !== undefined) {
                  var skuInstance = skuValue;
                  propertiesInstance.sku = skuInstance;
                }
                
                var numberOfWorkersValue = propertiesValue['numberOfWorkers'];
                if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {
                  var numberOfWorkersInstance = numberOfWorkersValue;
                  propertiesInstance.numberOfWorkers = numberOfWorkersInstance;
                }
                
                var workerSizeValue = propertiesValue['workerSize'];
                if (workerSizeValue !== null && workerSizeValue !== undefined) {
                  var workerSizeInstance = workerSizeValue;
                  propertiesInstance.workerSize = workerSizeInstance;
                }
                
                var adminSiteNameValue = propertiesValue['adminSiteName'];
                if (adminSiteNameValue !== null && adminSiteNameValue !== undefined) {
                  var adminSiteNameInstance = adminSiteNameValue;
                  propertiesInstance.adminSiteName = adminSiteNameInstance;
                }
              }
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                webHostingPlanInstance.id = idInstance;
              }
              
              var nameValue = valueValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                webHostingPlanInstance.name = nameInstance;
              }
              
              var locationValue = valueValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                webHostingPlanInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = valueValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property in tagsSequenceElement) {
                  var tagsKey = property;
                  var tagsValue = tagsSequenceElement[property];
                  webHostingPlanInstance.tags[tagsKey] = tagsValue;
                }
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                webHostingPlanInstance.type = typeInstance;
              }
            }
          }
        }
        
      }
      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.
   * __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;
  }
  
  /**
   * Backups a site on-demand.
   * 
   * @param {string} resourceGroupName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {BackupRequestEnvelope} backupRequestEnvelope A backup
   * specification.
   * 
   * @param {BackupRequest} [backupRequestEnvelope.request] TODO.
   * 
   * @param {BackupSchedule} [backupRequestEnvelope.request.backupSchedule] The
   * backup schedule structure - valid only when setting up a schedule. Should
   * be Null for on-demand backups.
   * 
   * @param {number}
   * [backupRequestEnvelope.request.backupSchedule.frequencyInterval] The
   * frequency of backups.
   * 
   * @param {FrequencyUnit}
   * [backupRequestEnvelope.request.backupSchedule.frequencyUnit] Units for
   * FrequencyInterval - e.g. Day or Hour
   * 
   * @param {boolean}
   * [backupRequestEnvelope.request.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}
   * [backupRequestEnvelope.request.backupSchedule.lastExecutionTime] The last
   * time when this schedule started a backup, Null if didn't start anything
   * yet.
   * 
   * @param {number}
   * [backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays]
   * Backups older N days (N defined by this value) will be automatically
   * deleted.
   * 
   * @param {date} [backupRequestEnvelope.request.backupSchedule.startTime]
   * When this schedule should start backing up the site. Null means
   * immediately.
   * 
   * @param {IEnumerable} [backupRequestEnvelope.request.databases] Database
   * settings for backup.
   * 
   * @param {boolean} [backupRequestEnvelope.request.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} [backupRequestEnvelope.request.name] The name of this
   * backup - will be used for generating a blob name.
   * 
   * @param {string} [backupRequestEnvelope.request.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 {string} [backupRequestEnvelope.id] Gets the ID of the resource.
   * 
   * @param {string} [backupRequestEnvelope.name] The name of the resource.
   * 
   * @param {string} backupRequestEnvelope.location Gets or sets the location
   * of the resource.
   * 
   * @param {object} [backupRequestEnvelope.tags] Gets or sets the tags
   * attached to the resource.
   * 
   * @param {string} [backupRequestEnvelope.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.backup = function(resourceGroupName, webSiteName, slotName, backupRequestEnvelope, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (backupRequestEnvelope === null || backupRequestEnvelope === undefined) {
      return callback(new Error('backupRequestEnvelope cannot be null.'));
    }
    if (backupRequestEnvelope.location === null || backupRequestEnvelope.location === undefined) {
      return callback(new Error('backupRequestEnvelope.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/backup';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json';
    httpRequest.headers['x-ms-version'] = '2014-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var backupRequestEnvelopeValue = {};
    requestDoc = backupRequestEnvelopeValue;
    
    if (backupRequestEnvelope.request !== null && backupRequestEnvelope.request !== undefined) {
      var propertiesValue = {};
      backupRequestEnvelopeValue['properties'] = propertiesValue;
      
      if (backupRequestEnvelope.request.backupSchedule !== null && backupRequestEnvelope.request.backupSchedule !== undefined) {
        var backupScheduleValue = {};
        propertiesValue['backupSchedule'] = backupScheduleValue;
        
        if (backupRequestEnvelope.request.backupSchedule.frequencyInterval !== null && backupRequestEnvelope.request.backupSchedule.frequencyInterval !== undefined) {
          backupScheduleValue['frequencyInterval'] = backupRequestEnvelope.request.backupSchedule.frequencyInterval;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined) {
          backupScheduleValue['frequencyUnit'] = backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined ? backupRequestEnvelope.request.backupSchedule.frequencyUnit.toString() : 'Day';
        }
        
        if (backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== null && backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== undefined) {
          backupScheduleValue['keepAtLeastOneBackup'] = backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== null && backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== undefined) {
          backupScheduleValue['lastExecutionTime'] = backupRequestEnvelope.request.backupSchedule.lastExecutionTime;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== null && backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== undefined) {
          backupScheduleValue['retentionPeriodInDays'] = backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.startTime !== null && backupRequestEnvelope.request.backupSchedule.startTime !== undefined) {
          backupScheduleValue['startTime'] = backupRequestEnvelope.request.backupSchedule.startTime;
        }
      }
      
      if (backupRequestEnvelope.request.databases !== null && backupRequestEnvelope.request.databases !== undefined) {
        var databasesArray = [];
        for (var loweredIndex1 = 0; loweredIndex1 < backupRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {
          var databasesItem = backupRequestEnvelope.request.databases[loweredIndex1];
          var databaseBackupSettingValue = {};
          databasesArray.push(databaseBackupSettingValue);
          
          if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
            databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;
          }
          
          if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
            databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;
          }
          
          if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
            databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;
          }
          
          if (databasesItem.name !== null && databasesItem.name !== undefined) {
            databaseBackupSettingValue['name'] = databasesItem.name;
          }
        }
        propertiesValue['databases'] = databasesArray;
      }
      
      if (backupRequestEnvelope.request.enabled !== null && backupRequestEnvelope.request.enabled !== undefined) {
        propertiesValue['enabled'] = backupRequestEnvelope.request.enabled;
      }
      
      if (backupRequestEnvelope.request.name !== null && backupRequestEnvelope.request.name !== undefined) {
        propertiesValue['name'] = backupRequestEnvelope.request.name;
      }
      
      if (backupRequestEnvelope.request.storageAccountUrl !== null && backupRequestEnvelope.request.storageAccountUrl !== undefined) {
        propertiesValue['storageAccountUrl'] = backupRequestEnvelope.request.storageAccountUrl;
      }
    }
    
    if (backupRequestEnvelope.id !== null && backupRequestEnvelope.id !== undefined) {
      backupRequestEnvelopeValue['id'] = backupRequestEnvelope.id;
    }
    
    if (backupRequestEnvelope.name !== null && backupRequestEnvelope.name !== undefined) {
      backupRequestEnvelopeValue['name'] = backupRequestEnvelope.name;
    }
    
    backupRequestEnvelopeValue['location'] = backupRequestEnvelope.location;
    
    if (backupRequestEnvelope.tags !== null && backupRequestEnvelope.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in backupRequestEnvelope.tags) {
        var tagsValue = backupRequestEnvelope.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      backupRequestEnvelopeValue['tags'] = tagsDictionary;
    }
    
    if (backupRequestEnvelope.type !== null && backupRequestEnvelope.type !== undefined) {
      backupRequestEnvelopeValue['type'] = backupRequestEnvelope.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var backupItemInstance = { tags: {} };
          result.backupItem = backupItemInstance;
          
          var propertiesValue2 = responseDoc['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var propertiesInstance = { databases: [] };
            backupItemInstance.properties = propertiesInstance;
            
            var storageAccountUrlValue = propertiesValue2['storageAccountUrl'];
            if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {
              var storageAccountUrlInstance = storageAccountUrlValue;
              propertiesInstance.storageAccountUrl = storageAccountUrlInstance;
            }
            
            var blobNameValue = propertiesValue2['blobName'];
            if (blobNameValue !== null && blobNameValue !== undefined) {
              var blobNameInstance = blobNameValue;
              propertiesInstance.blobName = blobNameInstance;
            }
            
            var nameValue = propertiesValue2['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              propertiesInstance.name = nameInstance;
            }
            
            var statusValue = propertiesValue2['status'];
            if (statusValue !== null && statusValue !== undefined) {
              var statusInstance = statusValue;
              propertiesInstance.status = statusInstance;
            }
            
            var sizeInBytesValue = propertiesValue2['sizeInBytes'];
            if (sizeInBytesValue !== null && sizeInBytesValue !== undefined) {
              var sizeInBytesInstance = sizeInBytesValue;
              propertiesInstance.sizeInBytes = sizeInBytesInstance;
            }
            
            var createdValue = propertiesValue2['created'];
            if (createdValue !== null && createdValue !== undefined) {
              var createdInstance = createdValue;
              propertiesInstance.created = createdInstance;
            }
            
            var logValue = propertiesValue2['log'];
            if (logValue !== null && logValue !== undefined) {
              var logInstance = logValue;
              propertiesInstance.log = logInstance;
            }
            
            var databasesArray2 = propertiesValue2['databases'];
            if (databasesArray2 !== null && databasesArray2 !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < databasesArray2.length; loweredIndex2 = loweredIndex2 + 1) {
                var databasesValue = databasesArray2[loweredIndex2];
                var databaseBackupSettingInstance = {};
                propertiesInstance.databases.push(databaseBackupSettingInstance);
                
                var connectionStringValue = databasesValue['connectionString'];
                if (connectionStringValue !== null && connectionStringValue !== undefined) {
                  var connectionStringInstance = connectionStringValue;
                  databaseBackupSettingInstance.connectionString = connectionStringInstance;
                }
                
                var connectionStringNameValue = databasesValue['connectionStringName'];
                if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {
                  var connectionStringNameInstance = connectionStringNameValue;
                  databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                }
                
                var databaseTypeValue = databasesValue['databaseType'];
                if (databaseTypeValue !== null && databaseTypeValue !== undefined) {
                  var databaseTypeInstance = databaseTypeValue;
                  databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                }
                
                var nameValue2 = databasesValue['name'];
                if (nameValue2 !== null && nameValue2 !== undefined) {
                  var nameInstance2 = nameValue2;
                  databaseBackupSettingInstance.name = nameInstance2;
                }
              }
            }
            
            var scheduledValue = propertiesValue2['scheduled'];
            if (scheduledValue !== null && scheduledValue !== undefined) {
              var scheduledInstance = scheduledValue;
              propertiesInstance.scheduled = scheduledInstance;
            }
            
            var lastRestoreTimeStampValue = propertiesValue2['lastRestoreTimeStamp'];
            if (lastRestoreTimeStampValue !== null && lastRestoreTimeStampValue !== undefined) {
              var lastRestoreTimeStampInstance = lastRestoreTimeStampValue;
              propertiesInstance.lastRestoreTimeStamp = lastRestoreTimeStampInstance;
            }
            
            var finishedTimeStampValue = propertiesValue2['finishedTimeStamp'];
            if (finishedTimeStampValue !== null && finishedTimeStampValue !== undefined) {
              var finishedTimeStampInstance = finishedTimeStampValue;
              propertiesInstance.finishedTimeStamp = finishedTimeStampInstance;
            }
            
            var correlationIdValue = propertiesValue2['correlationId'];
            if (correlationIdValue !== null && correlationIdValue !== undefined) {
              var correlationIdInstance = correlationIdValue;
              propertiesInstance.correlationId = correlationIdInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            backupItemInstance.id = idInstance;
          }
          
          var nameValue3 = responseDoc['name'];
          if (nameValue3 !== null && nameValue3 !== undefined) {
            var nameInstance3 = nameValue3;
            backupItemInstance.name = nameInstance3;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            backupItemInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              backupItemInstance.tags[tagsKey2] = tagsValue2;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            backupItemInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can clone a web site by using a PUT 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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteCloneParameters} parameters Parameters supplied to the
   * clone Web Site operation.
   * 
   * @param {WebSiteCloneBase} parameters.webSiteClone Gets or sets information
   * about the website being cloned.
   * 
   * @param {WebSiteCloneBaseProperties} [parameters.webSiteClone.properties]
   * Represents the properties of the website.
   * 
   * @param {string} [parameters.webSiteClone.properties.serverFarm] The name
   * of the Server Farm (Web Hosting Plan) associated with this website.
   * 
   * @param {CloningInfo} [parameters.webSiteClone.properties.cloningInfo] The
   * per site limits.
   * 
   * @param {Guid}
   * [parameters.webSiteClone.properties.cloningInfo.correlationId]
   * Correlation Id. Used for bulk cloning operations
   * 
   * @param {boolean}
   * [parameters.webSiteClone.properties.cloningInfo.overwrite] Overwrite
   * target site
   * 
   * @param {boolean}
   * [parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames]
   * Clone custom hostnames
   * 
   * @param {SourceWebSite}
   * [parameters.webSiteClone.properties.cloningInfo.source] Source website to
   * clone
   * 
   * @param {string}
   * [parameters.webSiteClone.properties.cloningInfo.source.name] Name of
   * source site
   * 
   * @param {string}
   * [parameters.webSiteClone.properties.cloningInfo.source.location] Locatio
   * (georegion) of source site
   * 
   * @param {string}
   * [parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName]
   * Name of resource group of source site
   * 
   * @param {string}
   * [parameters.webSiteClone.properties.cloningInfo.source.subscriptionId]
   * Subscription Id of source site
   * 
   * @param {string}
   * [parameters.webSiteClone.properties.cloningInfo.source.slot] Name of slot
   * of source site
   * 
   * @param {string}
   * [parameters.webSiteClone.properties.cloningInfo.hostingEnvironment]
   * Hosting environment
   * 
   * @param {string} [parameters.webSiteClone.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.webSiteClone.name] The name of the resource.
   * 
   * @param {string} parameters.webSiteClone.location Gets or sets the location
   * of the resource.
   * 
   * @param {object} [parameters.webSiteClone.tags] Gets or sets the tags
   * attached to the resource.
   * 
   * @param {string} [parameters.webSiteClone.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.clone = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.webSiteClone === null || parameters.webSiteClone === undefined) {
      return callback(new Error('parameters.webSiteClone cannot be null.'));
    }
    if (parameters.webSiteClone.location === null || parameters.webSiteClone.location === undefined) {
      return callback(new Error('parameters.webSiteClone.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteCloneParametersValue = {};
    requestDoc = webSiteCloneParametersValue;
    
    if (parameters.webSiteClone.properties !== null && parameters.webSiteClone.properties !== undefined) {
      var propertiesValue = {};
      webSiteCloneParametersValue['properties'] = propertiesValue;
      
      if (parameters.webSiteClone.properties.serverFarm !== null && parameters.webSiteClone.properties.serverFarm !== undefined) {
        propertiesValue['ServerFarm'] = parameters.webSiteClone.properties.serverFarm;
      }
      
      if (parameters.webSiteClone.properties.cloningInfo !== null && parameters.webSiteClone.properties.cloningInfo !== undefined) {
        var cloningInfoValue = {};
        propertiesValue['cloningInfo'] = cloningInfoValue;
        
        if (parameters.webSiteClone.properties.cloningInfo.correlationId !== null && parameters.webSiteClone.properties.cloningInfo.correlationId !== undefined) {
          cloningInfoValue['CorrelationId'] = parameters.webSiteClone.properties.cloningInfo.correlationId;
        }
        
        if (parameters.webSiteClone.properties.cloningInfo.overwrite !== null && parameters.webSiteClone.properties.cloningInfo.overwrite !== undefined) {
          cloningInfoValue['Overwrite'] = parameters.webSiteClone.properties.cloningInfo.overwrite;
        }
        
        if (parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames !== null && parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames !== undefined) {
          cloningInfoValue['CloneCustomHostNames'] = parameters.webSiteClone.properties.cloningInfo.cloneCustomHostNames;
        }
        
        if (parameters.webSiteClone.properties.cloningInfo.source !== null && parameters.webSiteClone.properties.cloningInfo.source !== undefined) {
          var sourceValue = {};
          cloningInfoValue['Source'] = sourceValue;
          
          if (parameters.webSiteClone.properties.cloningInfo.source.name !== null && parameters.webSiteClone.properties.cloningInfo.source.name !== undefined) {
            sourceValue['Name'] = parameters.webSiteClone.properties.cloningInfo.source.name;
          }
          
          if (parameters.webSiteClone.properties.cloningInfo.source.location !== null && parameters.webSiteClone.properties.cloningInfo.source.location !== undefined) {
            sourceValue['Location'] = parameters.webSiteClone.properties.cloningInfo.source.location;
          }
          
          if (parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName !== null && parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName !== undefined) {
            sourceValue['ResourceGroupName'] = parameters.webSiteClone.properties.cloningInfo.source.resourceGroupName;
          }
          
          if (parameters.webSiteClone.properties.cloningInfo.source.subscriptionId !== null && parameters.webSiteClone.properties.cloningInfo.source.subscriptionId !== undefined) {
            sourceValue['SubscriptionId'] = parameters.webSiteClone.properties.cloningInfo.source.subscriptionId;
          }
          
          if (parameters.webSiteClone.properties.cloningInfo.source.slot !== null && parameters.webSiteClone.properties.cloningInfo.source.slot !== undefined) {
            sourceValue['Slot'] = parameters.webSiteClone.properties.cloningInfo.source.slot;
          }
        }
        
        if (parameters.webSiteClone.properties.cloningInfo.hostingEnvironment !== null && parameters.webSiteClone.properties.cloningInfo.hostingEnvironment !== undefined) {
          cloningInfoValue['HostingEnvironment'] = parameters.webSiteClone.properties.cloningInfo.hostingEnvironment;
        }
      }
    }
    
    if (parameters.webSiteClone.id !== null && parameters.webSiteClone.id !== undefined) {
      webSiteCloneParametersValue['id'] = parameters.webSiteClone.id;
    }
    
    if (parameters.webSiteClone.name !== null && parameters.webSiteClone.name !== undefined) {
      webSiteCloneParametersValue['name'] = parameters.webSiteClone.name;
    }
    
    webSiteCloneParametersValue['location'] = parameters.webSiteClone.location;
    
    if (parameters.webSiteClone.tags !== null && parameters.webSiteClone.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.webSiteClone.tags) {
        var tagsValue = parameters.webSiteClone.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webSiteCloneParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.webSiteClone.type !== null && parameters.webSiteClone.type !== undefined) {
      webSiteCloneParametersValue['type'] = parameters.webSiteClone.type;
    }
    
    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 !== 202) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 202) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            result.location = locationInstance;
          }
          
          var retryAfterValue = responseDoc['retry-after'];
          if (retryAfterValue !== null && retryAfterValue !== undefined) {
            var retryAfterInstance = retryAfterValue;
            result.retryAfter = retryAfterInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.location = response.headers['location'];
      result.retryAfter = response.headers['retry-after'];
      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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteCreateOrUpdateParameters} parameters Parameters supplied to
   * the Create Web Site operation.
   * 
   * @param {WebSiteBase} parameters.webSite Gets or sets information about a
   * website being created of updated.
   * 
   * @param {WebSiteBaseProperties} [parameters.webSite.properties] Represents
   * the properties of the website.
   * 
   * @param {string} [parameters.webSite.properties.serverFarm] The name of the
   * Server Farm (Web Hosting Plan) associated with this website.
   * 
   * @param {string} [parameters.webSite.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.webSite.name] The name of the resource.
   * 
   * @param {string} parameters.webSite.location Gets or sets the location of
   * the resource.
   * 
   * @param {object} [parameters.webSite.tags] Gets or sets the tags attached
   * to the resource.
   * 
   * @param {string} [parameters.webSite.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.createOrUpdate = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.webSite === null || parameters.webSite === undefined) {
      return callback(new Error('parameters.webSite cannot be null.'));
    }
    if (parameters.webSite.location === null || parameters.webSite.location === undefined) {
      return callback(new Error('parameters.webSite.location cannot be null.'));
    }
    if (parameters.webSite.properties !== null && parameters.webSite.properties !== undefined) {
      if (parameters.webSite.properties.serverFarm === null || parameters.webSite.properties.serverFarm === undefined) {
        return callback(new Error('parameters.webSite.properties.serverFarm cannot be null.'));
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteCreateOrUpdateParametersValue = {};
    requestDoc = webSiteCreateOrUpdateParametersValue;
    
    if (parameters.webSite.properties !== null && parameters.webSite.properties !== undefined) {
      var propertiesValue = {};
      webSiteCreateOrUpdateParametersValue['properties'] = propertiesValue;
      
      propertiesValue['ServerFarm'] = parameters.webSite.properties.serverFarm;
    }
    
    if (parameters.webSite.id !== null && parameters.webSite.id !== undefined) {
      webSiteCreateOrUpdateParametersValue['id'] = parameters.webSite.id;
    }
    
    if (parameters.webSite.name !== null && parameters.webSite.name !== undefined) {
      webSiteCreateOrUpdateParametersValue['name'] = parameters.webSite.name;
    }
    
    webSiteCreateOrUpdateParametersValue['location'] = parameters.webSite.location;
    
    if (parameters.webSite.tags !== null && parameters.webSite.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.webSite.tags) {
        var tagsValue = parameters.webSite.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webSiteCreateOrUpdateParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.webSite.type !== null && parameters.webSite.type !== undefined) {
      webSiteCreateOrUpdateParametersValue['type'] = parameters.webSite.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
        }
        
      }
      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. You can create a
   * repository for your web site by issuing an HTTP POST request, or retrieve
   * information about the repository by using HTTP GET.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.createRepository = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/repository';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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 the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group..
   * 
   * @param {string} webSiteName The name of the Web Site resource.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteDeleteParameters} parameters The parameters to delete a web
   * site.
   * 
   * @param {boolean} parameters.deleteEmptyServerFarm If the site being
   * deleted is the last web site in a server farm, you can delete the server
   * farm.
   * 
   * @param {boolean} parameters.deleteMetrics Delete the metrics for the web
   * site.
   * 
   * @param {boolean} parameters.deleteAllSlots Delete all slots for the web
   * site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.deleteMethod = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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. You can create a
   * repository for your web site by issuing an HTTP POST request, or retrieve
   * information about the repository by using HTTP GET.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.deleteRepository = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/repository';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var uriValue = responseDoc['uri'];
          if (uriValue !== null && uriValue !== undefined) {
            var uriInstance = uriValue;
            result.uri = uriInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Unlink source control from website
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {string} repoUrl The repository url.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.deleteSiteSourceControl = function(resourceGroupName, webSiteName, slotName, repoUrl, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (repoUrl === null || repoUrl === undefined) {
      return callback(new Error('repoUrl cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/sourcecontrols/web';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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);
    });
  };
  
  /**
   * 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. KNOWN BUG: This has to be called
   * against an exisingsite, otherwise will hit an error about non-existing
   * resource.
   * 
   * @param {string} resourceGroupName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {RestoreRequestEnvelope} restoreRequestEnvelope A restore request.
   * 
   * @param {RestoreRequest} [restoreRequestEnvelope.request] TODO.
   * 
   * @param {boolean} [restoreRequestEnvelope.request.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} [restoreRequestEnvelope.request.blobName] The blob name
   * where the backup is stored. E.g. mysite1_20140203.zip
   * 
   * @param {IEnumerable} [restoreRequestEnvelope.request.databases] Database
   * settings for backup.
   * 
   * @param {boolean}
   * [restoreRequestEnvelope.request.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} [restoreRequestEnvelope.request.overwrite] True if the
   * restore operation will be used for overwrite an existing site; false
   * otherwise.
   * 
   * @param {string} [restoreRequestEnvelope.request.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 {string} [restoreRequestEnvelope.id] Gets the ID of the resource.
   * 
   * @param {string} [restoreRequestEnvelope.name] The name of the resource.
   * 
   * @param {string} restoreRequestEnvelope.location Gets or sets the location
   * of the resource.
   * 
   * @param {object} [restoreRequestEnvelope.tags] Gets or sets the tags
   * attached to the resource.
   * 
   * @param {string} [restoreRequestEnvelope.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.discover = function(resourceGroupName, webSiteName, slotName, restoreRequestEnvelope, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (restoreRequestEnvelope === null || restoreRequestEnvelope === undefined) {
      return callback(new Error('restoreRequestEnvelope cannot be null.'));
    }
    if (restoreRequestEnvelope.location === null || restoreRequestEnvelope.location === undefined) {
      return callback(new Error('restoreRequestEnvelope.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/restore/discover';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json';
    httpRequest.headers['x-ms-version'] = '2014-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var restoreRequestEnvelopeValue = {};
    requestDoc = restoreRequestEnvelopeValue;
    
    if (restoreRequestEnvelope.request !== null && restoreRequestEnvelope.request !== undefined) {
      var propertiesValue = {};
      restoreRequestEnvelopeValue['properties'] = propertiesValue;
      
      if (restoreRequestEnvelope.request.adjustConnectionStrings !== null && restoreRequestEnvelope.request.adjustConnectionStrings !== undefined) {
        propertiesValue['AdjustConnectionStrings'] = restoreRequestEnvelope.request.adjustConnectionStrings;
      }
      
      if (restoreRequestEnvelope.request.blobName !== null && restoreRequestEnvelope.request.blobName !== undefined) {
        propertiesValue['BlobName'] = restoreRequestEnvelope.request.blobName;
      }
      
      if (restoreRequestEnvelope.request.databases !== null && restoreRequestEnvelope.request.databases !== undefined) {
        var databasesArray = [];
        for (var loweredIndex1 = 0; loweredIndex1 < restoreRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {
          var databasesItem = restoreRequestEnvelope.request.databases[loweredIndex1];
          var databaseBackupSettingValue = {};
          databasesArray.push(databaseBackupSettingValue);
          
          if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
            databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;
          }
          
          if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
            databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;
          }
          
          if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
            databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;
          }
          
          if (databasesItem.name !== null && databasesItem.name !== undefined) {
            databaseBackupSettingValue['name'] = databasesItem.name;
          }
        }
        propertiesValue['Databases'] = databasesArray;
      }
      
      if (restoreRequestEnvelope.request.ignoreConflictingHostNames !== null && restoreRequestEnvelope.request.ignoreConflictingHostNames !== undefined) {
        propertiesValue['IgnoreConflictingHostNames'] = restoreRequestEnvelope.request.ignoreConflictingHostNames;
      }
      
      if (restoreRequestEnvelope.request.overwrite !== null && restoreRequestEnvelope.request.overwrite !== undefined) {
        propertiesValue['Overwrite'] = restoreRequestEnvelope.request.overwrite;
      }
      
      if (restoreRequestEnvelope.request.storageAccountUrl !== null && restoreRequestEnvelope.request.storageAccountUrl !== undefined) {
        propertiesValue['StorageAccountUrl'] = restoreRequestEnvelope.request.storageAccountUrl;
      }
    }
    
    if (restoreRequestEnvelope.id !== null && restoreRequestEnvelope.id !== undefined) {
      restoreRequestEnvelopeValue['id'] = restoreRequestEnvelope.id;
    }
    
    if (restoreRequestEnvelope.name !== null && restoreRequestEnvelope.name !== undefined) {
      restoreRequestEnvelopeValue['name'] = restoreRequestEnvelope.name;
    }
    
    restoreRequestEnvelopeValue['location'] = restoreRequestEnvelope.location;
    
    if (restoreRequestEnvelope.tags !== null && restoreRequestEnvelope.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in restoreRequestEnvelope.tags) {
        var tagsValue = restoreRequestEnvelope.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      restoreRequestEnvelopeValue['tags'] = tagsDictionary;
    }
    
    if (restoreRequestEnvelope.type !== null && restoreRequestEnvelope.type !== undefined) {
      restoreRequestEnvelopeValue['type'] = restoreRequestEnvelope.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var envelopeInstance = { tags: {} };
          result.envelope = envelopeInstance;
          
          var propertiesValue2 = responseDoc['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var propertiesInstance = { databases: [] };
            envelopeInstance.properties = propertiesInstance;
            
            var storageAccountUrlValue = propertiesValue2['storageAccountUrl'];
            if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {
              var storageAccountUrlInstance = storageAccountUrlValue;
              propertiesInstance.storageAccountUrl = storageAccountUrlInstance;
            }
            
            var blobNameValue = propertiesValue2['blobName'];
            if (blobNameValue !== null && blobNameValue !== undefined) {
              var blobNameInstance = blobNameValue;
              propertiesInstance.blobName = blobNameInstance;
            }
            
            var overwriteValue = propertiesValue2['overwrite'];
            if (overwriteValue !== null && overwriteValue !== undefined) {
              var overwriteInstance = overwriteValue;
              propertiesInstance.overwrite = overwriteInstance;
            }
            
            var databasesArray2 = propertiesValue2['databases'];
            if (databasesArray2 !== null && databasesArray2 !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < databasesArray2.length; loweredIndex2 = loweredIndex2 + 1) {
                var databasesValue = databasesArray2[loweredIndex2];
                var databaseBackupSettingInstance = {};
                propertiesInstance.databases.push(databaseBackupSettingInstance);
                
                var connectionStringValue = databasesValue['connectionString'];
                if (connectionStringValue !== null && connectionStringValue !== undefined) {
                  var connectionStringInstance = connectionStringValue;
                  databaseBackupSettingInstance.connectionString = connectionStringInstance;
                }
                
                var connectionStringNameValue = databasesValue['connectionStringName'];
                if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {
                  var connectionStringNameInstance = connectionStringNameValue;
                  databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                }
                
                var databaseTypeValue = databasesValue['databaseType'];
                if (databaseTypeValue !== null && databaseTypeValue !== undefined) {
                  var databaseTypeInstance = databaseTypeValue;
                  databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                }
                
                var nameValue = databasesValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  databaseBackupSettingInstance.name = nameInstance;
                }
              }
            }
            
            var ignoreConflictingHostNamesValue = propertiesValue2['ignoreConflictingHostNames'];
            if (ignoreConflictingHostNamesValue !== null && ignoreConflictingHostNamesValue !== undefined) {
              var ignoreConflictingHostNamesInstance = ignoreConflictingHostNamesValue;
              propertiesInstance.ignoreConflictingHostNames = ignoreConflictingHostNamesInstance;
            }
            
            var adjustConnectionStringsValue = propertiesValue2['adjustConnectionStrings'];
            if (adjustConnectionStringsValue !== null && adjustConnectionStringsValue !== undefined) {
              var adjustConnectionStringsInstance = adjustConnectionStringsValue;
              propertiesInstance.adjustConnectionStrings = adjustConnectionStringsInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            envelopeInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            envelopeInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            envelopeInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              envelopeInstance.tags[tagsKey2] = tagsValue2;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            envelopeInstance.type = typeInstance;
          }
        }
        
      }
      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, call 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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.generatePassword = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/newPassword';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteGetParameters} [parametersOrCallback] Additional parameters.
   * 
   * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list
   * of the names of any addtional parameters to return.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.get = function(resourceGroupName, webSiteName, slotName, 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 (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var webSiteInstance = { tags: {} };
          result.webSite = webSiteInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [], trafficManagerHostNames: [] };
            webSiteInstance.properties = propertiesInstance;
            
            var adminEnabledValue = propertiesValue['adminEnabled'];
            if (adminEnabledValue !== null && adminEnabledValue !== undefined) {
              var adminEnabledInstance = adminEnabledValue;
              propertiesInstance.adminEnabled = adminEnabledInstance;
            }
            
            var availabilityStateValue = propertiesValue['availabilityState'];
            if (availabilityStateValue !== null && availabilityStateValue !== undefined) {
              var availabilityStateInstance = availabilityStateValue;
              propertiesInstance.availabilityState = availabilityStateInstance;
            }
            
            var enabledValue = propertiesValue['enabled'];
            if (enabledValue !== null && enabledValue !== undefined) {
              var enabledInstance = enabledValue;
              propertiesInstance.enabled = enabledInstance;
            }
            
            var enabledHostNamesArray = propertiesValue['enabledHostNames'];
            if (enabledHostNamesArray !== null && enabledHostNamesArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < enabledHostNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var enabledHostNamesValue = enabledHostNamesArray[loweredIndex1];
                propertiesInstance.enabledHostNames.push(enabledHostNamesValue);
              }
            }
            
            var hostNameSslStatesArray = propertiesValue['hostNameSslStates'];
            if (hostNameSslStatesArray !== null && hostNameSslStatesArray !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < hostNameSslStatesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                var hostNameSslStatesValue = hostNameSslStatesArray[loweredIndex2];
                var webSiteHostNameSslStateInstance = {};
                propertiesInstance.hostNameSslStates.push(webSiteHostNameSslStateInstance);
                
                var nameValue = hostNameSslStatesValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  webSiteHostNameSslStateInstance.name = nameInstance;
                }
                
                var sslStateValue = hostNameSslStatesValue['sslState'];
                if (sslStateValue !== null && sslStateValue !== undefined) {
                  var sslStateInstance = sslStateValue;
                  webSiteHostNameSslStateInstance.sslState = sslStateInstance;
                }
                
                var thumbprintValue = hostNameSslStatesValue['thumbprint'];
                if (thumbprintValue !== null && thumbprintValue !== undefined) {
                  var thumbprintInstance = thumbprintValue;
                  webSiteHostNameSslStateInstance.thumbprint = thumbprintInstance;
                }
                
                var virtualIPValue = hostNameSslStatesValue['virtualIP'];
                if (virtualIPValue !== null && virtualIPValue !== undefined) {
                  var virtualIPInstance = virtualIPValue;
                  webSiteHostNameSslStateInstance.virtualIP = virtualIPInstance;
                }
                
                var ipBasedSslResultValue = hostNameSslStatesValue['ipBasedSslResult'];
                if (ipBasedSslResultValue !== null && ipBasedSslResultValue !== undefined) {
                  var ipBasedSslResultInstance = ipBasedSslResultValue;
                  webSiteHostNameSslStateInstance.ipBasedSslResult = ipBasedSslResultInstance;
                }
                
                var toUpdateValue = hostNameSslStatesValue['toUpdate'];
                if (toUpdateValue !== null && toUpdateValue !== undefined) {
                  var toUpdateInstance = toUpdateValue;
                  webSiteHostNameSslStateInstance.toUpdate = toUpdateInstance;
                }
                
                var toUpdateIpBasedSslValue = hostNameSslStatesValue['toUpdateIpBasedSsl'];
                if (toUpdateIpBasedSslValue !== null && toUpdateIpBasedSslValue !== undefined) {
                  var toUpdateIpBasedSslInstance = toUpdateIpBasedSslValue;
                  webSiteHostNameSslStateInstance.toUpdateIpBasedSsl = toUpdateIpBasedSslInstance;
                }
              }
            }
            
            var hostNamesArray = propertiesValue['hostNames'];
            if (hostNamesArray !== null && hostNamesArray !== undefined) {
              for (var loweredIndex3 = 0; loweredIndex3 < hostNamesArray.length; loweredIndex3 = loweredIndex3 + 1) {
                var hostNamesValue = hostNamesArray[loweredIndex3];
                propertiesInstance.hostNames.push(hostNamesValue);
              }
            }
            
            var lastModifiedTimeUtcValue = propertiesValue['lastModifiedTimeUtc'];
            if (lastModifiedTimeUtcValue !== null && lastModifiedTimeUtcValue !== undefined) {
              var lastModifiedTimeUtcInstance = lastModifiedTimeUtcValue;
              propertiesInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;
            }
            
            var repositorySiteNameValue = propertiesValue['repositorySiteName'];
            if (repositorySiteNameValue !== null && repositorySiteNameValue !== undefined) {
              var repositorySiteNameInstance = repositorySiteNameValue;
              propertiesInstance.repositorySiteName = repositorySiteNameInstance;
            }
            
            var runtimeAvailabilityStateValue = propertiesValue['runtimeAvailabilityState'];
            if (runtimeAvailabilityStateValue !== null && runtimeAvailabilityStateValue !== undefined) {
              var runtimeAvailabilityStateInstance = runtimeAvailabilityStateValue;
              propertiesInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;
            }
            
            var trafficManagerHostNamesArray = propertiesValue['trafficManagerHostNames'];
            if (trafficManagerHostNamesArray !== null && trafficManagerHostNamesArray !== undefined) {
              for (var loweredIndex4 = 0; loweredIndex4 < trafficManagerHostNamesArray.length; loweredIndex4 = loweredIndex4 + 1) {
                var trafficManagerHostNamesValue = trafficManagerHostNamesArray[loweredIndex4];
                propertiesInstance.trafficManagerHostNames.push(trafficManagerHostNamesValue);
              }
            }
            
            var selfLinkValue = propertiesValue['selfLink'];
            if (selfLinkValue !== null && selfLinkValue !== undefined) {
              var selfLinkInstance = selfLinkValue;
              propertiesInstance.uri = selfLinkInstance;
            }
            
            var serverFarmValue = propertiesValue['serverFarm'];
            if (serverFarmValue !== null && serverFarmValue !== undefined) {
              var serverFarmInstance = serverFarmValue;
              propertiesInstance.serverFarm = serverFarmInstance;
            }
            
            var skuValue = propertiesValue['sku'];
            if (skuValue !== null && skuValue !== undefined) {
              var skuInstance = skuValue;
              propertiesInstance.sku = skuInstance;
            }
            
            var sitePropertiesValue = propertiesValue['siteProperties'];
            if (sitePropertiesValue !== null && sitePropertiesValue !== undefined) {
              var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };
              propertiesInstance.properties = sitePropertiesInstance;
              
              var appSettingsSequenceElement = sitePropertiesValue['appSettings'];
              if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
                for (var property in appSettingsSequenceElement) {
                  var appSettingsKey = property;
                  var appSettingsValue = appSettingsSequenceElement[property];
                  sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
                }
              }
              
              var metadataSequenceElement = sitePropertiesValue['metadata'];
              if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
                for (var property2 in metadataSequenceElement) {
                  var metadataKey = property2;
                  var metadataValue = metadataSequenceElement[property2];
                  sitePropertiesInstance.metadata[metadataKey] = metadataValue;
                }
              }
              
              var propertiesSequenceElement = sitePropertiesValue['properties'];
              if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {
                for (var property3 in propertiesSequenceElement) {
                  var propertiesKey = property3;
                  var propertiesValue2 = propertiesSequenceElement[property3];
                  sitePropertiesInstance.properties[propertiesKey] = propertiesValue2;
                }
              }
            }
            
            var stateValue = propertiesValue['state'];
            if (stateValue !== null && stateValue !== undefined) {
              var stateInstance = stateValue;
              propertiesInstance.state = stateInstance;
            }
            
            var usageStateValue = propertiesValue['usageState'];
            if (usageStateValue !== null && usageStateValue !== undefined) {
              var usageStateInstance = usageStateValue;
              propertiesInstance.usageState = usageStateInstance;
            }
            
            var webSpaceValue = propertiesValue['webSpace'];
            if (webSpaceValue !== null && webSpaceValue !== undefined) {
              var webSpaceInstance = webSpaceValue;
              propertiesInstance.webSpace = webSpaceInstance;
            }
            
            var provisioningStateValue = propertiesValue['provisioningState'];
            if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
              var provisioningStateInstance = provisioningStateValue;
              propertiesInstance.provisioningState = provisioningStateInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            webSiteInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            webSiteInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            webSiteInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property4 in tagsSequenceElement) {
              var tagsKey = property4;
              var tagsValue = tagsSequenceElement[property4];
              webSiteInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            webSiteInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Restart the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot of the website
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getAppSettings = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/appsettings/list';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { properties: [], tags: {} };
          result.resource = resourceInstance;
          
          var propertiesArray = responseDoc['properties'];
          if (propertiesArray !== null && propertiesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var propertiesValue = propertiesArray[loweredIndex1];
              var nameValuePairInstance = {};
              resourceInstance.properties.push(nameValuePairInstance);
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                nameValuePairInstance.name = nameInstance;
              }
              
              var valueValue = propertiesValue['value'];
              if (valueValue !== null && valueValue !== undefined) {
                var valueInstance = valueValue;
                nameValuePairInstance.value = valueInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            resourceInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a schedule configuration for site backups.
   * 
   * @param {string} resourceGroupName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getBackupConfiguration = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/backup/config';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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-06-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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var backupScheduleInstance = { tags: {} };
          result.backupSchedule = backupScheduleInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { databases: [] };
            backupScheduleInstance.properties = propertiesInstance;
            
            var enabledValue = propertiesValue['enabled'];
            if (enabledValue !== null && enabledValue !== undefined) {
              var enabledInstance = enabledValue;
              propertiesInstance.enabled = enabledInstance;
            }
            
            var nameValue = propertiesValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              propertiesInstance.name = nameInstance;
            }
            
            var storageAccountUrlValue = propertiesValue['storageAccountUrl'];
            if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {
              var storageAccountUrlInstance = storageAccountUrlValue;
              propertiesInstance.storageAccountUrl = storageAccountUrlInstance;
            }
            
            var backupScheduleValue = propertiesValue['backupSchedule'];
            if (backupScheduleValue !== null && backupScheduleValue !== undefined) {
              var backupScheduleInstance2 = {};
              propertiesInstance.backupSchedule = backupScheduleInstance2;
              
              var frequencyIntervalValue = backupScheduleValue['frequencyInterval'];
              if (frequencyIntervalValue !== null && frequencyIntervalValue !== undefined) {
                var frequencyIntervalInstance = frequencyIntervalValue;
                backupScheduleInstance2.frequencyInterval = frequencyIntervalInstance;
              }
              
              var frequencyUnitValue = backupScheduleValue['frequencyUnit'];
              if (frequencyUnitValue !== null && frequencyUnitValue !== undefined) {
                var frequencyUnitInstance = frequencyUnitValue;
                backupScheduleInstance2.frequencyUnit = frequencyUnitInstance;
              }
              
              var keepAtLeastOneBackupValue = backupScheduleValue['keepAtLeastOneBackup'];
              if (keepAtLeastOneBackupValue !== null && keepAtLeastOneBackupValue !== undefined) {
                var keepAtLeastOneBackupInstance = keepAtLeastOneBackupValue;
                backupScheduleInstance2.keepAtLeastOneBackup = keepAtLeastOneBackupInstance;
              }
              
              var lastExecutionTimeValue = backupScheduleValue['lastExecutionTime'];
              if (lastExecutionTimeValue !== null && lastExecutionTimeValue !== undefined) {
                var lastExecutionTimeInstance = lastExecutionTimeValue;
                backupScheduleInstance2.lastExecutionTime = lastExecutionTimeInstance;
              }
              
              var retentionPeriodInDaysValue = backupScheduleValue['retentionPeriodInDays'];
              if (retentionPeriodInDaysValue !== null && retentionPeriodInDaysValue !== undefined) {
                var retentionPeriodInDaysInstance = retentionPeriodInDaysValue;
                backupScheduleInstance2.retentionPeriodInDays = retentionPeriodInDaysInstance;
              }
              
              var startTimeValue = backupScheduleValue['startTime'];
              if (startTimeValue !== null && startTimeValue !== undefined) {
                var startTimeInstance = startTimeValue;
                backupScheduleInstance2.startTime = startTimeInstance;
              }
            }
            
            var databasesArray = propertiesValue['databases'];
            if (databasesArray !== null && databasesArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < databasesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var databasesValue = databasesArray[loweredIndex1];
                var databaseBackupSettingInstance = {};
                propertiesInstance.databases.push(databaseBackupSettingInstance);
                
                var connectionStringValue = databasesValue['connectionString'];
                if (connectionStringValue !== null && connectionStringValue !== undefined) {
                  var connectionStringInstance = connectionStringValue;
                  databaseBackupSettingInstance.connectionString = connectionStringInstance;
                }
                
                var connectionStringNameValue = databasesValue['connectionStringName'];
                if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {
                  var connectionStringNameInstance = connectionStringNameValue;
                  databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                }
                
                var databaseTypeValue = databasesValue['databaseType'];
                if (databaseTypeValue !== null && databaseTypeValue !== undefined) {
                  var databaseTypeInstance = databaseTypeValue;
                  databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                }
                
                var nameValue2 = databasesValue['name'];
                if (nameValue2 !== null && nameValue2 !== undefined) {
                  var nameInstance2 = nameValue2;
                  databaseBackupSettingInstance.name = nameInstance2;
                }
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            backupScheduleInstance.id = idInstance;
          }
          
          var nameValue3 = responseDoc['name'];
          if (nameValue3 !== null && nameValue3 !== undefined) {
            var nameInstance3 = nameValue3;
            backupScheduleInstance.name = nameInstance3;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            backupScheduleInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              backupScheduleInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            backupScheduleInstance.type = typeInstance;
          }
        }
        
      }
      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, or update them by using HTTP PUT with a request body that
   * contains the settings to be updated.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteGetConfigurationParameters} [parametersOrCallback]
   * Additional parameters.
   * 
   * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list
   * of the names of any addtional parameters to return.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getConfiguration = function(resourceGroupName, webSiteName, slotName, 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 (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/web';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { tags: {} };
          result.resource = resourceInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { appSettings: {}, connectionStrings: [], defaultDocuments: [], handlerMappings: [], metadata: {} };
            resourceInstance.properties = propertiesInstance;
            
            var appSettingsSequenceElement = propertiesValue['appSettings'];
            if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
              for (var property in appSettingsSequenceElement) {
                var appSettingsKey = property;
                var appSettingsValue = appSettingsSequenceElement[property];
                propertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
              }
            }
            
            var connectionStringsArray = propertiesValue['connectionStrings'];
            if (connectionStringsArray !== null && connectionStringsArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < connectionStringsArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var connectionStringsValue = connectionStringsArray[loweredIndex1];
                var connStringInfoInstance = {};
                propertiesInstance.connectionStrings.push(connStringInfoInstance);
                
                var connectionStringValue = connectionStringsValue['connectionString'];
                if (connectionStringValue !== null && connectionStringValue !== undefined) {
                  var connectionStringInstance = connectionStringValue;
                  connStringInfoInstance.connectionString = connectionStringInstance;
                }
                
                var nameValue = connectionStringsValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  connStringInfoInstance.name = nameInstance;
                }
                
                var typeValue = connectionStringsValue['type'];
                if (typeValue !== null && typeValue !== undefined) {
                  var typeInstance = typeValue;
                  connStringInfoInstance.type = typeInstance;
                }
              }
            }
            
            var defaultDocumentsArray = propertiesValue['defaultDocuments'];
            if (defaultDocumentsArray !== null && defaultDocumentsArray !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < defaultDocumentsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                var defaultDocumentsValue = defaultDocumentsArray[loweredIndex2];
                propertiesInstance.defaultDocuments.push(defaultDocumentsValue);
              }
            }
            
            var detailedErrorLoggingEnabledValue = propertiesValue['detailedErrorLoggingEnabled'];
            if (detailedErrorLoggingEnabledValue !== null && detailedErrorLoggingEnabledValue !== undefined) {
              var detailedErrorLoggingEnabledInstance = detailedErrorLoggingEnabledValue;
              propertiesInstance.detailedErrorLoggingEnabled = detailedErrorLoggingEnabledInstance;
            }
            
            var documentRootValue = propertiesValue['documentRoot'];
            if (documentRootValue !== null && documentRootValue !== undefined) {
              var documentRootInstance = documentRootValue;
              propertiesInstance.documentRoot = documentRootInstance;
            }
            
            var handlerMappingsArray = propertiesValue['handlerMappings'];
            if (handlerMappingsArray !== null && handlerMappingsArray !== undefined) {
              for (var loweredIndex3 = 0; loweredIndex3 < handlerMappingsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                var handlerMappingsValue = handlerMappingsArray[loweredIndex3];
                var handlerMappingInstance = {};
                propertiesInstance.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 = propertiesValue['httpLoggingEnabled'];
            if (httpLoggingEnabledValue !== null && httpLoggingEnabledValue !== undefined) {
              var httpLoggingEnabledInstance = httpLoggingEnabledValue;
              propertiesInstance.httpLoggingEnabled = httpLoggingEnabledInstance;
            }
            
            var logsDirectorySizeLimitValue = propertiesValue['logsDirectorySizeLimit'];
            if (logsDirectorySizeLimitValue !== null && logsDirectorySizeLimitValue !== undefined) {
              var logsDirectorySizeLimitInstance = logsDirectorySizeLimitValue;
              propertiesInstance.logsDirectorySizeLimit = logsDirectorySizeLimitInstance;
            }
            
            var managedPipelineModeValue = propertiesValue['managedPipelineMode'];
            if (managedPipelineModeValue !== null && managedPipelineModeValue !== undefined) {
              var managedPipelineModeInstance = managedPipelineModeValue;
              propertiesInstance.managedPipelineMode = managedPipelineModeInstance;
            }
            
            var metadataSequenceElement = propertiesValue['metadata'];
            if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
              for (var property2 in metadataSequenceElement) {
                var metadataKey = property2;
                var metadataValue = metadataSequenceElement[property2];
                propertiesInstance.metadata[metadataKey] = metadataValue;
              }
            }
            
            var netFrameworkVersionValue = propertiesValue['netFrameworkVersion'];
            if (netFrameworkVersionValue !== null && netFrameworkVersionValue !== undefined) {
              var netFrameworkVersionInstance = netFrameworkVersionValue;
              propertiesInstance.netFrameworkVersion = netFrameworkVersionInstance;
            }
            
            var numberOfWorkersValue = propertiesValue['numberOfWorkers'];
            if (numberOfWorkersValue !== null && numberOfWorkersValue !== undefined) {
              var numberOfWorkersInstance = numberOfWorkersValue;
              propertiesInstance.numberOfWorkers = numberOfWorkersInstance;
            }
            
            var phpVersionValue = propertiesValue['phpVersion'];
            if (phpVersionValue !== null && phpVersionValue !== undefined) {
              var phpVersionInstance = phpVersionValue;
              propertiesInstance.phpVersion = phpVersionInstance;
            }
            
            var pythonVersionValue = propertiesValue['pythonVersion'];
            if (pythonVersionValue !== null && pythonVersionValue !== undefined) {
              var pythonVersionInstance = pythonVersionValue;
              propertiesInstance.pythonVersion = pythonVersionInstance;
            }
            
            var publishingPasswordValue = propertiesValue['publishingPassword'];
            if (publishingPasswordValue !== null && publishingPasswordValue !== undefined) {
              var publishingPasswordInstance = publishingPasswordValue;
              propertiesInstance.publishingPassword = publishingPasswordInstance;
            }
            
            var publishingUsernameValue = propertiesValue['publishingUsername'];
            if (publishingUsernameValue !== null && publishingUsernameValue !== undefined) {
              var publishingUsernameInstance = publishingUsernameValue;
              propertiesInstance.publishingUserName = publishingUsernameInstance;
            }
            
            var remoteDebuggingEnabledValue = propertiesValue['RemoteDebuggingEnabled'];
            if (remoteDebuggingEnabledValue !== null && remoteDebuggingEnabledValue !== undefined) {
              var remoteDebuggingEnabledInstance = remoteDebuggingEnabledValue;
              propertiesInstance.remoteDebuggingEnabled = remoteDebuggingEnabledInstance;
            }
            
            var remoteDebuggingVersionValue = propertiesValue['remoteDebuggingVersion'];
            if (remoteDebuggingVersionValue !== null && remoteDebuggingVersionValue !== undefined) {
              var remoteDebuggingVersionInstance = remoteDebuggingVersionValue;
              propertiesInstance.remoteDebuggingVersion = remoteDebuggingVersionInstance;
            }
            
            var requestTracingEnabledValue = propertiesValue['requestTracingEnabled'];
            if (requestTracingEnabledValue !== null && requestTracingEnabledValue !== undefined) {
              var requestTracingEnabledInstance = requestTracingEnabledValue;
              propertiesInstance.requestTracingEnabled = requestTracingEnabledInstance;
            }
            
            var requestTracingExpirationTimeValue = propertiesValue['requestTracingExpirationTime'];
            if (requestTracingExpirationTimeValue !== null && requestTracingExpirationTimeValue !== undefined) {
              var requestTracingExpirationTimeInstance = requestTracingExpirationTimeValue;
              propertiesInstance.requestTracingExpirationTime = requestTracingExpirationTimeInstance;
            }
            
            var scmTypeValue = propertiesValue['scmType'];
            if (scmTypeValue !== null && scmTypeValue !== undefined) {
              var scmTypeInstance = scmTypeValue;
              propertiesInstance.scmType = scmTypeInstance;
            }
            
            var autoSwapSlotNameValue = propertiesValue['autoSwapSlotName'];
            if (autoSwapSlotNameValue !== null && autoSwapSlotNameValue !== undefined) {
              var autoSwapSlotNameInstance = autoSwapSlotNameValue;
              propertiesInstance.autoSwapSlotName = autoSwapSlotNameInstance;
            }
            
            var use32BitWorkerProcessValue = propertiesValue['use32BitWorkerProcess'];
            if (use32BitWorkerProcessValue !== null && use32BitWorkerProcessValue !== undefined) {
              var use32BitWorkerProcessInstance = use32BitWorkerProcessValue;
              propertiesInstance.use32BitWorkerProcess = use32BitWorkerProcessInstance;
            }
            
            var webSocketsEnabledValue = propertiesValue['webSocketsEnabled'];
            if (webSocketsEnabledValue !== null && webSocketsEnabledValue !== undefined) {
              var webSocketsEnabledInstance = webSocketsEnabledValue;
              propertiesInstance.webSocketsEnabled = webSocketsEnabledInstance;
            }
            
            var limitsValue = propertiesValue['limits'];
            if (limitsValue !== null && limitsValue !== undefined) {
              var limitsInstance = {};
              propertiesInstance.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;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property3 in tagsSequenceElement) {
              var tagsKey = property3;
              var tagsValue = tagsSequenceElement[property3];
              resourceInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue2 = responseDoc['type'];
          if (typeValue2 !== null && typeValue2 !== undefined) {
            var typeInstance2 = typeValue2;
            resourceInstance.type = typeInstance2;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Restart the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot of the web site
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getConnectionStrings = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/connectionstrings/list';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { properties: [], tags: {} };
          result.resource = resourceInstance;
          
          var propertiesArray = responseDoc['properties'];
          if (propertiesArray !== null && propertiesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var propertiesValue = propertiesArray[loweredIndex1];
              var connStringInfoInstance = {};
              resourceInstance.properties.push(connStringInfoInstance);
              
              var connectionStringValue = propertiesValue['connectionString'];
              if (connectionStringValue !== null && connectionStringValue !== undefined) {
                var connectionStringInstance = connectionStringValue;
                connStringInfoInstance.connectionString = connectionStringInstance;
              }
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                connStringInfoInstance.name = nameInstance;
              }
              
              var typeValue = propertiesValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                connStringInfoInstance.type = typeInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue2 = responseDoc['type'];
          if (typeValue2 !== null && typeValue2 !== undefined) {
            var typeInstance2 = typeValue2;
            resourceInstance.type = typeInstance2;
          }
        }
        
      }
      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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteGetHistoricalUsageMetricsParameters} parameters The Get Web
   * Site Historical Usage Metrics parameters.
   * 
   * @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(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/metrics';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var propertiesArray = responseDoc['properties'];
          if (propertiesArray !== null && propertiesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var propertiesValue = propertiesArray[loweredIndex1];
              var historicalUsageMetricInstance = {};
              result.usageMetrics.push(historicalUsageMetricInstance);
              
              var codeValue = propertiesValue['code'];
              if (codeValue !== null && codeValue !== undefined) {
                var codeInstance = codeValue;
                historicalUsageMetricInstance.code = codeInstance;
              }
              
              var dataValue = propertiesValue['data'];
              if (dataValue !== null && dataValue !== undefined) {
                var dataInstance = { values: [] };
                historicalUsageMetricInstance.data = dataInstance;
                
                var displayNameValue = dataValue['displayName'];
                if (displayNameValue !== null && displayNameValue !== undefined) {
                  var displayNameInstance = displayNameValue;
                  dataInstance.displayName = displayNameInstance;
                }
                
                var endTimeValue = dataValue['EndTime'];
                if (endTimeValue !== null && endTimeValue !== undefined) {
                  var endTimeInstance = endTimeValue;
                  dataInstance.endTime = endTimeInstance;
                }
                
                var nameValue = dataValue['name'];
                if (nameValue !== null && nameValue !== undefined) {
                  var nameInstance = nameValue;
                  dataInstance.name = nameInstance;
                }
                
                var primaryAggregationTypeValue = dataValue['primaryAggregationType'];
                if (primaryAggregationTypeValue !== null && primaryAggregationTypeValue !== undefined) {
                  var primaryAggregationTypeInstance = primaryAggregationTypeValue;
                  dataInstance.primaryAggregationType = primaryAggregationTypeInstance;
                }
                
                var startTimeValue = dataValue['startTime'];
                if (startTimeValue !== null && startTimeValue !== undefined) {
                  var startTimeInstance = startTimeValue;
                  dataInstance.startTime = startTimeInstance;
                }
                
                var timeGrainValue = dataValue['timeGrain'];
                if (timeGrainValue !== null && timeGrainValue !== undefined) {
                  var timeGrainInstance = timeGrainValue;
                  dataInstance.timeGrain = timeGrainInstance;
                }
                
                var unitValue = dataValue['unit'];
                if (unitValue !== null && unitValue !== undefined) {
                  var unitInstance = unitValue;
                  dataInstance.unit = unitInstance;
                }
                
                var valuesArray = dataValue['values'];
                if (valuesArray !== null && valuesArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < valuesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var valuesValue = valuesArray[loweredIndex2];
                    var metricSampleInstance = {};
                    dataInstance.values.push(metricSampleInstance);
                    
                    var countValue = valuesValue['count'];
                    if (countValue !== null && countValue !== undefined) {
                      var countInstance = countValue;
                      metricSampleInstance.count = countInstance;
                    }
                    
                    var maximumValue = valuesValue['maximum'];
                    if (maximumValue !== null && maximumValue !== undefined) {
                      var maximumInstance = maximumValue;
                      metricSampleInstance.maximum = maximumInstance;
                    }
                    
                    var minimumValue = valuesValue['minimum'];
                    if (minimumValue !== null && minimumValue !== undefined) {
                      var minimumInstance = minimumValue;
                      metricSampleInstance.minimum = minimumInstance;
                    }
                    
                    var timeCreatedValue = valuesValue['timeCreated'];
                    if (timeCreatedValue !== null && timeCreatedValue !== undefined) {
                      var timeCreatedInstance = timeCreatedValue;
                      metricSampleInstance.timeCreated = timeCreatedInstance;
                    }
                    
                    var totalValue = valuesValue['total'];
                    if (totalValue !== null && totalValue !== undefined) {
                      var totalInstance = totalValue;
                      metricSampleInstance.total = totalInstance;
                    }
                    
                    var instanceNameValue = valuesValue['instanceName'];
                    if (instanceNameValue !== null && instanceNameValue !== undefined) {
                      var instanceNameInstance = instanceNameValue;
                      metricSampleInstance.instanceName = instanceNameInstance;
                    }
                  }
                }
              }
              
              var messageValue = propertiesValue['message'];
              if (messageValue !== null && messageValue !== undefined) {
                var messageInstance = messageValue;
                historicalUsageMetricInstance.message = messageInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Restart the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot of the web site
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getMetadata = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/metadata/list';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { properties: [], tags: {} };
          result.resource = resourceInstance;
          
          var propertiesArray = responseDoc['properties'];
          if (propertiesArray !== null && propertiesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var propertiesValue = propertiesArray[loweredIndex1];
              var nameValuePairInstance = {};
              resourceInstance.properties.push(nameValuePairInstance);
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                nameValuePairInstance.name = nameInstance;
              }
              
              var valueValue = propertiesValue['value'];
              if (valueValue !== null && valueValue !== undefined) {
                var valueInstance = valueValue;
                nameValuePairInstance.value = valueInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            resourceInstance.type = typeInstance;
          }
        }
        
      }
      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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {Guid} [operationId] Additional parameters.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getOperation = function(resourceGroupName, webSiteName, slotName, operationId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/operations/';
    if (operationId !== null && operationId !== undefined) {
      url2 = url2 + encodeURIComponent(operationId);
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 && 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 === 201 || statusCode === 202) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            result.location = locationInstance;
          }
          
          var retryAfterValue = responseDoc['retry-after'];
          if (retryAfterValue !== null && retryAfterValue !== undefined) {
            var retryAfterInstance = retryAfterValue;
            result.retryAfter = retryAfterInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.location = response.headers['location'];
      result.retryAfter = response.headers['retry-after'];
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get publishing credentials for the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot of the web site.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getPublishingCredentials = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/publishingcredentials/list';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { tags: {} };
          result.resource = resourceInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = {};
            resourceInstance.properties = propertiesInstance;
            
            var publishingPasswordValue = propertiesValue['publishingPassword'];
            if (publishingPasswordValue !== null && publishingPasswordValue !== undefined) {
              var publishingPasswordInstance = publishingPasswordValue;
              propertiesInstance.publishingPassword = publishingPasswordInstance;
            }
            
            var publishingUserNameValue = propertiesValue['publishingUserName'];
            if (publishingUserNameValue !== null && publishingUserNameValue !== undefined) {
              var publishingUserNameInstance = publishingUserNameValue;
              propertiesInstance.publishingUserName = publishingUserNameInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            resourceInstance.name = nameInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            resourceInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Retrieve the publish settings information for a web site.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166996.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getPublishProfile = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/publishxml';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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-Type'] = 'application/xml';
    
    // 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 publishDataSequenceElement = js2xml.getElement(responseDoc, responseDoc, 'PUBLISHDATA', '');
          if (publishDataSequenceElement !== null && publishDataSequenceElement !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, publishDataSequenceElement, 'PUBLISHPROFILE', '').length; loweredIndex1 = loweredIndex1 + 1) {
              var publishDataElement = js2xml.getElements(responseDoc, publishDataSequenceElement, 'PUBLISHPROFILE', '')[loweredIndex1];
              var publishProfileInstance = { databases: [] };
              result.publishProfiles.push(publishProfileInstance);
              
              var profileNameAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'PROFILENAME', '');
              if (profileNameAttribute !== null && profileNameAttribute !== undefined) {
                publishProfileInstance.profileName = profileNameAttribute;
              }
              
              var publishMethodAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'PUBLISHMETHOD', '');
              if (publishMethodAttribute !== null && publishMethodAttribute !== undefined) {
                publishProfileInstance.publishMethod = publishMethodAttribute;
              }
              
              var publishUrlAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'PUBLISHURL', '');
              if (publishUrlAttribute !== null && publishUrlAttribute !== undefined) {
                publishProfileInstance.publishUrl = publishUrlAttribute;
              }
              
              var msdeploySiteAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'MSDEPLOYSITE', '');
              if (msdeploySiteAttribute !== null && msdeploySiteAttribute !== undefined) {
                publishProfileInstance.mSDeploySite = msdeploySiteAttribute;
              }
              
              var ftpPassiveModeAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'FTPPASSIVEMODE', '');
              if (ftpPassiveModeAttribute !== null && ftpPassiveModeAttribute !== undefined && (ftpPassiveModeAttribute === null || ftpPassiveModeAttribute === undefined || ftpPassiveModeAttribute.length === 0) === false) {
                publishProfileInstance.ftpPassiveMode = ftpPassiveModeAttribute === 'true';
              }
              
              var userNameAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'USERNAME', '');
              if (userNameAttribute !== null && userNameAttribute !== undefined) {
                publishProfileInstance.userName = userNameAttribute;
              }
              
              var userPWDAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'USERPWD', '');
              if (userPWDAttribute !== null && userPWDAttribute !== undefined) {
                publishProfileInstance.userPassword = userPWDAttribute;
              }
              
              var destinationAppUrlAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'DESTINATIONAPPURL', '');
              if (destinationAppUrlAttribute !== null && destinationAppUrlAttribute !== undefined) {
                publishProfileInstance.destinationAppUri = destinationAppUrlAttribute;
              }
              
              var sQLServerDBConnectionStringAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'SQLSERVERDBCONNECTIONSTRING', '');
              if (sQLServerDBConnectionStringAttribute !== null && sQLServerDBConnectionStringAttribute !== undefined) {
                publishProfileInstance.sqlServerConnectionString = sQLServerDBConnectionStringAttribute;
              }
              
              var mySQLDBConnectionStringAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'MYSQLDBCONNECTIONSTRING', '');
              if (mySQLDBConnectionStringAttribute !== null && mySQLDBConnectionStringAttribute !== undefined) {
                publishProfileInstance.mySqlConnectionString = mySQLDBConnectionStringAttribute;
              }
              
              var hostingProviderForumLinkAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'HOSTINGPROVIDERFORUMLINK', '');
              if (hostingProviderForumLinkAttribute !== null && hostingProviderForumLinkAttribute !== undefined) {
                publishProfileInstance.hostingProviderForumUri = hostingProviderForumLinkAttribute;
              }
              
              var controlPanelLinkAttribute = js2xml.getAttribute(responseDoc, publishDataElement, 'CONTROLPANELLINK', '');
              if (controlPanelLinkAttribute !== null && controlPanelLinkAttribute !== undefined) {
                publishProfileInstance.controlPanelUri = controlPanelLinkAttribute;
              }
              
              var databasesSequenceElement = js2xml.getElement(responseDoc, publishDataElement, '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. You can create a
   * repository for your web site by issuing an HTTP POST request, or retrieve
   * information about the repository by using HTTP GET.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166967.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getRepository = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/repository';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var uriValue = responseDoc['uri'];
          if (uriValue !== null && uriValue !== undefined) {
            var uriInstance = uriValue;
            result.uri = uriInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Update list of app settings and connection strings which to be slot
   * specific. E.g. settings in staging slots remain in staging after swap
   * with production.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName The name of the website
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getSlotConfigNames = function(resourceGroupName, webSiteName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/slotConfigNames';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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['accept'] = 'application/json';
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { tags: {} };
          result.resource = resourceInstance;
          
          var propertiesValue = responseDoc['properties'];
          if (propertiesValue !== null && propertiesValue !== undefined) {
            var propertiesInstance = { appSettingNames: [], connectionStringNames: [] };
            resourceInstance.properties = propertiesInstance;
            
            var connectionStringNamesArray = propertiesValue['connectionStringNames'];
            if (connectionStringNamesArray !== null && connectionStringNamesArray !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < connectionStringNamesArray.length; loweredIndex1 = loweredIndex1 + 1) {
                var connectionStringNamesValue = connectionStringNamesArray[loweredIndex1];
                propertiesInstance.connectionStringNames.push(connectionStringNamesValue);
              }
            }
            
            var appSettingNamesArray = propertiesValue['appSettingNames'];
            if (appSettingNamesArray !== null && appSettingNamesArray !== undefined) {
              for (var loweredIndex2 = 0; loweredIndex2 < appSettingNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                var appSettingNamesValue = appSettingNamesArray[loweredIndex2];
                propertiesInstance.appSettingNames.push(appSettingNamesValue);
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            resourceInstance.name = nameInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            resourceInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Get a web site's current usage metrics. 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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.getUsageMetrics = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/usages';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        var usagesValue = responseDoc['usages'];
        if (usagesValue !== null && usagesValue !== undefined) {
          var usagesInstance = { usageMetrics: [] };
          
          var usageMetricsArray = usagesValue;
          if (usageMetricsArray !== null && usageMetricsArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < usageMetricsArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var usageMetricsValue = usageMetricsArray[loweredIndex1];
              var usageInstance = {};
              usagesInstance.usageMetrics.push(usageInstance);
              
              var currentValueValue = usageMetricsValue['currentValue'];
              if (currentValueValue !== null && currentValueValue !== undefined) {
                var currentValueInstance = currentValueValue;
                usageInstance.currentValue = currentValueInstance;
              }
              
              var displayNameValue = usageMetricsValue['displayName'];
              if (displayNameValue !== null && displayNameValue !== undefined) {
                var displayNameInstance = displayNameValue;
                usageInstance.displayName = displayNameInstance;
              }
              
              var limitValue = usageMetricsValue['limit'];
              if (limitValue !== null && limitValue !== undefined) {
                var limitInstance = limitValue;
                usageInstance.limit = limitInstance;
              }
              
              var nameValue = usageMetricsValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                usageInstance.name = nameInstance;
              }
              
              var nextResetTimeValue = usageMetricsValue['nextResetTime'];
              if (nextResetTimeValue !== null && nextResetTimeValue !== undefined) {
                var nextResetTimeInstance = nextResetTimeValue;
                usageInstance.nextResetTime = nextResetTimeInstance;
              }
              
              var resourceNameValue = usageMetricsValue['resourceName'];
              if (resourceNameValue !== null && resourceNameValue !== undefined) {
                var resourceNameInstance = resourceNameValue;
                usageInstance.resourceName = resourceNameInstance;
              }
              
              var unitValue = usageMetricsValue['unit'];
              if (unitValue !== null && unitValue !== undefined) {
                var unitInstance = unitValue;
                usageInstance.unit = unitInstance;
              }
            }
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * List the Web Sites in a resource group.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} [webSiteName] The name of the web site.
   * 
   * @param {WebSiteListParameters} [parametersOrCallback] Additional
   * parameters.
   * 
   * @param {array} [parametersOrCallback.propertiesToInclude] Specifies a list
   * of the names of any addtional parameters to return.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.list = function(resourceGroupName, 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 (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    if (webSiteName !== null && webSiteName !== undefined) {
      url2 = url2 + '/' + encodeURIComponent(webSiteName) + '/slots/';
    }
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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
    
    // 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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var valueArray = responseDoc['value'];
          if (valueArray !== null && valueArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var valueValue = valueArray[loweredIndex1];
              var webSiteInstance = { tags: {} };
              result.webSites.push(webSiteInstance);
              
              var propertiesValue = valueValue['properties'];
              if (propertiesValue !== null && propertiesValue !== undefined) {
                var propertiesInstance = { enabledHostNames: [], hostNames: [], hostNameSslStates: [], trafficManagerHostNames: [] };
                webSiteInstance.properties = propertiesInstance;
                
                var adminEnabledValue = propertiesValue['adminEnabled'];
                if (adminEnabledValue !== null && adminEnabledValue !== undefined) {
                  var adminEnabledInstance = adminEnabledValue;
                  propertiesInstance.adminEnabled = adminEnabledInstance;
                }
                
                var availabilityStateValue = propertiesValue['availabilityState'];
                if (availabilityStateValue !== null && availabilityStateValue !== undefined) {
                  var availabilityStateInstance = availabilityStateValue;
                  propertiesInstance.availabilityState = availabilityStateInstance;
                }
                
                var enabledValue = propertiesValue['enabled'];
                if (enabledValue !== null && enabledValue !== undefined) {
                  var enabledInstance = enabledValue;
                  propertiesInstance.enabled = enabledInstance;
                }
                
                var enabledHostNamesArray = propertiesValue['enabledHostNames'];
                if (enabledHostNamesArray !== null && enabledHostNamesArray !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < enabledHostNamesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                    var enabledHostNamesValue = enabledHostNamesArray[loweredIndex2];
                    propertiesInstance.enabledHostNames.push(enabledHostNamesValue);
                  }
                }
                
                var hostNameSslStatesArray = propertiesValue['hostNameSslStates'];
                if (hostNameSslStatesArray !== null && hostNameSslStatesArray !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < hostNameSslStatesArray.length; loweredIndex3 = loweredIndex3 + 1) {
                    var hostNameSslStatesValue = hostNameSslStatesArray[loweredIndex3];
                    var webSiteHostNameSslStateInstance = {};
                    propertiesInstance.hostNameSslStates.push(webSiteHostNameSslStateInstance);
                    
                    var nameValue = hostNameSslStatesValue['name'];
                    if (nameValue !== null && nameValue !== undefined) {
                      var nameInstance = nameValue;
                      webSiteHostNameSslStateInstance.name = nameInstance;
                    }
                    
                    var sslStateValue = hostNameSslStatesValue['sslState'];
                    if (sslStateValue !== null && sslStateValue !== undefined) {
                      var sslStateInstance = sslStateValue;
                      webSiteHostNameSslStateInstance.sslState = sslStateInstance;
                    }
                    
                    var thumbprintValue = hostNameSslStatesValue['thumbprint'];
                    if (thumbprintValue !== null && thumbprintValue !== undefined) {
                      var thumbprintInstance = thumbprintValue;
                      webSiteHostNameSslStateInstance.thumbprint = thumbprintInstance;
                    }
                    
                    var virtualIPValue = hostNameSslStatesValue['virtualIP'];
                    if (virtualIPValue !== null && virtualIPValue !== undefined) {
                      var virtualIPInstance = virtualIPValue;
                      webSiteHostNameSslStateInstance.virtualIP = virtualIPInstance;
                    }
                    
                    var ipBasedSslResultValue = hostNameSslStatesValue['ipBasedSslResult'];
                    if (ipBasedSslResultValue !== null && ipBasedSslResultValue !== undefined) {
                      var ipBasedSslResultInstance = ipBasedSslResultValue;
                      webSiteHostNameSslStateInstance.ipBasedSslResult = ipBasedSslResultInstance;
                    }
                    
                    var toUpdateValue = hostNameSslStatesValue['toUpdate'];
                    if (toUpdateValue !== null && toUpdateValue !== undefined) {
                      var toUpdateInstance = toUpdateValue;
                      webSiteHostNameSslStateInstance.toUpdate = toUpdateInstance;
                    }
                    
                    var toUpdateIpBasedSslValue = hostNameSslStatesValue['toUpdateIpBasedSsl'];
                    if (toUpdateIpBasedSslValue !== null && toUpdateIpBasedSslValue !== undefined) {
                      var toUpdateIpBasedSslInstance = toUpdateIpBasedSslValue;
                      webSiteHostNameSslStateInstance.toUpdateIpBasedSsl = toUpdateIpBasedSslInstance;
                    }
                  }
                }
                
                var hostNamesArray = propertiesValue['hostNames'];
                if (hostNamesArray !== null && hostNamesArray !== undefined) {
                  for (var loweredIndex4 = 0; loweredIndex4 < hostNamesArray.length; loweredIndex4 = loweredIndex4 + 1) {
                    var hostNamesValue = hostNamesArray[loweredIndex4];
                    propertiesInstance.hostNames.push(hostNamesValue);
                  }
                }
                
                var lastModifiedTimeUtcValue = propertiesValue['lastModifiedTimeUtc'];
                if (lastModifiedTimeUtcValue !== null && lastModifiedTimeUtcValue !== undefined) {
                  var lastModifiedTimeUtcInstance = lastModifiedTimeUtcValue;
                  propertiesInstance.lastModifiedTimeUtc = lastModifiedTimeUtcInstance;
                }
                
                var repositorySiteNameValue = propertiesValue['repositorySiteName'];
                if (repositorySiteNameValue !== null && repositorySiteNameValue !== undefined) {
                  var repositorySiteNameInstance = repositorySiteNameValue;
                  propertiesInstance.repositorySiteName = repositorySiteNameInstance;
                }
                
                var runtimeAvailabilityStateValue = propertiesValue['runtimeAvailabilityState'];
                if (runtimeAvailabilityStateValue !== null && runtimeAvailabilityStateValue !== undefined) {
                  var runtimeAvailabilityStateInstance = runtimeAvailabilityStateValue;
                  propertiesInstance.runtimeAvailabilityState = runtimeAvailabilityStateInstance;
                }
                
                var trafficManagerHostNamesArray = propertiesValue['trafficManagerHostNames'];
                if (trafficManagerHostNamesArray !== null && trafficManagerHostNamesArray !== undefined) {
                  for (var loweredIndex5 = 0; loweredIndex5 < trafficManagerHostNamesArray.length; loweredIndex5 = loweredIndex5 + 1) {
                    var trafficManagerHostNamesValue = trafficManagerHostNamesArray[loweredIndex5];
                    propertiesInstance.trafficManagerHostNames.push(trafficManagerHostNamesValue);
                  }
                }
                
                var selfLinkValue = propertiesValue['selfLink'];
                if (selfLinkValue !== null && selfLinkValue !== undefined) {
                  var selfLinkInstance = selfLinkValue;
                  propertiesInstance.uri = selfLinkInstance;
                }
                
                var serverFarmValue = propertiesValue['serverFarm'];
                if (serverFarmValue !== null && serverFarmValue !== undefined) {
                  var serverFarmInstance = serverFarmValue;
                  propertiesInstance.serverFarm = serverFarmInstance;
                }
                
                var skuValue = propertiesValue['sku'];
                if (skuValue !== null && skuValue !== undefined) {
                  var skuInstance = skuValue;
                  propertiesInstance.sku = skuInstance;
                }
                
                var sitePropertiesValue = propertiesValue['siteProperties'];
                if (sitePropertiesValue !== null && sitePropertiesValue !== undefined) {
                  var sitePropertiesInstance = { appSettings: {}, metadata: {}, properties: {} };
                  propertiesInstance.properties = sitePropertiesInstance;
                  
                  var appSettingsSequenceElement = sitePropertiesValue['appSettings'];
                  if (appSettingsSequenceElement !== null && appSettingsSequenceElement !== undefined) {
                    for (var property in appSettingsSequenceElement) {
                      var appSettingsKey = property;
                      var appSettingsValue = appSettingsSequenceElement[property];
                      sitePropertiesInstance.appSettings[appSettingsKey] = appSettingsValue;
                    }
                  }
                  
                  var metadataSequenceElement = sitePropertiesValue['metadata'];
                  if (metadataSequenceElement !== null && metadataSequenceElement !== undefined) {
                    for (var property2 in metadataSequenceElement) {
                      var metadataKey = property2;
                      var metadataValue = metadataSequenceElement[property2];
                      sitePropertiesInstance.metadata[metadataKey] = metadataValue;
                    }
                  }
                  
                  var propertiesSequenceElement = sitePropertiesValue['properties'];
                  if (propertiesSequenceElement !== null && propertiesSequenceElement !== undefined) {
                    for (var property3 in propertiesSequenceElement) {
                      var propertiesKey = property3;
                      var propertiesValue2 = propertiesSequenceElement[property3];
                      sitePropertiesInstance.properties[propertiesKey] = propertiesValue2;
                    }
                  }
                }
                
                var stateValue = propertiesValue['state'];
                if (stateValue !== null && stateValue !== undefined) {
                  var stateInstance = stateValue;
                  propertiesInstance.state = stateInstance;
                }
                
                var usageStateValue = propertiesValue['usageState'];
                if (usageStateValue !== null && usageStateValue !== undefined) {
                  var usageStateInstance = usageStateValue;
                  propertiesInstance.usageState = usageStateInstance;
                }
                
                var webSpaceValue = propertiesValue['webSpace'];
                if (webSpaceValue !== null && webSpaceValue !== undefined) {
                  var webSpaceInstance = webSpaceValue;
                  propertiesInstance.webSpace = webSpaceInstance;
                }
                
                var provisioningStateValue = propertiesValue['provisioningState'];
                if (provisioningStateValue !== null && provisioningStateValue !== undefined) {
                  var provisioningStateInstance = provisioningStateValue;
                  propertiesInstance.provisioningState = provisioningStateInstance;
                }
              }
              
              var idValue = valueValue['id'];
              if (idValue !== null && idValue !== undefined) {
                var idInstance = idValue;
                webSiteInstance.id = idInstance;
              }
              
              var nameValue2 = valueValue['name'];
              if (nameValue2 !== null && nameValue2 !== undefined) {
                var nameInstance2 = nameValue2;
                webSiteInstance.name = nameInstance2;
              }
              
              var locationValue = valueValue['location'];
              if (locationValue !== null && locationValue !== undefined) {
                var locationInstance = locationValue;
                webSiteInstance.location = locationInstance;
              }
              
              var tagsSequenceElement = valueValue['tags'];
              if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
                for (var property4 in tagsSequenceElement) {
                  var tagsKey = property4;
                  var tagsValue = tagsSequenceElement[property4];
                  webSiteInstance.tags[tagsKey] = tagsValue;
                }
              }
              
              var typeValue = valueValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                webSiteInstance.type = typeInstance;
              }
            }
          }
        }
        
      }
      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} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.listBackups = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/restore';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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-06-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 responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var backupListInstance = { properties: [], tags: {} };
          result.backupList = backupListInstance;
          
          var propertiesArray = responseDoc['properties'];
          if (propertiesArray !== null && propertiesArray !== undefined) {
            for (var loweredIndex1 = 0; loweredIndex1 < propertiesArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var propertiesValue = propertiesArray[loweredIndex1];
              var backupItemInstance = { databases: [] };
              backupListInstance.properties.push(backupItemInstance);
              
              var storageAccountUrlValue = propertiesValue['storageAccountUrl'];
              if (storageAccountUrlValue !== null && storageAccountUrlValue !== undefined) {
                var storageAccountUrlInstance = storageAccountUrlValue;
                backupItemInstance.storageAccountUrl = storageAccountUrlInstance;
              }
              
              var blobNameValue = propertiesValue['blobName'];
              if (blobNameValue !== null && blobNameValue !== undefined) {
                var blobNameInstance = blobNameValue;
                backupItemInstance.blobName = blobNameInstance;
              }
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                backupItemInstance.name = nameInstance;
              }
              
              var statusValue = propertiesValue['status'];
              if (statusValue !== null && statusValue !== undefined) {
                var statusInstance = statusValue;
                backupItemInstance.status = statusInstance;
              }
              
              var sizeInBytesValue = propertiesValue['sizeInBytes'];
              if (sizeInBytesValue !== null && sizeInBytesValue !== undefined) {
                var sizeInBytesInstance = sizeInBytesValue;
                backupItemInstance.sizeInBytes = sizeInBytesInstance;
              }
              
              var createdValue = propertiesValue['created'];
              if (createdValue !== null && createdValue !== undefined) {
                var createdInstance = createdValue;
                backupItemInstance.created = createdInstance;
              }
              
              var logValue = propertiesValue['log'];
              if (logValue !== null && logValue !== undefined) {
                var logInstance = logValue;
                backupItemInstance.log = logInstance;
              }
              
              var databasesArray = propertiesValue['databases'];
              if (databasesArray !== null && databasesArray !== undefined) {
                for (var loweredIndex2 = 0; loweredIndex2 < databasesArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var databasesValue = databasesArray[loweredIndex2];
                  var databaseBackupSettingInstance = {};
                  backupItemInstance.databases.push(databaseBackupSettingInstance);
                  
                  var connectionStringValue = databasesValue['connectionString'];
                  if (connectionStringValue !== null && connectionStringValue !== undefined) {
                    var connectionStringInstance = connectionStringValue;
                    databaseBackupSettingInstance.connectionString = connectionStringInstance;
                  }
                  
                  var connectionStringNameValue = databasesValue['connectionStringName'];
                  if (connectionStringNameValue !== null && connectionStringNameValue !== undefined) {
                    var connectionStringNameInstance = connectionStringNameValue;
                    databaseBackupSettingInstance.connectionStringName = connectionStringNameInstance;
                  }
                  
                  var databaseTypeValue = databasesValue['databaseType'];
                  if (databaseTypeValue !== null && databaseTypeValue !== undefined) {
                    var databaseTypeInstance = databaseTypeValue;
                    databaseBackupSettingInstance.databaseType = databaseTypeInstance;
                  }
                  
                  var nameValue2 = databasesValue['name'];
                  if (nameValue2 !== null && nameValue2 !== undefined) {
                    var nameInstance2 = nameValue2;
                    databaseBackupSettingInstance.name = nameInstance2;
                  }
                }
              }
              
              var scheduledValue = propertiesValue['scheduled'];
              if (scheduledValue !== null && scheduledValue !== undefined) {
                var scheduledInstance = scheduledValue;
                backupItemInstance.scheduled = scheduledInstance;
              }
              
              var lastRestoreTimeStampValue = propertiesValue['lastRestoreTimeStamp'];
              if (lastRestoreTimeStampValue !== null && lastRestoreTimeStampValue !== undefined) {
                var lastRestoreTimeStampInstance = lastRestoreTimeStampValue;
                backupItemInstance.lastRestoreTimeStamp = lastRestoreTimeStampInstance;
              }
              
              var finishedTimeStampValue = propertiesValue['finishedTimeStamp'];
              if (finishedTimeStampValue !== null && finishedTimeStampValue !== undefined) {
                var finishedTimeStampInstance = finishedTimeStampValue;
                backupItemInstance.finishedTimeStamp = finishedTimeStampInstance;
              }
              
              var correlationIdValue = propertiesValue['correlationId'];
              if (correlationIdValue !== null && correlationIdValue !== undefined) {
                var correlationIdInstance = correlationIdValue;
                backupItemInstance.correlationId = correlationIdInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            backupListInstance.id = idInstance;
          }
          
          var nameValue3 = responseDoc['name'];
          if (nameValue3 !== null && nameValue3 !== undefined) {
            var nameInstance3 = nameValue3;
            backupListInstance.name = nameInstance3;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            backupListInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              backupListInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            backupListInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Restart the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.restart = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/restart';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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} resourceGroupName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {RestoreRequestEnvelope} restoreRequestEnvelope A restore request.
   * 
   * @param {RestoreRequest} [restoreRequestEnvelope.request] TODO.
   * 
   * @param {boolean} [restoreRequestEnvelope.request.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} [restoreRequestEnvelope.request.blobName] The blob name
   * where the backup is stored. E.g. mysite1_20140203.zip
   * 
   * @param {IEnumerable} [restoreRequestEnvelope.request.databases] Database
   * settings for backup.
   * 
   * @param {boolean}
   * [restoreRequestEnvelope.request.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} [restoreRequestEnvelope.request.overwrite] True if the
   * restore operation will be used for overwrite an existing site; false
   * otherwise.
   * 
   * @param {string} [restoreRequestEnvelope.request.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 {string} [restoreRequestEnvelope.id] Gets the ID of the resource.
   * 
   * @param {string} [restoreRequestEnvelope.name] The name of the resource.
   * 
   * @param {string} restoreRequestEnvelope.location Gets or sets the location
   * of the resource.
   * 
   * @param {object} [restoreRequestEnvelope.tags] Gets or sets the tags
   * attached to the resource.
   * 
   * @param {string} [restoreRequestEnvelope.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.restore = function(resourceGroupName, webSiteName, slotName, restoreRequestEnvelope, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (restoreRequestEnvelope === null || restoreRequestEnvelope === undefined) {
      return callback(new Error('restoreRequestEnvelope cannot be null.'));
    }
    if (restoreRequestEnvelope.location === null || restoreRequestEnvelope.location === undefined) {
      return callback(new Error('restoreRequestEnvelope.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    queryParameters.push('operation=restore');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json';
    httpRequest.headers['x-ms-version'] = '2014-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var restoreRequestEnvelopeValue = {};
    requestDoc = restoreRequestEnvelopeValue;
    
    if (restoreRequestEnvelope.request !== null && restoreRequestEnvelope.request !== undefined) {
      var propertiesValue = {};
      restoreRequestEnvelopeValue['properties'] = propertiesValue;
      
      if (restoreRequestEnvelope.request.adjustConnectionStrings !== null && restoreRequestEnvelope.request.adjustConnectionStrings !== undefined) {
        propertiesValue['AdjustConnectionStrings'] = restoreRequestEnvelope.request.adjustConnectionStrings;
      }
      
      if (restoreRequestEnvelope.request.blobName !== null && restoreRequestEnvelope.request.blobName !== undefined) {
        propertiesValue['BlobName'] = restoreRequestEnvelope.request.blobName;
      }
      
      if (restoreRequestEnvelope.request.databases !== null && restoreRequestEnvelope.request.databases !== undefined) {
        var databasesArray = [];
        for (var loweredIndex1 = 0; loweredIndex1 < restoreRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {
          var databasesItem = restoreRequestEnvelope.request.databases[loweredIndex1];
          var databaseBackupSettingValue = {};
          databasesArray.push(databaseBackupSettingValue);
          
          if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
            databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;
          }
          
          if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
            databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;
          }
          
          if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
            databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;
          }
          
          if (databasesItem.name !== null && databasesItem.name !== undefined) {
            databaseBackupSettingValue['name'] = databasesItem.name;
          }
        }
        propertiesValue['Databases'] = databasesArray;
      }
      
      if (restoreRequestEnvelope.request.ignoreConflictingHostNames !== null && restoreRequestEnvelope.request.ignoreConflictingHostNames !== undefined) {
        propertiesValue['IgnoreConflictingHostNames'] = restoreRequestEnvelope.request.ignoreConflictingHostNames;
      }
      
      if (restoreRequestEnvelope.request.overwrite !== null && restoreRequestEnvelope.request.overwrite !== undefined) {
        propertiesValue['Overwrite'] = restoreRequestEnvelope.request.overwrite;
      }
      
      if (restoreRequestEnvelope.request.storageAccountUrl !== null && restoreRequestEnvelope.request.storageAccountUrl !== undefined) {
        propertiesValue['StorageAccountUrl'] = restoreRequestEnvelope.request.storageAccountUrl;
      }
    }
    
    if (restoreRequestEnvelope.id !== null && restoreRequestEnvelope.id !== undefined) {
      restoreRequestEnvelopeValue['id'] = restoreRequestEnvelope.id;
    }
    
    if (restoreRequestEnvelope.name !== null && restoreRequestEnvelope.name !== undefined) {
      restoreRequestEnvelopeValue['name'] = restoreRequestEnvelope.name;
    }
    
    restoreRequestEnvelopeValue['location'] = restoreRequestEnvelope.location;
    
    if (restoreRequestEnvelope.tags !== null && restoreRequestEnvelope.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in restoreRequestEnvelope.tags) {
        var tagsValue = restoreRequestEnvelope.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      restoreRequestEnvelopeValue['tags'] = tagsDictionary;
    }
    
    if (restoreRequestEnvelope.type !== null && restoreRequestEnvelope.type !== undefined) {
      restoreRequestEnvelopeValue['type'] = restoreRequestEnvelope.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        var restoreResponseValue = responseDoc['RestoreResponse'];
        if (restoreResponseValue !== null && restoreResponseValue !== undefined) {
          var restoreResponseInstance = {};
          
          var operationIdValue = restoreResponseValue['operationId'];
          if (operationIdValue !== null && operationIdValue !== undefined) {
            var operationIdInstance = operationIdValue;
            restoreResponseInstance.operationId = operationIdInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Restart the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot of the website
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.start = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/start';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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);
    });
  };
  
  /**
   * Restart the web site.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName Name of website
   * 
   * @param {string} [slotName] The name of the slot of the web site
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.stop = function(resourceGroupName, webSiteName, slotName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/stop';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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';
    
    // 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 the application settings for a web site by issuing an
   * HTTP GET request, or update them by using HTTP PUT with a request body
   * that contains the settings to be updated.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName The name of the web site
   * 
   * @param {string} [slotName] The name of the slot of the website
   * 
   * @param {WebSiteNameValueParameters} parameters The Update Web Site app
   * settings parameters
   * 
   * @param {array} parameters.properties The name value pair parameters for
   * the web site.
   * 
   * @param {string} [parameters.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.name] The name of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {string} [parameters.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateAppSettings = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    if (parameters.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/appsettings';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteNameValueParametersValue = {};
    requestDoc = webSiteNameValueParametersValue;
    
    if (parameters.properties !== null && parameters.properties !== undefined) {
      var propertiesArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.length; loweredIndex1 = loweredIndex1 + 1) {
        var propertiesItem = parameters.properties[loweredIndex1];
        var nameValuePairValue = {};
        propertiesArray.push(nameValuePairValue);
        
        if (propertiesItem.name !== null && propertiesItem.name !== undefined) {
          nameValuePairValue['name'] = propertiesItem.name;
        }
        
        if (propertiesItem.value !== null && propertiesItem.value !== undefined) {
          nameValuePairValue['value'] = propertiesItem.value;
        }
      }
      webSiteNameValueParametersValue['properties'] = propertiesArray;
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      webSiteNameValueParametersValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      webSiteNameValueParametersValue['name'] = parameters.name;
    }
    
    webSiteNameValueParametersValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.tags) {
        var tagsValue = parameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webSiteNameValueParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      webSiteNameValueParametersValue['type'] = parameters.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { properties: [], tags: {} };
          result.resource = resourceInstance;
          
          var propertiesArray2 = responseDoc['properties'];
          if (propertiesArray2 !== null && propertiesArray2 !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < propertiesArray2.length; loweredIndex2 = loweredIndex2 + 1) {
              var propertiesValue = propertiesArray2[loweredIndex2];
              var nameValuePairInstance = {};
              resourceInstance.properties.push(nameValuePairInstance);
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                nameValuePairInstance.name = nameInstance;
              }
              
              var valueValue = propertiesValue['value'];
              if (valueValue !== null && valueValue !== undefined) {
                var valueInstance = valueValue;
                nameValuePairInstance.value = valueInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey2] = tagsValue2;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            resourceInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates a backup schedule for a site.
   * 
   * @param {string} resourceGroupName The name of the web space.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {BackupRequestEnvelope} backupRequestEnvelope A backup schedule
   * specification.
   * 
   * @param {BackupRequest} [backupRequestEnvelope.request] TODO.
   * 
   * @param {BackupSchedule} [backupRequestEnvelope.request.backupSchedule] The
   * backup schedule structure - valid only when setting up a schedule. Should
   * be Null for on-demand backups.
   * 
   * @param {number}
   * [backupRequestEnvelope.request.backupSchedule.frequencyInterval] The
   * frequency of backups.
   * 
   * @param {FrequencyUnit}
   * [backupRequestEnvelope.request.backupSchedule.frequencyUnit] Units for
   * FrequencyInterval - e.g. Day or Hour
   * 
   * @param {boolean}
   * [backupRequestEnvelope.request.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}
   * [backupRequestEnvelope.request.backupSchedule.lastExecutionTime] The last
   * time when this schedule started a backup, Null if didn't start anything
   * yet.
   * 
   * @param {number}
   * [backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays]
   * Backups older N days (N defined by this value) will be automatically
   * deleted.
   * 
   * @param {date} [backupRequestEnvelope.request.backupSchedule.startTime]
   * When this schedule should start backing up the site. Null means
   * immediately.
   * 
   * @param {IEnumerable} [backupRequestEnvelope.request.databases] Database
   * settings for backup.
   * 
   * @param {boolean} [backupRequestEnvelope.request.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} [backupRequestEnvelope.request.name] The name of this
   * backup - will be used for generating a blob name.
   * 
   * @param {string} [backupRequestEnvelope.request.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 {string} [backupRequestEnvelope.id] Gets the ID of the resource.
   * 
   * @param {string} [backupRequestEnvelope.name] The name of the resource.
   * 
   * @param {string} backupRequestEnvelope.location Gets or sets the location
   * of the resource.
   * 
   * @param {object} [backupRequestEnvelope.tags] Gets or sets the tags
   * attached to the resource.
   * 
   * @param {string} [backupRequestEnvelope.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateBackupConfiguration = function(resourceGroupName, webSiteName, slotName, backupRequestEnvelope, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (webSiteName === null || webSiteName === undefined) {
      return callback(new Error('webSiteName cannot be null.'));
    }
    if (backupRequestEnvelope === null || backupRequestEnvelope === undefined) {
      return callback(new Error('backupRequestEnvelope cannot be null.'));
    }
    if (backupRequestEnvelope.location === null || backupRequestEnvelope.location === undefined) {
      return callback(new Error('backupRequestEnvelope.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/backup/config';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json';
    httpRequest.headers['x-ms-version'] = '2014-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var backupRequestEnvelopeValue = {};
    requestDoc = backupRequestEnvelopeValue;
    
    if (backupRequestEnvelope.request !== null && backupRequestEnvelope.request !== undefined) {
      var propertiesValue = {};
      backupRequestEnvelopeValue['properties'] = propertiesValue;
      
      if (backupRequestEnvelope.request.backupSchedule !== null && backupRequestEnvelope.request.backupSchedule !== undefined) {
        var backupScheduleValue = {};
        propertiesValue['backupSchedule'] = backupScheduleValue;
        
        if (backupRequestEnvelope.request.backupSchedule.frequencyInterval !== null && backupRequestEnvelope.request.backupSchedule.frequencyInterval !== undefined) {
          backupScheduleValue['frequencyInterval'] = backupRequestEnvelope.request.backupSchedule.frequencyInterval;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined) {
          backupScheduleValue['frequencyUnit'] = backupRequestEnvelope.request.backupSchedule.frequencyUnit !== null && backupRequestEnvelope.request.backupSchedule.frequencyUnit !== undefined ? backupRequestEnvelope.request.backupSchedule.frequencyUnit.toString() : 'Day';
        }
        
        if (backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== null && backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup !== undefined) {
          backupScheduleValue['keepAtLeastOneBackup'] = backupRequestEnvelope.request.backupSchedule.keepAtLeastOneBackup;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== null && backupRequestEnvelope.request.backupSchedule.lastExecutionTime !== undefined) {
          backupScheduleValue['lastExecutionTime'] = backupRequestEnvelope.request.backupSchedule.lastExecutionTime;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== null && backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays !== undefined) {
          backupScheduleValue['retentionPeriodInDays'] = backupRequestEnvelope.request.backupSchedule.retentionPeriodInDays;
        }
        
        if (backupRequestEnvelope.request.backupSchedule.startTime !== null && backupRequestEnvelope.request.backupSchedule.startTime !== undefined) {
          backupScheduleValue['startTime'] = backupRequestEnvelope.request.backupSchedule.startTime;
        }
      }
      
      if (backupRequestEnvelope.request.databases !== null && backupRequestEnvelope.request.databases !== undefined) {
        var databasesArray = [];
        for (var loweredIndex1 = 0; loweredIndex1 < backupRequestEnvelope.request.databases.length; loweredIndex1 = loweredIndex1 + 1) {
          var databasesItem = backupRequestEnvelope.request.databases[loweredIndex1];
          var databaseBackupSettingValue = {};
          databasesArray.push(databaseBackupSettingValue);
          
          if (databasesItem.connectionString !== null && databasesItem.connectionString !== undefined) {
            databaseBackupSettingValue['connectionString'] = databasesItem.connectionString;
          }
          
          if (databasesItem.connectionStringName !== null && databasesItem.connectionStringName !== undefined) {
            databaseBackupSettingValue['connectionStringName'] = databasesItem.connectionStringName;
          }
          
          if (databasesItem.databaseType !== null && databasesItem.databaseType !== undefined) {
            databaseBackupSettingValue['databaseType'] = databasesItem.databaseType;
          }
          
          if (databasesItem.name !== null && databasesItem.name !== undefined) {
            databaseBackupSettingValue['name'] = databasesItem.name;
          }
        }
        propertiesValue['databases'] = databasesArray;
      }
      
      if (backupRequestEnvelope.request.enabled !== null && backupRequestEnvelope.request.enabled !== undefined) {
        propertiesValue['enabled'] = backupRequestEnvelope.request.enabled;
      }
      
      if (backupRequestEnvelope.request.name !== null && backupRequestEnvelope.request.name !== undefined) {
        propertiesValue['name'] = backupRequestEnvelope.request.name;
      }
      
      if (backupRequestEnvelope.request.storageAccountUrl !== null && backupRequestEnvelope.request.storageAccountUrl !== undefined) {
        propertiesValue['storageAccountUrl'] = backupRequestEnvelope.request.storageAccountUrl;
      }
    }
    
    if (backupRequestEnvelope.id !== null && backupRequestEnvelope.id !== undefined) {
      backupRequestEnvelopeValue['id'] = backupRequestEnvelope.id;
    }
    
    if (backupRequestEnvelope.name !== null && backupRequestEnvelope.name !== undefined) {
      backupRequestEnvelopeValue['name'] = backupRequestEnvelope.name;
    }
    
    backupRequestEnvelopeValue['location'] = backupRequestEnvelope.location;
    
    if (backupRequestEnvelope.tags !== null && backupRequestEnvelope.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in backupRequestEnvelope.tags) {
        var tagsValue = backupRequestEnvelope.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      backupRequestEnvelopeValue['tags'] = tagsDictionary;
    }
    
    if (backupRequestEnvelope.type !== null && backupRequestEnvelope.type !== undefined) {
      backupRequestEnvelopeValue['type'] = backupRequestEnvelope.type;
    }
    
    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);
    });
  };
  
  /**
   * You can retrieve the config settings for a web site by issuing an HTTP GET
   * request, or update them by using HTTP PUT with a request body that
   * contains the settings to be updated.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} webSiteName The name of the web site.
   * 
   * @param {string} [slotName] The name of the slot.
   * 
   * @param {WebSiteUpdateConfigurationParameters} parameters The Update Web
   * Site Configuration parameters.
   * 
   * @param {WebSiteUpdateConfigurationDetails} parameters.properties The name
   * value pair parameters for the web site.
   * 
   * @param {object} [parameters.properties.appSettings] A set of name/value
   * pairs that contain application settings for a site.
   * 
   * @param {array} [parameters.properties.connectionStrings] Contains
   * connection strings for database and other external resources.
   * 
   * @param {array} [parameters.properties.defaultDocuments] Contains 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.properties.detailedErrorLoggingEnabled] True
   * if detailed error logging is enabled; otherwise, false.
   * 
   * @param {string} [parameters.properties.documentRoot] The document root.
   * 
   * @param {array} [parameters.properties.handlerMappings] Specifies custom
   * executable programs for handling requests for specific file name
   * extensions.
   * 
   * @param {boolean} [parameters.properties.httpLoggingEnabled] True if HTTP
   * error logging is enabled; otherwise, false.
   * 
   * @param {number} [parameters.properties.logsDirectorySizeLimit] The limit
   * of the logs directory.
   * 
   * @param {ManagedPipelineMode} [parameters.properties.managedPipelineMode]
   * Managed pipeline modes.
   * 
   * @param {object} [parameters.properties.metadata] Contains name/value pairs
   * for source control or other information.
   * 
   * @param {string} [parameters.properties.netFrameworkVersion] The .NET
   * Framework version. Supported values are v2.0, v4.0 and v4.5.
   * 
   * @param {number} [parameters.properties.numberOfWorkers] The number of web
   * workers allotted to the web site. If the site mode is Free, this value is
   * 1. If the site mode is Shared, this value can range from 1 through 6. If
   * the site mode is Standard, this value can range from 1 through 10.
   * 
   * @param {string} [parameters.properties.phpVersion] Supported values are an
   * empty string (an empty string disables PHP), 5.3, 5.4, 5.5 and 5.6.
   * 
   * @param {string} [parameters.properties.pythonVersion] Supported values are
   * an empty string (an empty string disables Python), 2.7 and 3.4.
   * 
   * @param {boolean} [parameters.properties.remoteDebuggingEnabled] True
   * remote debugging is enabled; otherwise, false.
   * 
   * @param {RemoteDebuggingVersion}
   * [parameters.properties.remoteDebuggingVersion] True remote debugging
   * version.
   * 
   * @param {boolean} [parameters.properties.requestTracingEnabled] True if
   * request tracing is enabled; otherwise, false.
   * 
   * @param {date} [parameters.properties.requestTracingExpirationTime] Time
   * remaining until request tracing expires.
   * 
   * @param {string} [parameters.properties.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.properties.use32BitWorkerProcess] True if
   * 32-bit mode is enabled; otherwise, false.
   * 
   * @param {boolean} [parameters.properties.webSocketsEnabled] True if Web
   * Sockets are enabled; otherwise, false.
   * 
   * @param {boolean} [parameters.properties.alwaysOn] True if Always On
   * functionality is enabled for the site; otherwise, false.
   * 
   * @param {string} [parameters.properties.autoSwapSlotName] Sets the slot
   * name to swap with after successful deployment.
   * 
   * @param {SiteLimits} [parameters.properties.limits] The per site limits.
   * 
   * @param {number} [parameters.properties.limits.maxPercentageCpu] The name
   * of the pair.
   * 
   * @param {number} [parameters.properties.limits.maxMemoryInMb] Maximum
   * memory allowed in MB
   * 
   * @param {number} [parameters.properties.limits.maxDiskSizeInMb] Maximum
   * disk size allowed in MB
   * 
   * @param {string} [parameters.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.name] The name of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {string} [parameters.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateConfiguration = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    if (parameters.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/web';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteUpdateConfigurationParametersValue = {};
    requestDoc = webSiteUpdateConfigurationParametersValue;
    
    var propertiesValue = {};
    webSiteUpdateConfigurationParametersValue['properties'] = propertiesValue;
    
    if (parameters.properties.appSettings !== null && parameters.properties.appSettings !== undefined) {
      var appSettingsDictionary = {};
      for (var appSettingsKey in parameters.properties.appSettings) {
        var appSettingsValue = parameters.properties.appSettings[appSettingsKey];
        appSettingsDictionary[appSettingsKey] = appSettingsValue;
      }
      propertiesValue['appSettings'] = appSettingsDictionary;
    }
    
    if (parameters.properties.connectionStrings !== null && parameters.properties.connectionStrings !== undefined) {
      var connectionStringsArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.connectionStrings.length; loweredIndex1 = loweredIndex1 + 1) {
        var connectionStringsItem = parameters.properties.connectionStrings[loweredIndex1];
        var connStringInfoValue = {};
        connectionStringsArray.push(connStringInfoValue);
        
        if (connectionStringsItem.connectionString !== null && connectionStringsItem.connectionString !== undefined) {
          connStringInfoValue['connectionString'] = connectionStringsItem.connectionString;
        }
        
        if (connectionStringsItem.name !== null && connectionStringsItem.name !== undefined) {
          connStringInfoValue['name'] = connectionStringsItem.name;
        }
        
        if (connectionStringsItem.type !== null && connectionStringsItem.type !== undefined) {
          connStringInfoValue['type'] = connectionStringsItem.type !== null && connectionStringsItem.type !== undefined ? connectionStringsItem.type.toString() : 'MySql';
        }
      }
      propertiesValue['connectionStrings'] = connectionStringsArray;
    }
    
    if (parameters.properties.defaultDocuments !== null && parameters.properties.defaultDocuments !== undefined) {
      var defaultDocumentsArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.properties.defaultDocuments.length; loweredIndex2 = loweredIndex2 + 1) {
        var defaultDocumentsItem = parameters.properties.defaultDocuments[loweredIndex2];
        defaultDocumentsArray.push(defaultDocumentsItem);
      }
      propertiesValue['defaultDocuments'] = defaultDocumentsArray;
    }
    
    if (parameters.properties.detailedErrorLoggingEnabled !== null && parameters.properties.detailedErrorLoggingEnabled !== undefined) {
      propertiesValue['detailedErrorLoggingEnabled'] = parameters.properties.detailedErrorLoggingEnabled;
    }
    
    if (parameters.properties.documentRoot !== null && parameters.properties.documentRoot !== undefined) {
      propertiesValue['documentRoot'] = parameters.properties.documentRoot;
    }
    
    if (parameters.properties.handlerMappings !== null && parameters.properties.handlerMappings !== undefined) {
      var handlerMappingsArray = [];
      for (var loweredIndex3 = 0; loweredIndex3 < parameters.properties.handlerMappings.length; loweredIndex3 = loweredIndex3 + 1) {
        var handlerMappingsItem = parameters.properties.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;
        }
      }
      propertiesValue['handlerMappings'] = handlerMappingsArray;
    }
    
    if (parameters.properties.httpLoggingEnabled !== null && parameters.properties.httpLoggingEnabled !== undefined) {
      propertiesValue['httpLoggingEnabled'] = parameters.properties.httpLoggingEnabled;
    }
    
    if (parameters.properties.logsDirectorySizeLimit !== null && parameters.properties.logsDirectorySizeLimit !== undefined) {
      propertiesValue['logsDirectorySizeLimit'] = parameters.properties.logsDirectorySizeLimit;
    }
    
    if (parameters.properties.managedPipelineMode !== null && parameters.properties.managedPipelineMode !== undefined) {
      propertiesValue['managedPipelineMode'] = parameters.properties.managedPipelineMode !== null && parameters.properties.managedPipelineMode !== undefined ? parameters.properties.managedPipelineMode.toString() : 'Integrated';
    }
    
    if (parameters.properties.metadata !== null && parameters.properties.metadata !== undefined) {
      var metadataDictionary = {};
      for (var metadataKey in parameters.properties.metadata) {
        var metadataValue = parameters.properties.metadata[metadataKey];
        metadataDictionary[metadataKey] = metadataValue;
      }
      propertiesValue['metadata'] = metadataDictionary;
    }
    
    if (parameters.properties.netFrameworkVersion !== null && parameters.properties.netFrameworkVersion !== undefined) {
      propertiesValue['netFrameworkVersion'] = parameters.properties.netFrameworkVersion;
    }
    
    if (parameters.properties.numberOfWorkers !== null && parameters.properties.numberOfWorkers !== undefined) {
      propertiesValue['numberOfWorkers'] = parameters.properties.numberOfWorkers;
    }
    
    if (parameters.properties.phpVersion !== null && parameters.properties.phpVersion !== undefined) {
      propertiesValue['phpVersion'] = parameters.properties.phpVersion;
    }
    
    if (parameters.properties.pythonVersion !== null && parameters.properties.pythonVersion !== undefined) {
      propertiesValue['pythonVersion'] = parameters.properties.pythonVersion;
    }
    
    if (parameters.properties.remoteDebuggingEnabled !== null && parameters.properties.remoteDebuggingEnabled !== undefined) {
      propertiesValue['remoteDebuggingEnabled'] = parameters.properties.remoteDebuggingEnabled;
    }
    
    if (parameters.properties.remoteDebuggingVersion !== null && parameters.properties.remoteDebuggingVersion !== undefined) {
      propertiesValue['remoteDebuggingVersion'] = parameters.properties.remoteDebuggingVersion !== null && parameters.properties.remoteDebuggingVersion !== undefined ? parameters.properties.remoteDebuggingVersion.toString() : 'VS2012';
    }
    
    if (parameters.properties.requestTracingEnabled !== null && parameters.properties.requestTracingEnabled !== undefined) {
      propertiesValue['requestTracingEnabled'] = parameters.properties.requestTracingEnabled;
    }
    
    if (parameters.properties.requestTracingExpirationTime !== null && parameters.properties.requestTracingExpirationTime !== undefined) {
      propertiesValue['requestTracingExpirationTime'] = parameters.properties.requestTracingExpirationTime;
    }
    
    if (parameters.properties.scmType !== null && parameters.properties.scmType !== undefined) {
      propertiesValue['scmType'] = parameters.properties.scmType;
    }
    
    if (parameters.properties.use32BitWorkerProcess !== null && parameters.properties.use32BitWorkerProcess !== undefined) {
      propertiesValue['use32BitWorkerProcess'] = parameters.properties.use32BitWorkerProcess;
    }
    
    if (parameters.properties.webSocketsEnabled !== null && parameters.properties.webSocketsEnabled !== undefined) {
      propertiesValue['webSocketsEnabled'] = parameters.properties.webSocketsEnabled;
    }
    
    if (parameters.properties.alwaysOn !== null && parameters.properties.alwaysOn !== undefined) {
      propertiesValue['alwaysOn'] = parameters.properties.alwaysOn;
    }
    
    if (parameters.properties.autoSwapSlotName !== null && parameters.properties.autoSwapSlotName !== undefined) {
      propertiesValue['autoSwapSlotName'] = parameters.properties.autoSwapSlotName;
    }
    
    if (parameters.properties.limits !== null && parameters.properties.limits !== undefined) {
      var limitsValue = {};
      propertiesValue['limits'] = limitsValue;
      
      if (parameters.properties.limits.maxPercentageCpu !== null && parameters.properties.limits.maxPercentageCpu !== undefined) {
        limitsValue['maxPercentageCpu'] = parameters.properties.limits.maxPercentageCpu;
      }
      
      if (parameters.properties.limits.maxMemoryInMb !== null && parameters.properties.limits.maxMemoryInMb !== undefined) {
        limitsValue['maxMemoryInMb'] = parameters.properties.limits.maxMemoryInMb;
      }
      
      if (parameters.properties.limits.maxDiskSizeInMb !== null && parameters.properties.limits.maxDiskSizeInMb !== undefined) {
        limitsValue['maxDiskSizeInMb'] = parameters.properties.limits.maxDiskSizeInMb;
      }
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      webSiteUpdateConfigurationParametersValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      webSiteUpdateConfigurationParametersValue['name'] = parameters.name;
    }
    
    webSiteUpdateConfigurationParametersValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.tags) {
        var tagsValue = parameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webSiteUpdateConfigurationParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      webSiteUpdateConfigurationParametersValue['type'] = parameters.type;
    }
    
    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);
    });
  };
  
  /**
   * You can retrieve the connection strings for a web site by issuing an HTTP
   * GET request, or update them by using HTTP PUT with a request body that
   * contains the settings to be updated.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName The name of the website
   * 
   * @param {string} [slotName] The name of the slot of the website
   * 
   * @param {WebSiteUpdateConnectionStringsParameters} parameters The Update
   * Web Site connection strings parameters
   * 
   * @param {array} parameters.properties The connection strings for the web
   * site.
   * 
   * @param {string} [parameters.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.name] The name of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {string} [parameters.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateConnectionStrings = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    if (parameters.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/connectionstrings';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteUpdateConnectionStringsParametersValue = {};
    requestDoc = webSiteUpdateConnectionStringsParametersValue;
    
    if (parameters.properties !== null && parameters.properties !== undefined) {
      var propertiesArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.length; loweredIndex1 = loweredIndex1 + 1) {
        var propertiesItem = parameters.properties[loweredIndex1];
        var connStringInfoValue = {};
        propertiesArray.push(connStringInfoValue);
        
        if (propertiesItem.connectionString !== null && propertiesItem.connectionString !== undefined) {
          connStringInfoValue['connectionString'] = propertiesItem.connectionString;
        }
        
        if (propertiesItem.name !== null && propertiesItem.name !== undefined) {
          connStringInfoValue['name'] = propertiesItem.name;
        }
        
        if (propertiesItem.type !== null && propertiesItem.type !== undefined) {
          connStringInfoValue['type'] = propertiesItem.type !== null && propertiesItem.type !== undefined ? propertiesItem.type.toString() : 'MySql';
        }
      }
      webSiteUpdateConnectionStringsParametersValue['properties'] = propertiesArray;
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      webSiteUpdateConnectionStringsParametersValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      webSiteUpdateConnectionStringsParametersValue['name'] = parameters.name;
    }
    
    webSiteUpdateConnectionStringsParametersValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.tags) {
        var tagsValue = parameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webSiteUpdateConnectionStringsParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      webSiteUpdateConnectionStringsParametersValue['type'] = parameters.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { properties: [], tags: {} };
          result.resource = resourceInstance;
          
          var propertiesArray2 = responseDoc['properties'];
          if (propertiesArray2 !== null && propertiesArray2 !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < propertiesArray2.length; loweredIndex2 = loweredIndex2 + 1) {
              var propertiesValue = propertiesArray2[loweredIndex2];
              var connStringInfoInstance = {};
              resourceInstance.properties.push(connStringInfoInstance);
              
              var connectionStringValue = propertiesValue['connectionString'];
              if (connectionStringValue !== null && connectionStringValue !== undefined) {
                var connectionStringInstance = connectionStringValue;
                connStringInfoInstance.connectionString = connectionStringInstance;
              }
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                connStringInfoInstance.name = nameInstance;
              }
              
              var typeValue = propertiesValue['type'];
              if (typeValue !== null && typeValue !== undefined) {
                var typeInstance = typeValue;
                connStringInfoInstance.type = typeInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey2] = tagsValue2;
            }
          }
          
          var typeValue2 = responseDoc['type'];
          if (typeValue2 !== null && typeValue2 !== undefined) {
            var typeInstance2 = typeValue2;
            resourceInstance.type = typeInstance2;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * You can retrieve the metadata for a web site by issuing an HTTP GET
   * request, or update them by using HTTP PUT with a request body that
   * contains the settings to be updated.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx for
   * more information)
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName The name of the website
   * 
   * @param {string} [slotName] The name of the slot of the website
   * 
   * @param {WebSiteNameValueParameters} parameters The Update Web Site
   * metadata parameters
   * 
   * @param {array} parameters.properties The name value pair parameters for
   * the web site.
   * 
   * @param {string} [parameters.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.name] The name of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {string} [parameters.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateMetadata = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    if (parameters.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/config/metadata';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var webSiteNameValueParametersValue = {};
    requestDoc = webSiteNameValueParametersValue;
    
    if (parameters.properties !== null && parameters.properties !== undefined) {
      var propertiesArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.length; loweredIndex1 = loweredIndex1 + 1) {
        var propertiesItem = parameters.properties[loweredIndex1];
        var nameValuePairValue = {};
        propertiesArray.push(nameValuePairValue);
        
        if (propertiesItem.name !== null && propertiesItem.name !== undefined) {
          nameValuePairValue['name'] = propertiesItem.name;
        }
        
        if (propertiesItem.value !== null && propertiesItem.value !== undefined) {
          nameValuePairValue['value'] = propertiesItem.value;
        }
      }
      webSiteNameValueParametersValue['properties'] = propertiesArray;
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      webSiteNameValueParametersValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      webSiteNameValueParametersValue['name'] = parameters.name;
    }
    
    webSiteNameValueParametersValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.tags) {
        var tagsValue = parameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      webSiteNameValueParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      webSiteNameValueParametersValue['type'] = parameters.type;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var resourceInstance = { properties: [], tags: {} };
          result.resource = resourceInstance;
          
          var propertiesArray2 = responseDoc['properties'];
          if (propertiesArray2 !== null && propertiesArray2 !== undefined) {
            for (var loweredIndex2 = 0; loweredIndex2 < propertiesArray2.length; loweredIndex2 = loweredIndex2 + 1) {
              var propertiesValue = propertiesArray2[loweredIndex2];
              var nameValuePairInstance = {};
              resourceInstance.properties.push(nameValuePairInstance);
              
              var nameValue = propertiesValue['name'];
              if (nameValue !== null && nameValue !== undefined) {
                var nameInstance = nameValue;
                nameValuePairInstance.name = nameInstance;
              }
              
              var valueValue = propertiesValue['value'];
              if (valueValue !== null && valueValue !== undefined) {
                var valueInstance = valueValue;
                nameValuePairInstance.value = valueInstance;
              }
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            resourceInstance.id = idInstance;
          }
          
          var nameValue2 = responseDoc['name'];
          if (nameValue2 !== null && nameValue2 !== undefined) {
            var nameInstance2 = nameValue2;
            resourceInstance.name = nameInstance2;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            resourceInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey2 = property;
              var tagsValue2 = tagsSequenceElement[property];
              resourceInstance.tags[tagsKey2] = tagsValue2;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            resourceInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Link source control to website (do not forget to setup the token, and if
   * needed token secret, for the specific source control type used).
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName The name of the web site
   * 
   * @param {string} [slotName] The name of the slot of the website
   * 
   * @param {SiteSourceControlUpdateParameters} parameters The update site
   * source control parameters.
   * 
   * @param {SiteSourceControlProperties} parameters.properties Gets or sets
   * the properties of the link site to source control.
   * 
   * @param {string} parameters.properties.repoUrl Gets or sets the repository
   * url.
   * 
   * @param {string} [parameters.properties.branch] Gets or sets the branch (if
   * required, will be master by default).
   * 
   * @param {boolean} [parameters.properties.isManualIntegration] Gets or sets
   * true for repository that requires to be manually synced or false (by
   * default) otherwise.
   * 
   * @param {boolean} [parameters.properties.deploymentRollbackEnabled] Gets or
   * sets true to keep a repository for non-repository source control provider
   * (like Dropbox) or false (by default) otherwise.
   * 
   * @param {boolean} [parameters.properties.isMercurial] Gets or sets true if
   * repository is Mercurial or false (by default) otherwise.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateSiteSourceControl = function(resourceGroupName, webSiteName, slotName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    if (parameters.properties.repoUrl === null || parameters.properties.repoUrl === undefined) {
      return callback(new Error('parameters.properties.repoUrl cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    if (slotName !== null && slotName !== undefined) {
      url2 = url2 + '/slots/' + encodeURIComponent(slotName);
    }
    url2 = url2 + '/sourcecontrols/web';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var siteSourceControlUpdateParametersValue = {};
    requestDoc = siteSourceControlUpdateParametersValue;
    
    var propertiesValue = {};
    siteSourceControlUpdateParametersValue['properties'] = propertiesValue;
    
    propertiesValue['repoUrl'] = parameters.properties.repoUrl;
    
    if (parameters.properties.branch !== null && parameters.properties.branch !== undefined) {
      propertiesValue['branch'] = parameters.properties.branch;
    }
    
    if (parameters.properties.isManualIntegration !== null && parameters.properties.isManualIntegration !== undefined) {
      propertiesValue['isManualIntegration'] = parameters.properties.isManualIntegration;
    }
    
    if (parameters.properties.deploymentRollbackEnabled !== null && parameters.properties.deploymentRollbackEnabled !== undefined) {
      propertiesValue['deploymentRollbackEnabled'] = parameters.properties.deploymentRollbackEnabled;
    }
    
    if (parameters.properties.isMercurial !== null && parameters.properties.isMercurial !== undefined) {
      propertiesValue['isMercurial'] = parameters.properties.isMercurial;
    }
    
    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
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var responseDoc = null;
        if (responseContent) {
          responseDoc = JSON.parse(responseContent);
        }
        
        if (responseDoc !== null && responseDoc !== undefined) {
          var siteSourceControlInstance = { tags: {} };
          result.siteSourceControl = siteSourceControlInstance;
          
          var propertiesValue2 = responseDoc['properties'];
          if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
            var propertiesInstance = {};
            siteSourceControlInstance.properties = propertiesInstance;
            
            var repoUrlValue = propertiesValue2['repoUrl'];
            if (repoUrlValue !== null && repoUrlValue !== undefined) {
              var repoUrlInstance = repoUrlValue;
              propertiesInstance.repoUrl = repoUrlInstance;
            }
            
            var branchValue = propertiesValue2['branch'];
            if (branchValue !== null && branchValue !== undefined) {
              var branchInstance = branchValue;
              propertiesInstance.branch = branchInstance;
            }
            
            var isManualIntegrationValue = propertiesValue2['isManualIntegration'];
            if (isManualIntegrationValue !== null && isManualIntegrationValue !== undefined) {
              var isManualIntegrationInstance = isManualIntegrationValue;
              propertiesInstance.isManualIntegration = isManualIntegrationInstance;
            }
            
            var deploymentRollbackEnabledValue = propertiesValue2['deploymentRollbackEnabled'];
            if (deploymentRollbackEnabledValue !== null && deploymentRollbackEnabledValue !== undefined) {
              var deploymentRollbackEnabledInstance = deploymentRollbackEnabledValue;
              propertiesInstance.deploymentRollbackEnabled = deploymentRollbackEnabledInstance;
            }
            
            var isMercurialValue = propertiesValue2['isMercurial'];
            if (isMercurialValue !== null && isMercurialValue !== undefined) {
              var isMercurialInstance = isMercurialValue;
              propertiesInstance.isMercurial = isMercurialInstance;
            }
          }
          
          var idValue = responseDoc['id'];
          if (idValue !== null && idValue !== undefined) {
            var idInstance = idValue;
            siteSourceControlInstance.id = idInstance;
          }
          
          var nameValue = responseDoc['name'];
          if (nameValue !== null && nameValue !== undefined) {
            var nameInstance = nameValue;
            siteSourceControlInstance.name = nameInstance;
          }
          
          var locationValue = responseDoc['location'];
          if (locationValue !== null && locationValue !== undefined) {
            var locationInstance = locationValue;
            siteSourceControlInstance.location = locationInstance;
          }
          
          var tagsSequenceElement = responseDoc['tags'];
          if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
            for (var property in tagsSequenceElement) {
              var tagsKey = property;
              var tagsValue = tagsSequenceElement[property];
              siteSourceControlInstance.tags[tagsKey] = tagsValue;
            }
          }
          
          var typeValue = responseDoc['type'];
          if (typeValue !== null && typeValue !== undefined) {
            var typeInstance = typeValue;
            siteSourceControlInstance.type = typeInstance;
          }
        }
        
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Update list of app settings and connection strings which to be slot
   * specific. E.g. settings in staging slots remain in staging after swap
   * with production.
   * 
   * @param {string} resourceGroupName The name of the resource group
   * 
   * @param {string} webSiteName The name of the website
   * 
   * @param {SlotConfigNamesUpdateParameters} parameters The Update slot
   * configs parameters
   * 
   * @param {SlotConfigNames} parameters.properties The name value pair
   * parameters for the web site.
   * 
   * @param {array} [parameters.properties.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.properties.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 {string} [parameters.id] Gets the ID of the resource.
   * 
   * @param {string} [parameters.name] The name of the resource.
   * 
   * @param {string} parameters.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.tags] Gets or sets the tags attached to the
   * resource.
   * 
   * @param {string} [parameters.type] The type of the resource
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  WebSiteOperations.prototype.updateSlotConfigNames = function(resourceGroupName, webSiteName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (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.location === null || parameters.location === undefined) {
      return callback(new Error('parameters.location cannot be null.'));
    }
    if (parameters.properties === null || parameters.properties === undefined) {
      return callback(new Error('parameters.properties cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Web';
    url2 = url2 + '/';
    url2 = url2 + 'sites';
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(webSiteName);
    url2 = url2 + '/slotConfigNames';
    var queryParameters = [];
    queryParameters.push('api-version=2014-06-01');
    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['accept'] = 'application/json';
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var slotConfigNamesUpdateParametersValue = {};
    requestDoc = slotConfigNamesUpdateParametersValue;
    
    var propertiesValue = {};
    slotConfigNamesUpdateParametersValue['properties'] = propertiesValue;
    
    if (parameters.properties.connectionStringNames !== null && parameters.properties.connectionStringNames !== undefined) {
      var connectionStringNamesArray = [];
      for (var loweredIndex1 = 0; loweredIndex1 < parameters.properties.connectionStringNames.length; loweredIndex1 = loweredIndex1 + 1) {
        var connectionStringNamesItem = parameters.properties.connectionStringNames[loweredIndex1];
        connectionStringNamesArray.push(connectionStringNamesItem);
      }
      propertiesValue['connectionStringNames'] = connectionStringNamesArray;
    }
    
    if (parameters.properties.appSettingNames !== null && parameters.properties.appSettingNames !== undefined) {
      var appSettingNamesArray = [];
      for (var loweredIndex2 = 0; loweredIndex2 < parameters.properties.appSettingNames.length; loweredIndex2 = loweredIndex2 + 1) {
        var appSettingNamesItem = parameters.properties.appSettingNames[loweredIndex2];
        appSettingNamesArray.push(appSettingNamesItem);
      }
      propertiesValue['appSettingNames'] = appSettingNamesArray;
    }
    
    if (parameters.id !== null && parameters.id !== undefined) {
      slotConfigNamesUpdateParametersValue['id'] = parameters.id;
    }
    
    if (parameters.name !== null && parameters.name !== undefined) {
      slotConfigNamesUpdateParametersValue['name'] = parameters.name;
    }
    
    slotConfigNamesUpdateParametersValue['location'] = parameters.location;
    
    if (parameters.tags !== null && parameters.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.tags) {
        var tagsValue = parameters.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      slotConfigNamesUpdateParametersValue['tags'] = tagsDictionary;
    }
    
    if (parameters.type !== null && parameters.type !== undefined) {
      slotConfigNamesUpdateParametersValue['type'] = parameters.type;
    }
    
    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;
})();
