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

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

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

'use strict';

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

var ServiceBusManagementClient = ( /** @lends ServiceBusManagementClient */ function() {
  /**
   * @class
   * The Service Bus Management API is a REST API for managing Service Bus
   * queues, topics, rules and subscriptions.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh780776.aspx for
   * more information)
   * Initializes a new instance of the ServiceBusManagementClient 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 ServiceBusManagementClient(credentials, baseUri, filters) {
    if (credentials === null || credentials === undefined) {
      throw new Error('credentials cannot be null.');
    }
    
    ServiceBusManagementClient['super_'].call(this, credentials, filters);
    
    this.credentials = credentials;
    this.baseUri = baseUri;
    if (this.baseUri === null || this.baseUri === undefined) {
      this.baseUri = 'https://management.core.windows.net';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2013-08-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
     * [NamespaceOperations](-NamespaceOperations.html) object.
     * @type {object}
     */
    this.namespaces = new NamespaceOperations(this);
    /**
     * Provides an instance of the
     * [NotificationHubOperations](-NotificationHubOperations.html) object.
     * @type {object}
     */
    this.notificationHubs = new NotificationHubOperations(this);
    /**
     * Provides an instance of the [QueueOperations](-QueueOperations.html)
     * object.
     * @type {object}
     */
    this.queues = new QueueOperations(this);
    /**
     * Provides an instance of the [RelayOperations](-RelayOperations.html)
     * object.
     * @type {object}
     */
    this.relays = new RelayOperations(this);
    /**
     * Provides an instance of the [TopicOperations](-TopicOperations.html)
     * object.
     * @type {object}
     */
    this.topics = new TopicOperations(this);
  }
  
  util.inherits(ServiceBusManagementClient, Service);
  
  /**
   * The Get Operation Status operation returns the status of thespecified
   * operation. After calling an asynchronous operation, you can call Get
   * Operation Status to determine whether the operation has succeeded,
   * failed, or is still in progress.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx for
   * more information)
   * 
   * @param {string} requestId The request ID for the request you wish to
   * track. The request ID is returned in the x-ms-request-id response header
   * for every request.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceBusManagementClient.prototype.getOperationStatus = function(requestId, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (requestId === null || requestId === undefined) {
      return callback(new Error('requestId cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.credentials.subscriptionId);
    }
    url2 = url2 + '/operations/';
    url2 = url2 + encodeURIComponent(requestId);
    var baseUrl = this.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var operationElement = js2xml.getElement(responseDoc, responseDoc, 'OPERATION', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
          if (operationElement !== null && operationElement !== undefined) {
            var idElement = js2xml.getElement(responseDoc, operationElement, 'ID', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (idElement !== null && idElement !== undefined) {
              var idInstance = idElement;
              result.id = idInstance;
            }
            
            var statusElement = js2xml.getElement(responseDoc, operationElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (statusElement !== null && statusElement !== undefined && statusElement.length !== 0) {
              var statusInstance = statusElement;
              result.status = statusInstance;
            }
            
            var httpStatusCodeElement = js2xml.getElement(responseDoc, operationElement, 'HTTPSTATUSCODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (httpStatusCodeElement !== null && httpStatusCodeElement !== undefined && httpStatusCodeElement.length !== 0) {
              var httpStatusCodeInstance = httpStatusCodeElement;
              result.httpStatusCode = httpStatusCodeInstance;
            }
            
            var errorElement = js2xml.getElement(responseDoc, operationElement, 'ERROR', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
            if (errorElement !== null && errorElement !== undefined) {
              var errorInstance = {};
              result.error = errorInstance;
              
              var codeElement = js2xml.getElement(responseDoc, errorElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (codeElement !== null && codeElement !== undefined) {
                var codeInstance = codeElement;
                errorInstance.code = codeInstance;
              }
              
              var messageElement = js2xml.getElement(responseDoc, errorElement, 'MESSAGE', 'HTTP://SCHEMAS.MICROSOFT.COM/WINDOWSAZURE');
              if (messageElement !== null && messageElement !== undefined) {
                var messageInstance = messageElement;
                errorInstance.message = messageInstance;
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Retrieves the list of regions that support the creation and management of
   * Service Bus service namespaces.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj860465.aspx for
   * more information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ServiceBusManagementClient.prototype.getServiceBusRegions = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.credentials.subscriptionId !== null && this.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/regions';
    var baseUrl = this.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Accept'] = 'application/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = { regions: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = {};
                result.regions.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var regionCodeDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'REGIONCODEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (regionCodeDescriptionElement !== null && regionCodeDescriptionElement !== undefined) {
                    var codeElement = js2xml.getElement(responseDoc, regionCodeDescriptionElement, 'CODE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (codeElement !== null && codeElement !== undefined) {
                      var codeInstance = codeElement;
                      entryInstance.code = codeInstance;
                    }
                    
                    var fullNameElement = js2xml.getElement(responseDoc, regionCodeDescriptionElement, 'FULLNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (fullNameElement !== null && fullNameElement !== undefined) {
                      var fullNameInstance = fullNameElement;
                      entryInstance.fullName = fullNameInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return ServiceBusManagementClient;
})();
exports.ServiceBusManagementClient = ServiceBusManagementClient;

var NamespaceOperations = ( /** @lends NamespaceOperations */ function() {
  /**
   * @class
   * The Service Bus Management API includes operations for managing Service
   * Bus namespaces.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ServiceBusManagementClient] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient}.
   * See [namespaces] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient#namespaces}.
   * Initializes a new instance of the NamespaceOperations class.
   * @constructor
   * 
   * @param {ServiceBusManagementClient} client Reference to the service client.
   */
  function NamespaceOperations(client) {
    this.client = client;
  }
  
  /**
   * Checks the availability of the given service namespace across all Windows
   * Azure subscriptions. This is useful because the domain name is created
   * based on the service namespace name.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj870968.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.checkAvailability = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/ServiceBus/CheckNamespaceAvailability';
    var queryParameters = [];
    queryParameters.push('namespace=' + encodeURIComponent(namespaceName));
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['x-ms-version'] = '2013-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 options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement !== null && entryElement !== undefined) {
            var contentElement = js2xml.getElement(responseDoc, entryElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement !== null && contentElement !== undefined) {
              var namespaceAvailabilityElement = js2xml.getElement(responseDoc, contentElement, 'NAMESPACEAVAILABILITY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (namespaceAvailabilityElement !== null && namespaceAvailabilityElement !== undefined) {
                var resultElement = js2xml.getElement(responseDoc, namespaceAvailabilityElement, 'RESULT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (resultElement !== null && resultElement !== undefined && resultElement.length !== 0) {
                  var resultInstance = resultElement === 'true';
                  result.isAvailable = resultInstance;
                }
                
                var reasonDetailElement = js2xml.getElement(responseDoc, namespaceAvailabilityElement, 'REASONDETAIL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (reasonDetailElement !== null && reasonDetailElement !== undefined) {
                  var reasonDetailInstance = reasonDetailElement;
                  result.reasonDetails = reasonDetailInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Creates a new service namespace. Once created, this namespace's resource
   * manifest is immutable. This operation is idempotent.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj856303.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} [region] The namespace region.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.create = function(namespaceName, region, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2013-07-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/xml');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var namespaceDescriptionElement = js2xml.createElement('NamespaceDescription', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, namespaceDescriptionElement);
    
    if (region !== null && region !== undefined) {
      var regionElement = js2xml.createElement('Region', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(regionElement, region);
      js2xml.addChildElement(namespaceDescriptionElement, regionElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var namespaceDescriptionElement2 = js2xml.getElement(responseDoc, contentElement2, 'NAMESPACEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (namespaceDescriptionElement2 !== null && namespaceDescriptionElement2 !== undefined) {
                var namespaceDescriptionInstance = {};
                result.namespace = namespaceDescriptionInstance;
                
                var nameElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  namespaceDescriptionInstance.name = nameInstance;
                }
                
                var regionElement2 = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'REGION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (regionElement2 !== null && regionElement2 !== undefined) {
                  var regionInstance = regionElement2;
                  namespaceDescriptionInstance.region = regionInstance;
                }
                
                var statusElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement !== null && statusElement !== undefined) {
                  var statusInstance = statusElement;
                  namespaceDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  namespaceDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var acsManagementEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'ACSMANAGEMENTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (acsManagementEndpointElement !== null && acsManagementEndpointElement !== undefined) {
                  var acsManagementEndpointInstance = acsManagementEndpointElement;
                  namespaceDescriptionInstance.acsManagementEndpoint = acsManagementEndpointInstance;
                }
                
                var serviceBusEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'SERVICEBUSENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (serviceBusEndpointElement !== null && serviceBusEndpointElement !== undefined) {
                  var serviceBusEndpointInstance = serviceBusEndpointElement;
                  namespaceDescriptionInstance.serviceBusEndpoint = serviceBusEndpointInstance;
                }
                
                var subscriptionIdElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'SUBSCRIPTIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (subscriptionIdElement !== null && subscriptionIdElement !== undefined) {
                  var subscriptionIdInstance = subscriptionIdElement;
                  namespaceDescriptionInstance.subscriptionId = subscriptionIdInstance;
                }
                
                var enabledElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
                  var enabledInstance = enabledElement === 'true';
                  namespaceDescriptionInstance.enabled = enabledInstance;
                }
                
                var createACSNamespaceElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'CREATEACSNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createACSNamespaceElement !== null && createACSNamespaceElement !== undefined && createACSNamespaceElement.length !== 0) {
                  var createACSNamespaceInstance = createACSNamespaceElement === 'true';
                  namespaceDescriptionInstance.createACSNamespace = createACSNamespaceInstance;
                }
                
                var namespaceTypeElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'NAMESPACETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (namespaceTypeElement !== null && namespaceTypeElement !== undefined && namespaceTypeElement.length !== 0) {
                  var namespaceTypeInstance = namespaceTypeElement;
                  namespaceDescriptionInstance.namespaceType = namespaceTypeInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The create namespace authorization rule operation creates an authorization
   * rule for a namespace
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusSharedAccessAuthorizationRule} rule The shared access
   * authorization rule.
   * 
   * @param {string} [rule.keyName] The name of the key that was used.
   * 
   * @param {string} [rule.primaryKey] The primary key that was used.
   * 
   * @param {string} [rule.secondaryKey] The secondary key that was used.
   * 
   * @param {string} [rule.claimType] The type of the claim.
   * 
   * @param {string} [rule.claimValue] The value of the claim.
   * 
   * @param {array} [rule.rights] The rights associated with the rule.
   * 
   * @param {date} [rule.createdTime] The time at which the authorization rule
   * was created.
   * 
   * @param {date} [rule.modifiedTime] The most recent time the rule was
   * updated.
   * 
   * @param {number} [rule.revision] The revision number for the rule.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.createAuthorizationRule = function(namespaceName, rule, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (rule === null || rule === undefined) {
      return callback(new Error('rule cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/AuthorizationRules';
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'POST';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Accept'] = 'application/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/atom+xml');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var sharedAccessAuthorizationRuleElement = js2xml.createElement('SharedAccessAuthorizationRule', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, sharedAccessAuthorizationRuleElement);
    
    if (rule.claimType !== null && rule.claimType !== undefined) {
      var claimTypeElement = js2xml.createElement('ClaimType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(claimTypeElement, rule.claimType);
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, claimTypeElement);
    }
    
    if (rule.claimValue !== null && rule.claimValue !== undefined) {
      var claimValueElement = js2xml.createElement('ClaimValue', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(claimValueElement, rule.claimValue);
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, claimValueElement);
    }
    
    if (rule.rights !== null && rule.rights !== undefined) {
      var rightsSequenceElement = js2xml.createElement('Rights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      for (var loweredIndex1 = 0; loweredIndex1 < rule.rights.length; loweredIndex1 = loweredIndex1 + 1) {
        var rightsItem = rule.rights[loweredIndex1];
        var rightsItemElement = js2xml.createElement('AccessRights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(rightsItemElement, rightsItem !== null && rightsItem !== undefined ? rightsItem.toString() : 'Listen');
        js2xml.addChildElement(rightsSequenceElement, rightsItemElement);
      }
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, rightsSequenceElement);
    }
    
    if (rule.createdTime !== null && rule.createdTime !== undefined) {
      var createdTimeElement = js2xml.createElement('CreatedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(createdTimeElement, rule.createdTime.toISOString());
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, createdTimeElement);
    }
    
    if (rule.modifiedTime !== null && rule.modifiedTime !== undefined) {
      var modifiedTimeElement = js2xml.createElement('ModifiedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(modifiedTimeElement, rule.modifiedTime.toISOString());
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, modifiedTimeElement);
    }
    
    if (rule.revision !== null && rule.revision !== undefined) {
      var revisionElement = js2xml.createElement('Revision', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(revisionElement, rule.revision.toString());
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, revisionElement);
    }
    
    if (rule.keyName !== null && rule.keyName !== undefined) {
      var keyNameElement = js2xml.createElement('KeyName', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(keyNameElement, rule.keyName);
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, keyNameElement);
    }
    
    if (rule.primaryKey !== null && rule.primaryKey !== undefined) {
      var primaryKeyElement = js2xml.createElement('PrimaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(primaryKeyElement, rule.primaryKey);
      js2xml.addChildElement(sharedAccessAuthorizationRuleElement, primaryKeyElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var sharedAccessAuthorizationRuleElement2 = js2xml.getElement(responseDoc, contentElement2, 'SHAREDACCESSAUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (sharedAccessAuthorizationRuleElement2 !== null && sharedAccessAuthorizationRuleElement2 !== undefined) {
                var sharedAccessAuthorizationRuleInstance = { rights: [] };
                result.authorizationRule = sharedAccessAuthorizationRuleInstance;
                
                var claimTypeElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (claimTypeElement2 !== null && claimTypeElement2 !== undefined) {
                  var claimTypeInstance = claimTypeElement2;
                  sharedAccessAuthorizationRuleInstance.claimType = claimTypeInstance;
                }
                
                var claimValueElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (claimValueElement2 !== null && claimValueElement2 !== undefined) {
                  var claimValueInstance = claimValueElement2;
                  sharedAccessAuthorizationRuleInstance.claimValue = claimValueInstance;
                }
                
                var rightsSequenceElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (rightsSequenceElement2 !== null && rightsSequenceElement2 !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                    var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                    sharedAccessAuthorizationRuleInstance.rights.push(rightsElement);
                  }
                }
                
                var createdTimeElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdTimeElement2 !== null && createdTimeElement2 !== undefined && createdTimeElement2.length !== 0) {
                  var createdTimeInstance = new Date(createdTimeElement2);
                  sharedAccessAuthorizationRuleInstance.createdTime = createdTimeInstance;
                }
                
                var modifiedTimeElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (modifiedTimeElement2 !== null && modifiedTimeElement2 !== undefined && modifiedTimeElement2.length !== 0) {
                  var modifiedTimeInstance = new Date(modifiedTimeElement2);
                  sharedAccessAuthorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                }
                
                var keyNameElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (keyNameElement2 !== null && keyNameElement2 !== undefined) {
                  var keyNameInstance = keyNameElement2;
                  sharedAccessAuthorizationRuleInstance.keyName = keyNameInstance;
                }
                
                var primaryKeyElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (primaryKeyElement2 !== null && primaryKeyElement2 !== undefined) {
                  var primaryKeyInstance = primaryKeyElement2;
                  sharedAccessAuthorizationRuleInstance.primaryKey = primaryKeyInstance;
                }
                
                var secondaryKeyElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                  var secondaryKeyInstance = secondaryKeyElement;
                  sharedAccessAuthorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                }
                
                var revisionElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'REVISION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (revisionElement2 !== null && revisionElement2 !== undefined && revisionElement2.length !== 0) {
                  var revisionInstance = parseInt(revisionElement2, 10);
                  sharedAccessAuthorizationRuleInstance.revision = revisionInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Creates a new service namespace. Once created, this namespace's resource
   * manifest is immutable. This operation is idempotent.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj856303.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusNamespaceCreateParameters} namespaceEntity The service
   * bus namespace.
   * 
   * @param {string} namespaceEntity.region The namespace region.
   * 
   * @param {boolean} [namespaceEntity.createACSNamespace] Whether or not ACS
   * authentication is needed for ServiceBus.
   * 
   * @param {NamespaceType} namespaceEntity.namespaceType Gets or sets the
   * namespace type.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.createNamespace = function(namespaceName, namespaceEntity, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (namespaceEntity === null || namespaceEntity === undefined) {
      return callback(new Error('namespaceEntity cannot be null.'));
    }
    if (namespaceEntity.namespaceType === null || namespaceEntity.namespaceType === undefined) {
      return callback(new Error('namespaceEntity.namespaceType cannot be null.'));
    }
    if (namespaceEntity.region === null || namespaceEntity.region === undefined) {
      return callback(new Error('namespaceEntity.region cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2014-06-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/atom+xml;type=entry;charset=utf-8');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var namespaceDescriptionElement = js2xml.createElement('NamespaceDescription', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, namespaceDescriptionElement);
    
    if (namespaceEntity.region !== null && namespaceEntity.region !== undefined) {
      var regionElement = js2xml.createElement('Region', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(regionElement, namespaceEntity.region);
      js2xml.addChildElement(namespaceDescriptionElement, regionElement);
    }
    
    if (namespaceEntity.createACSNamespace !== null && namespaceEntity.createACSNamespace !== undefined) {
      var createACSNamespaceElement = js2xml.createElement('CreateACSNamespace', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(createACSNamespaceElement, namespaceEntity.createACSNamespace.toString());
      js2xml.addChildElement(namespaceDescriptionElement, createACSNamespaceElement);
    }
    
    if (namespaceEntity.namespaceType !== null && namespaceEntity.namespaceType !== undefined) {
      var namespaceTypeElement = js2xml.createElement('NamespaceType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(namespaceTypeElement, namespaceEntity.namespaceType !== null && namespaceEntity.namespaceType !== undefined ? namespaceEntity.namespaceType.toString() : 'Messaging');
      js2xml.addChildElement(namespaceDescriptionElement, namespaceTypeElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var namespaceDescriptionElement2 = js2xml.getElement(responseDoc, contentElement2, 'NAMESPACEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (namespaceDescriptionElement2 !== null && namespaceDescriptionElement2 !== undefined) {
                var namespaceDescriptionInstance = {};
                result.namespace = namespaceDescriptionInstance;
                
                var nameElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  namespaceDescriptionInstance.name = nameInstance;
                }
                
                var regionElement2 = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'REGION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (regionElement2 !== null && regionElement2 !== undefined) {
                  var regionInstance = regionElement2;
                  namespaceDescriptionInstance.region = regionInstance;
                }
                
                var statusElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement !== null && statusElement !== undefined) {
                  var statusInstance = statusElement;
                  namespaceDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  namespaceDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var acsManagementEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'ACSMANAGEMENTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (acsManagementEndpointElement !== null && acsManagementEndpointElement !== undefined) {
                  var acsManagementEndpointInstance = acsManagementEndpointElement;
                  namespaceDescriptionInstance.acsManagementEndpoint = acsManagementEndpointInstance;
                }
                
                var serviceBusEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'SERVICEBUSENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (serviceBusEndpointElement !== null && serviceBusEndpointElement !== undefined) {
                  var serviceBusEndpointInstance = serviceBusEndpointElement;
                  namespaceDescriptionInstance.serviceBusEndpoint = serviceBusEndpointInstance;
                }
                
                var subscriptionIdElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'SUBSCRIPTIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (subscriptionIdElement !== null && subscriptionIdElement !== undefined) {
                  var subscriptionIdInstance = subscriptionIdElement;
                  namespaceDescriptionInstance.subscriptionId = subscriptionIdInstance;
                }
                
                var enabledElement = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
                  var enabledInstance = enabledElement === 'true';
                  namespaceDescriptionInstance.enabled = enabledInstance;
                }
                
                var createACSNamespaceElement2 = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'CREATEACSNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createACSNamespaceElement2 !== null && createACSNamespaceElement2 !== undefined && createACSNamespaceElement2.length !== 0) {
                  var createACSNamespaceInstance = createACSNamespaceElement2 === 'true';
                  namespaceDescriptionInstance.createACSNamespace = createACSNamespaceInstance;
                }
                
                var namespaceTypeElement2 = js2xml.getElement(responseDoc, namespaceDescriptionElement2, 'NAMESPACETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (namespaceTypeElement2 !== null && namespaceTypeElement2 !== undefined && namespaceTypeElement2.length !== 0) {
                  var namespaceTypeInstance = namespaceTypeElement2;
                  namespaceDescriptionInstance.namespaceType = namespaceTypeInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes an existing namespace. This operation also removes all associated
   * entities including queues, topics, relay points, and messages stored
   * under the namespace.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj856296.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.deleteMethod = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Accept'] = 'application/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The delete namespace authorization rule operation deletes an authorization
   * rule for a namespace
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} ruleName The rule name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.deleteAuthorizationRule = function(namespaceName, ruleName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (ruleName === null || ruleName === undefined) {
      return callback(new Error('ruleName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/AuthorizationRules/';
    url2 = url2 + encodeURIComponent(ruleName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2012-03-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 !== 204) {
        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);
    });
  };
  
  /**
   * Returns the description for the specified namespace.  (see
   * http://msdn.microsoft.com/library/azure/dn140232.aspx for more
   * information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.get = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement !== null && entryElement !== undefined) {
            var contentElement = js2xml.getElement(responseDoc, entryElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement !== null && contentElement !== undefined) {
              var namespaceDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'NAMESPACEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (namespaceDescriptionElement !== null && namespaceDescriptionElement !== undefined) {
                var namespaceDescriptionInstance = {};
                result.namespace = namespaceDescriptionInstance;
                
                var nameElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (nameElement !== null && nameElement !== undefined) {
                  var nameInstance = nameElement;
                  namespaceDescriptionInstance.name = nameInstance;
                }
                
                var regionElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'REGION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (regionElement !== null && regionElement !== undefined) {
                  var regionInstance = regionElement;
                  namespaceDescriptionInstance.region = regionInstance;
                }
                
                var statusElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement !== null && statusElement !== undefined) {
                  var statusInstance = statusElement;
                  namespaceDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  namespaceDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var acsManagementEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'ACSMANAGEMENTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (acsManagementEndpointElement !== null && acsManagementEndpointElement !== undefined) {
                  var acsManagementEndpointInstance = acsManagementEndpointElement;
                  namespaceDescriptionInstance.acsManagementEndpoint = acsManagementEndpointInstance;
                }
                
                var serviceBusEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'SERVICEBUSENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (serviceBusEndpointElement !== null && serviceBusEndpointElement !== undefined) {
                  var serviceBusEndpointInstance = serviceBusEndpointElement;
                  namespaceDescriptionInstance.serviceBusEndpoint = serviceBusEndpointInstance;
                }
                
                var subscriptionIdElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'SUBSCRIPTIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (subscriptionIdElement !== null && subscriptionIdElement !== undefined) {
                  var subscriptionIdInstance = subscriptionIdElement;
                  namespaceDescriptionInstance.subscriptionId = subscriptionIdInstance;
                }
                
                var enabledElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
                  var enabledInstance = enabledElement === 'true';
                  namespaceDescriptionInstance.enabled = enabledInstance;
                }
                
                var createACSNamespaceElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'CREATEACSNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createACSNamespaceElement !== null && createACSNamespaceElement !== undefined && createACSNamespaceElement.length !== 0) {
                  var createACSNamespaceInstance = createACSNamespaceElement === 'true';
                  namespaceDescriptionInstance.createACSNamespace = createACSNamespaceInstance;
                }
                
                var namespaceTypeElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'NAMESPACETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (namespaceTypeElement !== null && namespaceTypeElement !== undefined && namespaceTypeElement.length !== 0) {
                  var namespaceTypeInstance = namespaceTypeElement;
                  namespaceDescriptionInstance.namespaceType = namespaceTypeInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The get authorization rule operation gets an authorization rule for a
   * namespace by name.
   * 
   * @param {string} namespaceName The namespace to get the authorization rule
   * for.
   * 
   * @param {string} entityName The entity name to get the authorization rule
   * for.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.getAuthorizationRule = function(namespaceName, entityName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (entityName === null || entityName === undefined) {
      return callback(new Error('entityName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/AuthorizationRules/';
    url2 = url2 + encodeURIComponent(entityName);
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement !== null && entryElement !== undefined) {
            var contentElement = js2xml.getElement(responseDoc, entryElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement !== null && contentElement !== undefined) {
              var sharedAccessAuthorizationRuleElement = js2xml.getElement(responseDoc, contentElement, 'SHAREDACCESSAUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (sharedAccessAuthorizationRuleElement !== null && sharedAccessAuthorizationRuleElement !== undefined) {
                var sharedAccessAuthorizationRuleInstance = { rights: [] };
                result.authorizationRule = sharedAccessAuthorizationRuleInstance;
                
                var claimTypeElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (claimTypeElement !== null && claimTypeElement !== undefined) {
                  var claimTypeInstance = claimTypeElement;
                  sharedAccessAuthorizationRuleInstance.claimType = claimTypeInstance;
                }
                
                var claimValueElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (claimValueElement !== null && claimValueElement !== undefined) {
                  var claimValueInstance = claimValueElement;
                  sharedAccessAuthorizationRuleInstance.claimValue = claimValueInstance;
                }
                
                var rightsSequenceElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                  for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex1 = loweredIndex1 + 1) {
                    var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex1];
                    sharedAccessAuthorizationRuleInstance.rights.push(rightsElement);
                  }
                }
                
                var createdTimeElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                  var createdTimeInstance = new Date(createdTimeElement);
                  sharedAccessAuthorizationRuleInstance.createdTime = createdTimeInstance;
                }
                
                var modifiedTimeElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                  var modifiedTimeInstance = new Date(modifiedTimeElement);
                  sharedAccessAuthorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                }
                
                var keyNameElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (keyNameElement !== null && keyNameElement !== undefined) {
                  var keyNameInstance = keyNameElement;
                  sharedAccessAuthorizationRuleInstance.keyName = keyNameInstance;
                }
                
                var primaryKeyElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                  var primaryKeyInstance = primaryKeyElement;
                  sharedAccessAuthorizationRuleInstance.primaryKey = primaryKeyInstance;
                }
                
                var secondaryKeyElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                  var secondaryKeyInstance = secondaryKeyElement;
                  sharedAccessAuthorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                }
                
                var revisionElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'REVISION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (revisionElement !== null && revisionElement !== undefined && revisionElement.length !== 0) {
                  var revisionInstance = parseInt(revisionElement, 10);
                  sharedAccessAuthorizationRuleInstance.revision = revisionInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The namespace description is an XML AtomPub document that defines the
   * desired semantics for a service namespace. The namespace description
   * contains the following properties.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj873988.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.getNamespaceDescription = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/ConnectionDetails';
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { namespaceDescriptions: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { rights: [] };
                result.namespaceDescriptions.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var connectionDetailElement = js2xml.getElement(responseDoc, contentElement, 'CONNECTIONDETAIL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (connectionDetailElement !== null && connectionDetailElement !== undefined) {
                    var keyNameElement = js2xml.getElement(responseDoc, connectionDetailElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      entryInstance.keyName = keyNameInstance;
                    }
                    
                    var connectionStringElement = js2xml.getElement(responseDoc, connectionDetailElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (connectionStringElement !== null && connectionStringElement !== undefined) {
                      var connectionStringInstance = connectionStringElement;
                      entryInstance.connectionString = connectionStringInstance;
                    }
                    
                    var authorizationTypeElement = js2xml.getElement(responseDoc, connectionDetailElement, 'AUTHORIZATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationTypeElement !== null && authorizationTypeElement !== undefined) {
                      var authorizationTypeInstance = authorizationTypeElement;
                      entryInstance.authorizationType = authorizationTypeInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, connectionDetailElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        entryInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var secondaryConnectionStringElement = js2xml.getElement(responseDoc, connectionDetailElement, 'SECONDARYCONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryConnectionStringElement !== null && secondaryConnectionStringElement !== undefined) {
                      var secondaryConnectionStringInstance = secondaryConnectionStringElement;
                      entryInstance.secondaryConnectionString = secondaryConnectionStringInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the available namespaces.  (see
   * http://msdn.microsoft.com/en-us/library/azure/hh780759.aspx for more
   * information)
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.list = function(callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { namespaces: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = {};
                result.namespaces.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var namespaceDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'NAMESPACEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (namespaceDescriptionElement !== null && namespaceDescriptionElement !== undefined) {
                    var nameElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'NAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (nameElement !== null && nameElement !== undefined) {
                      var nameInstance = nameElement;
                      entryInstance.name = nameInstance;
                    }
                    
                    var regionElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'REGION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (regionElement !== null && regionElement !== undefined) {
                      var regionInstance = regionElement;
                      entryInstance.region = regionInstance;
                    }
                    
                    var statusElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (statusElement !== null && statusElement !== undefined) {
                      var statusInstance = statusElement;
                      entryInstance.status = statusInstance;
                    }
                    
                    var createdAtElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                      var createdAtInstance = new Date(createdAtElement);
                      entryInstance.createdAt = createdAtInstance;
                    }
                    
                    var acsManagementEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'ACSMANAGEMENTENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (acsManagementEndpointElement !== null && acsManagementEndpointElement !== undefined) {
                      var acsManagementEndpointInstance = acsManagementEndpointElement;
                      entryInstance.acsManagementEndpoint = acsManagementEndpointInstance;
                    }
                    
                    var serviceBusEndpointElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'SERVICEBUSENDPOINT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (serviceBusEndpointElement !== null && serviceBusEndpointElement !== undefined) {
                      var serviceBusEndpointInstance = serviceBusEndpointElement;
                      entryInstance.serviceBusEndpoint = serviceBusEndpointInstance;
                    }
                    
                    var subscriptionIdElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'SUBSCRIPTIONID', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (subscriptionIdElement !== null && subscriptionIdElement !== undefined) {
                      var subscriptionIdInstance = subscriptionIdElement;
                      entryInstance.subscriptionId = subscriptionIdInstance;
                    }
                    
                    var enabledElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'ENABLED', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (enabledElement !== null && enabledElement !== undefined && enabledElement.length !== 0) {
                      var enabledInstance = enabledElement === 'true';
                      entryInstance.enabled = enabledInstance;
                    }
                    
                    var createACSNamespaceElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'CREATEACSNAMESPACE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createACSNamespaceElement !== null && createACSNamespaceElement !== undefined && createACSNamespaceElement.length !== 0) {
                      var createACSNamespaceInstance = createACSNamespaceElement === 'true';
                      entryInstance.createACSNamespace = createACSNamespaceInstance;
                    }
                    
                    var namespaceTypeElement = js2xml.getElement(responseDoc, namespaceDescriptionElement, 'NAMESPACETYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (namespaceTypeElement !== null && namespaceTypeElement !== undefined && namespaceTypeElement.length !== 0) {
                      var namespaceTypeInstance = namespaceTypeElement;
                      entryInstance.namespaceType = namespaceTypeInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The get authorization rules operation gets the authorization rules for a
   * namespace.
   * 
   * @param {string} namespaceName The namespace to get the authorization rule
   * for.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.listAuthorizationRules = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/AuthorizationRules';
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/xml';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { authorizationRules: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { rights: [] };
                result.authorizationRules.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var sharedAccessAuthorizationRuleElement = js2xml.getElement(responseDoc, contentElement, 'SHAREDACCESSAUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (sharedAccessAuthorizationRuleElement !== null && sharedAccessAuthorizationRuleElement !== undefined) {
                    var claimTypeElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement !== null && claimTypeElement !== undefined) {
                      var claimTypeInstance = claimTypeElement;
                      entryInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement !== null && claimValueElement !== undefined) {
                      var claimValueInstance = claimValueElement;
                      entryInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        entryInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement);
                      entryInstance.createdTime = createdTimeInstance;
                    }
                    
                    var modifiedTimeElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement);
                      entryInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var keyNameElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      entryInstance.keyName = keyNameInstance;
                    }
                    
                    var primaryKeyElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                      var primaryKeyInstance = primaryKeyElement;
                      entryInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement;
                      entryInstance.secondaryKey = secondaryKeyInstance;
                    }
                    
                    var revisionElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement, 'REVISION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (revisionElement !== null && revisionElement !== undefined && revisionElement.length !== 0) {
                      var revisionInstance = parseInt(revisionElement, 10);
                      entryInstance.revision = revisionInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The update authorization rule operation updates an authorization rule for
   * a namespace.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusSharedAccessAuthorizationRule} [rule] Updated access
   * authorization rule.
   * 
   * @param {string} [rule.keyName] The name of the key that was used.
   * 
   * @param {string} [rule.primaryKey] The primary key that was used.
   * 
   * @param {string} [rule.secondaryKey] The secondary key that was used.
   * 
   * @param {string} [rule.claimType] The type of the claim.
   * 
   * @param {string} [rule.claimValue] The value of the claim.
   * 
   * @param {array} [rule.rights] The rights associated with the rule.
   * 
   * @param {date} [rule.createdTime] The time at which the authorization rule
   * was created.
   * 
   * @param {date} [rule.modifiedTime] The most recent time the rule was
   * updated.
   * 
   * @param {number} [rule.revision] The revision number for the rule.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NamespaceOperations.prototype.updateAuthorizationRule = function(namespaceName, rule, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/AuthorizationRules/';
    if (rule !== null && rule !== undefined && rule.keyName !== null && rule.keyName !== undefined) {
      url2 = url2 + encodeURIComponent(rule.keyName);
    }
    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/atom+xml';
    httpRequest.headers['Content-Type'] = 'application/atom+xml';
    httpRequest.headers['if-match'] = '*';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2012-03-01';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    if (rule !== null && rule !== undefined) {
      var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
      js2xml.addChildElement(requestDoc, entryElement);
      
      var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
      js2xml.addChildElement(entryElement, contentElement);
      
      var typeAttribute = js2xml.createAttribute('type', '');
      js2xml.setAttributeValue(typeAttribute, 'application/atom+xml');
      js2xml.addAttribute(contentElement, typeAttribute);
      
      var sharedAccessAuthorizationRuleElement = js2xml.createElement('SharedAccessAuthorizationRule', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.addChildElement(contentElement, sharedAccessAuthorizationRuleElement);
      
      if (rule.claimType !== null && rule.claimType !== undefined) {
        var claimTypeElement = js2xml.createElement('ClaimType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(claimTypeElement, rule.claimType);
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, claimTypeElement);
      }
      
      if (rule.claimValue !== null && rule.claimValue !== undefined) {
        var claimValueElement = js2xml.createElement('ClaimValue', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(claimValueElement, rule.claimValue);
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, claimValueElement);
      }
      
      if (rule.rights !== null && rule.rights !== undefined) {
        var rightsSequenceElement = js2xml.createElement('Rights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        for (var loweredIndex1 = 0; loweredIndex1 < rule.rights.length; loweredIndex1 = loweredIndex1 + 1) {
          var rightsItem = rule.rights[loweredIndex1];
          var rightsItemElement = js2xml.createElement('AccessRights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(rightsItemElement, rightsItem !== null && rightsItem !== undefined ? rightsItem.toString() : 'Listen');
          js2xml.addChildElement(rightsSequenceElement, rightsItemElement);
        }
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, rightsSequenceElement);
      }
      
      if (rule.createdTime !== null && rule.createdTime !== undefined) {
        var createdTimeElement = js2xml.createElement('CreatedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(createdTimeElement, rule.createdTime.toISOString());
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, createdTimeElement);
      }
      
      if (rule.modifiedTime !== null && rule.modifiedTime !== undefined) {
        var modifiedTimeElement = js2xml.createElement('ModifiedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(modifiedTimeElement, rule.modifiedTime.toISOString());
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, modifiedTimeElement);
      }
      
      if (rule.revision !== null && rule.revision !== undefined) {
        var revisionElement = js2xml.createElement('Revision', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(revisionElement, rule.revision.toString());
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, revisionElement);
      }
      
      if (rule.keyName !== null && rule.keyName !== undefined) {
        var keyNameElement = js2xml.createElement('KeyName', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(keyNameElement, rule.keyName);
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, keyNameElement);
      }
      
      if (rule.primaryKey !== null && rule.primaryKey !== undefined) {
        var primaryKeyElement = js2xml.createElement('PrimaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.setElementValue(primaryKeyElement, rule.primaryKey);
        js2xml.addChildElement(sharedAccessAuthorizationRuleElement, primaryKeyElement);
      }
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var sharedAccessAuthorizationRuleElement2 = js2xml.getElement(responseDoc, contentElement2, 'SHAREDACCESSAUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (sharedAccessAuthorizationRuleElement2 !== null && sharedAccessAuthorizationRuleElement2 !== undefined) {
                var sharedAccessAuthorizationRuleInstance = { rights: [] };
                result.authorizationRule = sharedAccessAuthorizationRuleInstance;
                
                var claimTypeElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (claimTypeElement2 !== null && claimTypeElement2 !== undefined) {
                  var claimTypeInstance = claimTypeElement2;
                  sharedAccessAuthorizationRuleInstance.claimType = claimTypeInstance;
                }
                
                var claimValueElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (claimValueElement2 !== null && claimValueElement2 !== undefined) {
                  var claimValueInstance = claimValueElement2;
                  sharedAccessAuthorizationRuleInstance.claimValue = claimValueInstance;
                }
                
                var rightsSequenceElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (rightsSequenceElement2 !== null && rightsSequenceElement2 !== undefined) {
                  for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                    var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                    sharedAccessAuthorizationRuleInstance.rights.push(rightsElement);
                  }
                }
                
                var createdTimeElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdTimeElement2 !== null && createdTimeElement2 !== undefined && createdTimeElement2.length !== 0) {
                  var createdTimeInstance = new Date(createdTimeElement2);
                  sharedAccessAuthorizationRuleInstance.createdTime = createdTimeInstance;
                }
                
                var modifiedTimeElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (modifiedTimeElement2 !== null && modifiedTimeElement2 !== undefined && modifiedTimeElement2.length !== 0) {
                  var modifiedTimeInstance = new Date(modifiedTimeElement2);
                  sharedAccessAuthorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                }
                
                var keyNameElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (keyNameElement2 !== null && keyNameElement2 !== undefined) {
                  var keyNameInstance = keyNameElement2;
                  sharedAccessAuthorizationRuleInstance.keyName = keyNameInstance;
                }
                
                var primaryKeyElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (primaryKeyElement2 !== null && primaryKeyElement2 !== undefined) {
                  var primaryKeyInstance = primaryKeyElement2;
                  sharedAccessAuthorizationRuleInstance.primaryKey = primaryKeyInstance;
                }
                
                var secondaryKeyElement = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                  var secondaryKeyInstance = secondaryKeyElement;
                  sharedAccessAuthorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                }
                
                var revisionElement2 = js2xml.getElement(responseDoc, sharedAccessAuthorizationRuleElement2, 'REVISION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (revisionElement2 !== null && revisionElement2 !== undefined && revisionElement2.length !== 0) {
                  var revisionInstance = parseInt(revisionElement2, 10);
                  sharedAccessAuthorizationRuleInstance.revision = revisionInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return NamespaceOperations;
})();

var NotificationHubOperations = ( /** @lends NotificationHubOperations */ function() {
  /**
   * @class
   * The Service Bus Management API includes operations for managing Service
   * Bus notification hubs.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ServiceBusManagementClient] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient}.
   * See [notificationHubs] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient#notificationHubs}.
   * Initializes a new instance of the NotificationHubOperations class.
   * @constructor
   * 
   * @param {ServiceBusManagementClient} client Reference to the service client.
   */
  function NotificationHubOperations(client) {
    this.client = client;
  }
  
  /**
   * Deletes a notification hub associated with a namespace.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} notificationHubName The notification hub name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NotificationHubOperations.prototype.deleteMethod = function(namespaceName, notificationHubName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (notificationHubName === null || notificationHubName === undefined) {
      return callback(new Error('notificationHubName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/NotificationHubs/';
    url2 = url2 + encodeURIComponent(notificationHubName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the notification hubs associated with a namespace.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} notificationHubName The notification hub name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NotificationHubOperations.prototype.get = function(namespaceName, notificationHubName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (notificationHubName === null || notificationHubName === undefined) {
      return callback(new Error('notificationHubName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/NotificationHubs/';
    url2 = url2 + encodeURIComponent(notificationHubName);
    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'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement !== null && entryElement !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement = js2xml.getElement(responseDoc, entryElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement !== null && contentElement !== undefined) {
              var notificationHubDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'NOTIFICATIONHUBDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (notificationHubDescriptionElement !== null && notificationHubDescriptionElement !== undefined) {
                var notificationHubDescriptionInstance = { authorizationRules: [] };
                result.notificationHub = notificationHubDescriptionInstance;
                
                var registrationTtlElement = js2xml.getElement(responseDoc, notificationHubDescriptionElement, 'REGISTRATIONTTL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (registrationTtlElement !== null && registrationTtlElement !== undefined) {
                  var registrationTtlInstance = registrationTtlElement;
                  notificationHubDescriptionInstance.registrationTtl = registrationTtlInstance;
                }
                
                var authorizationRulesSequenceElement = js2xml.getElement(responseDoc, notificationHubDescriptionElement, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement !== null && authorizationRulesSequenceElement !== undefined) {
                  for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex1 = loweredIndex1 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex1];
                    var authorizationRuleInstance = { rights: [] };
                    notificationHubDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement !== null && claimTypeElement !== undefined) {
                      var claimTypeInstance = claimTypeElement;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement !== null && claimValueElement !== undefined) {
                      var claimValueInstance = claimValueElement;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                      var primaryKeyInstance = primaryKeyElement;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the notification hubs associated with a namespace.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} notificationHubName The notification hub name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NotificationHubOperations.prototype.getConnectionDetails = function(namespaceName, notificationHubName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (notificationHubName === null || notificationHubName === undefined) {
      return callback(new Error('notificationHubName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/NotificationHubs/';
    url2 = url2 + encodeURIComponent(notificationHubName);
    url2 = url2 + '/ConnectionDetails';
    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'] = '2013-08-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 = { connectionDetails: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { rights: [] };
                result.connectionDetails.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var connectionDetailElement = js2xml.getElement(responseDoc, contentElement, 'CONNECTIONDETAIL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (connectionDetailElement !== null && connectionDetailElement !== undefined) {
                    var keyNameElement = js2xml.getElement(responseDoc, connectionDetailElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      entryInstance.keyName = keyNameInstance;
                    }
                    
                    var connectionStringElement = js2xml.getElement(responseDoc, connectionDetailElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (connectionStringElement !== null && connectionStringElement !== undefined) {
                      var connectionStringInstance = connectionStringElement;
                      entryInstance.connectionString = connectionStringInstance;
                    }
                    
                    var authorizationTypeElement = js2xml.getElement(responseDoc, connectionDetailElement, 'AUTHORIZATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationTypeElement !== null && authorizationTypeElement !== undefined) {
                      var authorizationTypeInstance = authorizationTypeElement;
                      entryInstance.authorizationType = authorizationTypeInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, connectionDetailElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        entryInstance.rights.push(rightsElement);
                      }
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the notification hubs associated with a namespace.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  NotificationHubOperations.prototype.list = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/NotificationHubs';
    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'] = '2013-08-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 = { notificationHubs: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { authorizationRules: [] };
                result.notificationHubs.push(entryInstance);
                
                var titleElement = js2xml.getElement(responseDoc, entriesElement, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (titleElement !== null && titleElement !== undefined) {
                  var titleInstance = titleElement;
                  entryInstance.name = titleInstance;
                }
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var notificationHubDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'NOTIFICATIONHUBDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (notificationHubDescriptionElement !== null && notificationHubDescriptionElement !== undefined) {
                    var registrationTtlElement = js2xml.getElement(responseDoc, notificationHubDescriptionElement, 'REGISTRATIONTTL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (registrationTtlElement !== null && registrationTtlElement !== undefined) {
                      var registrationTtlInstance = registrationTtlElement;
                      entryInstance.registrationTtl = registrationTtlInstance;
                    }
                    
                    var authorizationRulesSequenceElement = js2xml.getElement(responseDoc, notificationHubDescriptionElement, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationRulesSequenceElement !== null && authorizationRulesSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        var authorizationRuleInstance = { rights: [] };
                        entryInstance.authorizationRules.push(authorizationRuleInstance);
                        
                        var claimTypeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (claimTypeElement !== null && claimTypeElement !== undefined) {
                          var claimTypeInstance = claimTypeElement;
                          authorizationRuleInstance.claimType = claimTypeInstance;
                        }
                        
                        var claimValueElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (claimValueElement !== null && claimValueElement !== undefined) {
                          var claimValueInstance = claimValueElement;
                          authorizationRuleInstance.claimValue = claimValueInstance;
                        }
                        
                        var rightsSequenceElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                          for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                            var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                            authorizationRuleInstance.rights.push(rightsElement);
                          }
                        }
                        
                        var createdTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                          var createdTimeInstance = new Date(createdTimeElement);
                          authorizationRuleInstance.createdTime = createdTimeInstance;
                        }
                        
                        var keyNameElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (keyNameElement !== null && keyNameElement !== undefined) {
                          var keyNameInstance = keyNameElement;
                          authorizationRuleInstance.keyName = keyNameInstance;
                        }
                        
                        var modifiedTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                          var modifiedTimeInstance = new Date(modifiedTimeElement);
                          authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                        }
                        
                        var primaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                          var primaryKeyInstance = primaryKeyElement;
                          authorizationRuleInstance.primaryKey = primaryKeyInstance;
                        }
                        
                        var secondaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                          var secondaryKeyInstance = secondaryKeyElement;
                          authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return NotificationHubOperations;
})();

var QueueOperations = ( /** @lends QueueOperations */ function() {
  /**
   * @class
   * The Service Bus Management API includes operations for managing Service
   * Bus queues.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ServiceBusManagementClient] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient}.
   * See [queues] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient#queues}.
   * Initializes a new instance of the QueueOperations class.
   * @constructor
   * 
   * @param {ServiceBusManagementClient} client Reference to the service client.
   */
  function QueueOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a new queue. Once created, this queue's resource manifest is
   * immutable. This operation is idempotent. Repeating the create call, after
   * a queue with same name has been created successfully, will result in a
   * 409 Conflict error message.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj856295.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusQueueCreateParameters} queue The service bus queue.
   * 
   * @param {string} queue.name The name of the queue.
   * 
   * @param {string} [queue.lockDuration] Determines the amount of time in
   * seconds in which a message should be locked for processing by a receiver.
   * After this period, the message is unlocked and available for consumption
   * by the next receiver. Settable only at queue creation time:* Range: 0 - 5
   * minutes. 0 means that the message is not locked* Default: 30 seconds
   * 
   * @param {number} [queue.maxSizeInMegabytes] Specifies the maximum queue
   * size in megabytes. Any attempt to enqueue a message that will cause the
   * queue to exceed this value will fail. You can only set this parameter at
   * queue creation time using the following values: * Range: 1 - 1024 (valid
   * values are 1024, 2048, 3072, 4096, 5120) * Default: 1*1024 (valid values
   * are 1024, 2048, 3072, 4096, 5120)
   * 
   * @param {boolean} [queue.requiresDuplicateDetection] Settable only at queue
   * creation time.* Default for durable queue: false
   * 
   * @param {boolean} [queue.requiresSession] Settable only at queue creation
   * time. If set to true, the queue will be session-aware and only
   * SessionReceiver will be supported. Session-aware queues are not supported
   * through REST.* Default for durable queue: false
   * 
   * @param {string} [queue.defaultMessageTimeToLive] Depending on whether
   * DeadLettering is enabled, a message is automatically moved to the
   * DeadLetterQueue or deleted if it has been stored in the queue for longer
   * than the specified time. This value is overwritten by a TTL specified on
   * the message if and only if the message TTL is smaller than the TTL set on
   * the queue. This value is immutable after the Queue has been created:*
   * Range: 1 second - TimeSpan.MaxValue* Default: TimeSpan.MaxValue
   * 
   * @param {boolean} [queue.deadLetteringOnMessageExpiration] This field
   * controls how the Service Bus handles a message whose TTL has expired. If
   * it is enabled and a message expires, the Service Bus moves the message
   * from the queue into the queue's dead-letter sub-queue. If disabled,
   * message will be permanently deleted from the queue. Settable only at
   * queue creation time.* Default: false
   * 
   * @param {string} [queue.duplicateDetectionHistoryTimeWindow] Specifies the
   * time span during which the Service Bus detects message duplication:*
   * Range: 1 second - 7 days* Default: 10 minutes
   * 
   * @param {number} [queue.maxDeliveryCount] The maximum number of times a
   * message SB will try to deliver before being dead lettered or discarded.
   * 
   * @param {boolean} [queue.enableBatchedOperations] Enables or disables
   * service side batching behavior when performing operations for the
   * specific queue. When enabled, service bus will collect/batch multiple
   * operations to the backend to be more connection efficient. If user wants
   * lower operation latency then they can disable this feature.
   * 
   * @param {number} [queue.sizeInBytes] Reflects the actual bytes that
   * messages in the queue currently occupy toward the queue's quota.* Range:
   * 0 -MaxTopicSizeinMegaBytes
   * 
   * @param {number} [queue.messageCount] Displays the number of messages
   * currently in the queue.
   * 
   * @param {boolean} [queue.isAnonymousAccessible] Gets whether anonymous
   * access is allowed.
   * 
   * @param {array} [queue.authorizationRules] Gets the authorization rules for
   * the description.
   * 
   * @param {string} [queue.status] Gets or sets the current status of the
   * queue (enabled or disabled). When a queue is disabled, that queue cannot
   * send or receive messages.
   * 
   * @param {boolean} [queue.supportOrdering] Gets or sets whether the queue
   * supports ordering.
   * 
   * @param {CountDetails} [queue.countDetails] Current queue statistics.
   * 
   * @param {number} [queue.countDetails.activeMessageCount] The current number
   * of active messages.
   * 
   * @param {number} [queue.countDetails.deadLetterMessageCount] The current
   * number of dead letters.
   * 
   * @param {number} [queue.countDetails.scheduledMessageCount] The current
   * number of scheduled messages.
   * 
   * @param {number} [queue.countDetails.transferDeadLetterMessageCount] The
   * current number of transfer dead letters.
   * 
   * @param {number} [queue.countDetails.transferMessageCount] The current
   * number of transfer messages.
   * 
   * @param {string} [queue.autoDeleteOnIdle] Implemented.
   * 
   * @param {string} [queue.entityAvailabilityStatus] The current availability
   * status of the queue.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  QueueOperations.prototype.create = function(namespaceName, queue, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (queue === null || queue === undefined) {
      return callback(new Error('queue cannot be null.'));
    }
    if (queue.name === null || queue.name === undefined) {
      return callback(new Error('queue.name cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/queues/';
    url2 = url2 + encodeURIComponent(queue.name);
    url2 = url2 + '/';
    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/atom+xml';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    httpRequest.headers['x-process-at'] = 'ServiceBus';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/atom+xml;type=entry;charset=utf-8');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var queueDescriptionElement = js2xml.createElement('QueueDescription', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, queueDescriptionElement);
    
    if (queue.lockDuration !== null && queue.lockDuration !== undefined) {
      var lockDurationElement = js2xml.createElement('LockDuration', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(lockDurationElement, queue.lockDuration);
      js2xml.addChildElement(queueDescriptionElement, lockDurationElement);
    }
    
    if (queue.maxSizeInMegabytes !== null && queue.maxSizeInMegabytes !== undefined) {
      var maxSizeInMegabytesElement = js2xml.createElement('MaxSizeInMegabytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(maxSizeInMegabytesElement, queue.maxSizeInMegabytes.toString());
      js2xml.addChildElement(queueDescriptionElement, maxSizeInMegabytesElement);
    }
    
    if (queue.requiresDuplicateDetection !== null && queue.requiresDuplicateDetection !== undefined) {
      var requiresDuplicateDetectionElement = js2xml.createElement('RequiresDuplicateDetection', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(requiresDuplicateDetectionElement, queue.requiresDuplicateDetection.toString());
      js2xml.addChildElement(queueDescriptionElement, requiresDuplicateDetectionElement);
    }
    
    if (queue.requiresSession !== null && queue.requiresSession !== undefined) {
      var requiresSessionElement = js2xml.createElement('RequiresSession', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(requiresSessionElement, queue.requiresSession.toString());
      js2xml.addChildElement(queueDescriptionElement, requiresSessionElement);
    }
    
    if (queue.defaultMessageTimeToLive !== null && queue.defaultMessageTimeToLive !== undefined) {
      var defaultMessageTimeToLiveElement = js2xml.createElement('DefaultMessageTimeToLive', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(defaultMessageTimeToLiveElement, queue.defaultMessageTimeToLive);
      js2xml.addChildElement(queueDescriptionElement, defaultMessageTimeToLiveElement);
    }
    
    if (queue.deadLetteringOnMessageExpiration !== null && queue.deadLetteringOnMessageExpiration !== undefined) {
      var deadLetteringOnMessageExpirationElement = js2xml.createElement('DeadLetteringOnMessageExpiration', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(deadLetteringOnMessageExpirationElement, queue.deadLetteringOnMessageExpiration.toString());
      js2xml.addChildElement(queueDescriptionElement, deadLetteringOnMessageExpirationElement);
    }
    
    if (queue.duplicateDetectionHistoryTimeWindow !== null && queue.duplicateDetectionHistoryTimeWindow !== undefined) {
      var duplicateDetectionHistoryTimeWindowElement = js2xml.createElement('DuplicateDetectionHistoryTimeWindow', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(duplicateDetectionHistoryTimeWindowElement, queue.duplicateDetectionHistoryTimeWindow);
      js2xml.addChildElement(queueDescriptionElement, duplicateDetectionHistoryTimeWindowElement);
    }
    
    if (queue.enableBatchedOperations !== null && queue.enableBatchedOperations !== undefined) {
      var enableBatchedOperationsElement = js2xml.createElement('EnableBatchedOperations', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(enableBatchedOperationsElement, queue.enableBatchedOperations.toString());
      js2xml.addChildElement(queueDescriptionElement, enableBatchedOperationsElement);
    }
    
    if (queue.sizeInBytes !== null && queue.sizeInBytes !== undefined) {
      var sizeInBytesElement = js2xml.createElement('SizeInBytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(sizeInBytesElement, queue.sizeInBytes.toString());
      js2xml.addChildElement(queueDescriptionElement, sizeInBytesElement);
    }
    
    if (queue.messageCount !== null && queue.messageCount !== undefined) {
      var messageCountElement = js2xml.createElement('MessageCount', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(messageCountElement, queue.messageCount.toString());
      js2xml.addChildElement(queueDescriptionElement, messageCountElement);
    }
    
    if (queue.isAnonymousAccessible !== null && queue.isAnonymousAccessible !== undefined) {
      var isAnonymousAccessibleElement = js2xml.createElement('IsAnonymousAccessible', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(isAnonymousAccessibleElement, queue.isAnonymousAccessible.toString());
      js2xml.addChildElement(queueDescriptionElement, isAnonymousAccessibleElement);
    }
    
    if (queue.authorizationRules !== null && queue.authorizationRules !== undefined) {
      var authorizationRulesSequenceElement = js2xml.createElement('AuthorizationRules', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      for (var loweredIndex1 = 0; loweredIndex1 < queue.authorizationRules.length; loweredIndex1 = loweredIndex1 + 1) {
        var authorizationRulesItem = queue.authorizationRules[loweredIndex1];
        var authorizationRuleElement = js2xml.createElement('AuthorizationRule', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.addChildElement(authorizationRulesSequenceElement, authorizationRuleElement);
        
        var typeAttribute2 = js2xml.createAttribute('type', 'http://www.w3.org/2001/XMLSchema-instance');
        js2xml.setAttributeValue(typeAttribute2, 'SharedAccessAuthorizationRule');
        js2xml.addAttribute(authorizationRuleElement, typeAttribute2);
        
        if (authorizationRulesItem.claimType !== null && authorizationRulesItem.claimType !== undefined) {
          var claimTypeElement = js2xml.createElement('ClaimType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimTypeElement, authorizationRulesItem.claimType);
          js2xml.addChildElement(authorizationRuleElement, claimTypeElement);
        }
        
        if (authorizationRulesItem.claimValue !== null && authorizationRulesItem.claimValue !== undefined) {
          var claimValueElement = js2xml.createElement('ClaimValue', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimValueElement, authorizationRulesItem.claimValue);
          js2xml.addChildElement(authorizationRuleElement, claimValueElement);
        }
        
        if (authorizationRulesItem.rights !== null && authorizationRulesItem.rights !== undefined) {
          var rightsSequenceElement = js2xml.createElement('Rights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          for (var loweredIndex2 = 0; loweredIndex2 < authorizationRulesItem.rights.length; loweredIndex2 = loweredIndex2 + 1) {
            var rightsItem = authorizationRulesItem.rights[loweredIndex2];
            var rightsItemElement = js2xml.createElement('AccessRights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
            js2xml.setElementValue(rightsItemElement, rightsItem !== null && rightsItem !== undefined ? rightsItem.toString() : 'Listen');
            js2xml.addChildElement(rightsSequenceElement, rightsItemElement);
          }
          js2xml.addChildElement(authorizationRuleElement, rightsSequenceElement);
        }
        
        if (authorizationRulesItem.createdTime !== null && authorizationRulesItem.createdTime !== undefined) {
          var createdTimeElement = js2xml.createElement('CreatedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(createdTimeElement, authorizationRulesItem.createdTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, createdTimeElement);
        }
        
        if (authorizationRulesItem.keyName !== null && authorizationRulesItem.keyName !== undefined) {
          var keyNameElement = js2xml.createElement('KeyName', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(keyNameElement, authorizationRulesItem.keyName);
          js2xml.addChildElement(authorizationRuleElement, keyNameElement);
        }
        
        if (authorizationRulesItem.modifiedTime !== null && authorizationRulesItem.modifiedTime !== undefined) {
          var modifiedTimeElement = js2xml.createElement('ModifiedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(modifiedTimeElement, authorizationRulesItem.modifiedTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, modifiedTimeElement);
        }
        
        if (authorizationRulesItem.primaryKey !== null && authorizationRulesItem.primaryKey !== undefined) {
          var primaryKeyElement = js2xml.createElement('PrimaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(primaryKeyElement, authorizationRulesItem.primaryKey);
          js2xml.addChildElement(authorizationRuleElement, primaryKeyElement);
        }
        
        if (authorizationRulesItem.secondaryKey !== null && authorizationRulesItem.secondaryKey !== undefined) {
          var secondaryKeyElement = js2xml.createElement('SecondaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(secondaryKeyElement, authorizationRulesItem.secondaryKey);
          js2xml.addChildElement(authorizationRuleElement, secondaryKeyElement);
        }
      }
      js2xml.addChildElement(queueDescriptionElement, authorizationRulesSequenceElement);
    }
    
    if (queue.status !== null && queue.status !== undefined) {
      var statusElement = js2xml.createElement('Status', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(statusElement, queue.status);
      js2xml.addChildElement(queueDescriptionElement, statusElement);
    }
    
    if (queue.supportOrdering !== null && queue.supportOrdering !== undefined) {
      var supportOrderingElement = js2xml.createElement('SupportOrdering', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(supportOrderingElement, queue.supportOrdering.toString());
      js2xml.addChildElement(queueDescriptionElement, supportOrderingElement);
    }
    
    if (queue.countDetails !== null && queue.countDetails !== undefined) {
      var countDetailsElement = js2xml.createElement('CountDetails', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.addChildElement(queueDescriptionElement, countDetailsElement);
      
      if (queue.countDetails.activeMessageCount !== null && queue.countDetails.activeMessageCount !== undefined) {
        var activeMessageCountElement = js2xml.createElement('ActiveMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(activeMessageCountElement, queue.countDetails.activeMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, activeMessageCountElement);
      }
      
      if (queue.countDetails.deadLetterMessageCount !== null && queue.countDetails.deadLetterMessageCount !== undefined) {
        var deadLetterMessageCountElement = js2xml.createElement('DeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(deadLetterMessageCountElement, queue.countDetails.deadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, deadLetterMessageCountElement);
      }
      
      if (queue.countDetails.scheduledMessageCount !== null && queue.countDetails.scheduledMessageCount !== undefined) {
        var scheduledMessageCountElement = js2xml.createElement('ScheduledMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(scheduledMessageCountElement, queue.countDetails.scheduledMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, scheduledMessageCountElement);
      }
      
      if (queue.countDetails.transferDeadLetterMessageCount !== null && queue.countDetails.transferDeadLetterMessageCount !== undefined) {
        var transferDeadLetterMessageCountElement = js2xml.createElement('TransferDeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferDeadLetterMessageCountElement, queue.countDetails.transferDeadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferDeadLetterMessageCountElement);
      }
      
      if (queue.countDetails.transferMessageCount !== null && queue.countDetails.transferMessageCount !== undefined) {
        var transferMessageCountElement = js2xml.createElement('TransferMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferMessageCountElement, queue.countDetails.transferMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferMessageCountElement);
      }
    }
    
    if (queue.autoDeleteOnIdle !== null && queue.autoDeleteOnIdle !== undefined) {
      var autoDeleteOnIdleElement = js2xml.createElement('AutoDeleteOnIdle', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(autoDeleteOnIdleElement, queue.autoDeleteOnIdle);
      js2xml.addChildElement(queueDescriptionElement, autoDeleteOnIdleElement);
    }
    
    if (queue.entityAvailabilityStatus !== null && queue.entityAvailabilityStatus !== undefined) {
      var entityAvailabilityStatusElement = js2xml.createElement('EntityAvailabilityStatus', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(entityAvailabilityStatusElement, queue.entityAvailabilityStatus);
      js2xml.addChildElement(queueDescriptionElement, entityAvailabilityStatusElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement2, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var queueDescriptionElement2 = js2xml.getElement(responseDoc, contentElement2, 'QUEUEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (queueDescriptionElement2 !== null && queueDescriptionElement2 !== undefined) {
                var queueDescriptionInstance = { authorizationRules: [] };
                result.queue = queueDescriptionInstance;
                
                var lockDurationElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'LOCKDURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (lockDurationElement2 !== null && lockDurationElement2 !== undefined) {
                  var lockDurationInstance = lockDurationElement2;
                  queueDescriptionInstance.lockDuration = lockDurationInstance;
                }
                
                var maxSizeInMegabytesElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxSizeInMegabytesElement2 !== null && maxSizeInMegabytesElement2 !== undefined && maxSizeInMegabytesElement2.length !== 0) {
                  var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement2, 10);
                  queueDescriptionInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                }
                
                var requiresDuplicateDetectionElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresDuplicateDetectionElement2 !== null && requiresDuplicateDetectionElement2 !== undefined && requiresDuplicateDetectionElement2.length !== 0) {
                  var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement2 === 'true';
                  queueDescriptionInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                }
                
                var requiresSessionElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'REQUIRESSESSION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresSessionElement2 !== null && requiresSessionElement2 !== undefined && requiresSessionElement2.length !== 0) {
                  var requiresSessionInstance = requiresSessionElement2 === 'true';
                  queueDescriptionInstance.requiresSession = requiresSessionInstance;
                }
                
                var defaultMessageTimeToLiveElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (defaultMessageTimeToLiveElement2 !== null && defaultMessageTimeToLiveElement2 !== undefined) {
                  var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement2;
                  queueDescriptionInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                }
                
                var deadLetteringOnMessageExpirationElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'DEADLETTERINGONMESSAGEEXPIRATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (deadLetteringOnMessageExpirationElement2 !== null && deadLetteringOnMessageExpirationElement2 !== undefined && deadLetteringOnMessageExpirationElement2.length !== 0) {
                  var deadLetteringOnMessageExpirationInstance = deadLetteringOnMessageExpirationElement2 === 'true';
                  queueDescriptionInstance.deadLetteringOnMessageExpiration = deadLetteringOnMessageExpirationInstance;
                }
                
                var duplicateDetectionHistoryTimeWindowElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (duplicateDetectionHistoryTimeWindowElement2 !== null && duplicateDetectionHistoryTimeWindowElement2 !== undefined) {
                  var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement2;
                  queueDescriptionInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                }
                
                var maxDeliveryCountElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'MAXDELIVERYCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxDeliveryCountElement !== null && maxDeliveryCountElement !== undefined && maxDeliveryCountElement.length !== 0) {
                  var maxDeliveryCountInstance = parseInt(maxDeliveryCountElement, 10);
                  queueDescriptionInstance.maxDeliveryCount = maxDeliveryCountInstance;
                }
                
                var enableBatchedOperationsElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enableBatchedOperationsElement2 !== null && enableBatchedOperationsElement2 !== undefined && enableBatchedOperationsElement2.length !== 0) {
                  var enableBatchedOperationsInstance = enableBatchedOperationsElement2 === 'true';
                  queueDescriptionInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                }
                
                var sizeInBytesElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (sizeInBytesElement2 !== null && sizeInBytesElement2 !== undefined && sizeInBytesElement2.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement2, 10);
                  queueDescriptionInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var messageCountElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'MESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (messageCountElement2 !== null && messageCountElement2 !== undefined && messageCountElement2.length !== 0) {
                  var messageCountInstance = parseInt(messageCountElement2, 10);
                  queueDescriptionInstance.messageCount = messageCountInstance;
                }
                
                var isAnonymousAccessibleElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (isAnonymousAccessibleElement2 !== null && isAnonymousAccessibleElement2 !== undefined && isAnonymousAccessibleElement2.length !== 0) {
                  var isAnonymousAccessibleInstance = isAnonymousAccessibleElement2 === 'true';
                  queueDescriptionInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                }
                
                var authorizationRulesSequenceElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement2 !== null && authorizationRulesSequenceElement2 !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                    var authorizationRuleInstance = { rights: [] };
                    queueDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement2 !== null && claimTypeElement2 !== undefined) {
                      var claimTypeInstance = claimTypeElement2;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement2 !== null && claimValueElement2 !== undefined) {
                      var claimValueInstance = claimValueElement2;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement2 !== null && rightsSequenceElement2 !== undefined) {
                      for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex4 = loweredIndex4 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex4];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement2 !== null && createdTimeElement2 !== undefined && createdTimeElement2.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement2);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement2 !== null && keyNameElement2 !== undefined) {
                      var keyNameInstance = keyNameElement2;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement2 !== null && modifiedTimeElement2 !== undefined && modifiedTimeElement2.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement2);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement2 !== null && primaryKeyElement2 !== undefined) {
                      var primaryKeyInstance = primaryKeyElement2;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement2 !== null && secondaryKeyElement2 !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement2;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
                
                var statusElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement2 !== null && statusElement2 !== undefined) {
                  var statusInstance = statusElement2;
                  queueDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  queueDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var updatedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (updatedAtElement !== null && updatedAtElement !== undefined && updatedAtElement.length !== 0) {
                  var updatedAtInstance = new Date(updatedAtElement);
                  queueDescriptionInstance.updatedAt = updatedAtInstance;
                }
                
                var accessedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (accessedAtElement !== null && accessedAtElement !== undefined && accessedAtElement.length !== 0) {
                  var accessedAtInstance = new Date(accessedAtElement);
                  queueDescriptionInstance.accessedAt = accessedAtInstance;
                }
                
                var supportOrderingElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (supportOrderingElement2 !== null && supportOrderingElement2 !== undefined && supportOrderingElement2.length !== 0) {
                  var supportOrderingInstance = supportOrderingElement2 === 'true';
                  queueDescriptionInstance.supportOrdering = supportOrderingInstance;
                }
                
                var countDetailsElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (countDetailsElement2 !== null && countDetailsElement2 !== undefined) {
                  var countDetailsInstance = {};
                  queueDescriptionInstance.countDetails = countDetailsInstance;
                  
                  var activeMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'ACTIVEMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (activeMessageCountElement2 !== null && activeMessageCountElement2 !== undefined && activeMessageCountElement2.length !== 0) {
                    var activeMessageCountInstance = parseInt(activeMessageCountElement2, 10);
                    countDetailsInstance.activeMessageCount = activeMessageCountInstance;
                  }
                  
                  var deadLetterMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'DEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (deadLetterMessageCountElement2 !== null && deadLetterMessageCountElement2 !== undefined && deadLetterMessageCountElement2.length !== 0) {
                    var deadLetterMessageCountInstance = parseInt(deadLetterMessageCountElement2, 10);
                    countDetailsInstance.deadLetterMessageCount = deadLetterMessageCountInstance;
                  }
                  
                  var scheduledMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'SCHEDULEDMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (scheduledMessageCountElement2 !== null && scheduledMessageCountElement2 !== undefined && scheduledMessageCountElement2.length !== 0) {
                    var scheduledMessageCountInstance = parseInt(scheduledMessageCountElement2, 10);
                    countDetailsInstance.scheduledMessageCount = scheduledMessageCountInstance;
                  }
                  
                  var transferDeadLetterMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'TRANSFERDEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (transferDeadLetterMessageCountElement2 !== null && transferDeadLetterMessageCountElement2 !== undefined && transferDeadLetterMessageCountElement2.length !== 0) {
                    var transferDeadLetterMessageCountInstance = parseInt(transferDeadLetterMessageCountElement2, 10);
                    countDetailsInstance.transferDeadLetterMessageCount = transferDeadLetterMessageCountInstance;
                  }
                  
                  var transferMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'TRANSFERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (transferMessageCountElement2 !== null && transferMessageCountElement2 !== undefined && transferMessageCountElement2.length !== 0) {
                    var transferMessageCountInstance = parseInt(transferMessageCountElement2, 10);
                    countDetailsInstance.transferMessageCount = transferMessageCountInstance;
                  }
                }
                
                var autoDeleteOnIdleElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (autoDeleteOnIdleElement2 !== null && autoDeleteOnIdleElement2 !== undefined) {
                  var autoDeleteOnIdleInstance = autoDeleteOnIdleElement2;
                  queueDescriptionInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                }
                
                var entityAvailabilityStatusElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (entityAvailabilityStatusElement2 !== null && entityAvailabilityStatusElement2 !== undefined) {
                  var entityAvailabilityStatusInstance = entityAvailabilityStatusElement2;
                  queueDescriptionInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes an existing queue. This operation will also remove all associated
   * state including messages in the queue.  (see
   * http://msdn.microsoft.com/en-us/library/hh780747.aspx for more
   * information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} queueName The queue name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  QueueOperations.prototype.deleteMethod = function(namespaceName, queueName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (queueName === null || queueName === undefined) {
      return callback(new Error('queueName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/Queues/';
    url2 = url2 + encodeURIComponent(queueName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The queue description is an XML AtomPub document that defines the desired
   * semantics for a subscription. The queue description contains the
   * following properties. For more information, see the QueueDescription
   * Properties topic.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh780773.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} queueName The queue name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  QueueOperations.prototype.get = function(namespaceName, queueName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (queueName === null || queueName === undefined) {
      return callback(new Error('queueName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/Queues/';
    url2 = url2 + encodeURIComponent(queueName);
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement !== null && entryElement !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement = js2xml.getElement(responseDoc, entryElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement !== null && contentElement !== undefined) {
              var queueDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'QUEUEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (queueDescriptionElement !== null && queueDescriptionElement !== undefined) {
                var queueDescriptionInstance = { authorizationRules: [] };
                result.queue = queueDescriptionInstance;
                
                var lockDurationElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'LOCKDURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (lockDurationElement !== null && lockDurationElement !== undefined) {
                  var lockDurationInstance = lockDurationElement;
                  queueDescriptionInstance.lockDuration = lockDurationInstance;
                }
                
                var maxSizeInMegabytesElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxSizeInMegabytesElement !== null && maxSizeInMegabytesElement !== undefined && maxSizeInMegabytesElement.length !== 0) {
                  var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement, 10);
                  queueDescriptionInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                }
                
                var requiresDuplicateDetectionElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresDuplicateDetectionElement !== null && requiresDuplicateDetectionElement !== undefined && requiresDuplicateDetectionElement.length !== 0) {
                  var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement === 'true';
                  queueDescriptionInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                }
                
                var requiresSessionElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'REQUIRESSESSION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresSessionElement !== null && requiresSessionElement !== undefined && requiresSessionElement.length !== 0) {
                  var requiresSessionInstance = requiresSessionElement === 'true';
                  queueDescriptionInstance.requiresSession = requiresSessionInstance;
                }
                
                var defaultMessageTimeToLiveElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (defaultMessageTimeToLiveElement !== null && defaultMessageTimeToLiveElement !== undefined) {
                  var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement;
                  queueDescriptionInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                }
                
                var deadLetteringOnMessageExpirationElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'DEADLETTERINGONMESSAGEEXPIRATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (deadLetteringOnMessageExpirationElement !== null && deadLetteringOnMessageExpirationElement !== undefined && deadLetteringOnMessageExpirationElement.length !== 0) {
                  var deadLetteringOnMessageExpirationInstance = deadLetteringOnMessageExpirationElement === 'true';
                  queueDescriptionInstance.deadLetteringOnMessageExpiration = deadLetteringOnMessageExpirationInstance;
                }
                
                var duplicateDetectionHistoryTimeWindowElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (duplicateDetectionHistoryTimeWindowElement !== null && duplicateDetectionHistoryTimeWindowElement !== undefined) {
                  var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement;
                  queueDescriptionInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                }
                
                var maxDeliveryCountElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'MAXDELIVERYCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxDeliveryCountElement !== null && maxDeliveryCountElement !== undefined && maxDeliveryCountElement.length !== 0) {
                  var maxDeliveryCountInstance = parseInt(maxDeliveryCountElement, 10);
                  queueDescriptionInstance.maxDeliveryCount = maxDeliveryCountInstance;
                }
                
                var enableBatchedOperationsElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enableBatchedOperationsElement !== null && enableBatchedOperationsElement !== undefined && enableBatchedOperationsElement.length !== 0) {
                  var enableBatchedOperationsInstance = enableBatchedOperationsElement === 'true';
                  queueDescriptionInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                }
                
                var sizeInBytesElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (sizeInBytesElement !== null && sizeInBytesElement !== undefined && sizeInBytesElement.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement, 10);
                  queueDescriptionInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var messageCountElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'MESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (messageCountElement !== null && messageCountElement !== undefined && messageCountElement.length !== 0) {
                  var messageCountInstance = parseInt(messageCountElement, 10);
                  queueDescriptionInstance.messageCount = messageCountInstance;
                }
                
                var isAnonymousAccessibleElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (isAnonymousAccessibleElement !== null && isAnonymousAccessibleElement !== undefined && isAnonymousAccessibleElement.length !== 0) {
                  var isAnonymousAccessibleInstance = isAnonymousAccessibleElement === 'true';
                  queueDescriptionInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                }
                
                var authorizationRulesSequenceElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement !== null && authorizationRulesSequenceElement !== undefined) {
                  for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex1 = loweredIndex1 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex1];
                    var authorizationRuleInstance = { rights: [] };
                    queueDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement !== null && claimTypeElement !== undefined) {
                      var claimTypeInstance = claimTypeElement;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement !== null && claimValueElement !== undefined) {
                      var claimValueInstance = claimValueElement;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                      var primaryKeyInstance = primaryKeyElement;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
                
                var statusElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement !== null && statusElement !== undefined) {
                  var statusInstance = statusElement;
                  queueDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  queueDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var updatedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (updatedAtElement !== null && updatedAtElement !== undefined && updatedAtElement.length !== 0) {
                  var updatedAtInstance = new Date(updatedAtElement);
                  queueDescriptionInstance.updatedAt = updatedAtInstance;
                }
                
                var accessedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (accessedAtElement !== null && accessedAtElement !== undefined && accessedAtElement.length !== 0) {
                  var accessedAtInstance = new Date(accessedAtElement);
                  queueDescriptionInstance.accessedAt = accessedAtInstance;
                }
                
                var supportOrderingElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (supportOrderingElement !== null && supportOrderingElement !== undefined && supportOrderingElement.length !== 0) {
                  var supportOrderingInstance = supportOrderingElement === 'true';
                  queueDescriptionInstance.supportOrdering = supportOrderingInstance;
                }
                
                var countDetailsElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (countDetailsElement !== null && countDetailsElement !== undefined) {
                  var countDetailsInstance = {};
                  queueDescriptionInstance.countDetails = countDetailsInstance;
                  
                  var activeMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'ACTIVEMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (activeMessageCountElement !== null && activeMessageCountElement !== undefined && activeMessageCountElement.length !== 0) {
                    var activeMessageCountInstance = parseInt(activeMessageCountElement, 10);
                    countDetailsInstance.activeMessageCount = activeMessageCountInstance;
                  }
                  
                  var deadLetterMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'DEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (deadLetterMessageCountElement !== null && deadLetterMessageCountElement !== undefined && deadLetterMessageCountElement.length !== 0) {
                    var deadLetterMessageCountInstance = parseInt(deadLetterMessageCountElement, 10);
                    countDetailsInstance.deadLetterMessageCount = deadLetterMessageCountInstance;
                  }
                  
                  var scheduledMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'SCHEDULEDMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (scheduledMessageCountElement !== null && scheduledMessageCountElement !== undefined && scheduledMessageCountElement.length !== 0) {
                    var scheduledMessageCountInstance = parseInt(scheduledMessageCountElement, 10);
                    countDetailsInstance.scheduledMessageCount = scheduledMessageCountInstance;
                  }
                  
                  var transferDeadLetterMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'TRANSFERDEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (transferDeadLetterMessageCountElement !== null && transferDeadLetterMessageCountElement !== undefined && transferDeadLetterMessageCountElement.length !== 0) {
                    var transferDeadLetterMessageCountInstance = parseInt(transferDeadLetterMessageCountElement, 10);
                    countDetailsInstance.transferDeadLetterMessageCount = transferDeadLetterMessageCountInstance;
                  }
                  
                  var transferMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'TRANSFERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (transferMessageCountElement !== null && transferMessageCountElement !== undefined && transferMessageCountElement.length !== 0) {
                    var transferMessageCountInstance = parseInt(transferMessageCountElement, 10);
                    countDetailsInstance.transferMessageCount = transferMessageCountInstance;
                  }
                }
                
                var autoDeleteOnIdleElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (autoDeleteOnIdleElement !== null && autoDeleteOnIdleElement !== undefined) {
                  var autoDeleteOnIdleInstance = autoDeleteOnIdleElement;
                  queueDescriptionInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                }
                
                var entityAvailabilityStatusElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (entityAvailabilityStatusElement !== null && entityAvailabilityStatusElement !== undefined) {
                  var entityAvailabilityStatusInstance = entityAvailabilityStatusElement;
                  queueDescriptionInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets the set of connection strings for a queue.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} queueName The queue name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  QueueOperations.prototype.getConnectionDetails = function(namespaceName, queueName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (queueName === null || queueName === undefined) {
      return callback(new Error('queueName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/Queues/';
    url2 = url2 + encodeURIComponent(queueName);
    url2 = url2 + '/ConnectionDetails';
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { connectionDetails: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { rights: [] };
                result.connectionDetails.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var connectionDetailElement = js2xml.getElement(responseDoc, contentElement, 'CONNECTIONDETAIL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (connectionDetailElement !== null && connectionDetailElement !== undefined) {
                    var keyNameElement = js2xml.getElement(responseDoc, connectionDetailElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      entryInstance.keyName = keyNameInstance;
                    }
                    
                    var connectionStringElement = js2xml.getElement(responseDoc, connectionDetailElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (connectionStringElement !== null && connectionStringElement !== undefined) {
                      var connectionStringInstance = connectionStringElement;
                      entryInstance.connectionString = connectionStringInstance;
                    }
                    
                    var authorizationTypeElement = js2xml.getElement(responseDoc, connectionDetailElement, 'AUTHORIZATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationTypeElement !== null && authorizationTypeElement !== undefined) {
                      var authorizationTypeInstance = authorizationTypeElement;
                      entryInstance.authorizationType = authorizationTypeInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, connectionDetailElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        entryInstance.rights.push(rightsElement);
                      }
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Enumerates the queues in the service namespace. The result is returned in
   * pages, each containing up to 100 queues. If the namespace contains more
   * than 100 queues, a feed is returned that contains the first page and a
   * next link with the URI to view the next page of data.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh780759.asp for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  QueueOperations.prototype.list = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/Queues';
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { queues: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { authorizationRules: [] };
                result.queues.push(entryInstance);
                
                var titleElement = js2xml.getElement(responseDoc, entriesElement, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (titleElement !== null && titleElement !== undefined) {
                  var titleInstance = titleElement;
                  entryInstance.name = titleInstance;
                }
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var queueDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'QUEUEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (queueDescriptionElement !== null && queueDescriptionElement !== undefined) {
                    var lockDurationElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'LOCKDURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (lockDurationElement !== null && lockDurationElement !== undefined) {
                      var lockDurationInstance = lockDurationElement;
                      entryInstance.lockDuration = lockDurationInstance;
                    }
                    
                    var maxSizeInMegabytesElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (maxSizeInMegabytesElement !== null && maxSizeInMegabytesElement !== undefined && maxSizeInMegabytesElement.length !== 0) {
                      var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement, 10);
                      entryInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                    }
                    
                    var requiresDuplicateDetectionElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (requiresDuplicateDetectionElement !== null && requiresDuplicateDetectionElement !== undefined && requiresDuplicateDetectionElement.length !== 0) {
                      var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement === 'true';
                      entryInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                    }
                    
                    var requiresSessionElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'REQUIRESSESSION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (requiresSessionElement !== null && requiresSessionElement !== undefined && requiresSessionElement.length !== 0) {
                      var requiresSessionInstance = requiresSessionElement === 'true';
                      entryInstance.requiresSession = requiresSessionInstance;
                    }
                    
                    var defaultMessageTimeToLiveElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (defaultMessageTimeToLiveElement !== null && defaultMessageTimeToLiveElement !== undefined) {
                      var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement;
                      entryInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                    }
                    
                    var deadLetteringOnMessageExpirationElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'DEADLETTERINGONMESSAGEEXPIRATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (deadLetteringOnMessageExpirationElement !== null && deadLetteringOnMessageExpirationElement !== undefined && deadLetteringOnMessageExpirationElement.length !== 0) {
                      var deadLetteringOnMessageExpirationInstance = deadLetteringOnMessageExpirationElement === 'true';
                      entryInstance.deadLetteringOnMessageExpiration = deadLetteringOnMessageExpirationInstance;
                    }
                    
                    var duplicateDetectionHistoryTimeWindowElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (duplicateDetectionHistoryTimeWindowElement !== null && duplicateDetectionHistoryTimeWindowElement !== undefined) {
                      var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement;
                      entryInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                    }
                    
                    var maxDeliveryCountElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'MAXDELIVERYCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (maxDeliveryCountElement !== null && maxDeliveryCountElement !== undefined && maxDeliveryCountElement.length !== 0) {
                      var maxDeliveryCountInstance = parseInt(maxDeliveryCountElement, 10);
                      entryInstance.maxDeliveryCount = maxDeliveryCountInstance;
                    }
                    
                    var enableBatchedOperationsElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (enableBatchedOperationsElement !== null && enableBatchedOperationsElement !== undefined && enableBatchedOperationsElement.length !== 0) {
                      var enableBatchedOperationsInstance = enableBatchedOperationsElement === 'true';
                      entryInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                    }
                    
                    var sizeInBytesElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (sizeInBytesElement !== null && sizeInBytesElement !== undefined && sizeInBytesElement.length !== 0) {
                      var sizeInBytesInstance = parseInt(sizeInBytesElement, 10);
                      entryInstance.sizeInBytes = sizeInBytesInstance;
                    }
                    
                    var messageCountElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'MESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (messageCountElement !== null && messageCountElement !== undefined && messageCountElement.length !== 0) {
                      var messageCountInstance = parseInt(messageCountElement, 10);
                      entryInstance.messageCount = messageCountInstance;
                    }
                    
                    var isAnonymousAccessibleElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (isAnonymousAccessibleElement !== null && isAnonymousAccessibleElement !== undefined && isAnonymousAccessibleElement.length !== 0) {
                      var isAnonymousAccessibleInstance = isAnonymousAccessibleElement === 'true';
                      entryInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                    }
                    
                    var authorizationRulesSequenceElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationRulesSequenceElement !== null && authorizationRulesSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        var authorizationRuleInstance = { rights: [] };
                        entryInstance.authorizationRules.push(authorizationRuleInstance);
                        
                        var claimTypeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (claimTypeElement !== null && claimTypeElement !== undefined) {
                          var claimTypeInstance = claimTypeElement;
                          authorizationRuleInstance.claimType = claimTypeInstance;
                        }
                        
                        var claimValueElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (claimValueElement !== null && claimValueElement !== undefined) {
                          var claimValueInstance = claimValueElement;
                          authorizationRuleInstance.claimValue = claimValueInstance;
                        }
                        
                        var rightsSequenceElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                          for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                            var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                            authorizationRuleInstance.rights.push(rightsElement);
                          }
                        }
                        
                        var createdTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                          var createdTimeInstance = new Date(createdTimeElement);
                          authorizationRuleInstance.createdTime = createdTimeInstance;
                        }
                        
                        var keyNameElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (keyNameElement !== null && keyNameElement !== undefined) {
                          var keyNameInstance = keyNameElement;
                          authorizationRuleInstance.keyName = keyNameInstance;
                        }
                        
                        var modifiedTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                          var modifiedTimeInstance = new Date(modifiedTimeElement);
                          authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                        }
                        
                        var primaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                          var primaryKeyInstance = primaryKeyElement;
                          authorizationRuleInstance.primaryKey = primaryKeyInstance;
                        }
                        
                        var secondaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                          var secondaryKeyInstance = secondaryKeyElement;
                          authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                        }
                      }
                    }
                    
                    var statusElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (statusElement !== null && statusElement !== undefined) {
                      var statusInstance = statusElement;
                      entryInstance.status = statusInstance;
                    }
                    
                    var createdAtElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                      var createdAtInstance = new Date(createdAtElement);
                      entryInstance.createdAt = createdAtInstance;
                    }
                    
                    var updatedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (updatedAtElement !== null && updatedAtElement !== undefined && updatedAtElement.length !== 0) {
                      var updatedAtInstance = new Date(updatedAtElement);
                      entryInstance.updatedAt = updatedAtInstance;
                    }
                    
                    var accessedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (accessedAtElement !== null && accessedAtElement !== undefined && accessedAtElement.length !== 0) {
                      var accessedAtInstance = new Date(accessedAtElement);
                      entryInstance.accessedAt = accessedAtInstance;
                    }
                    
                    var supportOrderingElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (supportOrderingElement !== null && supportOrderingElement !== undefined && supportOrderingElement.length !== 0) {
                      var supportOrderingInstance = supportOrderingElement === 'true';
                      entryInstance.supportOrdering = supportOrderingInstance;
                    }
                    
                    var countDetailsElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (countDetailsElement !== null && countDetailsElement !== undefined) {
                      var countDetailsInstance = {};
                      entryInstance.countDetails = countDetailsInstance;
                      
                      var activeMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'ACTIVEMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                      if (activeMessageCountElement !== null && activeMessageCountElement !== undefined && activeMessageCountElement.length !== 0) {
                        var activeMessageCountInstance = parseInt(activeMessageCountElement, 10);
                        countDetailsInstance.activeMessageCount = activeMessageCountInstance;
                      }
                      
                      var deadLetterMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'DEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                      if (deadLetterMessageCountElement !== null && deadLetterMessageCountElement !== undefined && deadLetterMessageCountElement.length !== 0) {
                        var deadLetterMessageCountInstance = parseInt(deadLetterMessageCountElement, 10);
                        countDetailsInstance.deadLetterMessageCount = deadLetterMessageCountInstance;
                      }
                      
                      var scheduledMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'SCHEDULEDMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                      if (scheduledMessageCountElement !== null && scheduledMessageCountElement !== undefined && scheduledMessageCountElement.length !== 0) {
                        var scheduledMessageCountInstance = parseInt(scheduledMessageCountElement, 10);
                        countDetailsInstance.scheduledMessageCount = scheduledMessageCountInstance;
                      }
                      
                      var transferDeadLetterMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'TRANSFERDEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                      if (transferDeadLetterMessageCountElement !== null && transferDeadLetterMessageCountElement !== undefined && transferDeadLetterMessageCountElement.length !== 0) {
                        var transferDeadLetterMessageCountInstance = parseInt(transferDeadLetterMessageCountElement, 10);
                        countDetailsInstance.transferDeadLetterMessageCount = transferDeadLetterMessageCountInstance;
                      }
                      
                      var transferMessageCountElement = js2xml.getElement(responseDoc, countDetailsElement, 'TRANSFERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                      if (transferMessageCountElement !== null && transferMessageCountElement !== undefined && transferMessageCountElement.length !== 0) {
                        var transferMessageCountInstance = parseInt(transferMessageCountElement, 10);
                        countDetailsInstance.transferMessageCount = transferMessageCountInstance;
                      }
                    }
                    
                    var autoDeleteOnIdleElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (autoDeleteOnIdleElement !== null && autoDeleteOnIdleElement !== undefined) {
                      var autoDeleteOnIdleInstance = autoDeleteOnIdleElement;
                      entryInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                    }
                    
                    var entityAvailabilityStatusElement = js2xml.getElement(responseDoc, queueDescriptionElement, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (entityAvailabilityStatusElement !== null && entityAvailabilityStatusElement !== undefined) {
                      var entityAvailabilityStatusInstance = entityAvailabilityStatusElement;
                      entryInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates the queue description and makes a call to update corresponding DB
   * entries.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj856305.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusQueue} queue The service bus queue.
   * 
   * @param {string} [queue.name] The name of the queue.
   * 
   * @param {string} [queue.lockDuration] Determines the amount of time in
   * seconds in which a message should be locked for processing by a receiver.
   * After this period, the message is unlocked and available for consumption
   * by the next receiver. Settable only at queue creation time:* Range: 0 - 5
   * minutes. 0 means that the message is not locked* Default: 30 seconds
   * 
   * @param {number} [queue.maxSizeInMegabytes] Specifies the maximum queue
   * size in megabytes. Any attempt to enqueue a message that will cause the
   * queue to exceed this value will fail. You can only set this parameter at
   * queue creation time using the following values: * Range: 1 - 1024 (valid
   * values are 1024, 2048, 3072, 4096, 5120) * Default: 1*1024 (valid values
   * are 1024, 2048, 3072, 4096, 5120)
   * 
   * @param {boolean} [queue.requiresDuplicateDetection] Settable only at queue
   * creation time.* Default for durable queue: false
   * 
   * @param {boolean} [queue.requiresSession] Settable only at queue creation
   * time. If set to true, the queue will be session-aware and only
   * SessionReceiver will be supported. Session-aware queues are not supported
   * through REST.* Default for durable queue: false
   * 
   * @param {string} [queue.defaultMessageTimeToLive] Depending on whether
   * DeadLettering is enabled, a message is automatically moved to the
   * DeadLetterQueue or deleted if it has been stored in the queue for longer
   * than the specified time. This value is overwritten by a TTL specified on
   * the message if and only if the message TTL is smaller than the TTL set on
   * the queue. This value is immutable after the Queue has been created:*
   * Range: 1 second - TimeSpan.MaxValue* Default: TimeSpan.MaxValue
   * 
   * @param {boolean} [queue.deadLetteringOnMessageExpiration] This field
   * controls how the Service Bus handles a message whose TTL has expired. If
   * it is enabled and a message expires, the Service Bus moves the message
   * from the queue into the queue's dead-letter sub-queue. If disabled,
   * message will be permanently deleted from the queue. Settable only at
   * queue creation time.* Default: false
   * 
   * @param {string} [queue.duplicateDetectionHistoryTimeWindow] Specifies the
   * time span during which the Service Bus detects message duplication:*
   * Range: 1 second - 7 days* Default: 10 minutes
   * 
   * @param {number} [queue.maxDeliveryCount] The maximum number of times a
   * message SB will try to deliver before being dead lettered or discarded.
   * 
   * @param {boolean} [queue.enableBatchedOperations] Enables or disables
   * service side batching behavior when performing operations for the
   * specific queue. When enabled, service bus will collect/batch multiple
   * operations to the backend to be more connection efficient. If user wants
   * lower operation latency then they can disable this feature.
   * 
   * @param {number} [queue.sizeInBytes] Reflects the actual bytes that
   * messages in the queue currently occupy toward the queue's quota.* Range:
   * 0 -MaxTopicSizeinMegaBytes
   * 
   * @param {number} [queue.messageCount] Displays the number of messages
   * currently in the queue.
   * 
   * @param {boolean} [queue.isAnonymousAccessible] Gets whether anonymous
   * access is allowed.
   * 
   * @param {array} [queue.authorizationRules] Gets the authorization rules for
   * the description.
   * 
   * @param {string} [queue.status] Gets or sets the current status of the
   * queue (enabled or disabled). When a queue is disabled, that queue cannot
   * send or receive messages.
   * 
   * @param {date} [queue.createdAt] The time the queue was created at.
   * 
   * @param {date} [queue.updatedAt] The time the queue was last updated.
   * 
   * @param {date} [queue.accessedAt] The time the queue was last accessed.
   * 
   * @param {boolean} [queue.supportOrdering] Gets or sets whether the queue
   * supports ordering.
   * 
   * @param {CountDetails} [queue.countDetails] Current queue statistics.
   * 
   * @param {number} [queue.countDetails.activeMessageCount] The current number
   * of active messages.
   * 
   * @param {number} [queue.countDetails.deadLetterMessageCount] The current
   * number of dead letters.
   * 
   * @param {number} [queue.countDetails.scheduledMessageCount] The current
   * number of scheduled messages.
   * 
   * @param {number} [queue.countDetails.transferDeadLetterMessageCount] The
   * current number of transfer dead letters.
   * 
   * @param {number} [queue.countDetails.transferMessageCount] The current
   * number of transfer messages.
   * 
   * @param {string} [queue.autoDeleteOnIdle] Implemented.
   * 
   * @param {string} [queue.entityAvailabilityStatus] The current availability
   * status of the queue.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  QueueOperations.prototype.update = function(namespaceName, queue, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (queue === null || queue === undefined) {
      return callback(new Error('queue cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/queues/';
    if (queue.name !== null && queue.name !== undefined) {
      url2 = url2 + encodeURIComponent(queue.name);
    }
    url2 = url2 + '/';
    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/atom+xml';
    httpRequest.headers['if-match'] = '*';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    httpRequest.headers['x-process-at'] = 'ServiceBus';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/atom+xml;type=entry;charset=utf-8');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var queueDescriptionElement = js2xml.createElement('QueueDescription', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, queueDescriptionElement);
    
    if (queue.lockDuration !== null && queue.lockDuration !== undefined) {
      var lockDurationElement = js2xml.createElement('LockDuration', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(lockDurationElement, queue.lockDuration);
      js2xml.addChildElement(queueDescriptionElement, lockDurationElement);
    }
    
    if (queue.maxSizeInMegabytes !== null && queue.maxSizeInMegabytes !== undefined) {
      var maxSizeInMegabytesElement = js2xml.createElement('MaxSizeInMegabytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(maxSizeInMegabytesElement, queue.maxSizeInMegabytes.toString());
      js2xml.addChildElement(queueDescriptionElement, maxSizeInMegabytesElement);
    }
    
    if (queue.requiresDuplicateDetection !== null && queue.requiresDuplicateDetection !== undefined) {
      var requiresDuplicateDetectionElement = js2xml.createElement('RequiresDuplicateDetection', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(requiresDuplicateDetectionElement, queue.requiresDuplicateDetection.toString());
      js2xml.addChildElement(queueDescriptionElement, requiresDuplicateDetectionElement);
    }
    
    if (queue.requiresSession !== null && queue.requiresSession !== undefined) {
      var requiresSessionElement = js2xml.createElement('RequiresSession', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(requiresSessionElement, queue.requiresSession.toString());
      js2xml.addChildElement(queueDescriptionElement, requiresSessionElement);
    }
    
    if (queue.defaultMessageTimeToLive !== null && queue.defaultMessageTimeToLive !== undefined) {
      var defaultMessageTimeToLiveElement = js2xml.createElement('DefaultMessageTimeToLive', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(defaultMessageTimeToLiveElement, queue.defaultMessageTimeToLive);
      js2xml.addChildElement(queueDescriptionElement, defaultMessageTimeToLiveElement);
    }
    
    if (queue.deadLetteringOnMessageExpiration !== null && queue.deadLetteringOnMessageExpiration !== undefined) {
      var deadLetteringOnMessageExpirationElement = js2xml.createElement('DeadLetteringOnMessageExpiration', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(deadLetteringOnMessageExpirationElement, queue.deadLetteringOnMessageExpiration.toString());
      js2xml.addChildElement(queueDescriptionElement, deadLetteringOnMessageExpirationElement);
    }
    
    if (queue.duplicateDetectionHistoryTimeWindow !== null && queue.duplicateDetectionHistoryTimeWindow !== undefined) {
      var duplicateDetectionHistoryTimeWindowElement = js2xml.createElement('DuplicateDetectionHistoryTimeWindow', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(duplicateDetectionHistoryTimeWindowElement, queue.duplicateDetectionHistoryTimeWindow);
      js2xml.addChildElement(queueDescriptionElement, duplicateDetectionHistoryTimeWindowElement);
    }
    
    if (queue.enableBatchedOperations !== null && queue.enableBatchedOperations !== undefined) {
      var enableBatchedOperationsElement = js2xml.createElement('EnableBatchedOperations', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(enableBatchedOperationsElement, queue.enableBatchedOperations.toString());
      js2xml.addChildElement(queueDescriptionElement, enableBatchedOperationsElement);
    }
    
    if (queue.sizeInBytes !== null && queue.sizeInBytes !== undefined) {
      var sizeInBytesElement = js2xml.createElement('SizeInBytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(sizeInBytesElement, queue.sizeInBytes.toString());
      js2xml.addChildElement(queueDescriptionElement, sizeInBytesElement);
    }
    
    if (queue.messageCount !== null && queue.messageCount !== undefined) {
      var messageCountElement = js2xml.createElement('MessageCount', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(messageCountElement, queue.messageCount.toString());
      js2xml.addChildElement(queueDescriptionElement, messageCountElement);
    }
    
    if (queue.isAnonymousAccessible !== null && queue.isAnonymousAccessible !== undefined) {
      var isAnonymousAccessibleElement = js2xml.createElement('IsAnonymousAccessible', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(isAnonymousAccessibleElement, queue.isAnonymousAccessible.toString());
      js2xml.addChildElement(queueDescriptionElement, isAnonymousAccessibleElement);
    }
    
    if (queue.authorizationRules !== null && queue.authorizationRules !== undefined) {
      var authorizationRulesSequenceElement = js2xml.createElement('AuthorizationRules', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      for (var loweredIndex1 = 0; loweredIndex1 < queue.authorizationRules.length; loweredIndex1 = loweredIndex1 + 1) {
        var authorizationRulesItem = queue.authorizationRules[loweredIndex1];
        var authorizationRuleElement = js2xml.createElement('AuthorizationRule', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.addChildElement(authorizationRulesSequenceElement, authorizationRuleElement);
        
        var typeAttribute2 = js2xml.createAttribute('type', 'http://www.w3.org/2001/XMLSchema-instance');
        js2xml.setAttributeValue(typeAttribute2, 'SharedAccessAuthorizationRule');
        js2xml.addAttribute(authorizationRuleElement, typeAttribute2);
        
        if (authorizationRulesItem.claimType !== null && authorizationRulesItem.claimType !== undefined) {
          var claimTypeElement = js2xml.createElement('ClaimType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimTypeElement, authorizationRulesItem.claimType);
          js2xml.addChildElement(authorizationRuleElement, claimTypeElement);
        }
        
        if (authorizationRulesItem.claimValue !== null && authorizationRulesItem.claimValue !== undefined) {
          var claimValueElement = js2xml.createElement('ClaimValue', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimValueElement, authorizationRulesItem.claimValue);
          js2xml.addChildElement(authorizationRuleElement, claimValueElement);
        }
        
        if (authorizationRulesItem.rights !== null && authorizationRulesItem.rights !== undefined) {
          var rightsSequenceElement = js2xml.createElement('Rights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          for (var loweredIndex2 = 0; loweredIndex2 < authorizationRulesItem.rights.length; loweredIndex2 = loweredIndex2 + 1) {
            var rightsItem = authorizationRulesItem.rights[loweredIndex2];
            var rightsItemElement = js2xml.createElement('AccessRights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
            js2xml.setElementValue(rightsItemElement, rightsItem !== null && rightsItem !== undefined ? rightsItem.toString() : 'Listen');
            js2xml.addChildElement(rightsSequenceElement, rightsItemElement);
          }
          js2xml.addChildElement(authorizationRuleElement, rightsSequenceElement);
        }
        
        if (authorizationRulesItem.createdTime !== null && authorizationRulesItem.createdTime !== undefined) {
          var createdTimeElement = js2xml.createElement('CreatedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(createdTimeElement, authorizationRulesItem.createdTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, createdTimeElement);
        }
        
        if (authorizationRulesItem.keyName !== null && authorizationRulesItem.keyName !== undefined) {
          var keyNameElement = js2xml.createElement('KeyName', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(keyNameElement, authorizationRulesItem.keyName);
          js2xml.addChildElement(authorizationRuleElement, keyNameElement);
        }
        
        if (authorizationRulesItem.modifiedTime !== null && authorizationRulesItem.modifiedTime !== undefined) {
          var modifiedTimeElement = js2xml.createElement('ModifiedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(modifiedTimeElement, authorizationRulesItem.modifiedTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, modifiedTimeElement);
        }
        
        if (authorizationRulesItem.primaryKey !== null && authorizationRulesItem.primaryKey !== undefined) {
          var primaryKeyElement = js2xml.createElement('PrimaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(primaryKeyElement, authorizationRulesItem.primaryKey);
          js2xml.addChildElement(authorizationRuleElement, primaryKeyElement);
        }
        
        if (authorizationRulesItem.secondaryKey !== null && authorizationRulesItem.secondaryKey !== undefined) {
          var secondaryKeyElement = js2xml.createElement('SecondaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(secondaryKeyElement, authorizationRulesItem.secondaryKey);
          js2xml.addChildElement(authorizationRuleElement, secondaryKeyElement);
        }
      }
      js2xml.addChildElement(queueDescriptionElement, authorizationRulesSequenceElement);
    }
    
    if (queue.status !== null && queue.status !== undefined) {
      var statusElement = js2xml.createElement('Status', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(statusElement, queue.status);
      js2xml.addChildElement(queueDescriptionElement, statusElement);
    }
    
    if (queue.supportOrdering !== null && queue.supportOrdering !== undefined) {
      var supportOrderingElement = js2xml.createElement('SupportOrdering', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(supportOrderingElement, queue.supportOrdering.toString());
      js2xml.addChildElement(queueDescriptionElement, supportOrderingElement);
    }
    
    if (queue.countDetails !== null && queue.countDetails !== undefined) {
      var countDetailsElement = js2xml.createElement('CountDetails', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.addChildElement(queueDescriptionElement, countDetailsElement);
      
      if (queue.countDetails.activeMessageCount !== null && queue.countDetails.activeMessageCount !== undefined) {
        var activeMessageCountElement = js2xml.createElement('ActiveMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(activeMessageCountElement, queue.countDetails.activeMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, activeMessageCountElement);
      }
      
      if (queue.countDetails.deadLetterMessageCount !== null && queue.countDetails.deadLetterMessageCount !== undefined) {
        var deadLetterMessageCountElement = js2xml.createElement('DeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(deadLetterMessageCountElement, queue.countDetails.deadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, deadLetterMessageCountElement);
      }
      
      if (queue.countDetails.scheduledMessageCount !== null && queue.countDetails.scheduledMessageCount !== undefined) {
        var scheduledMessageCountElement = js2xml.createElement('ScheduledMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(scheduledMessageCountElement, queue.countDetails.scheduledMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, scheduledMessageCountElement);
      }
      
      if (queue.countDetails.transferDeadLetterMessageCount !== null && queue.countDetails.transferDeadLetterMessageCount !== undefined) {
        var transferDeadLetterMessageCountElement = js2xml.createElement('TransferDeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferDeadLetterMessageCountElement, queue.countDetails.transferDeadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferDeadLetterMessageCountElement);
      }
      
      if (queue.countDetails.transferMessageCount !== null && queue.countDetails.transferMessageCount !== undefined) {
        var transferMessageCountElement = js2xml.createElement('TransferMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferMessageCountElement, queue.countDetails.transferMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferMessageCountElement);
      }
    }
    
    if (queue.autoDeleteOnIdle !== null && queue.autoDeleteOnIdle !== undefined) {
      var autoDeleteOnIdleElement = js2xml.createElement('AutoDeleteOnIdle', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(autoDeleteOnIdleElement, queue.autoDeleteOnIdle);
      js2xml.addChildElement(queueDescriptionElement, autoDeleteOnIdleElement);
    }
    
    if (queue.entityAvailabilityStatus !== null && queue.entityAvailabilityStatus !== undefined) {
      var entityAvailabilityStatusElement = js2xml.createElement('EntityAvailabilityStatus', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(entityAvailabilityStatusElement, queue.entityAvailabilityStatus);
      js2xml.addChildElement(queueDescriptionElement, entityAvailabilityStatusElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement2, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var queueDescriptionElement2 = js2xml.getElement(responseDoc, contentElement2, 'QUEUEDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (queueDescriptionElement2 !== null && queueDescriptionElement2 !== undefined) {
                var queueDescriptionInstance = { authorizationRules: [] };
                result.queue = queueDescriptionInstance;
                
                var lockDurationElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'LOCKDURATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (lockDurationElement2 !== null && lockDurationElement2 !== undefined) {
                  var lockDurationInstance = lockDurationElement2;
                  queueDescriptionInstance.lockDuration = lockDurationInstance;
                }
                
                var maxSizeInMegabytesElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxSizeInMegabytesElement2 !== null && maxSizeInMegabytesElement2 !== undefined && maxSizeInMegabytesElement2.length !== 0) {
                  var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement2, 10);
                  queueDescriptionInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                }
                
                var requiresDuplicateDetectionElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresDuplicateDetectionElement2 !== null && requiresDuplicateDetectionElement2 !== undefined && requiresDuplicateDetectionElement2.length !== 0) {
                  var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement2 === 'true';
                  queueDescriptionInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                }
                
                var requiresSessionElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'REQUIRESSESSION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresSessionElement2 !== null && requiresSessionElement2 !== undefined && requiresSessionElement2.length !== 0) {
                  var requiresSessionInstance = requiresSessionElement2 === 'true';
                  queueDescriptionInstance.requiresSession = requiresSessionInstance;
                }
                
                var defaultMessageTimeToLiveElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (defaultMessageTimeToLiveElement2 !== null && defaultMessageTimeToLiveElement2 !== undefined) {
                  var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement2;
                  queueDescriptionInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                }
                
                var deadLetteringOnMessageExpirationElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'DEADLETTERINGONMESSAGEEXPIRATION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (deadLetteringOnMessageExpirationElement2 !== null && deadLetteringOnMessageExpirationElement2 !== undefined && deadLetteringOnMessageExpirationElement2.length !== 0) {
                  var deadLetteringOnMessageExpirationInstance = deadLetteringOnMessageExpirationElement2 === 'true';
                  queueDescriptionInstance.deadLetteringOnMessageExpiration = deadLetteringOnMessageExpirationInstance;
                }
                
                var duplicateDetectionHistoryTimeWindowElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (duplicateDetectionHistoryTimeWindowElement2 !== null && duplicateDetectionHistoryTimeWindowElement2 !== undefined) {
                  var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement2;
                  queueDescriptionInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                }
                
                var maxDeliveryCountElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'MAXDELIVERYCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxDeliveryCountElement !== null && maxDeliveryCountElement !== undefined && maxDeliveryCountElement.length !== 0) {
                  var maxDeliveryCountInstance = parseInt(maxDeliveryCountElement, 10);
                  queueDescriptionInstance.maxDeliveryCount = maxDeliveryCountInstance;
                }
                
                var enableBatchedOperationsElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enableBatchedOperationsElement2 !== null && enableBatchedOperationsElement2 !== undefined && enableBatchedOperationsElement2.length !== 0) {
                  var enableBatchedOperationsInstance = enableBatchedOperationsElement2 === 'true';
                  queueDescriptionInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                }
                
                var sizeInBytesElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (sizeInBytesElement2 !== null && sizeInBytesElement2 !== undefined && sizeInBytesElement2.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement2, 10);
                  queueDescriptionInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var messageCountElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'MESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (messageCountElement2 !== null && messageCountElement2 !== undefined && messageCountElement2.length !== 0) {
                  var messageCountInstance = parseInt(messageCountElement2, 10);
                  queueDescriptionInstance.messageCount = messageCountInstance;
                }
                
                var isAnonymousAccessibleElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (isAnonymousAccessibleElement2 !== null && isAnonymousAccessibleElement2 !== undefined && isAnonymousAccessibleElement2.length !== 0) {
                  var isAnonymousAccessibleInstance = isAnonymousAccessibleElement2 === 'true';
                  queueDescriptionInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                }
                
                var authorizationRulesSequenceElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement2 !== null && authorizationRulesSequenceElement2 !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                    var authorizationRuleInstance = { rights: [] };
                    queueDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement2 !== null && claimTypeElement2 !== undefined) {
                      var claimTypeInstance = claimTypeElement2;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement2 !== null && claimValueElement2 !== undefined) {
                      var claimValueInstance = claimValueElement2;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement2 !== null && rightsSequenceElement2 !== undefined) {
                      for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex4 = loweredIndex4 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex4];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement2 !== null && createdTimeElement2 !== undefined && createdTimeElement2.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement2);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement2 !== null && keyNameElement2 !== undefined) {
                      var keyNameInstance = keyNameElement2;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement2 !== null && modifiedTimeElement2 !== undefined && modifiedTimeElement2.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement2);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement2 !== null && primaryKeyElement2 !== undefined) {
                      var primaryKeyInstance = primaryKeyElement2;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement2 !== null && secondaryKeyElement2 !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement2;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
                
                var statusElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement2 !== null && statusElement2 !== undefined) {
                  var statusInstance = statusElement2;
                  queueDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  queueDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var updatedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (updatedAtElement !== null && updatedAtElement !== undefined && updatedAtElement.length !== 0) {
                  var updatedAtInstance = new Date(updatedAtElement);
                  queueDescriptionInstance.updatedAt = updatedAtInstance;
                }
                
                var accessedAtElement = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (accessedAtElement !== null && accessedAtElement !== undefined && accessedAtElement.length !== 0) {
                  var accessedAtInstance = new Date(accessedAtElement);
                  queueDescriptionInstance.accessedAt = accessedAtInstance;
                }
                
                var supportOrderingElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (supportOrderingElement2 !== null && supportOrderingElement2 !== undefined && supportOrderingElement2.length !== 0) {
                  var supportOrderingInstance = supportOrderingElement2 === 'true';
                  queueDescriptionInstance.supportOrdering = supportOrderingInstance;
                }
                
                var countDetailsElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (countDetailsElement2 !== null && countDetailsElement2 !== undefined) {
                  var countDetailsInstance = {};
                  queueDescriptionInstance.countDetails = countDetailsInstance;
                  
                  var activeMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'ACTIVEMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (activeMessageCountElement2 !== null && activeMessageCountElement2 !== undefined && activeMessageCountElement2.length !== 0) {
                    var activeMessageCountInstance = parseInt(activeMessageCountElement2, 10);
                    countDetailsInstance.activeMessageCount = activeMessageCountInstance;
                  }
                  
                  var deadLetterMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'DEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (deadLetterMessageCountElement2 !== null && deadLetterMessageCountElement2 !== undefined && deadLetterMessageCountElement2.length !== 0) {
                    var deadLetterMessageCountInstance = parseInt(deadLetterMessageCountElement2, 10);
                    countDetailsInstance.deadLetterMessageCount = deadLetterMessageCountInstance;
                  }
                  
                  var scheduledMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'SCHEDULEDMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (scheduledMessageCountElement2 !== null && scheduledMessageCountElement2 !== undefined && scheduledMessageCountElement2.length !== 0) {
                    var scheduledMessageCountInstance = parseInt(scheduledMessageCountElement2, 10);
                    countDetailsInstance.scheduledMessageCount = scheduledMessageCountInstance;
                  }
                  
                  var transferDeadLetterMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'TRANSFERDEADLETTERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (transferDeadLetterMessageCountElement2 !== null && transferDeadLetterMessageCountElement2 !== undefined && transferDeadLetterMessageCountElement2.length !== 0) {
                    var transferDeadLetterMessageCountInstance = parseInt(transferDeadLetterMessageCountElement2, 10);
                    countDetailsInstance.transferDeadLetterMessageCount = transferDeadLetterMessageCountInstance;
                  }
                  
                  var transferMessageCountElement2 = js2xml.getElement(responseDoc, countDetailsElement2, 'TRANSFERMESSAGECOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2011/06/SERVICEBUS');
                  if (transferMessageCountElement2 !== null && transferMessageCountElement2 !== undefined && transferMessageCountElement2.length !== 0) {
                    var transferMessageCountInstance = parseInt(transferMessageCountElement2, 10);
                    countDetailsInstance.transferMessageCount = transferMessageCountInstance;
                  }
                }
                
                var autoDeleteOnIdleElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (autoDeleteOnIdleElement2 !== null && autoDeleteOnIdleElement2 !== undefined) {
                  var autoDeleteOnIdleInstance = autoDeleteOnIdleElement2;
                  queueDescriptionInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                }
                
                var entityAvailabilityStatusElement2 = js2xml.getElement(responseDoc, queueDescriptionElement2, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (entityAvailabilityStatusElement2 !== null && entityAvailabilityStatusElement2 !== undefined) {
                  var entityAvailabilityStatusInstance = entityAvailabilityStatusElement2;
                  queueDescriptionInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return QueueOperations;
})();

var RelayOperations = ( /** @lends RelayOperations */ function() {
  /**
   * @class
   * The Service Bus Management API includes operations for managing Service
   * Bus relays.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ServiceBusManagementClient] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient}.
   * See [relays] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient#relays}.
   * Initializes a new instance of the RelayOperations class.
   * @constructor
   * 
   * @param {ServiceBusManagementClient} client Reference to the service client.
   */
  function RelayOperations(client) {
    this.client = client;
  }
  
  /**
   * Gets the set of connection strings for a relay.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} relayName The relay name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RelayOperations.prototype.getConnectionDetails = function(namespaceName, relayName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (relayName === null || relayName === undefined) {
      return callback(new Error('relayName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/Relays/';
    url2 = url2 + encodeURIComponent(relayName);
    url2 = url2 + '/ConnectionDetails';
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { connectionDetails: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { rights: [] };
                result.connectionDetails.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var connectionDetailElement = js2xml.getElement(responseDoc, contentElement, 'CONNECTIONDETAIL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (connectionDetailElement !== null && connectionDetailElement !== undefined) {
                    var keyNameElement = js2xml.getElement(responseDoc, connectionDetailElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      entryInstance.keyName = keyNameInstance;
                    }
                    
                    var connectionStringElement = js2xml.getElement(responseDoc, connectionDetailElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (connectionStringElement !== null && connectionStringElement !== undefined) {
                      var connectionStringInstance = connectionStringElement;
                      entryInstance.connectionString = connectionStringInstance;
                    }
                    
                    var authorizationTypeElement = js2xml.getElement(responseDoc, connectionDetailElement, 'AUTHORIZATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationTypeElement !== null && authorizationTypeElement !== undefined) {
                      var authorizationTypeInstance = authorizationTypeElement;
                      entryInstance.authorizationType = authorizationTypeInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, connectionDetailElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        entryInstance.rights.push(rightsElement);
                      }
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return RelayOperations;
})();

var TopicOperations = ( /** @lends TopicOperations */ function() {
  /**
   * @class
   * The Service Bus Management API includes operations for managing Service
   * Bus topics for a namespace.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [ServiceBusManagementClient] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient}.
   * See [topics] {@link
   * ServiceBusManagementClient~ServiceBusManagementClient#topics}.
   * Initializes a new instance of the TopicOperations class.
   * @constructor
   * 
   * @param {ServiceBusManagementClient} client Reference to the service client.
   */
  function TopicOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a new topic. Once created, this topic resource manifest is
   * immutable. This operation is not idempotent. Repeating the create call,
   * after a topic with same name has been created successfully, will result
   * in a 409 Conflict error message.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh780728.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusTopic} topic The Service Bus topic.
   * 
   * @param {string} [topic.name] The name of the topic.
   * 
   * @param {string} [topic.defaultMessageTimeToLive] Determines how long a
   * message lives in the associated subscriptions. Subscriptions inherit the
   * TTL from the topic unless they are created explicitly with a smaller TTL.
   * Based on whether dead-lettering is enabled, a message whose TTL has
   * expired will either be moved to the subscription's associated
   * DeadLtterQueue or will be permanently deleted. The following values are
   * settable at topic creation time:* Range: 1 second - TimeSpan.MaxValue*
   * Default: TimeSpan.MaxValue
   * 
   * @param {number} [topic.maxSizeInMegabytes] Specifies the maximum topic
   * size in megabytes. Any attempt to enqueue a message that will cause the
   * topic to exceed this value will fail. All messages that are stored in the
   * topic or any of its subscriptions count towards this value. Multiple
   * copies of a message that reside in one or multiple subscriptions count as
   * a single messages. For example, if message m exists once in subscription
   * s1 and twice in subscription s2, m is counted as a single message. You
   * can only set this parameter at topic creation time using the following
   * values:* Range: 1 - 5*1024 MB* Default: 1*1024
   * 
   * @param {boolean} [topic.requiresDuplicateDetection] If enabled, the topic
   * will detect duplicate messages within the time span specified by the
   * DuplicateDetectionHistoryTimeWindow property. Settable only at topic
   * creation time.* Default: false
   * 
   * @param {string} [topic.duplicateDetectionHistoryTimeWindow] Specifies the
   * time span during which the Service Bus will detect message duplication.*
   * Range: 1 second - 7 days* Default: 10 minutes
   * 
   * @param {boolean} [topic.enableBatchedOperations] Enables or disables
   * service side batching behavior when performing operations for the
   * specific queue. When enabled, service bus will collect/batch multiple
   * operations to the backend to be more connection efficient. If user wants
   * lower operation latency then they can disable this feature.
   * 
   * @param {number} [topic.sizeInBytes] Reflects the actual bytes toward the
   * topic quota that messages in the topic currently occupy. (read-only)*
   * Range: 0 -MaxTopicSizeinMegaBytes
   * 
   * @param {boolean} [topic.filteringMessagesBeforePublishing] Gets or sets
   * whether messages should be filtered before publishing.
   * 
   * @param {boolean} [topic.isAnonymousAccessible] Gets whether anonymous
   * access is allowed.
   * 
   * @param {array} [topic.authorizationRules] Gets the authorization rules for
   * the description.
   * 
   * @param {string} [topic.status] Gets or sets the current status of the
   * topic (enabled or disabled). When a topic is disabled, that topic cannot
   * send or receive messages.
   * 
   * @param {date} [topic.createdAt] The time the queue was created at.
   * 
   * @param {date} [topic.updatedAt] The time the queue was last updated.
   * 
   * @param {date} [topic.accessedAt] The time the queue was last accessed.
   * 
   * @param {boolean} [topic.supportOrdering] Gets or sets whether the topics
   * can be ordered.
   * 
   * @param {CountDetails} [topic.countDetails] Current queue statistics.
   * 
   * @param {number} [topic.countDetails.activeMessageCount] The current number
   * of active messages.
   * 
   * @param {number} [topic.countDetails.deadLetterMessageCount] The current
   * number of dead letters.
   * 
   * @param {number} [topic.countDetails.scheduledMessageCount] The current
   * number of scheduled messages.
   * 
   * @param {number} [topic.countDetails.transferDeadLetterMessageCount] The
   * current number of transfer dead letters.
   * 
   * @param {number} [topic.countDetails.transferMessageCount] The current
   * number of transfer messages.
   * 
   * @param {number} [topic.subscriptionCount] The current number of
   * subscriptions to the topic.
   * 
   * @param {string} [topic.autoDeleteOnIdle] Implemented.
   * 
   * @param {string} [topic.entityAvailabilityStatus] The current availability
   * status of the topic.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  TopicOperations.prototype.create = function(namespaceName, topic, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (topic === null || topic === undefined) {
      return callback(new Error('topic cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/topics/';
    if (topic.name !== null && topic.name !== undefined) {
      url2 = url2 + encodeURIComponent(topic.name);
    }
    url2 = url2 + '/';
    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/atom+xml';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    httpRequest.headers['x-process-at'] = 'ServiceBus';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/atom+xml;type=entry;charset=utf-8');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var topicDescriptionElement = js2xml.createElement('TopicDescription', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, topicDescriptionElement);
    
    if (topic.defaultMessageTimeToLive !== null && topic.defaultMessageTimeToLive !== undefined) {
      var defaultMessageTimeToLiveElement = js2xml.createElement('DefaultMessageTimeToLive', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(defaultMessageTimeToLiveElement, topic.defaultMessageTimeToLive);
      js2xml.addChildElement(topicDescriptionElement, defaultMessageTimeToLiveElement);
    }
    
    if (topic.maxSizeInMegabytes !== null && topic.maxSizeInMegabytes !== undefined) {
      var maxSizeInMegabytesElement = js2xml.createElement('MaxSizeInMegabytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(maxSizeInMegabytesElement, topic.maxSizeInMegabytes.toString());
      js2xml.addChildElement(topicDescriptionElement, maxSizeInMegabytesElement);
    }
    
    if (topic.requiresDuplicateDetection !== null && topic.requiresDuplicateDetection !== undefined) {
      var requiresDuplicateDetectionElement = js2xml.createElement('RequiresDuplicateDetection', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(requiresDuplicateDetectionElement, topic.requiresDuplicateDetection.toString());
      js2xml.addChildElement(topicDescriptionElement, requiresDuplicateDetectionElement);
    }
    
    if (topic.duplicateDetectionHistoryTimeWindow !== null && topic.duplicateDetectionHistoryTimeWindow !== undefined) {
      var duplicateDetectionHistoryTimeWindowElement = js2xml.createElement('DuplicateDetectionHistoryTimeWindow', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(duplicateDetectionHistoryTimeWindowElement, topic.duplicateDetectionHistoryTimeWindow);
      js2xml.addChildElement(topicDescriptionElement, duplicateDetectionHistoryTimeWindowElement);
    }
    
    if (topic.enableBatchedOperations !== null && topic.enableBatchedOperations !== undefined) {
      var enableBatchedOperationsElement = js2xml.createElement('EnableBatchedOperations', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(enableBatchedOperationsElement, topic.enableBatchedOperations.toString());
      js2xml.addChildElement(topicDescriptionElement, enableBatchedOperationsElement);
    }
    
    if (topic.sizeInBytes !== null && topic.sizeInBytes !== undefined) {
      var sizeInBytesElement = js2xml.createElement('SizeInBytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(sizeInBytesElement, topic.sizeInBytes.toString());
      js2xml.addChildElement(topicDescriptionElement, sizeInBytesElement);
    }
    
    if (topic.filteringMessagesBeforePublishing !== null && topic.filteringMessagesBeforePublishing !== undefined) {
      var filteringMessagesBeforePublishingElement = js2xml.createElement('FilteringMessagesBeforePublishing', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(filteringMessagesBeforePublishingElement, topic.filteringMessagesBeforePublishing.toString());
      js2xml.addChildElement(topicDescriptionElement, filteringMessagesBeforePublishingElement);
    }
    
    if (topic.isAnonymousAccessible !== null && topic.isAnonymousAccessible !== undefined) {
      var isAnonymousAccessibleElement = js2xml.createElement('IsAnonymousAccessible', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(isAnonymousAccessibleElement, topic.isAnonymousAccessible.toString());
      js2xml.addChildElement(topicDescriptionElement, isAnonymousAccessibleElement);
    }
    
    if (topic.authorizationRules !== null && topic.authorizationRules !== undefined) {
      var authorizationRulesSequenceElement = js2xml.createElement('AuthorizationRules', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      for (var loweredIndex1 = 0; loweredIndex1 < topic.authorizationRules.length; loweredIndex1 = loweredIndex1 + 1) {
        var authorizationRulesItem = topic.authorizationRules[loweredIndex1];
        var authorizationRuleElement = js2xml.createElement('AuthorizationRule', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.addChildElement(authorizationRulesSequenceElement, authorizationRuleElement);
        
        var typeAttribute2 = js2xml.createAttribute('type', 'http://www.w3.org/2001/XMLSchema-instance');
        js2xml.setAttributeValue(typeAttribute2, 'SharedAccessAuthorizationRule');
        js2xml.addAttribute(authorizationRuleElement, typeAttribute2);
        
        if (authorizationRulesItem.claimType !== null && authorizationRulesItem.claimType !== undefined) {
          var claimTypeElement = js2xml.createElement('ClaimType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimTypeElement, authorizationRulesItem.claimType);
          js2xml.addChildElement(authorizationRuleElement, claimTypeElement);
        }
        
        if (authorizationRulesItem.claimValue !== null && authorizationRulesItem.claimValue !== undefined) {
          var claimValueElement = js2xml.createElement('ClaimValue', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimValueElement, authorizationRulesItem.claimValue);
          js2xml.addChildElement(authorizationRuleElement, claimValueElement);
        }
        
        if (authorizationRulesItem.rights !== null && authorizationRulesItem.rights !== undefined) {
          var rightsSequenceElement = js2xml.createElement('Rights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          for (var loweredIndex2 = 0; loweredIndex2 < authorizationRulesItem.rights.length; loweredIndex2 = loweredIndex2 + 1) {
            var rightsItem = authorizationRulesItem.rights[loweredIndex2];
            var rightsItemElement = js2xml.createElement('AccessRights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
            js2xml.setElementValue(rightsItemElement, rightsItem !== null && rightsItem !== undefined ? rightsItem.toString() : 'Listen');
            js2xml.addChildElement(rightsSequenceElement, rightsItemElement);
          }
          js2xml.addChildElement(authorizationRuleElement, rightsSequenceElement);
        }
        
        if (authorizationRulesItem.createdTime !== null && authorizationRulesItem.createdTime !== undefined) {
          var createdTimeElement = js2xml.createElement('CreatedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(createdTimeElement, authorizationRulesItem.createdTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, createdTimeElement);
        }
        
        if (authorizationRulesItem.keyName !== null && authorizationRulesItem.keyName !== undefined) {
          var keyNameElement = js2xml.createElement('KeyName', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(keyNameElement, authorizationRulesItem.keyName);
          js2xml.addChildElement(authorizationRuleElement, keyNameElement);
        }
        
        if (authorizationRulesItem.modifiedTime !== null && authorizationRulesItem.modifiedTime !== undefined) {
          var modifiedTimeElement = js2xml.createElement('ModifiedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(modifiedTimeElement, authorizationRulesItem.modifiedTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, modifiedTimeElement);
        }
        
        if (authorizationRulesItem.primaryKey !== null && authorizationRulesItem.primaryKey !== undefined) {
          var primaryKeyElement = js2xml.createElement('PrimaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(primaryKeyElement, authorizationRulesItem.primaryKey);
          js2xml.addChildElement(authorizationRuleElement, primaryKeyElement);
        }
        
        if (authorizationRulesItem.secondaryKey !== null && authorizationRulesItem.secondaryKey !== undefined) {
          var secondaryKeyElement = js2xml.createElement('SecondaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(secondaryKeyElement, authorizationRulesItem.secondaryKey);
          js2xml.addChildElement(authorizationRuleElement, secondaryKeyElement);
        }
      }
      js2xml.addChildElement(topicDescriptionElement, authorizationRulesSequenceElement);
    }
    
    if (topic.status !== null && topic.status !== undefined) {
      var statusElement = js2xml.createElement('Status', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(statusElement, topic.status);
      js2xml.addChildElement(topicDescriptionElement, statusElement);
    }
    
    if (topic.createdAt !== null && topic.createdAt !== undefined) {
      var createdAtElement = js2xml.createElement('CreatedAt', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(createdAtElement, topic.createdAt.toISOString());
      js2xml.addChildElement(topicDescriptionElement, createdAtElement);
    }
    
    if (topic.updatedAt !== null && topic.updatedAt !== undefined) {
      var updatedAtElement = js2xml.createElement('UpdatedAt', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(updatedAtElement, topic.updatedAt.toISOString());
      js2xml.addChildElement(topicDescriptionElement, updatedAtElement);
    }
    
    if (topic.accessedAt !== null && topic.accessedAt !== undefined) {
      var accessedAtElement = js2xml.createElement('AccessedAt', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(accessedAtElement, topic.accessedAt.toISOString());
      js2xml.addChildElement(topicDescriptionElement, accessedAtElement);
    }
    
    if (topic.supportOrdering !== null && topic.supportOrdering !== undefined) {
      var supportOrderingElement = js2xml.createElement('SupportOrdering', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(supportOrderingElement, topic.supportOrdering.toString());
      js2xml.addChildElement(topicDescriptionElement, supportOrderingElement);
    }
    
    if (topic.countDetails !== null && topic.countDetails !== undefined) {
      var countDetailsElement = js2xml.createElement('CountDetails', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.addChildElement(topicDescriptionElement, countDetailsElement);
      
      if (topic.countDetails.activeMessageCount !== null && topic.countDetails.activeMessageCount !== undefined) {
        var activeMessageCountElement = js2xml.createElement('ActiveMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(activeMessageCountElement, topic.countDetails.activeMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, activeMessageCountElement);
      }
      
      if (topic.countDetails.deadLetterMessageCount !== null && topic.countDetails.deadLetterMessageCount !== undefined) {
        var deadLetterMessageCountElement = js2xml.createElement('DeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(deadLetterMessageCountElement, topic.countDetails.deadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, deadLetterMessageCountElement);
      }
      
      if (topic.countDetails.scheduledMessageCount !== null && topic.countDetails.scheduledMessageCount !== undefined) {
        var scheduledMessageCountElement = js2xml.createElement('ScheduledMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(scheduledMessageCountElement, topic.countDetails.scheduledMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, scheduledMessageCountElement);
      }
      
      if (topic.countDetails.transferDeadLetterMessageCount !== null && topic.countDetails.transferDeadLetterMessageCount !== undefined) {
        var transferDeadLetterMessageCountElement = js2xml.createElement('TransferDeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferDeadLetterMessageCountElement, topic.countDetails.transferDeadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferDeadLetterMessageCountElement);
      }
      
      if (topic.countDetails.transferMessageCount !== null && topic.countDetails.transferMessageCount !== undefined) {
        var transferMessageCountElement = js2xml.createElement('TransferMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferMessageCountElement, topic.countDetails.transferMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferMessageCountElement);
      }
    }
    
    if (topic.subscriptionCount !== null && topic.subscriptionCount !== undefined) {
      var subscriptionCountElement = js2xml.createElement('SubscriptionCount', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(subscriptionCountElement, topic.subscriptionCount.toString());
      js2xml.addChildElement(topicDescriptionElement, subscriptionCountElement);
    }
    
    if (topic.autoDeleteOnIdle !== null && topic.autoDeleteOnIdle !== undefined) {
      var autoDeleteOnIdleElement = js2xml.createElement('AutoDeleteOnIdle', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(autoDeleteOnIdleElement, topic.autoDeleteOnIdle);
      js2xml.addChildElement(topicDescriptionElement, autoDeleteOnIdleElement);
    }
    
    if (topic.entityAvailabilityStatus !== null && topic.entityAvailabilityStatus !== undefined) {
      var entityAvailabilityStatusElement = js2xml.createElement('EntityAvailabilityStatus', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(entityAvailabilityStatusElement, topic.entityAvailabilityStatus);
      js2xml.addChildElement(topicDescriptionElement, entityAvailabilityStatusElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 201) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 201) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement2, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var topicDescriptionElement2 = js2xml.getElement(responseDoc, contentElement2, 'TOPICDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (topicDescriptionElement2 !== null && topicDescriptionElement2 !== undefined) {
                var topicDescriptionInstance = { authorizationRules: [] };
                result.topic = topicDescriptionInstance;
                
                var defaultMessageTimeToLiveElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (defaultMessageTimeToLiveElement2 !== null && defaultMessageTimeToLiveElement2 !== undefined) {
                  var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement2;
                  topicDescriptionInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                }
                
                var maxSizeInMegabytesElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxSizeInMegabytesElement2 !== null && maxSizeInMegabytesElement2 !== undefined && maxSizeInMegabytesElement2.length !== 0) {
                  var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement2, 10);
                  topicDescriptionInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                }
                
                var requiresDuplicateDetectionElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresDuplicateDetectionElement2 !== null && requiresDuplicateDetectionElement2 !== undefined && requiresDuplicateDetectionElement2.length !== 0) {
                  var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement2 === 'true';
                  topicDescriptionInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                }
                
                var duplicateDetectionHistoryTimeWindowElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (duplicateDetectionHistoryTimeWindowElement2 !== null && duplicateDetectionHistoryTimeWindowElement2 !== undefined) {
                  var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement2;
                  topicDescriptionInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                }
                
                var enableBatchedOperationsElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enableBatchedOperationsElement2 !== null && enableBatchedOperationsElement2 !== undefined && enableBatchedOperationsElement2.length !== 0) {
                  var enableBatchedOperationsInstance = enableBatchedOperationsElement2 === 'true';
                  topicDescriptionInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                }
                
                var sizeInBytesElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (sizeInBytesElement2 !== null && sizeInBytesElement2 !== undefined && sizeInBytesElement2.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement2, 10);
                  topicDescriptionInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var filteringMessagesBeforePublishingElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'FILTERINGMESSAGESBEFOREPUBLISHING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (filteringMessagesBeforePublishingElement2 !== null && filteringMessagesBeforePublishingElement2 !== undefined && filteringMessagesBeforePublishingElement2.length !== 0) {
                  var filteringMessagesBeforePublishingInstance = filteringMessagesBeforePublishingElement2 === 'true';
                  topicDescriptionInstance.filteringMessagesBeforePublishing = filteringMessagesBeforePublishingInstance;
                }
                
                var isAnonymousAccessibleElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (isAnonymousAccessibleElement2 !== null && isAnonymousAccessibleElement2 !== undefined && isAnonymousAccessibleElement2.length !== 0) {
                  var isAnonymousAccessibleInstance = isAnonymousAccessibleElement2 === 'true';
                  topicDescriptionInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                }
                
                var authorizationRulesSequenceElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement2 !== null && authorizationRulesSequenceElement2 !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                    var authorizationRuleInstance = { rights: [] };
                    topicDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement2 !== null && claimTypeElement2 !== undefined) {
                      var claimTypeInstance = claimTypeElement2;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement2 !== null && claimValueElement2 !== undefined) {
                      var claimValueInstance = claimValueElement2;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement2 !== null && rightsSequenceElement2 !== undefined) {
                      for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex4 = loweredIndex4 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex4];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement2 !== null && createdTimeElement2 !== undefined && createdTimeElement2.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement2);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement2 !== null && keyNameElement2 !== undefined) {
                      var keyNameInstance = keyNameElement2;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement2 !== null && modifiedTimeElement2 !== undefined && modifiedTimeElement2.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement2);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement2 !== null && primaryKeyElement2 !== undefined) {
                      var primaryKeyInstance = primaryKeyElement2;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement2 !== null && secondaryKeyElement2 !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement2;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
                
                var statusElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement2 !== null && statusElement2 !== undefined) {
                  var statusInstance = statusElement2;
                  topicDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement2 !== null && createdAtElement2 !== undefined && createdAtElement2.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement2);
                  topicDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var updatedAtElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (updatedAtElement2 !== null && updatedAtElement2 !== undefined && updatedAtElement2.length !== 0) {
                  var updatedAtInstance = new Date(updatedAtElement2);
                  topicDescriptionInstance.updatedAt = updatedAtInstance;
                }
                
                var accessedAtElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (accessedAtElement2 !== null && accessedAtElement2 !== undefined && accessedAtElement2.length !== 0) {
                  var accessedAtInstance = new Date(accessedAtElement2);
                  topicDescriptionInstance.accessedAt = accessedAtInstance;
                }
                
                var supportOrderingElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (supportOrderingElement2 !== null && supportOrderingElement2 !== undefined && supportOrderingElement2.length !== 0) {
                  var supportOrderingInstance = supportOrderingElement2 === 'true';
                  topicDescriptionInstance.supportOrdering = supportOrderingInstance;
                }
                
                var countDetailsElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (countDetailsElement2 !== null && countDetailsElement2 !== undefined) {
                  var countDetailsInstance = {};
                  topicDescriptionInstance.countDetails = countDetailsInstance;
                }
                
                var subscriptionCountElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'SUBSCRIPTIONCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (subscriptionCountElement2 !== null && subscriptionCountElement2 !== undefined && subscriptionCountElement2.length !== 0) {
                  var subscriptionCountInstance = parseInt(subscriptionCountElement2, 10);
                  topicDescriptionInstance.subscriptionCount = subscriptionCountInstance;
                }
                
                var autoDeleteOnIdleElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (autoDeleteOnIdleElement2 !== null && autoDeleteOnIdleElement2 !== undefined) {
                  var autoDeleteOnIdleInstance = autoDeleteOnIdleElement2;
                  topicDescriptionInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                }
                
                var entityAvailabilityStatusElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (entityAvailabilityStatusElement2 !== null && entityAvailabilityStatusElement2 !== undefined) {
                  var entityAvailabilityStatusInstance = entityAvailabilityStatusElement2;
                  topicDescriptionInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Deletes an existing topic. This operation will also remove all associated
   * state including associated subscriptions.  (see
   * http://msdn.microsoft.com/en-us/library/hh780721.aspx for more
   * information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} topicName The topic.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  TopicOperations.prototype.deleteMethod = function(namespaceName, topicName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (topicName === null || topicName === undefined) {
      return callback(new Error('topicName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/topics/';
    url2 = url2 + encodeURIComponent(topicName);
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * The topic description is an XML AtomPub document that defines the desired
   * semantics for a topic. The topic description contains the following
   * properties. For more information, see the TopicDescription Properties
   * topic.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh780749.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} topicName The topic.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  TopicOperations.prototype.get = function(namespaceName, topicName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (topicName === null || topicName === undefined) {
      return callback(new Error('topicName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/topics/';
    url2 = url2 + encodeURIComponent(topicName);
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement !== null && entryElement !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement = js2xml.getElement(responseDoc, entryElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement !== null && contentElement !== undefined) {
              var topicDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'TOPICDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (topicDescriptionElement !== null && topicDescriptionElement !== undefined) {
                var topicDescriptionInstance = { authorizationRules: [] };
                result.topic = topicDescriptionInstance;
                
                var defaultMessageTimeToLiveElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (defaultMessageTimeToLiveElement !== null && defaultMessageTimeToLiveElement !== undefined) {
                  var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement;
                  topicDescriptionInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                }
                
                var maxSizeInMegabytesElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxSizeInMegabytesElement !== null && maxSizeInMegabytesElement !== undefined && maxSizeInMegabytesElement.length !== 0) {
                  var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement, 10);
                  topicDescriptionInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                }
                
                var requiresDuplicateDetectionElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresDuplicateDetectionElement !== null && requiresDuplicateDetectionElement !== undefined && requiresDuplicateDetectionElement.length !== 0) {
                  var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement === 'true';
                  topicDescriptionInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                }
                
                var duplicateDetectionHistoryTimeWindowElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (duplicateDetectionHistoryTimeWindowElement !== null && duplicateDetectionHistoryTimeWindowElement !== undefined) {
                  var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement;
                  topicDescriptionInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                }
                
                var enableBatchedOperationsElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enableBatchedOperationsElement !== null && enableBatchedOperationsElement !== undefined && enableBatchedOperationsElement.length !== 0) {
                  var enableBatchedOperationsInstance = enableBatchedOperationsElement === 'true';
                  topicDescriptionInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                }
                
                var sizeInBytesElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (sizeInBytesElement !== null && sizeInBytesElement !== undefined && sizeInBytesElement.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement, 10);
                  topicDescriptionInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var filteringMessagesBeforePublishingElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'FILTERINGMESSAGESBEFOREPUBLISHING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (filteringMessagesBeforePublishingElement !== null && filteringMessagesBeforePublishingElement !== undefined && filteringMessagesBeforePublishingElement.length !== 0) {
                  var filteringMessagesBeforePublishingInstance = filteringMessagesBeforePublishingElement === 'true';
                  topicDescriptionInstance.filteringMessagesBeforePublishing = filteringMessagesBeforePublishingInstance;
                }
                
                var isAnonymousAccessibleElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (isAnonymousAccessibleElement !== null && isAnonymousAccessibleElement !== undefined && isAnonymousAccessibleElement.length !== 0) {
                  var isAnonymousAccessibleInstance = isAnonymousAccessibleElement === 'true';
                  topicDescriptionInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                }
                
                var authorizationRulesSequenceElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement !== null && authorizationRulesSequenceElement !== undefined) {
                  for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex1 = loweredIndex1 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex1];
                    var authorizationRuleInstance = { rights: [] };
                    topicDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement !== null && claimTypeElement !== undefined) {
                      var claimTypeInstance = claimTypeElement;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement !== null && claimValueElement !== undefined) {
                      var claimValueInstance = claimValueElement;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                      var primaryKeyInstance = primaryKeyElement;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
                
                var statusElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement !== null && statusElement !== undefined) {
                  var statusInstance = statusElement;
                  topicDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement);
                  topicDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var updatedAtElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (updatedAtElement !== null && updatedAtElement !== undefined && updatedAtElement.length !== 0) {
                  var updatedAtInstance = new Date(updatedAtElement);
                  topicDescriptionInstance.updatedAt = updatedAtInstance;
                }
                
                var accessedAtElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (accessedAtElement !== null && accessedAtElement !== undefined && accessedAtElement.length !== 0) {
                  var accessedAtInstance = new Date(accessedAtElement);
                  topicDescriptionInstance.accessedAt = accessedAtInstance;
                }
                
                var supportOrderingElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (supportOrderingElement !== null && supportOrderingElement !== undefined && supportOrderingElement.length !== 0) {
                  var supportOrderingInstance = supportOrderingElement === 'true';
                  topicDescriptionInstance.supportOrdering = supportOrderingInstance;
                }
                
                var countDetailsElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (countDetailsElement !== null && countDetailsElement !== undefined) {
                  var countDetailsInstance = {};
                  topicDescriptionInstance.countDetails = countDetailsInstance;
                }
                
                var subscriptionCountElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'SUBSCRIPTIONCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (subscriptionCountElement !== null && subscriptionCountElement !== undefined && subscriptionCountElement.length !== 0) {
                  var subscriptionCountInstance = parseInt(subscriptionCountElement, 10);
                  topicDescriptionInstance.subscriptionCount = subscriptionCountInstance;
                }
                
                var autoDeleteOnIdleElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (autoDeleteOnIdleElement !== null && autoDeleteOnIdleElement !== undefined) {
                  var autoDeleteOnIdleInstance = autoDeleteOnIdleElement;
                  topicDescriptionInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                }
                
                var entityAvailabilityStatusElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (entityAvailabilityStatusElement !== null && entityAvailabilityStatusElement !== undefined) {
                  var entityAvailabilityStatusInstance = entityAvailabilityStatusElement;
                  topicDescriptionInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets the set of connection strings for a topic.
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {string} topicName The topic.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  TopicOperations.prototype.getConnectionDetails = function(namespaceName, topicName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (topicName === null || topicName === undefined) {
      return callback(new Error('topicName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/Topics/';
    url2 = url2 + encodeURIComponent(topicName);
    url2 = url2 + '/ConnectionDetails';
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { connectionDetails: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { rights: [] };
                result.connectionDetails.push(entryInstance);
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var connectionDetailElement = js2xml.getElement(responseDoc, contentElement, 'CONNECTIONDETAIL', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (connectionDetailElement !== null && connectionDetailElement !== undefined) {
                    var keyNameElement = js2xml.getElement(responseDoc, connectionDetailElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement !== null && keyNameElement !== undefined) {
                      var keyNameInstance = keyNameElement;
                      entryInstance.keyName = keyNameInstance;
                    }
                    
                    var connectionStringElement = js2xml.getElement(responseDoc, connectionDetailElement, 'CONNECTIONSTRING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (connectionStringElement !== null && connectionStringElement !== undefined) {
                      var connectionStringInstance = connectionStringElement;
                      entryInstance.connectionString = connectionStringInstance;
                    }
                    
                    var authorizationTypeElement = js2xml.getElement(responseDoc, connectionDetailElement, 'AUTHORIZATIONTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationTypeElement !== null && authorizationTypeElement !== undefined) {
                      var authorizationTypeInstance = authorizationTypeElement;
                      entryInstance.authorizationType = authorizationTypeInstance;
                    }
                    
                    var rightsSequenceElement = js2xml.getElement(responseDoc, connectionDetailElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        entryInstance.rights.push(rightsElement);
                      }
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Enumerates the topics in the service namespace. An empty feed is returned
   * if no topic exists in the service namespace.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/hh780744.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  TopicOperations.prototype.list = function(namespaceName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/topics/';
    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['Content-Type'] = 'application/xml; charset=utf-8';
    httpRequest.headers['x-ms-version'] = '2013-08-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 = { topics: [] };
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var feedElement = js2xml.getElement(responseDoc, responseDoc, 'FEED', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (feedElement !== null && feedElement !== undefined) {
            if (feedElement !== null && feedElement !== undefined) {
              for (var loweredIndex1 = 0; loweredIndex1 < js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM').length; loweredIndex1 = loweredIndex1 + 1) {
                var entriesElement = js2xml.getElements(responseDoc, feedElement, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM')[loweredIndex1];
                var entryInstance = { authorizationRules: [] };
                result.topics.push(entryInstance);
                
                var titleElement = js2xml.getElement(responseDoc, entriesElement, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (titleElement !== null && titleElement !== undefined) {
                  var titleInstance = titleElement;
                  entryInstance.name = titleInstance;
                }
                
                var contentElement = js2xml.getElement(responseDoc, entriesElement, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
                if (contentElement !== null && contentElement !== undefined) {
                  var topicDescriptionElement = js2xml.getElement(responseDoc, contentElement, 'TOPICDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                  if (topicDescriptionElement !== null && topicDescriptionElement !== undefined) {
                    var defaultMessageTimeToLiveElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (defaultMessageTimeToLiveElement !== null && defaultMessageTimeToLiveElement !== undefined) {
                      var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement;
                      entryInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                    }
                    
                    var maxSizeInMegabytesElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (maxSizeInMegabytesElement !== null && maxSizeInMegabytesElement !== undefined && maxSizeInMegabytesElement.length !== 0) {
                      var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement, 10);
                      entryInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                    }
                    
                    var requiresDuplicateDetectionElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (requiresDuplicateDetectionElement !== null && requiresDuplicateDetectionElement !== undefined && requiresDuplicateDetectionElement.length !== 0) {
                      var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement === 'true';
                      entryInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                    }
                    
                    var duplicateDetectionHistoryTimeWindowElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (duplicateDetectionHistoryTimeWindowElement !== null && duplicateDetectionHistoryTimeWindowElement !== undefined) {
                      var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement;
                      entryInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                    }
                    
                    var enableBatchedOperationsElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (enableBatchedOperationsElement !== null && enableBatchedOperationsElement !== undefined && enableBatchedOperationsElement.length !== 0) {
                      var enableBatchedOperationsInstance = enableBatchedOperationsElement === 'true';
                      entryInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                    }
                    
                    var sizeInBytesElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (sizeInBytesElement !== null && sizeInBytesElement !== undefined && sizeInBytesElement.length !== 0) {
                      var sizeInBytesInstance = parseInt(sizeInBytesElement, 10);
                      entryInstance.sizeInBytes = sizeInBytesInstance;
                    }
                    
                    var filteringMessagesBeforePublishingElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'FILTERINGMESSAGESBEFOREPUBLISHING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (filteringMessagesBeforePublishingElement !== null && filteringMessagesBeforePublishingElement !== undefined && filteringMessagesBeforePublishingElement.length !== 0) {
                      var filteringMessagesBeforePublishingInstance = filteringMessagesBeforePublishingElement === 'true';
                      entryInstance.filteringMessagesBeforePublishing = filteringMessagesBeforePublishingInstance;
                    }
                    
                    var isAnonymousAccessibleElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (isAnonymousAccessibleElement !== null && isAnonymousAccessibleElement !== undefined && isAnonymousAccessibleElement.length !== 0) {
                      var isAnonymousAccessibleInstance = isAnonymousAccessibleElement === 'true';
                      entryInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                    }
                    
                    var authorizationRulesSequenceElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (authorizationRulesSequenceElement !== null && authorizationRulesSequenceElement !== undefined) {
                      for (var loweredIndex2 = 0; loweredIndex2 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex2 = loweredIndex2 + 1) {
                        var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex2];
                        var authorizationRuleInstance = { rights: [] };
                        entryInstance.authorizationRules.push(authorizationRuleInstance);
                        
                        var claimTypeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (claimTypeElement !== null && claimTypeElement !== undefined) {
                          var claimTypeInstance = claimTypeElement;
                          authorizationRuleInstance.claimType = claimTypeInstance;
                        }
                        
                        var claimValueElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (claimValueElement !== null && claimValueElement !== undefined) {
                          var claimValueInstance = claimValueElement;
                          authorizationRuleInstance.claimValue = claimValueInstance;
                        }
                        
                        var rightsSequenceElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (rightsSequenceElement !== null && rightsSequenceElement !== undefined) {
                          for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                            var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                            authorizationRuleInstance.rights.push(rightsElement);
                          }
                        }
                        
                        var createdTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (createdTimeElement !== null && createdTimeElement !== undefined && createdTimeElement.length !== 0) {
                          var createdTimeInstance = new Date(createdTimeElement);
                          authorizationRuleInstance.createdTime = createdTimeInstance;
                        }
                        
                        var keyNameElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (keyNameElement !== null && keyNameElement !== undefined) {
                          var keyNameInstance = keyNameElement;
                          authorizationRuleInstance.keyName = keyNameInstance;
                        }
                        
                        var modifiedTimeElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (modifiedTimeElement !== null && modifiedTimeElement !== undefined && modifiedTimeElement.length !== 0) {
                          var modifiedTimeInstance = new Date(modifiedTimeElement);
                          authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                        }
                        
                        var primaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (primaryKeyElement !== null && primaryKeyElement !== undefined) {
                          var primaryKeyInstance = primaryKeyElement;
                          authorizationRuleInstance.primaryKey = primaryKeyInstance;
                        }
                        
                        var secondaryKeyElement = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                        if (secondaryKeyElement !== null && secondaryKeyElement !== undefined) {
                          var secondaryKeyInstance = secondaryKeyElement;
                          authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                        }
                      }
                    }
                    
                    var statusElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (statusElement !== null && statusElement !== undefined) {
                      var statusInstance = statusElement;
                      entryInstance.status = statusInstance;
                    }
                    
                    var createdAtElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdAtElement !== null && createdAtElement !== undefined && createdAtElement.length !== 0) {
                      var createdAtInstance = new Date(createdAtElement);
                      entryInstance.createdAt = createdAtInstance;
                    }
                    
                    var updatedAtElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (updatedAtElement !== null && updatedAtElement !== undefined && updatedAtElement.length !== 0) {
                      var updatedAtInstance = new Date(updatedAtElement);
                      entryInstance.updatedAt = updatedAtInstance;
                    }
                    
                    var accessedAtElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (accessedAtElement !== null && accessedAtElement !== undefined && accessedAtElement.length !== 0) {
                      var accessedAtInstance = new Date(accessedAtElement);
                      entryInstance.accessedAt = accessedAtInstance;
                    }
                    
                    var supportOrderingElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (supportOrderingElement !== null && supportOrderingElement !== undefined && supportOrderingElement.length !== 0) {
                      var supportOrderingInstance = supportOrderingElement === 'true';
                      entryInstance.supportOrdering = supportOrderingInstance;
                    }
                    
                    var countDetailsElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (countDetailsElement !== null && countDetailsElement !== undefined) {
                      var countDetailsInstance = {};
                      entryInstance.countDetails = countDetailsInstance;
                    }
                    
                    var subscriptionCountElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'SUBSCRIPTIONCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (subscriptionCountElement !== null && subscriptionCountElement !== undefined && subscriptionCountElement.length !== 0) {
                      var subscriptionCountInstance = parseInt(subscriptionCountElement, 10);
                      entryInstance.subscriptionCount = subscriptionCountInstance;
                    }
                    
                    var autoDeleteOnIdleElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (autoDeleteOnIdleElement !== null && autoDeleteOnIdleElement !== undefined) {
                      var autoDeleteOnIdleInstance = autoDeleteOnIdleElement;
                      entryInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                    }
                    
                    var entityAvailabilityStatusElement = js2xml.getElement(responseDoc, topicDescriptionElement, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (entityAvailabilityStatusElement !== null && entityAvailabilityStatusElement !== undefined) {
                      var entityAvailabilityStatusInstance = entityAvailabilityStatusElement;
                      entryInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                    }
                  }
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Updates a topic.  (see
   * http://msdn.microsoft.com/en-us/library/windowsazure/jj839740.aspx for
   * more information)
   * 
   * @param {string} namespaceName The namespace name.
   * 
   * @param {ServiceBusTopic} topic The Service Bus topic.
   * 
   * @param {string} [topic.name] The name of the topic.
   * 
   * @param {string} [topic.defaultMessageTimeToLive] Determines how long a
   * message lives in the associated subscriptions. Subscriptions inherit the
   * TTL from the topic unless they are created explicitly with a smaller TTL.
   * Based on whether dead-lettering is enabled, a message whose TTL has
   * expired will either be moved to the subscription's associated
   * DeadLtterQueue or will be permanently deleted. The following values are
   * settable at topic creation time:* Range: 1 second - TimeSpan.MaxValue*
   * Default: TimeSpan.MaxValue
   * 
   * @param {number} [topic.maxSizeInMegabytes] Specifies the maximum topic
   * size in megabytes. Any attempt to enqueue a message that will cause the
   * topic to exceed this value will fail. All messages that are stored in the
   * topic or any of its subscriptions count towards this value. Multiple
   * copies of a message that reside in one or multiple subscriptions count as
   * a single messages. For example, if message m exists once in subscription
   * s1 and twice in subscription s2, m is counted as a single message. You
   * can only set this parameter at topic creation time using the following
   * values:* Range: 1 - 5*1024 MB* Default: 1*1024
   * 
   * @param {boolean} [topic.requiresDuplicateDetection] If enabled, the topic
   * will detect duplicate messages within the time span specified by the
   * DuplicateDetectionHistoryTimeWindow property. Settable only at topic
   * creation time.* Default: false
   * 
   * @param {string} [topic.duplicateDetectionHistoryTimeWindow] Specifies the
   * time span during which the Service Bus will detect message duplication.*
   * Range: 1 second - 7 days* Default: 10 minutes
   * 
   * @param {boolean} [topic.enableBatchedOperations] Enables or disables
   * service side batching behavior when performing operations for the
   * specific queue. When enabled, service bus will collect/batch multiple
   * operations to the backend to be more connection efficient. If user wants
   * lower operation latency then they can disable this feature.
   * 
   * @param {number} [topic.sizeInBytes] Reflects the actual bytes toward the
   * topic quota that messages in the topic currently occupy. (read-only)*
   * Range: 0 -MaxTopicSizeinMegaBytes
   * 
   * @param {boolean} [topic.filteringMessagesBeforePublishing] Gets or sets
   * whether messages should be filtered before publishing.
   * 
   * @param {boolean} [topic.isAnonymousAccessible] Gets whether anonymous
   * access is allowed.
   * 
   * @param {array} [topic.authorizationRules] Gets the authorization rules for
   * the description.
   * 
   * @param {string} [topic.status] Gets or sets the current status of the
   * topic (enabled or disabled). When a topic is disabled, that topic cannot
   * send or receive messages.
   * 
   * @param {date} [topic.createdAt] The time the queue was created at.
   * 
   * @param {date} [topic.updatedAt] The time the queue was last updated.
   * 
   * @param {date} [topic.accessedAt] The time the queue was last accessed.
   * 
   * @param {boolean} [topic.supportOrdering] Gets or sets whether the topics
   * can be ordered.
   * 
   * @param {CountDetails} [topic.countDetails] Current queue statistics.
   * 
   * @param {number} [topic.countDetails.activeMessageCount] The current number
   * of active messages.
   * 
   * @param {number} [topic.countDetails.deadLetterMessageCount] The current
   * number of dead letters.
   * 
   * @param {number} [topic.countDetails.scheduledMessageCount] The current
   * number of scheduled messages.
   * 
   * @param {number} [topic.countDetails.transferDeadLetterMessageCount] The
   * current number of transfer dead letters.
   * 
   * @param {number} [topic.countDetails.transferMessageCount] The current
   * number of transfer messages.
   * 
   * @param {number} [topic.subscriptionCount] The current number of
   * subscriptions to the topic.
   * 
   * @param {string} [topic.autoDeleteOnIdle] Implemented.
   * 
   * @param {string} [topic.entityAvailabilityStatus] The current availability
   * status of the topic.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  TopicOperations.prototype.update = function(namespaceName, topic, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (namespaceName === null || namespaceName === undefined) {
      return callback(new Error('namespaceName cannot be null.'));
    }
    if (topic === null || topic === undefined) {
      return callback(new Error('topic cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/services/servicebus/namespaces/';
    url2 = url2 + encodeURIComponent(namespaceName);
    url2 = url2 + '/topics/';
    if (topic.name !== null && topic.name !== undefined) {
      url2 = url2 + encodeURIComponent(topic.name);
    }
    url2 = url2 + '/';
    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/atom+xml';
    httpRequest.headers['if-match'] = '*';
    httpRequest.headers['type'] = 'entry';
    httpRequest.headers['x-ms-version'] = '2013-08-01';
    httpRequest.headers['x-process-at'] = 'ServiceBus';
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = {};
    
    var entryElement = js2xml.createElement('entry', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(requestDoc, entryElement);
    
    var contentElement = js2xml.createElement('content', 'http://www.w3.org/2005/Atom');
    js2xml.addChildElement(entryElement, contentElement);
    
    var typeAttribute = js2xml.createAttribute('type', '');
    js2xml.setAttributeValue(typeAttribute, 'application/atom+xml;type=entry;charset=utf-8');
    js2xml.addAttribute(contentElement, typeAttribute);
    
    var topicDescriptionElement = js2xml.createElement('TopicDescription', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
    js2xml.addChildElement(contentElement, topicDescriptionElement);
    
    if (topic.defaultMessageTimeToLive !== null && topic.defaultMessageTimeToLive !== undefined) {
      var defaultMessageTimeToLiveElement = js2xml.createElement('DefaultMessageTimeToLive', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(defaultMessageTimeToLiveElement, topic.defaultMessageTimeToLive);
      js2xml.addChildElement(topicDescriptionElement, defaultMessageTimeToLiveElement);
    }
    
    if (topic.maxSizeInMegabytes !== null && topic.maxSizeInMegabytes !== undefined) {
      var maxSizeInMegabytesElement = js2xml.createElement('MaxSizeInMegabytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(maxSizeInMegabytesElement, topic.maxSizeInMegabytes.toString());
      js2xml.addChildElement(topicDescriptionElement, maxSizeInMegabytesElement);
    }
    
    if (topic.requiresDuplicateDetection !== null && topic.requiresDuplicateDetection !== undefined) {
      var requiresDuplicateDetectionElement = js2xml.createElement('RequiresDuplicateDetection', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(requiresDuplicateDetectionElement, topic.requiresDuplicateDetection.toString());
      js2xml.addChildElement(topicDescriptionElement, requiresDuplicateDetectionElement);
    }
    
    if (topic.duplicateDetectionHistoryTimeWindow !== null && topic.duplicateDetectionHistoryTimeWindow !== undefined) {
      var duplicateDetectionHistoryTimeWindowElement = js2xml.createElement('DuplicateDetectionHistoryTimeWindow', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(duplicateDetectionHistoryTimeWindowElement, topic.duplicateDetectionHistoryTimeWindow);
      js2xml.addChildElement(topicDescriptionElement, duplicateDetectionHistoryTimeWindowElement);
    }
    
    if (topic.enableBatchedOperations !== null && topic.enableBatchedOperations !== undefined) {
      var enableBatchedOperationsElement = js2xml.createElement('EnableBatchedOperations', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(enableBatchedOperationsElement, topic.enableBatchedOperations.toString());
      js2xml.addChildElement(topicDescriptionElement, enableBatchedOperationsElement);
    }
    
    if (topic.sizeInBytes !== null && topic.sizeInBytes !== undefined) {
      var sizeInBytesElement = js2xml.createElement('SizeInBytes', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(sizeInBytesElement, topic.sizeInBytes.toString());
      js2xml.addChildElement(topicDescriptionElement, sizeInBytesElement);
    }
    
    if (topic.filteringMessagesBeforePublishing !== null && topic.filteringMessagesBeforePublishing !== undefined) {
      var filteringMessagesBeforePublishingElement = js2xml.createElement('FilteringMessagesBeforePublishing', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(filteringMessagesBeforePublishingElement, topic.filteringMessagesBeforePublishing.toString());
      js2xml.addChildElement(topicDescriptionElement, filteringMessagesBeforePublishingElement);
    }
    
    if (topic.isAnonymousAccessible !== null && topic.isAnonymousAccessible !== undefined) {
      var isAnonymousAccessibleElement = js2xml.createElement('IsAnonymousAccessible', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(isAnonymousAccessibleElement, topic.isAnonymousAccessible.toString());
      js2xml.addChildElement(topicDescriptionElement, isAnonymousAccessibleElement);
    }
    
    if (topic.authorizationRules !== null && topic.authorizationRules !== undefined) {
      var authorizationRulesSequenceElement = js2xml.createElement('AuthorizationRules', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      for (var loweredIndex1 = 0; loweredIndex1 < topic.authorizationRules.length; loweredIndex1 = loweredIndex1 + 1) {
        var authorizationRulesItem = topic.authorizationRules[loweredIndex1];
        var authorizationRuleElement = js2xml.createElement('AuthorizationRule', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
        js2xml.addChildElement(authorizationRulesSequenceElement, authorizationRuleElement);
        
        var typeAttribute2 = js2xml.createAttribute('type', 'http://www.w3.org/2001/XMLSchema-instance');
        js2xml.setAttributeValue(typeAttribute2, 'SharedAccessAuthorizationRule');
        js2xml.addAttribute(authorizationRuleElement, typeAttribute2);
        
        if (authorizationRulesItem.claimType !== null && authorizationRulesItem.claimType !== undefined) {
          var claimTypeElement = js2xml.createElement('ClaimType', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimTypeElement, authorizationRulesItem.claimType);
          js2xml.addChildElement(authorizationRuleElement, claimTypeElement);
        }
        
        if (authorizationRulesItem.claimValue !== null && authorizationRulesItem.claimValue !== undefined) {
          var claimValueElement = js2xml.createElement('ClaimValue', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(claimValueElement, authorizationRulesItem.claimValue);
          js2xml.addChildElement(authorizationRuleElement, claimValueElement);
        }
        
        if (authorizationRulesItem.rights !== null && authorizationRulesItem.rights !== undefined) {
          var rightsSequenceElement = js2xml.createElement('Rights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          for (var loweredIndex2 = 0; loweredIndex2 < authorizationRulesItem.rights.length; loweredIndex2 = loweredIndex2 + 1) {
            var rightsItem = authorizationRulesItem.rights[loweredIndex2];
            var rightsItemElement = js2xml.createElement('AccessRights', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
            js2xml.setElementValue(rightsItemElement, rightsItem !== null && rightsItem !== undefined ? rightsItem.toString() : 'Listen');
            js2xml.addChildElement(rightsSequenceElement, rightsItemElement);
          }
          js2xml.addChildElement(authorizationRuleElement, rightsSequenceElement);
        }
        
        if (authorizationRulesItem.createdTime !== null && authorizationRulesItem.createdTime !== undefined) {
          var createdTimeElement = js2xml.createElement('CreatedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(createdTimeElement, authorizationRulesItem.createdTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, createdTimeElement);
        }
        
        if (authorizationRulesItem.keyName !== null && authorizationRulesItem.keyName !== undefined) {
          var keyNameElement = js2xml.createElement('KeyName', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(keyNameElement, authorizationRulesItem.keyName);
          js2xml.addChildElement(authorizationRuleElement, keyNameElement);
        }
        
        if (authorizationRulesItem.modifiedTime !== null && authorizationRulesItem.modifiedTime !== undefined) {
          var modifiedTimeElement = js2xml.createElement('ModifiedTime', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(modifiedTimeElement, authorizationRulesItem.modifiedTime.toISOString());
          js2xml.addChildElement(authorizationRuleElement, modifiedTimeElement);
        }
        
        if (authorizationRulesItem.primaryKey !== null && authorizationRulesItem.primaryKey !== undefined) {
          var primaryKeyElement = js2xml.createElement('PrimaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(primaryKeyElement, authorizationRulesItem.primaryKey);
          js2xml.addChildElement(authorizationRuleElement, primaryKeyElement);
        }
        
        if (authorizationRulesItem.secondaryKey !== null && authorizationRulesItem.secondaryKey !== undefined) {
          var secondaryKeyElement = js2xml.createElement('SecondaryKey', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
          js2xml.setElementValue(secondaryKeyElement, authorizationRulesItem.secondaryKey);
          js2xml.addChildElement(authorizationRuleElement, secondaryKeyElement);
        }
      }
      js2xml.addChildElement(topicDescriptionElement, authorizationRulesSequenceElement);
    }
    
    if (topic.status !== null && topic.status !== undefined) {
      var statusElement = js2xml.createElement('Status', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(statusElement, topic.status);
      js2xml.addChildElement(topicDescriptionElement, statusElement);
    }
    
    if (topic.createdAt !== null && topic.createdAt !== undefined) {
      var createdAtElement = js2xml.createElement('CreatedAt', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(createdAtElement, topic.createdAt.toISOString());
      js2xml.addChildElement(topicDescriptionElement, createdAtElement);
    }
    
    if (topic.updatedAt !== null && topic.updatedAt !== undefined) {
      var updatedAtElement = js2xml.createElement('UpdatedAt', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(updatedAtElement, topic.updatedAt.toISOString());
      js2xml.addChildElement(topicDescriptionElement, updatedAtElement);
    }
    
    if (topic.accessedAt !== null && topic.accessedAt !== undefined) {
      var accessedAtElement = js2xml.createElement('AccessedAt', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(accessedAtElement, topic.accessedAt.toISOString());
      js2xml.addChildElement(topicDescriptionElement, accessedAtElement);
    }
    
    if (topic.supportOrdering !== null && topic.supportOrdering !== undefined) {
      var supportOrderingElement = js2xml.createElement('SupportOrdering', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(supportOrderingElement, topic.supportOrdering.toString());
      js2xml.addChildElement(topicDescriptionElement, supportOrderingElement);
    }
    
    if (topic.countDetails !== null && topic.countDetails !== undefined) {
      var countDetailsElement = js2xml.createElement('CountDetails', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.addChildElement(topicDescriptionElement, countDetailsElement);
      
      if (topic.countDetails.activeMessageCount !== null && topic.countDetails.activeMessageCount !== undefined) {
        var activeMessageCountElement = js2xml.createElement('ActiveMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(activeMessageCountElement, topic.countDetails.activeMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, activeMessageCountElement);
      }
      
      if (topic.countDetails.deadLetterMessageCount !== null && topic.countDetails.deadLetterMessageCount !== undefined) {
        var deadLetterMessageCountElement = js2xml.createElement('DeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(deadLetterMessageCountElement, topic.countDetails.deadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, deadLetterMessageCountElement);
      }
      
      if (topic.countDetails.scheduledMessageCount !== null && topic.countDetails.scheduledMessageCount !== undefined) {
        var scheduledMessageCountElement = js2xml.createElement('ScheduledMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(scheduledMessageCountElement, topic.countDetails.scheduledMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, scheduledMessageCountElement);
      }
      
      if (topic.countDetails.transferDeadLetterMessageCount !== null && topic.countDetails.transferDeadLetterMessageCount !== undefined) {
        var transferDeadLetterMessageCountElement = js2xml.createElement('TransferDeadLetterMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferDeadLetterMessageCountElement, topic.countDetails.transferDeadLetterMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferDeadLetterMessageCountElement);
      }
      
      if (topic.countDetails.transferMessageCount !== null && topic.countDetails.transferMessageCount !== undefined) {
        var transferMessageCountElement = js2xml.createElement('TransferMessageCount', 'http://schemas.microsoft.com/netservices/2011/06/servicebus');
        js2xml.setElementValue(transferMessageCountElement, topic.countDetails.transferMessageCount.toString());
        js2xml.addChildElement(countDetailsElement, transferMessageCountElement);
      }
    }
    
    if (topic.subscriptionCount !== null && topic.subscriptionCount !== undefined) {
      var subscriptionCountElement = js2xml.createElement('SubscriptionCount', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(subscriptionCountElement, topic.subscriptionCount.toString());
      js2xml.addChildElement(topicDescriptionElement, subscriptionCountElement);
    }
    
    if (topic.autoDeleteOnIdle !== null && topic.autoDeleteOnIdle !== undefined) {
      var autoDeleteOnIdleElement = js2xml.createElement('AutoDeleteOnIdle', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(autoDeleteOnIdleElement, topic.autoDeleteOnIdle);
      js2xml.addChildElement(topicDescriptionElement, autoDeleteOnIdleElement);
    }
    
    if (topic.entityAvailabilityStatus !== null && topic.entityAvailabilityStatus !== undefined) {
      var entityAvailabilityStatusElement = js2xml.createElement('EntityAvailabilityStatus', 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect');
      js2xml.setElementValue(entityAvailabilityStatusElement, topic.entityAvailabilityStatus);
      js2xml.addChildElement(topicDescriptionElement, entityAvailabilityStatusElement);
    }
    
    requestContent = js2xml.serializeDocument(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      if (statusCode === 200) {
        var responseContent = body;
        result = {};
        var options = {};
        options.trim = false;
        options.strict = false;
        xml.parseString(responseContent, options, function (err2, responseDoc) {
          if (err2 !== null && err2 !== undefined) {
            return callback(err2);
          }
          
          var entryElement2 = js2xml.getElement(responseDoc, responseDoc, 'ENTRY', 'HTTP://WWW.W3.ORG/2005/ATOM');
          if (entryElement2 !== null && entryElement2 !== undefined) {
            var titleElement = js2xml.getElement(responseDoc, entryElement2, 'TITLE', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (titleElement !== null && titleElement !== undefined) {
            }
            
            var contentElement2 = js2xml.getElement(responseDoc, entryElement2, 'CONTENT', 'HTTP://WWW.W3.ORG/2005/ATOM');
            if (contentElement2 !== null && contentElement2 !== undefined) {
              var topicDescriptionElement2 = js2xml.getElement(responseDoc, contentElement2, 'TOPICDESCRIPTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
              if (topicDescriptionElement2 !== null && topicDescriptionElement2 !== undefined) {
                var topicDescriptionInstance = { authorizationRules: [] };
                result.topic = topicDescriptionInstance;
                
                var defaultMessageTimeToLiveElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'DEFAULTMESSAGETIMETOLIVE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (defaultMessageTimeToLiveElement2 !== null && defaultMessageTimeToLiveElement2 !== undefined) {
                  var defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement2;
                  topicDescriptionInstance.defaultMessageTimeToLive = defaultMessageTimeToLiveInstance;
                }
                
                var maxSizeInMegabytesElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'MAXSIZEINMEGABYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (maxSizeInMegabytesElement2 !== null && maxSizeInMegabytesElement2 !== undefined && maxSizeInMegabytesElement2.length !== 0) {
                  var maxSizeInMegabytesInstance = parseInt(maxSizeInMegabytesElement2, 10);
                  topicDescriptionInstance.maxSizeInMegabytes = maxSizeInMegabytesInstance;
                }
                
                var requiresDuplicateDetectionElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'REQUIRESDUPLICATEDETECTION', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (requiresDuplicateDetectionElement2 !== null && requiresDuplicateDetectionElement2 !== undefined && requiresDuplicateDetectionElement2.length !== 0) {
                  var requiresDuplicateDetectionInstance = requiresDuplicateDetectionElement2 === 'true';
                  topicDescriptionInstance.requiresDuplicateDetection = requiresDuplicateDetectionInstance;
                }
                
                var duplicateDetectionHistoryTimeWindowElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'DUPLICATEDETECTIONHISTORYTIMEWINDOW', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (duplicateDetectionHistoryTimeWindowElement2 !== null && duplicateDetectionHistoryTimeWindowElement2 !== undefined) {
                  var duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement2;
                  topicDescriptionInstance.duplicateDetectionHistoryTimeWindow = duplicateDetectionHistoryTimeWindowInstance;
                }
                
                var enableBatchedOperationsElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ENABLEBATCHEDOPERATIONS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (enableBatchedOperationsElement2 !== null && enableBatchedOperationsElement2 !== undefined && enableBatchedOperationsElement2.length !== 0) {
                  var enableBatchedOperationsInstance = enableBatchedOperationsElement2 === 'true';
                  topicDescriptionInstance.enableBatchedOperations = enableBatchedOperationsInstance;
                }
                
                var sizeInBytesElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'SIZEINBYTES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (sizeInBytesElement2 !== null && sizeInBytesElement2 !== undefined && sizeInBytesElement2.length !== 0) {
                  var sizeInBytesInstance = parseInt(sizeInBytesElement2, 10);
                  topicDescriptionInstance.sizeInBytes = sizeInBytesInstance;
                }
                
                var filteringMessagesBeforePublishingElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'FILTERINGMESSAGESBEFOREPUBLISHING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (filteringMessagesBeforePublishingElement2 !== null && filteringMessagesBeforePublishingElement2 !== undefined && filteringMessagesBeforePublishingElement2.length !== 0) {
                  var filteringMessagesBeforePublishingInstance = filteringMessagesBeforePublishingElement2 === 'true';
                  topicDescriptionInstance.filteringMessagesBeforePublishing = filteringMessagesBeforePublishingInstance;
                }
                
                var isAnonymousAccessibleElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ISANONYMOUSACCESSIBLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (isAnonymousAccessibleElement2 !== null && isAnonymousAccessibleElement2 !== undefined && isAnonymousAccessibleElement2.length !== 0) {
                  var isAnonymousAccessibleInstance = isAnonymousAccessibleElement2 === 'true';
                  topicDescriptionInstance.isAnonymousAccessible = isAnonymousAccessibleInstance;
                }
                
                var authorizationRulesSequenceElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'AUTHORIZATIONRULES', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (authorizationRulesSequenceElement2 !== null && authorizationRulesSequenceElement2 !== undefined) {
                  for (var loweredIndex3 = 0; loweredIndex3 < js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex3 = loweredIndex3 + 1) {
                    var authorizationRulesElement = js2xml.getElements(responseDoc, authorizationRulesSequenceElement2, 'AUTHORIZATIONRULE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex3];
                    var authorizationRuleInstance = { rights: [] };
                    topicDescriptionInstance.authorizationRules.push(authorizationRuleInstance);
                    
                    var claimTypeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMTYPE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimTypeElement2 !== null && claimTypeElement2 !== undefined) {
                      var claimTypeInstance = claimTypeElement2;
                      authorizationRuleInstance.claimType = claimTypeInstance;
                    }
                    
                    var claimValueElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CLAIMVALUE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (claimValueElement2 !== null && claimValueElement2 !== undefined) {
                      var claimValueInstance = claimValueElement2;
                      authorizationRuleInstance.claimValue = claimValueInstance;
                    }
                    
                    var rightsSequenceElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'RIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (rightsSequenceElement2 !== null && rightsSequenceElement2 !== undefined) {
                      for (var loweredIndex4 = 0; loweredIndex4 < js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT').length; loweredIndex4 = loweredIndex4 + 1) {
                        var rightsElement = js2xml.getElements(responseDoc, rightsSequenceElement2, 'ACCESSRIGHTS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT')[loweredIndex4];
                        authorizationRuleInstance.rights.push(rightsElement);
                      }
                    }
                    
                    var createdTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'CREATEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (createdTimeElement2 !== null && createdTimeElement2 !== undefined && createdTimeElement2.length !== 0) {
                      var createdTimeInstance = new Date(createdTimeElement2);
                      authorizationRuleInstance.createdTime = createdTimeInstance;
                    }
                    
                    var keyNameElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'KEYNAME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (keyNameElement2 !== null && keyNameElement2 !== undefined) {
                      var keyNameInstance = keyNameElement2;
                      authorizationRuleInstance.keyName = keyNameInstance;
                    }
                    
                    var modifiedTimeElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'MODIFIEDTIME', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (modifiedTimeElement2 !== null && modifiedTimeElement2 !== undefined && modifiedTimeElement2.length !== 0) {
                      var modifiedTimeInstance = new Date(modifiedTimeElement2);
                      authorizationRuleInstance.modifiedTime = modifiedTimeInstance;
                    }
                    
                    var primaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'PRIMARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (primaryKeyElement2 !== null && primaryKeyElement2 !== undefined) {
                      var primaryKeyInstance = primaryKeyElement2;
                      authorizationRuleInstance.primaryKey = primaryKeyInstance;
                    }
                    
                    var secondaryKeyElement2 = js2xml.getElement(responseDoc, authorizationRulesElement, 'SECONDARYKEY', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                    if (secondaryKeyElement2 !== null && secondaryKeyElement2 !== undefined) {
                      var secondaryKeyInstance = secondaryKeyElement2;
                      authorizationRuleInstance.secondaryKey = secondaryKeyInstance;
                    }
                  }
                }
                
                var statusElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'STATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (statusElement2 !== null && statusElement2 !== undefined) {
                  var statusInstance = statusElement2;
                  topicDescriptionInstance.status = statusInstance;
                }
                
                var createdAtElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'CREATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (createdAtElement2 !== null && createdAtElement2 !== undefined && createdAtElement2.length !== 0) {
                  var createdAtInstance = new Date(createdAtElement2);
                  topicDescriptionInstance.createdAt = createdAtInstance;
                }
                
                var updatedAtElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'UPDATEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (updatedAtElement2 !== null && updatedAtElement2 !== undefined && updatedAtElement2.length !== 0) {
                  var updatedAtInstance = new Date(updatedAtElement2);
                  topicDescriptionInstance.updatedAt = updatedAtInstance;
                }
                
                var accessedAtElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ACCESSEDAT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (accessedAtElement2 !== null && accessedAtElement2 !== undefined && accessedAtElement2.length !== 0) {
                  var accessedAtInstance = new Date(accessedAtElement2);
                  topicDescriptionInstance.accessedAt = accessedAtInstance;
                }
                
                var supportOrderingElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'SUPPORTORDERING', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (supportOrderingElement2 !== null && supportOrderingElement2 !== undefined && supportOrderingElement2.length !== 0) {
                  var supportOrderingInstance = supportOrderingElement2 === 'true';
                  topicDescriptionInstance.supportOrdering = supportOrderingInstance;
                }
                
                var countDetailsElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'COUNTDETAILS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (countDetailsElement2 !== null && countDetailsElement2 !== undefined) {
                  var countDetailsInstance = {};
                  topicDescriptionInstance.countDetails = countDetailsInstance;
                }
                
                var subscriptionCountElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'SUBSCRIPTIONCOUNT', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (subscriptionCountElement2 !== null && subscriptionCountElement2 !== undefined && subscriptionCountElement2.length !== 0) {
                  var subscriptionCountInstance = parseInt(subscriptionCountElement2, 10);
                  topicDescriptionInstance.subscriptionCount = subscriptionCountInstance;
                }
                
                var autoDeleteOnIdleElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'AUTODELETEONIDLE', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (autoDeleteOnIdleElement2 !== null && autoDeleteOnIdleElement2 !== undefined) {
                  var autoDeleteOnIdleInstance = autoDeleteOnIdleElement2;
                  topicDescriptionInstance.autoDeleteOnIdle = autoDeleteOnIdleInstance;
                }
                
                var entityAvailabilityStatusElement2 = js2xml.getElement(responseDoc, topicDescriptionElement2, 'ENTITYAVAILABILITYSTATUS', 'HTTP://SCHEMAS.MICROSOFT.COM/NETSERVICES/2010/10/SERVICEBUS/CONNECT');
                if (entityAvailabilityStatusElement2 !== null && entityAvailabilityStatusElement2 !== undefined) {
                  var entityAvailabilityStatusInstance = entityAvailabilityStatusElement2;
                  topicDescriptionInstance.entityAvailabilityStatus = entityAvailabilityStatusInstance;
                }
              }
            }
          }
          
        });
      }
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return TopicOperations;
})();
