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

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

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

'use strict';

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

var DnsManagementClient = ( /** @lends DnsManagementClient */ function() {
  /**
   * @class
   * Client for managing DNS zones and record.
   * Initializes a new instance of the DnsManagementClient 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 DnsManagementClient(credentials, baseUri, filters) {
    if (credentials === null || credentials === undefined) {
      throw new Error('credentials cannot be null.');
    }
    
    DnsManagementClient['super_'].call(this, credentials, filters);
    
    this.credentials = credentials;
    this.baseUri = baseUri;
    if (this.baseUri === null || this.baseUri === undefined) {
      this.baseUri = 'https://management.azure.com';
    }
    if (this.apiVersion === null || this.apiVersion === undefined) {
      this.apiVersion = '2015-05-04-preview';
    }
    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
     * [RecordSetOperations](-RecordSetOperations.html) object.
     * @type {object}
     */
    this.recordSets = new RecordSetOperations(this);
    /**
     * Provides an instance of the [ZoneOperations](-ZoneOperations.html)
     * object.
     * @type {object}
     */
    this.zones = new ZoneOperations(this);
  }
  
  util.inherits(DnsManagementClient, Service);
  
  
  return DnsManagementClient;
})();
exports.DnsManagementClient = DnsManagementClient;

var RecordSetOperations = ( /** @lends RecordSetOperations */ function() {
  /**
   * @class
   * Operations for managing the RecordSets in a DNS zone.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [DnsManagementClient] {@link
   * DnsManagementClient~DnsManagementClient}.
   * See [recordSets] {@link
   * DnsManagementClient~DnsManagementClient#recordSets}.
   * Initializes a new instance of the RecordSetOperations class.
   * @constructor
   * 
   * @param {DnsManagementClient} client Reference to the service client.
   */
  function RecordSetOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a RecordSet within a DNS zone.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} zoneName The name of the zone without a terminating dot.
   * 
   * @param {string} relativeRecordSetName The name of the RecordSet, relative
   * to the name of the zone.
   * 
   * @param {RecordType} recordType The type of DNS record.
   * 
   * @param {RecordSetCreateOrUpdateParameters} parameters Parameters supplied
   * to the CreateOrUpdate operation.
   * 
   * @param {RecordSet} parameters.recordSet Gets or sets information about the
   * RecordSet being created or updated.
   * 
   * @param {string} [parameters.recordSet.eTag] Gets or sets the ETag of the
   * RecordSet.
   * 
   * @param {RecordSetProperties} [parameters.recordSet.properties] Gets or
   * sets the properties of the RecordSet.
   * 
   * @param {number} [parameters.recordSet.properties.ttl] Gets or sets the TTL
   * of the records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.aRecords] Gets or sets the
   * list of A records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.aaaaRecords] Gets or sets
   * the list of AAAA records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.mxRecords] Gets or sets
   * the list of MX records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.nsRecords] Gets or sets
   * the list of NS records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.ptrRecords] Gets or sets
   * the list of PTR records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.srvRecords] Gets or sets
   * the list of SRV records in the RecordSet.
   * 
   * @param {array} [parameters.recordSet.properties.txtRecords] Gets or sets
   * the list of TXT records in the RecordSet.
   * 
   * @param {CnameRecord} [parameters.recordSet.properties.cnameRecord] Gets or
   * sets the CNAME record in the RecordSet.
   * 
   * @param {string} [parameters.recordSet.properties.cnameRecord.cname] Gets
   * or sets the canonical name for this record without a terminating dot.
   * 
   * @param {SoaRecord} [parameters.recordSet.properties.soaRecord] Gets or
   * sets the SOA record in the RecordSet.
   * 
   * @param {string} [parameters.recordSet.properties.soaRecord.host] Gets or
   * sets the domain name of the authoritative name server, without a
   * temrinating dot.
   * 
   * @param {string} [parameters.recordSet.properties.soaRecord.email] Gets or
   * sets the email for this record.
   * 
   * @param {number} [parameters.recordSet.properties.soaRecord.serialNumber]
   * Gets or sets the serial number for this record.
   * 
   * @param {number} [parameters.recordSet.properties.soaRecord.refreshTime]
   * Gets or sets the refresh value for this record.
   * 
   * @param {number} [parameters.recordSet.properties.soaRecord.retryTime] Gets
   * or sets the retry time for this record.
   * 
   * @param {number} [parameters.recordSet.properties.soaRecord.expireTime]
   * Gets or sets the expire time for this record.
   * 
   * @param {number} [parameters.recordSet.properties.soaRecord.minimumTtl]
   * Gets or sets the minimum TTL value for this record.
   * 
   * @param {string} [parameters.recordSet.id] Gets or sets the ID of the
   * resource.
   * 
   * @param {string} [parameters.recordSet.name] Gets or sets the name of the
   * resource.
   * 
   * @param {string} [parameters.recordSet.type] Gets or sets the type of the
   * resource.
   * 
   * @param {string} parameters.recordSet.location Gets or sets the location of
   * the resource.
   * 
   * @param {object} [parameters.recordSet.tags] Gets or sets the tags attached
   * to the resource.
   * 
   * @param {string} [parameters.ifNoneMatch] Gets or sets the If-None-Match
   * precondition. Set to '*' to force Create-If-Not-Exist. Other values will
   * be ignored.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RecordSetOperations.prototype.createOrUpdate = function(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    if (relativeRecordSetName === null || relativeRecordSetName === undefined) {
      return callback(new Error('relativeRecordSetName cannot be null.'));
    }
    if (recordType === null || recordType === undefined) {
      return callback(new Error('recordType cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.recordSet === null || parameters.recordSet === undefined) {
      return callback(new Error('parameters.recordSet cannot be null.'));
    }
    if (parameters.recordSet.location === null || parameters.recordSet.location === undefined) {
      return callback(new Error('parameters.recordSet.location cannot be null.'));
    }
    if (parameters.recordSet.properties !== null && parameters.recordSet.properties !== undefined) {
      if (parameters.recordSet.properties.aaaaRecords !== null && parameters.recordSet.properties.aaaaRecords !== undefined) {
        for (var loweredIndex1 = 0; loweredIndex1 < parameters.recordSet.properties.aaaaRecords.length; loweredIndex1 = loweredIndex1 + 1) {
          var aaaaRecordsParameterItem = parameters.recordSet.properties.aaaaRecords[loweredIndex1];
          if (aaaaRecordsParameterItem.ipv6Address === null || aaaaRecordsParameterItem.ipv6Address === undefined) {
            return callback(new Error('parameters.recordSet.properties.aaaaRecords.ipv6Address cannot be null.'));
          }
        }
      }
      if (parameters.recordSet.properties.aRecords !== null && parameters.recordSet.properties.aRecords !== undefined) {
        for (var loweredIndex2 = 0; loweredIndex2 < parameters.recordSet.properties.aRecords.length; loweredIndex2 = loweredIndex2 + 1) {
          var aRecordsParameterItem = parameters.recordSet.properties.aRecords[loweredIndex2];
          if (aRecordsParameterItem.ipv4Address === null || aRecordsParameterItem.ipv4Address === undefined) {
            return callback(new Error('parameters.recordSet.properties.aRecords.ipv4Address cannot be null.'));
          }
        }
      }
      if (parameters.recordSet.properties.cnameRecord !== null && parameters.recordSet.properties.cnameRecord !== undefined) {
        if (parameters.recordSet.properties.cnameRecord.cname === null || parameters.recordSet.properties.cnameRecord.cname === undefined) {
          return callback(new Error('parameters.recordSet.properties.cnameRecord.cname cannot be null.'));
        }
      }
      if (parameters.recordSet.properties.mxRecords !== null && parameters.recordSet.properties.mxRecords !== undefined) {
        for (var loweredIndex3 = 0; loweredIndex3 < parameters.recordSet.properties.mxRecords.length; loweredIndex3 = loweredIndex3 + 1) {
          var mxRecordsParameterItem = parameters.recordSet.properties.mxRecords[loweredIndex3];
          if (mxRecordsParameterItem.exchange === null || mxRecordsParameterItem.exchange === undefined) {
            return callback(new Error('parameters.recordSet.properties.mxRecords.exchange cannot be null.'));
          }
          if (mxRecordsParameterItem.preference === null || mxRecordsParameterItem.preference === undefined) {
            return callback(new Error('parameters.recordSet.properties.mxRecords.preference cannot be null.'));
          }
        }
      }
      if (parameters.recordSet.properties.nsRecords !== null && parameters.recordSet.properties.nsRecords !== undefined) {
        for (var loweredIndex4 = 0; loweredIndex4 < parameters.recordSet.properties.nsRecords.length; loweredIndex4 = loweredIndex4 + 1) {
          var nsRecordsParameterItem = parameters.recordSet.properties.nsRecords[loweredIndex4];
          if (nsRecordsParameterItem.nsdname === null || nsRecordsParameterItem.nsdname === undefined) {
            return callback(new Error('parameters.recordSet.properties.nsRecords.nsdname cannot be null.'));
          }
        }
      }
      if (parameters.recordSet.properties.ptrRecords !== null && parameters.recordSet.properties.ptrRecords !== undefined) {
        for (var loweredIndex5 = 0; loweredIndex5 < parameters.recordSet.properties.ptrRecords.length; loweredIndex5 = loweredIndex5 + 1) {
          var ptrRecordsParameterItem = parameters.recordSet.properties.ptrRecords[loweredIndex5];
          if (ptrRecordsParameterItem.ptrdname === null || ptrRecordsParameterItem.ptrdname === undefined) {
            return callback(new Error('parameters.recordSet.properties.ptrRecords.ptrdname cannot be null.'));
          }
        }
      }
      if (parameters.recordSet.properties.soaRecord !== null && parameters.recordSet.properties.soaRecord !== undefined) {
        if (parameters.recordSet.properties.soaRecord.email === null || parameters.recordSet.properties.soaRecord.email === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.email cannot be null.'));
        }
        if (parameters.recordSet.properties.soaRecord.expireTime === null || parameters.recordSet.properties.soaRecord.expireTime === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.expireTime cannot be null.'));
        }
        if (parameters.recordSet.properties.soaRecord.host === null || parameters.recordSet.properties.soaRecord.host === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.host cannot be null.'));
        }
        if (parameters.recordSet.properties.soaRecord.minimumTtl === null || parameters.recordSet.properties.soaRecord.minimumTtl === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.minimumTtl cannot be null.'));
        }
        if (parameters.recordSet.properties.soaRecord.refreshTime === null || parameters.recordSet.properties.soaRecord.refreshTime === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.refreshTime cannot be null.'));
        }
        if (parameters.recordSet.properties.soaRecord.retryTime === null || parameters.recordSet.properties.soaRecord.retryTime === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.retryTime cannot be null.'));
        }
        if (parameters.recordSet.properties.soaRecord.serialNumber === null || parameters.recordSet.properties.soaRecord.serialNumber === undefined) {
          return callback(new Error('parameters.recordSet.properties.soaRecord.serialNumber cannot be null.'));
        }
      }
      if (parameters.recordSet.properties.srvRecords !== null && parameters.recordSet.properties.srvRecords !== undefined) {
        for (var loweredIndex6 = 0; loweredIndex6 < parameters.recordSet.properties.srvRecords.length; loweredIndex6 = loweredIndex6 + 1) {
          var srvRecordsParameterItem = parameters.recordSet.properties.srvRecords[loweredIndex6];
          if (srvRecordsParameterItem.port === null || srvRecordsParameterItem.port === undefined) {
            return callback(new Error('parameters.recordSet.properties.srvRecords.port cannot be null.'));
          }
          if (srvRecordsParameterItem.priority === null || srvRecordsParameterItem.priority === undefined) {
            return callback(new Error('parameters.recordSet.properties.srvRecords.priority cannot be null.'));
          }
          if (srvRecordsParameterItem.target === null || srvRecordsParameterItem.target === undefined) {
            return callback(new Error('parameters.recordSet.properties.srvRecords.target cannot be null.'));
          }
          if (srvRecordsParameterItem.weight === null || srvRecordsParameterItem.weight === undefined) {
            return callback(new Error('parameters.recordSet.properties.srvRecords.weight cannot be null.'));
          }
        }
      }
      if (parameters.recordSet.properties.ttl === null || parameters.recordSet.properties.ttl === undefined) {
        return callback(new Error('parameters.recordSet.properties.ttl cannot be null.'));
      }
      if (parameters.recordSet.properties.txtRecords !== null && parameters.recordSet.properties.txtRecords !== undefined) {
        for (var loweredIndex7 = 0; loweredIndex7 < parameters.recordSet.properties.txtRecords.length; loweredIndex7 = loweredIndex7 + 1) {
          var txtRecordsParameterItem = parameters.recordSet.properties.txtRecords[loweredIndex7];
          if (txtRecordsParameterItem.value === null || txtRecordsParameterItem.value === undefined) {
            return callback(new Error('parameters.recordSet.properties.txtRecords.value cannot be null.'));
          }
        }
      }
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(recordType !== null && recordType !== undefined ? recordType.toString() : 'A');
    url2 = url2 + '/';
    url2 = url2 + relativeRecordSetName;
    var queryParameters = [];
    queryParameters.push('api-version=2015-05-04-preview');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (parameters.recordSet.eTag !== null && parameters.recordSet.eTag !== undefined) {
      httpRequest.headers['If-Match'] = parameters.recordSet.eTag;
    }
    if (parameters.ifNoneMatch !== null && parameters.ifNoneMatch !== undefined) {
      httpRequest.headers['If-None-Match'] = parameters.ifNoneMatch;
    }
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var recordSetCreateOrUpdateParametersValue = {};
    requestDoc = recordSetCreateOrUpdateParametersValue;
    
    if (parameters.recordSet.eTag !== null && parameters.recordSet.eTag !== undefined) {
      recordSetCreateOrUpdateParametersValue['etag'] = parameters.recordSet.eTag;
    }
    
    if (parameters.recordSet.properties !== null && parameters.recordSet.properties !== undefined) {
      var propertiesValue = {};
      recordSetCreateOrUpdateParametersValue['properties'] = propertiesValue;
      
      propertiesValue['TTL'] = parameters.recordSet.properties.ttl;
      
      if (parameters.recordSet.properties.aRecords !== null && parameters.recordSet.properties.aRecords !== undefined) {
        var aRecordsArray = [];
        for (var loweredIndex8 = 0; loweredIndex8 < parameters.recordSet.properties.aRecords.length; loweredIndex8 = loweredIndex8 + 1) {
          var aRecordsItem = parameters.recordSet.properties.aRecords[loweredIndex8];
          var aRecordValue = {};
          aRecordsArray.push(aRecordValue);
          
          aRecordValue['ipv4Address'] = aRecordsItem.ipv4Address;
        }
        propertiesValue['ARecords'] = aRecordsArray;
      }
      
      if (parameters.recordSet.properties.aaaaRecords !== null && parameters.recordSet.properties.aaaaRecords !== undefined) {
        var aAAARecordsArray = [];
        for (var loweredIndex9 = 0; loweredIndex9 < parameters.recordSet.properties.aaaaRecords.length; loweredIndex9 = loweredIndex9 + 1) {
          var aAAARecordsItem = parameters.recordSet.properties.aaaaRecords[loweredIndex9];
          var aaaaRecordValue = {};
          aAAARecordsArray.push(aaaaRecordValue);
          
          aaaaRecordValue['ipv6Address'] = aAAARecordsItem.ipv6Address;
        }
        propertiesValue['AAAARecords'] = aAAARecordsArray;
      }
      
      if (parameters.recordSet.properties.mxRecords !== null && parameters.recordSet.properties.mxRecords !== undefined) {
        var mXRecordsArray = [];
        for (var loweredIndex10 = 0; loweredIndex10 < parameters.recordSet.properties.mxRecords.length; loweredIndex10 = loweredIndex10 + 1) {
          var mXRecordsItem = parameters.recordSet.properties.mxRecords[loweredIndex10];
          var mxRecordValue = {};
          mXRecordsArray.push(mxRecordValue);
          
          mxRecordValue['preference'] = mXRecordsItem.preference;
          
          mxRecordValue['exchange'] = mXRecordsItem.exchange;
        }
        propertiesValue['MXRecords'] = mXRecordsArray;
      }
      
      if (parameters.recordSet.properties.nsRecords !== null && parameters.recordSet.properties.nsRecords !== undefined) {
        var nSRecordsArray = [];
        for (var loweredIndex11 = 0; loweredIndex11 < parameters.recordSet.properties.nsRecords.length; loweredIndex11 = loweredIndex11 + 1) {
          var nSRecordsItem = parameters.recordSet.properties.nsRecords[loweredIndex11];
          var nsRecordValue = {};
          nSRecordsArray.push(nsRecordValue);
          
          nsRecordValue['nsdname'] = nSRecordsItem.nsdname;
        }
        propertiesValue['NSRecords'] = nSRecordsArray;
      }
      
      if (parameters.recordSet.properties.ptrRecords !== null && parameters.recordSet.properties.ptrRecords !== undefined) {
        var pTRRecordsArray = [];
        for (var loweredIndex12 = 0; loweredIndex12 < parameters.recordSet.properties.ptrRecords.length; loweredIndex12 = loweredIndex12 + 1) {
          var pTRRecordsItem = parameters.recordSet.properties.ptrRecords[loweredIndex12];
          var ptrRecordValue = {};
          pTRRecordsArray.push(ptrRecordValue);
          
          ptrRecordValue['ptrdname'] = pTRRecordsItem.ptrdname;
        }
        propertiesValue['PTRRecords'] = pTRRecordsArray;
      }
      
      if (parameters.recordSet.properties.srvRecords !== null && parameters.recordSet.properties.srvRecords !== undefined) {
        var sRVRecordsArray = [];
        for (var loweredIndex13 = 0; loweredIndex13 < parameters.recordSet.properties.srvRecords.length; loweredIndex13 = loweredIndex13 + 1) {
          var sRVRecordsItem = parameters.recordSet.properties.srvRecords[loweredIndex13];
          var srvRecordValue = {};
          sRVRecordsArray.push(srvRecordValue);
          
          srvRecordValue['priority'] = sRVRecordsItem.priority;
          
          srvRecordValue['weight'] = sRVRecordsItem.weight;
          
          srvRecordValue['port'] = sRVRecordsItem.port;
          
          srvRecordValue['target'] = sRVRecordsItem.target;
        }
        propertiesValue['SRVRecords'] = sRVRecordsArray;
      }
      
      if (parameters.recordSet.properties.txtRecords !== null && parameters.recordSet.properties.txtRecords !== undefined) {
        var tXTRecordsArray = [];
        for (var loweredIndex14 = 0; loweredIndex14 < parameters.recordSet.properties.txtRecords.length; loweredIndex14 = loweredIndex14 + 1) {
          var tXTRecordsItem = parameters.recordSet.properties.txtRecords[loweredIndex14];
          var txtRecordValue = {};
          tXTRecordsArray.push(txtRecordValue);
          
          txtRecordValue['value'] = tXTRecordsItem.value;
        }
        propertiesValue['TXTRecords'] = tXTRecordsArray;
      }
      
      if (parameters.recordSet.properties.cnameRecord !== null && parameters.recordSet.properties.cnameRecord !== undefined) {
        var cNAMERecordValue = {};
        propertiesValue['CNAMERecord'] = cNAMERecordValue;
        
        cNAMERecordValue['cname'] = parameters.recordSet.properties.cnameRecord.cname;
      }
      
      if (parameters.recordSet.properties.soaRecord !== null && parameters.recordSet.properties.soaRecord !== undefined) {
        var sOARecordValue = {};
        propertiesValue['SOARecord'] = sOARecordValue;
        
        sOARecordValue['host'] = parameters.recordSet.properties.soaRecord.host;
        
        sOARecordValue['email'] = parameters.recordSet.properties.soaRecord.email;
        
        sOARecordValue['serialNumber'] = parameters.recordSet.properties.soaRecord.serialNumber;
        
        sOARecordValue['refreshTime'] = parameters.recordSet.properties.soaRecord.refreshTime;
        
        sOARecordValue['retryTime'] = parameters.recordSet.properties.soaRecord.retryTime;
        
        sOARecordValue['expireTime'] = parameters.recordSet.properties.soaRecord.expireTime;
        
        sOARecordValue['minimumTTL'] = parameters.recordSet.properties.soaRecord.minimumTtl;
      }
    }
    
    if (parameters.recordSet.id !== null && parameters.recordSet.id !== undefined) {
      recordSetCreateOrUpdateParametersValue['id'] = parameters.recordSet.id;
    }
    
    if (parameters.recordSet.name !== null && parameters.recordSet.name !== undefined) {
      recordSetCreateOrUpdateParametersValue['name'] = parameters.recordSet.name;
    }
    
    if (parameters.recordSet.type !== null && parameters.recordSet.type !== undefined) {
      recordSetCreateOrUpdateParametersValue['type'] = parameters.recordSet.type;
    }
    
    recordSetCreateOrUpdateParametersValue['location'] = parameters.recordSet.location;
    
    if (parameters.recordSet.tags !== null && parameters.recordSet.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.recordSet.tags) {
        var tagsValue = parameters.recordSet.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      recordSetCreateOrUpdateParametersValue['tags'] = tagsDictionary;
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = {};
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var recordSetInstance = { tags: {} };
        result.recordSet = recordSetInstance;
        
        var etagValue = responseDoc['etag'];
        if (etagValue !== null && etagValue !== undefined) {
          var etagInstance = etagValue;
          recordSetInstance.eTag = etagInstance;
        }
        
        var propertiesValue2 = responseDoc['properties'];
        if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
          var propertiesInstance = { aaaaRecords: [], aRecords: [], mxRecords: [], nsRecords: [], ptrRecords: [], srvRecords: [], txtRecords: [] };
          recordSetInstance.properties = propertiesInstance;
          
          var tTLValue = propertiesValue2['TTL'];
          if (tTLValue !== null && tTLValue !== undefined) {
            var tTLInstance = tTLValue;
            propertiesInstance.ttl = tTLInstance;
          }
          
          var aRecordsArray2 = propertiesValue2['ARecords'];
          if (aRecordsArray2 !== null && aRecordsArray2 !== undefined) {
            propertiesInstance.aRecords = [];
            for (var loweredIndex15 = 0; loweredIndex15 < aRecordsArray2.length; loweredIndex15 = loweredIndex15 + 1) {
              var aRecordsValue = aRecordsArray2[loweredIndex15];
              var aRecordInstance = {};
              propertiesInstance.aRecords.push(aRecordInstance);
              
              var ipv4AddressValue = aRecordsValue['ipv4Address'];
              if (ipv4AddressValue !== null && ipv4AddressValue !== undefined) {
                var ipv4AddressInstance = ipv4AddressValue;
                aRecordInstance.ipv4Address = ipv4AddressInstance;
              }
            }
          }
          
          var aAAARecordsArray2 = propertiesValue2['AAAARecords'];
          if (aAAARecordsArray2 !== null && aAAARecordsArray2 !== undefined) {
            propertiesInstance.aaaaRecords = [];
            for (var loweredIndex16 = 0; loweredIndex16 < aAAARecordsArray2.length; loweredIndex16 = loweredIndex16 + 1) {
              var aAAARecordsValue = aAAARecordsArray2[loweredIndex16];
              var aaaaRecordInstance = {};
              propertiesInstance.aaaaRecords.push(aaaaRecordInstance);
              
              var ipv6AddressValue = aAAARecordsValue['ipv6Address'];
              if (ipv6AddressValue !== null && ipv6AddressValue !== undefined) {
                var ipv6AddressInstance = ipv6AddressValue;
                aaaaRecordInstance.ipv6Address = ipv6AddressInstance;
              }
            }
          }
          
          var mXRecordsArray2 = propertiesValue2['MXRecords'];
          if (mXRecordsArray2 !== null && mXRecordsArray2 !== undefined) {
            propertiesInstance.mxRecords = [];
            for (var loweredIndex17 = 0; loweredIndex17 < mXRecordsArray2.length; loweredIndex17 = loweredIndex17 + 1) {
              var mXRecordsValue = mXRecordsArray2[loweredIndex17];
              var mxRecordInstance = {};
              propertiesInstance.mxRecords.push(mxRecordInstance);
              
              var preferenceValue = mXRecordsValue['preference'];
              if (preferenceValue !== null && preferenceValue !== undefined) {
                var preferenceInstance = preferenceValue;
                mxRecordInstance.preference = preferenceInstance;
              }
              
              var exchangeValue = mXRecordsValue['exchange'];
              if (exchangeValue !== null && exchangeValue !== undefined) {
                var exchangeInstance = exchangeValue;
                mxRecordInstance.exchange = exchangeInstance;
              }
            }
          }
          
          var nSRecordsArray2 = propertiesValue2['NSRecords'];
          if (nSRecordsArray2 !== null && nSRecordsArray2 !== undefined) {
            propertiesInstance.nsRecords = [];
            for (var loweredIndex18 = 0; loweredIndex18 < nSRecordsArray2.length; loweredIndex18 = loweredIndex18 + 1) {
              var nSRecordsValue = nSRecordsArray2[loweredIndex18];
              var nsRecordInstance = {};
              propertiesInstance.nsRecords.push(nsRecordInstance);
              
              var nsdnameValue = nSRecordsValue['nsdname'];
              if (nsdnameValue !== null && nsdnameValue !== undefined) {
                var nsdnameInstance = nsdnameValue;
                nsRecordInstance.nsdname = nsdnameInstance;
              }
            }
          }
          
          var pTRRecordsArray2 = propertiesValue2['PTRRecords'];
          if (pTRRecordsArray2 !== null && pTRRecordsArray2 !== undefined) {
            propertiesInstance.ptrRecords = [];
            for (var loweredIndex19 = 0; loweredIndex19 < pTRRecordsArray2.length; loweredIndex19 = loweredIndex19 + 1) {
              var pTRRecordsValue = pTRRecordsArray2[loweredIndex19];
              var ptrRecordInstance = {};
              propertiesInstance.ptrRecords.push(ptrRecordInstance);
              
              var ptrdnameValue = pTRRecordsValue['ptrdname'];
              if (ptrdnameValue !== null && ptrdnameValue !== undefined) {
                var ptrdnameInstance = ptrdnameValue;
                ptrRecordInstance.ptrdname = ptrdnameInstance;
              }
            }
          }
          
          var sRVRecordsArray2 = propertiesValue2['SRVRecords'];
          if (sRVRecordsArray2 !== null && sRVRecordsArray2 !== undefined) {
            propertiesInstance.srvRecords = [];
            for (var loweredIndex20 = 0; loweredIndex20 < sRVRecordsArray2.length; loweredIndex20 = loweredIndex20 + 1) {
              var sRVRecordsValue = sRVRecordsArray2[loweredIndex20];
              var srvRecordInstance = {};
              propertiesInstance.srvRecords.push(srvRecordInstance);
              
              var priorityValue = sRVRecordsValue['priority'];
              if (priorityValue !== null && priorityValue !== undefined) {
                var priorityInstance = priorityValue;
                srvRecordInstance.priority = priorityInstance;
              }
              
              var weightValue = sRVRecordsValue['weight'];
              if (weightValue !== null && weightValue !== undefined) {
                var weightInstance = weightValue;
                srvRecordInstance.weight = weightInstance;
              }
              
              var portValue = sRVRecordsValue['port'];
              if (portValue !== null && portValue !== undefined) {
                var portInstance = portValue;
                srvRecordInstance.port = portInstance;
              }
              
              var targetValue = sRVRecordsValue['target'];
              if (targetValue !== null && targetValue !== undefined) {
                var targetInstance = targetValue;
                srvRecordInstance.target = targetInstance;
              }
            }
          }
          
          var tXTRecordsArray2 = propertiesValue2['TXTRecords'];
          if (tXTRecordsArray2 !== null && tXTRecordsArray2 !== undefined) {
            propertiesInstance.txtRecords = [];
            for (var loweredIndex21 = 0; loweredIndex21 < tXTRecordsArray2.length; loweredIndex21 = loweredIndex21 + 1) {
              var tXTRecordsValue = tXTRecordsArray2[loweredIndex21];
              var txtRecordInstance = {};
              propertiesInstance.txtRecords.push(txtRecordInstance);
              
              var valueValue = tXTRecordsValue['value'];
              if (valueValue !== null && valueValue !== undefined) {
                var valueInstance = valueValue;
                txtRecordInstance.value = valueInstance;
              }
            }
          }
          
          var cNAMERecordValue2 = propertiesValue2['CNAMERecord'];
          if (cNAMERecordValue2 !== null && cNAMERecordValue2 !== undefined) {
            var cNAMERecordInstance = {};
            propertiesInstance.cnameRecord = cNAMERecordInstance;
            
            var cnameValue = cNAMERecordValue2['cname'];
            if (cnameValue !== null && cnameValue !== undefined) {
              var cnameInstance = cnameValue;
              cNAMERecordInstance.cname = cnameInstance;
            }
          }
          
          var sOARecordValue2 = propertiesValue2['SOARecord'];
          if (sOARecordValue2 !== null && sOARecordValue2 !== undefined) {
            var sOARecordInstance = {};
            propertiesInstance.soaRecord = sOARecordInstance;
            
            var hostValue = sOARecordValue2['host'];
            if (hostValue !== null && hostValue !== undefined) {
              var hostInstance = hostValue;
              sOARecordInstance.host = hostInstance;
            }
            
            var emailValue = sOARecordValue2['email'];
            if (emailValue !== null && emailValue !== undefined) {
              var emailInstance = emailValue;
              sOARecordInstance.email = emailInstance;
            }
            
            var serialNumberValue = sOARecordValue2['serialNumber'];
            if (serialNumberValue !== null && serialNumberValue !== undefined) {
              var serialNumberInstance = serialNumberValue;
              sOARecordInstance.serialNumber = serialNumberInstance;
            }
            
            var refreshTimeValue = sOARecordValue2['refreshTime'];
            if (refreshTimeValue !== null && refreshTimeValue !== undefined) {
              var refreshTimeInstance = refreshTimeValue;
              sOARecordInstance.refreshTime = refreshTimeInstance;
            }
            
            var retryTimeValue = sOARecordValue2['retryTime'];
            if (retryTimeValue !== null && retryTimeValue !== undefined) {
              var retryTimeInstance = retryTimeValue;
              sOARecordInstance.retryTime = retryTimeInstance;
            }
            
            var expireTimeValue = sOARecordValue2['expireTime'];
            if (expireTimeValue !== null && expireTimeValue !== undefined) {
              var expireTimeInstance = expireTimeValue;
              sOARecordInstance.expireTime = expireTimeInstance;
            }
            
            var minimumTTLValue = sOARecordValue2['minimumTTL'];
            if (minimumTTLValue !== null && minimumTTLValue !== undefined) {
              var minimumTTLInstance = minimumTTLValue;
              sOARecordInstance.minimumTtl = minimumTTLInstance;
            }
          }
        }
        
        var idValue = responseDoc['id'];
        if (idValue !== null && idValue !== undefined) {
          var idInstance = idValue;
          recordSetInstance.id = idInstance;
        }
        
        var nameValue = responseDoc['name'];
        if (nameValue !== null && nameValue !== undefined) {
          var nameInstance = nameValue;
          recordSetInstance.name = nameInstance;
        }
        
        var typeValue = responseDoc['type'];
        if (typeValue !== null && typeValue !== undefined) {
          var typeInstance = typeValue;
          recordSetInstance.type = typeInstance;
        }
        
        var locationValue = responseDoc['location'];
        if (locationValue !== null && locationValue !== undefined) {
          var locationInstance = locationValue;
          recordSetInstance.location = locationInstance;
        }
        
        var tagsSequenceElement = responseDoc['tags'];
        if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
          for (var property in tagsSequenceElement) {
            var tagsKey2 = property;
            var tagsValue2 = tagsSequenceElement[property];
            recordSetInstance.tags[tagsKey2] = tagsValue2;
          }
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Removes a RecordSet from a DNS zone.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} zoneName The name of the zone without a terminating dot.
   * 
   * @param {string} relativeRecordSetName The name of the RecordSet, relative
   * to the name of the zone.
   * 
   * @param {RecordType} recordType The type of DNS record.
   * 
   * @param {RecordSetDeleteParameters} parameters The parameters supplied to
   * delete a record set.
   * 
   * @param {string} [parameters.ifMatch] Gets or sets the If-Match
   * pre-condition. The delete operation will be performedonly if the ETag of
   * the zone on the server matches this value.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RecordSetOperations.prototype.deleteMethod = function(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    if (relativeRecordSetName === null || relativeRecordSetName === undefined) {
      return callback(new Error('relativeRecordSetName cannot be null.'));
    }
    if (recordType === null || recordType === undefined) {
      return callback(new Error('recordType cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(recordType !== null && recordType !== undefined ? recordType.toString() : 'A');
    url2 = url2 + '/';
    url2 = url2 + relativeRecordSetName;
    var queryParameters = [];
    queryParameters.push('api-version=2015-05-04-preview');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (parameters.ifMatch !== null && parameters.ifMatch !== undefined) {
      httpRequest.headers['If-Match'] = parameters.ifMatch;
    }
    
    // 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 >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a RecordSet.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} zoneName The name of the zone without a terminating dot.
   * 
   * @param {string} relativeRecordSetName The name of the RecordSet, relative
   * to the name of the zone.
   * 
   * @param {RecordType} recordType The type of DNS record.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RecordSetOperations.prototype.get = function(resourceGroupName, zoneName, relativeRecordSetName, recordType, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    if (relativeRecordSetName === null || relativeRecordSetName === undefined) {
      return callback(new Error('relativeRecordSetName cannot be null.'));
    }
    if (recordType === null || recordType === undefined) {
      return callback(new Error('recordType cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    url2 = url2 + '/';
    url2 = url2 + encodeURIComponent(recordType !== null && recordType !== undefined ? recordType.toString() : 'A');
    url2 = url2 + '/';
    url2 = url2 + relativeRecordSetName;
    var queryParameters = [];
    queryParameters.push('api-version=2015-05-04-preview');
    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['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = {};
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var recordSetInstance = { tags: {} };
        result.recordSet = recordSetInstance;
        
        var etagValue = responseDoc['etag'];
        if (etagValue !== null && etagValue !== undefined) {
          var etagInstance = etagValue;
          recordSetInstance.eTag = etagInstance;
        }
        
        var propertiesValue = responseDoc['properties'];
        if (propertiesValue !== null && propertiesValue !== undefined) {
          var propertiesInstance = { aaaaRecords: [], aRecords: [], mxRecords: [], nsRecords: [], ptrRecords: [], srvRecords: [], txtRecords: [] };
          recordSetInstance.properties = propertiesInstance;
          
          var tTLValue = propertiesValue['TTL'];
          if (tTLValue !== null && tTLValue !== undefined) {
            var tTLInstance = tTLValue;
            propertiesInstance.ttl = tTLInstance;
          }
          
          var aRecordsArray = propertiesValue['ARecords'];
          if (aRecordsArray !== null && aRecordsArray !== undefined) {
            propertiesInstance.aRecords = [];
            for (var loweredIndex1 = 0; loweredIndex1 < aRecordsArray.length; loweredIndex1 = loweredIndex1 + 1) {
              var aRecordsValue = aRecordsArray[loweredIndex1];
              var aRecordInstance = {};
              propertiesInstance.aRecords.push(aRecordInstance);
              
              var ipv4AddressValue = aRecordsValue['ipv4Address'];
              if (ipv4AddressValue !== null && ipv4AddressValue !== undefined) {
                var ipv4AddressInstance = ipv4AddressValue;
                aRecordInstance.ipv4Address = ipv4AddressInstance;
              }
            }
          }
          
          var aAAARecordsArray = propertiesValue['AAAARecords'];
          if (aAAARecordsArray !== null && aAAARecordsArray !== undefined) {
            propertiesInstance.aaaaRecords = [];
            for (var loweredIndex2 = 0; loweredIndex2 < aAAARecordsArray.length; loweredIndex2 = loweredIndex2 + 1) {
              var aAAARecordsValue = aAAARecordsArray[loweredIndex2];
              var aaaaRecordInstance = {};
              propertiesInstance.aaaaRecords.push(aaaaRecordInstance);
              
              var ipv6AddressValue = aAAARecordsValue['ipv6Address'];
              if (ipv6AddressValue !== null && ipv6AddressValue !== undefined) {
                var ipv6AddressInstance = ipv6AddressValue;
                aaaaRecordInstance.ipv6Address = ipv6AddressInstance;
              }
            }
          }
          
          var mXRecordsArray = propertiesValue['MXRecords'];
          if (mXRecordsArray !== null && mXRecordsArray !== undefined) {
            propertiesInstance.mxRecords = [];
            for (var loweredIndex3 = 0; loweredIndex3 < mXRecordsArray.length; loweredIndex3 = loweredIndex3 + 1) {
              var mXRecordsValue = mXRecordsArray[loweredIndex3];
              var mxRecordInstance = {};
              propertiesInstance.mxRecords.push(mxRecordInstance);
              
              var preferenceValue = mXRecordsValue['preference'];
              if (preferenceValue !== null && preferenceValue !== undefined) {
                var preferenceInstance = preferenceValue;
                mxRecordInstance.preference = preferenceInstance;
              }
              
              var exchangeValue = mXRecordsValue['exchange'];
              if (exchangeValue !== null && exchangeValue !== undefined) {
                var exchangeInstance = exchangeValue;
                mxRecordInstance.exchange = exchangeInstance;
              }
            }
          }
          
          var nSRecordsArray = propertiesValue['NSRecords'];
          if (nSRecordsArray !== null && nSRecordsArray !== undefined) {
            propertiesInstance.nsRecords = [];
            for (var loweredIndex4 = 0; loweredIndex4 < nSRecordsArray.length; loweredIndex4 = loweredIndex4 + 1) {
              var nSRecordsValue = nSRecordsArray[loweredIndex4];
              var nsRecordInstance = {};
              propertiesInstance.nsRecords.push(nsRecordInstance);
              
              var nsdnameValue = nSRecordsValue['nsdname'];
              if (nsdnameValue !== null && nsdnameValue !== undefined) {
                var nsdnameInstance = nsdnameValue;
                nsRecordInstance.nsdname = nsdnameInstance;
              }
            }
          }
          
          var pTRRecordsArray = propertiesValue['PTRRecords'];
          if (pTRRecordsArray !== null && pTRRecordsArray !== undefined) {
            propertiesInstance.ptrRecords = [];
            for (var loweredIndex5 = 0; loweredIndex5 < pTRRecordsArray.length; loweredIndex5 = loweredIndex5 + 1) {
              var pTRRecordsValue = pTRRecordsArray[loweredIndex5];
              var ptrRecordInstance = {};
              propertiesInstance.ptrRecords.push(ptrRecordInstance);
              
              var ptrdnameValue = pTRRecordsValue['ptrdname'];
              if (ptrdnameValue !== null && ptrdnameValue !== undefined) {
                var ptrdnameInstance = ptrdnameValue;
                ptrRecordInstance.ptrdname = ptrdnameInstance;
              }
            }
          }
          
          var sRVRecordsArray = propertiesValue['SRVRecords'];
          if (sRVRecordsArray !== null && sRVRecordsArray !== undefined) {
            propertiesInstance.srvRecords = [];
            for (var loweredIndex6 = 0; loweredIndex6 < sRVRecordsArray.length; loweredIndex6 = loweredIndex6 + 1) {
              var sRVRecordsValue = sRVRecordsArray[loweredIndex6];
              var srvRecordInstance = {};
              propertiesInstance.srvRecords.push(srvRecordInstance);
              
              var priorityValue = sRVRecordsValue['priority'];
              if (priorityValue !== null && priorityValue !== undefined) {
                var priorityInstance = priorityValue;
                srvRecordInstance.priority = priorityInstance;
              }
              
              var weightValue = sRVRecordsValue['weight'];
              if (weightValue !== null && weightValue !== undefined) {
                var weightInstance = weightValue;
                srvRecordInstance.weight = weightInstance;
              }
              
              var portValue = sRVRecordsValue['port'];
              if (portValue !== null && portValue !== undefined) {
                var portInstance = portValue;
                srvRecordInstance.port = portInstance;
              }
              
              var targetValue = sRVRecordsValue['target'];
              if (targetValue !== null && targetValue !== undefined) {
                var targetInstance = targetValue;
                srvRecordInstance.target = targetInstance;
              }
            }
          }
          
          var tXTRecordsArray = propertiesValue['TXTRecords'];
          if (tXTRecordsArray !== null && tXTRecordsArray !== undefined) {
            propertiesInstance.txtRecords = [];
            for (var loweredIndex7 = 0; loweredIndex7 < tXTRecordsArray.length; loweredIndex7 = loweredIndex7 + 1) {
              var tXTRecordsValue = tXTRecordsArray[loweredIndex7];
              var txtRecordInstance = {};
              propertiesInstance.txtRecords.push(txtRecordInstance);
              
              var valueValue = tXTRecordsValue['value'];
              if (valueValue !== null && valueValue !== undefined) {
                var valueInstance = valueValue;
                txtRecordInstance.value = valueInstance;
              }
            }
          }
          
          var cNAMERecordValue = propertiesValue['CNAMERecord'];
          if (cNAMERecordValue !== null && cNAMERecordValue !== undefined) {
            var cNAMERecordInstance = {};
            propertiesInstance.cnameRecord = cNAMERecordInstance;
            
            var cnameValue = cNAMERecordValue['cname'];
            if (cnameValue !== null && cnameValue !== undefined) {
              var cnameInstance = cnameValue;
              cNAMERecordInstance.cname = cnameInstance;
            }
          }
          
          var sOARecordValue = propertiesValue['SOARecord'];
          if (sOARecordValue !== null && sOARecordValue !== undefined) {
            var sOARecordInstance = {};
            propertiesInstance.soaRecord = sOARecordInstance;
            
            var hostValue = sOARecordValue['host'];
            if (hostValue !== null && hostValue !== undefined) {
              var hostInstance = hostValue;
              sOARecordInstance.host = hostInstance;
            }
            
            var emailValue = sOARecordValue['email'];
            if (emailValue !== null && emailValue !== undefined) {
              var emailInstance = emailValue;
              sOARecordInstance.email = emailInstance;
            }
            
            var serialNumberValue = sOARecordValue['serialNumber'];
            if (serialNumberValue !== null && serialNumberValue !== undefined) {
              var serialNumberInstance = serialNumberValue;
              sOARecordInstance.serialNumber = serialNumberInstance;
            }
            
            var refreshTimeValue = sOARecordValue['refreshTime'];
            if (refreshTimeValue !== null && refreshTimeValue !== undefined) {
              var refreshTimeInstance = refreshTimeValue;
              sOARecordInstance.refreshTime = refreshTimeInstance;
            }
            
            var retryTimeValue = sOARecordValue['retryTime'];
            if (retryTimeValue !== null && retryTimeValue !== undefined) {
              var retryTimeInstance = retryTimeValue;
              sOARecordInstance.retryTime = retryTimeInstance;
            }
            
            var expireTimeValue = sOARecordValue['expireTime'];
            if (expireTimeValue !== null && expireTimeValue !== undefined) {
              var expireTimeInstance = expireTimeValue;
              sOARecordInstance.expireTime = expireTimeInstance;
            }
            
            var minimumTTLValue = sOARecordValue['minimumTTL'];
            if (minimumTTLValue !== null && minimumTTLValue !== undefined) {
              var minimumTTLInstance = minimumTTLValue;
              sOARecordInstance.minimumTtl = minimumTTLInstance;
            }
          }
        }
        
        var idValue = responseDoc['id'];
        if (idValue !== null && idValue !== undefined) {
          var idInstance = idValue;
          recordSetInstance.id = idInstance;
        }
        
        var nameValue = responseDoc['name'];
        if (nameValue !== null && nameValue !== undefined) {
          var nameInstance = nameValue;
          recordSetInstance.name = nameInstance;
        }
        
        var typeValue = responseDoc['type'];
        if (typeValue !== null && typeValue !== undefined) {
          var typeInstance = typeValue;
          recordSetInstance.type = typeInstance;
        }
        
        var locationValue = responseDoc['location'];
        if (locationValue !== null && locationValue !== undefined) {
          var locationInstance = locationValue;
          recordSetInstance.location = locationInstance;
        }
        
        var tagsSequenceElement = responseDoc['tags'];
        if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
          for (var property in tagsSequenceElement) {
            var tagsKey = property;
            var tagsValue = tagsSequenceElement[property];
            recordSetInstance.tags[tagsKey] = tagsValue;
          }
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the RecordSets of a specified type in a DNS zone.
   * 
   * @param {string} resourceGroupName The name of the resource group that
   * contains the zone.
   * 
   * @param {string} zoneName The name of the zone from which to enumerate
   * RecordsSets.
   * 
   * @param {RecordType} [recordType] The type of record sets to enumerate.
   * 
   * @param {RecordSetListParameters} [parametersOrCallback] Query parameters.
   * If null is passed returns the default number of zones.
   * 
   * @param {string} [parametersOrCallback.top] Gets or sets the number of
   * elements to retrieve (first N elements).
   * 
   * @param {string} [parametersOrCallback.filter] Gets or sets the filter for
   * the records enumeration.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RecordSetOperations.prototype.list = function(resourceGroupName, zoneName, recordType, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    url2 = url2 + '/';
    if (recordType !== null && recordType !== undefined) {
      url2 = url2 + encodeURIComponent(recordType !== null && recordType !== undefined ? recordType.toString() : 'A');
    }
    var queryParameters = [];
    if (parameters !== null && parameters !== undefined && parameters.top !== null && parameters.top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(parameters.top));
    }
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.filter !== null && parameters.filter !== undefined) {
      odataFilter.push(encodeURIComponent(parameters.filter));
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    queryParameters.push('api-version=2015-05-04-preview');
    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['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = { recordSets: [] };
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var valueArray = responseDoc['value'];
        if (valueArray !== null && valueArray !== undefined) {
          for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
            var valueValue = valueArray[loweredIndex1];
            var recordSetInstance = { tags: {} };
            result.recordSets.push(recordSetInstance);
            
            var etagValue = valueValue['etag'];
            if (etagValue !== null && etagValue !== undefined) {
              var etagInstance = etagValue;
              recordSetInstance.eTag = etagInstance;
            }
            
            var propertiesValue = valueValue['properties'];
            if (propertiesValue !== null && propertiesValue !== undefined) {
              var propertiesInstance = { aaaaRecords: [], aRecords: [], mxRecords: [], nsRecords: [], ptrRecords: [], srvRecords: [], txtRecords: [] };
              recordSetInstance.properties = propertiesInstance;
              
              var tTLValue = propertiesValue['TTL'];
              if (tTLValue !== null && tTLValue !== undefined) {
                var tTLInstance = tTLValue;
                propertiesInstance.ttl = tTLInstance;
              }
              
              var aRecordsArray = propertiesValue['ARecords'];
              if (aRecordsArray !== null && aRecordsArray !== undefined) {
                propertiesInstance.aRecords = [];
                for (var loweredIndex2 = 0; loweredIndex2 < aRecordsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var aRecordsValue = aRecordsArray[loweredIndex2];
                  var aRecordInstance = {};
                  propertiesInstance.aRecords.push(aRecordInstance);
                  
                  var ipv4AddressValue = aRecordsValue['ipv4Address'];
                  if (ipv4AddressValue !== null && ipv4AddressValue !== undefined) {
                    var ipv4AddressInstance = ipv4AddressValue;
                    aRecordInstance.ipv4Address = ipv4AddressInstance;
                  }
                }
              }
              
              var aAAARecordsArray = propertiesValue['AAAARecords'];
              if (aAAARecordsArray !== null && aAAARecordsArray !== undefined) {
                propertiesInstance.aaaaRecords = [];
                for (var loweredIndex3 = 0; loweredIndex3 < aAAARecordsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                  var aAAARecordsValue = aAAARecordsArray[loweredIndex3];
                  var aaaaRecordInstance = {};
                  propertiesInstance.aaaaRecords.push(aaaaRecordInstance);
                  
                  var ipv6AddressValue = aAAARecordsValue['ipv6Address'];
                  if (ipv6AddressValue !== null && ipv6AddressValue !== undefined) {
                    var ipv6AddressInstance = ipv6AddressValue;
                    aaaaRecordInstance.ipv6Address = ipv6AddressInstance;
                  }
                }
              }
              
              var mXRecordsArray = propertiesValue['MXRecords'];
              if (mXRecordsArray !== null && mXRecordsArray !== undefined) {
                propertiesInstance.mxRecords = [];
                for (var loweredIndex4 = 0; loweredIndex4 < mXRecordsArray.length; loweredIndex4 = loweredIndex4 + 1) {
                  var mXRecordsValue = mXRecordsArray[loweredIndex4];
                  var mxRecordInstance = {};
                  propertiesInstance.mxRecords.push(mxRecordInstance);
                  
                  var preferenceValue = mXRecordsValue['preference'];
                  if (preferenceValue !== null && preferenceValue !== undefined) {
                    var preferenceInstance = preferenceValue;
                    mxRecordInstance.preference = preferenceInstance;
                  }
                  
                  var exchangeValue = mXRecordsValue['exchange'];
                  if (exchangeValue !== null && exchangeValue !== undefined) {
                    var exchangeInstance = exchangeValue;
                    mxRecordInstance.exchange = exchangeInstance;
                  }
                }
              }
              
              var nSRecordsArray = propertiesValue['NSRecords'];
              if (nSRecordsArray !== null && nSRecordsArray !== undefined) {
                propertiesInstance.nsRecords = [];
                for (var loweredIndex5 = 0; loweredIndex5 < nSRecordsArray.length; loweredIndex5 = loweredIndex5 + 1) {
                  var nSRecordsValue = nSRecordsArray[loweredIndex5];
                  var nsRecordInstance = {};
                  propertiesInstance.nsRecords.push(nsRecordInstance);
                  
                  var nsdnameValue = nSRecordsValue['nsdname'];
                  if (nsdnameValue !== null && nsdnameValue !== undefined) {
                    var nsdnameInstance = nsdnameValue;
                    nsRecordInstance.nsdname = nsdnameInstance;
                  }
                }
              }
              
              var pTRRecordsArray = propertiesValue['PTRRecords'];
              if (pTRRecordsArray !== null && pTRRecordsArray !== undefined) {
                propertiesInstance.ptrRecords = [];
                for (var loweredIndex6 = 0; loweredIndex6 < pTRRecordsArray.length; loweredIndex6 = loweredIndex6 + 1) {
                  var pTRRecordsValue = pTRRecordsArray[loweredIndex6];
                  var ptrRecordInstance = {};
                  propertiesInstance.ptrRecords.push(ptrRecordInstance);
                  
                  var ptrdnameValue = pTRRecordsValue['ptrdname'];
                  if (ptrdnameValue !== null && ptrdnameValue !== undefined) {
                    var ptrdnameInstance = ptrdnameValue;
                    ptrRecordInstance.ptrdname = ptrdnameInstance;
                  }
                }
              }
              
              var sRVRecordsArray = propertiesValue['SRVRecords'];
              if (sRVRecordsArray !== null && sRVRecordsArray !== undefined) {
                propertiesInstance.srvRecords = [];
                for (var loweredIndex7 = 0; loweredIndex7 < sRVRecordsArray.length; loweredIndex7 = loweredIndex7 + 1) {
                  var sRVRecordsValue = sRVRecordsArray[loweredIndex7];
                  var srvRecordInstance = {};
                  propertiesInstance.srvRecords.push(srvRecordInstance);
                  
                  var priorityValue = sRVRecordsValue['priority'];
                  if (priorityValue !== null && priorityValue !== undefined) {
                    var priorityInstance = priorityValue;
                    srvRecordInstance.priority = priorityInstance;
                  }
                  
                  var weightValue = sRVRecordsValue['weight'];
                  if (weightValue !== null && weightValue !== undefined) {
                    var weightInstance = weightValue;
                    srvRecordInstance.weight = weightInstance;
                  }
                  
                  var portValue = sRVRecordsValue['port'];
                  if (portValue !== null && portValue !== undefined) {
                    var portInstance = portValue;
                    srvRecordInstance.port = portInstance;
                  }
                  
                  var targetValue = sRVRecordsValue['target'];
                  if (targetValue !== null && targetValue !== undefined) {
                    var targetInstance = targetValue;
                    srvRecordInstance.target = targetInstance;
                  }
                }
              }
              
              var tXTRecordsArray = propertiesValue['TXTRecords'];
              if (tXTRecordsArray !== null && tXTRecordsArray !== undefined) {
                propertiesInstance.txtRecords = [];
                for (var loweredIndex8 = 0; loweredIndex8 < tXTRecordsArray.length; loweredIndex8 = loweredIndex8 + 1) {
                  var tXTRecordsValue = tXTRecordsArray[loweredIndex8];
                  var txtRecordInstance = {};
                  propertiesInstance.txtRecords.push(txtRecordInstance);
                  
                  var valueValue2 = tXTRecordsValue['value'];
                  if (valueValue2 !== null && valueValue2 !== undefined) {
                    var valueInstance = valueValue2;
                    txtRecordInstance.value = valueInstance;
                  }
                }
              }
              
              var cNAMERecordValue = propertiesValue['CNAMERecord'];
              if (cNAMERecordValue !== null && cNAMERecordValue !== undefined) {
                var cNAMERecordInstance = {};
                propertiesInstance.cnameRecord = cNAMERecordInstance;
                
                var cnameValue = cNAMERecordValue['cname'];
                if (cnameValue !== null && cnameValue !== undefined) {
                  var cnameInstance = cnameValue;
                  cNAMERecordInstance.cname = cnameInstance;
                }
              }
              
              var sOARecordValue = propertiesValue['SOARecord'];
              if (sOARecordValue !== null && sOARecordValue !== undefined) {
                var sOARecordInstance = {};
                propertiesInstance.soaRecord = sOARecordInstance;
                
                var hostValue = sOARecordValue['host'];
                if (hostValue !== null && hostValue !== undefined) {
                  var hostInstance = hostValue;
                  sOARecordInstance.host = hostInstance;
                }
                
                var emailValue = sOARecordValue['email'];
                if (emailValue !== null && emailValue !== undefined) {
                  var emailInstance = emailValue;
                  sOARecordInstance.email = emailInstance;
                }
                
                var serialNumberValue = sOARecordValue['serialNumber'];
                if (serialNumberValue !== null && serialNumberValue !== undefined) {
                  var serialNumberInstance = serialNumberValue;
                  sOARecordInstance.serialNumber = serialNumberInstance;
                }
                
                var refreshTimeValue = sOARecordValue['refreshTime'];
                if (refreshTimeValue !== null && refreshTimeValue !== undefined) {
                  var refreshTimeInstance = refreshTimeValue;
                  sOARecordInstance.refreshTime = refreshTimeInstance;
                }
                
                var retryTimeValue = sOARecordValue['retryTime'];
                if (retryTimeValue !== null && retryTimeValue !== undefined) {
                  var retryTimeInstance = retryTimeValue;
                  sOARecordInstance.retryTime = retryTimeInstance;
                }
                
                var expireTimeValue = sOARecordValue['expireTime'];
                if (expireTimeValue !== null && expireTimeValue !== undefined) {
                  var expireTimeInstance = expireTimeValue;
                  sOARecordInstance.expireTime = expireTimeInstance;
                }
                
                var minimumTTLValue = sOARecordValue['minimumTTL'];
                if (minimumTTLValue !== null && minimumTTLValue !== undefined) {
                  var minimumTTLInstance = minimumTTLValue;
                  sOARecordInstance.minimumTtl = minimumTTLInstance;
                }
              }
            }
            
            var idValue = valueValue['id'];
            if (idValue !== null && idValue !== undefined) {
              var idInstance = idValue;
              recordSetInstance.id = idInstance;
            }
            
            var nameValue = valueValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              recordSetInstance.name = nameInstance;
            }
            
            var typeValue = valueValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              recordSetInstance.type = typeInstance;
            }
            
            var locationValue = valueValue['location'];
            if (locationValue !== null && locationValue !== undefined) {
              var locationInstance = locationValue;
              recordSetInstance.location = locationInstance;
            }
            
            var tagsSequenceElement = valueValue['tags'];
            if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
              for (var property in tagsSequenceElement) {
                var tagsKey = property;
                var tagsValue = tagsSequenceElement[property];
                recordSetInstance.tags[tagsKey] = tagsValue;
              }
            }
          }
        }
        
        var nextLinkValue = responseDoc['nextLink'];
        if (nextLinkValue !== null && nextLinkValue !== undefined) {
          var nextLinkInstance = nextLinkValue;
          result.nextLink = nextLinkInstance;
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists all RecordSets in a DNS zone.
   * 
   * @param {string} resourceGroupName The name of the resource group that
   * contains the zone.
   * 
   * @param {string} zoneName The name of the zone from which to enumerate
   * RecordSets.
   * 
   * @param {RecordSetListParameters} [parametersOrCallback] Query parameters.
   * If null is passed returns the default number of zones.
   * 
   * @param {string} [parametersOrCallback.top] Gets or sets the number of
   * elements to retrieve (first N elements).
   * 
   * @param {string} [parametersOrCallback.filter] Gets or sets the filter for
   * the records enumeration.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RecordSetOperations.prototype.listAll = function(resourceGroupName, zoneName, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    url2 = url2 + '/recordsets';
    var queryParameters = [];
    if (parameters !== null && parameters !== undefined && parameters.top !== null && parameters.top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(parameters.top));
    }
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.filter !== null && parameters.filter !== undefined) {
      odataFilter.push(encodeURIComponent(parameters.filter));
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    queryParameters.push('api-version=2015-05-04-preview');
    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['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = { recordSets: [] };
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var valueArray = responseDoc['value'];
        if (valueArray !== null && valueArray !== undefined) {
          for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
            var valueValue = valueArray[loweredIndex1];
            var recordSetInstance = { tags: {} };
            result.recordSets.push(recordSetInstance);
            
            var etagValue = valueValue['etag'];
            if (etagValue !== null && etagValue !== undefined) {
              var etagInstance = etagValue;
              recordSetInstance.eTag = etagInstance;
            }
            
            var propertiesValue = valueValue['properties'];
            if (propertiesValue !== null && propertiesValue !== undefined) {
              var propertiesInstance = { aaaaRecords: [], aRecords: [], mxRecords: [], nsRecords: [], ptrRecords: [], srvRecords: [], txtRecords: [] };
              recordSetInstance.properties = propertiesInstance;
              
              var tTLValue = propertiesValue['TTL'];
              if (tTLValue !== null && tTLValue !== undefined) {
                var tTLInstance = tTLValue;
                propertiesInstance.ttl = tTLInstance;
              }
              
              var aRecordsArray = propertiesValue['ARecords'];
              if (aRecordsArray !== null && aRecordsArray !== undefined) {
                propertiesInstance.aRecords = [];
                for (var loweredIndex2 = 0; loweredIndex2 < aRecordsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var aRecordsValue = aRecordsArray[loweredIndex2];
                  var aRecordInstance = {};
                  propertiesInstance.aRecords.push(aRecordInstance);
                  
                  var ipv4AddressValue = aRecordsValue['ipv4Address'];
                  if (ipv4AddressValue !== null && ipv4AddressValue !== undefined) {
                    var ipv4AddressInstance = ipv4AddressValue;
                    aRecordInstance.ipv4Address = ipv4AddressInstance;
                  }
                }
              }
              
              var aAAARecordsArray = propertiesValue['AAAARecords'];
              if (aAAARecordsArray !== null && aAAARecordsArray !== undefined) {
                propertiesInstance.aaaaRecords = [];
                for (var loweredIndex3 = 0; loweredIndex3 < aAAARecordsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                  var aAAARecordsValue = aAAARecordsArray[loweredIndex3];
                  var aaaaRecordInstance = {};
                  propertiesInstance.aaaaRecords.push(aaaaRecordInstance);
                  
                  var ipv6AddressValue = aAAARecordsValue['ipv6Address'];
                  if (ipv6AddressValue !== null && ipv6AddressValue !== undefined) {
                    var ipv6AddressInstance = ipv6AddressValue;
                    aaaaRecordInstance.ipv6Address = ipv6AddressInstance;
                  }
                }
              }
              
              var mXRecordsArray = propertiesValue['MXRecords'];
              if (mXRecordsArray !== null && mXRecordsArray !== undefined) {
                propertiesInstance.mxRecords = [];
                for (var loweredIndex4 = 0; loweredIndex4 < mXRecordsArray.length; loweredIndex4 = loweredIndex4 + 1) {
                  var mXRecordsValue = mXRecordsArray[loweredIndex4];
                  var mxRecordInstance = {};
                  propertiesInstance.mxRecords.push(mxRecordInstance);
                  
                  var preferenceValue = mXRecordsValue['preference'];
                  if (preferenceValue !== null && preferenceValue !== undefined) {
                    var preferenceInstance = preferenceValue;
                    mxRecordInstance.preference = preferenceInstance;
                  }
                  
                  var exchangeValue = mXRecordsValue['exchange'];
                  if (exchangeValue !== null && exchangeValue !== undefined) {
                    var exchangeInstance = exchangeValue;
                    mxRecordInstance.exchange = exchangeInstance;
                  }
                }
              }
              
              var nSRecordsArray = propertiesValue['NSRecords'];
              if (nSRecordsArray !== null && nSRecordsArray !== undefined) {
                propertiesInstance.nsRecords = [];
                for (var loweredIndex5 = 0; loweredIndex5 < nSRecordsArray.length; loweredIndex5 = loweredIndex5 + 1) {
                  var nSRecordsValue = nSRecordsArray[loweredIndex5];
                  var nsRecordInstance = {};
                  propertiesInstance.nsRecords.push(nsRecordInstance);
                  
                  var nsdnameValue = nSRecordsValue['nsdname'];
                  if (nsdnameValue !== null && nsdnameValue !== undefined) {
                    var nsdnameInstance = nsdnameValue;
                    nsRecordInstance.nsdname = nsdnameInstance;
                  }
                }
              }
              
              var pTRRecordsArray = propertiesValue['PTRRecords'];
              if (pTRRecordsArray !== null && pTRRecordsArray !== undefined) {
                propertiesInstance.ptrRecords = [];
                for (var loweredIndex6 = 0; loweredIndex6 < pTRRecordsArray.length; loweredIndex6 = loweredIndex6 + 1) {
                  var pTRRecordsValue = pTRRecordsArray[loweredIndex6];
                  var ptrRecordInstance = {};
                  propertiesInstance.ptrRecords.push(ptrRecordInstance);
                  
                  var ptrdnameValue = pTRRecordsValue['ptrdname'];
                  if (ptrdnameValue !== null && ptrdnameValue !== undefined) {
                    var ptrdnameInstance = ptrdnameValue;
                    ptrRecordInstance.ptrdname = ptrdnameInstance;
                  }
                }
              }
              
              var sRVRecordsArray = propertiesValue['SRVRecords'];
              if (sRVRecordsArray !== null && sRVRecordsArray !== undefined) {
                propertiesInstance.srvRecords = [];
                for (var loweredIndex7 = 0; loweredIndex7 < sRVRecordsArray.length; loweredIndex7 = loweredIndex7 + 1) {
                  var sRVRecordsValue = sRVRecordsArray[loweredIndex7];
                  var srvRecordInstance = {};
                  propertiesInstance.srvRecords.push(srvRecordInstance);
                  
                  var priorityValue = sRVRecordsValue['priority'];
                  if (priorityValue !== null && priorityValue !== undefined) {
                    var priorityInstance = priorityValue;
                    srvRecordInstance.priority = priorityInstance;
                  }
                  
                  var weightValue = sRVRecordsValue['weight'];
                  if (weightValue !== null && weightValue !== undefined) {
                    var weightInstance = weightValue;
                    srvRecordInstance.weight = weightInstance;
                  }
                  
                  var portValue = sRVRecordsValue['port'];
                  if (portValue !== null && portValue !== undefined) {
                    var portInstance = portValue;
                    srvRecordInstance.port = portInstance;
                  }
                  
                  var targetValue = sRVRecordsValue['target'];
                  if (targetValue !== null && targetValue !== undefined) {
                    var targetInstance = targetValue;
                    srvRecordInstance.target = targetInstance;
                  }
                }
              }
              
              var tXTRecordsArray = propertiesValue['TXTRecords'];
              if (tXTRecordsArray !== null && tXTRecordsArray !== undefined) {
                propertiesInstance.txtRecords = [];
                for (var loweredIndex8 = 0; loweredIndex8 < tXTRecordsArray.length; loweredIndex8 = loweredIndex8 + 1) {
                  var tXTRecordsValue = tXTRecordsArray[loweredIndex8];
                  var txtRecordInstance = {};
                  propertiesInstance.txtRecords.push(txtRecordInstance);
                  
                  var valueValue2 = tXTRecordsValue['value'];
                  if (valueValue2 !== null && valueValue2 !== undefined) {
                    var valueInstance = valueValue2;
                    txtRecordInstance.value = valueInstance;
                  }
                }
              }
              
              var cNAMERecordValue = propertiesValue['CNAMERecord'];
              if (cNAMERecordValue !== null && cNAMERecordValue !== undefined) {
                var cNAMERecordInstance = {};
                propertiesInstance.cnameRecord = cNAMERecordInstance;
                
                var cnameValue = cNAMERecordValue['cname'];
                if (cnameValue !== null && cnameValue !== undefined) {
                  var cnameInstance = cnameValue;
                  cNAMERecordInstance.cname = cnameInstance;
                }
              }
              
              var sOARecordValue = propertiesValue['SOARecord'];
              if (sOARecordValue !== null && sOARecordValue !== undefined) {
                var sOARecordInstance = {};
                propertiesInstance.soaRecord = sOARecordInstance;
                
                var hostValue = sOARecordValue['host'];
                if (hostValue !== null && hostValue !== undefined) {
                  var hostInstance = hostValue;
                  sOARecordInstance.host = hostInstance;
                }
                
                var emailValue = sOARecordValue['email'];
                if (emailValue !== null && emailValue !== undefined) {
                  var emailInstance = emailValue;
                  sOARecordInstance.email = emailInstance;
                }
                
                var serialNumberValue = sOARecordValue['serialNumber'];
                if (serialNumberValue !== null && serialNumberValue !== undefined) {
                  var serialNumberInstance = serialNumberValue;
                  sOARecordInstance.serialNumber = serialNumberInstance;
                }
                
                var refreshTimeValue = sOARecordValue['refreshTime'];
                if (refreshTimeValue !== null && refreshTimeValue !== undefined) {
                  var refreshTimeInstance = refreshTimeValue;
                  sOARecordInstance.refreshTime = refreshTimeInstance;
                }
                
                var retryTimeValue = sOARecordValue['retryTime'];
                if (retryTimeValue !== null && retryTimeValue !== undefined) {
                  var retryTimeInstance = retryTimeValue;
                  sOARecordInstance.retryTime = retryTimeInstance;
                }
                
                var expireTimeValue = sOARecordValue['expireTime'];
                if (expireTimeValue !== null && expireTimeValue !== undefined) {
                  var expireTimeInstance = expireTimeValue;
                  sOARecordInstance.expireTime = expireTimeInstance;
                }
                
                var minimumTTLValue = sOARecordValue['minimumTTL'];
                if (minimumTTLValue !== null && minimumTTLValue !== undefined) {
                  var minimumTTLInstance = minimumTTLValue;
                  sOARecordInstance.minimumTtl = minimumTTLInstance;
                }
              }
            }
            
            var idValue = valueValue['id'];
            if (idValue !== null && idValue !== undefined) {
              var idInstance = idValue;
              recordSetInstance.id = idInstance;
            }
            
            var nameValue = valueValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              recordSetInstance.name = nameInstance;
            }
            
            var typeValue = valueValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              recordSetInstance.type = typeInstance;
            }
            
            var locationValue = valueValue['location'];
            if (locationValue !== null && locationValue !== undefined) {
              var locationInstance = locationValue;
              recordSetInstance.location = locationInstance;
            }
            
            var tagsSequenceElement = valueValue['tags'];
            if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
              for (var property in tagsSequenceElement) {
                var tagsKey = property;
                var tagsValue = tagsSequenceElement[property];
                recordSetInstance.tags[tagsKey] = tagsValue;
              }
            }
          }
        }
        
        var nextLinkValue = responseDoc['nextLink'];
        if (nextLinkValue !== null && nextLinkValue !== undefined) {
          var nextLinkInstance = nextLinkValue;
          result.nextLink = nextLinkInstance;
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists RecordSets in a DNS zone. Depending on the previous call, it will
   * list all types or by type.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  RecordSetOperations.prototype.listNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + nextLink;
    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/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = { recordSets: [] };
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var valueArray = responseDoc['value'];
        if (valueArray !== null && valueArray !== undefined) {
          for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
            var valueValue = valueArray[loweredIndex1];
            var recordSetInstance = { tags: {} };
            result.recordSets.push(recordSetInstance);
            
            var etagValue = valueValue['etag'];
            if (etagValue !== null && etagValue !== undefined) {
              var etagInstance = etagValue;
              recordSetInstance.eTag = etagInstance;
            }
            
            var propertiesValue = valueValue['properties'];
            if (propertiesValue !== null && propertiesValue !== undefined) {
              var propertiesInstance = { aaaaRecords: [], aRecords: [], mxRecords: [], nsRecords: [], ptrRecords: [], srvRecords: [], txtRecords: [] };
              recordSetInstance.properties = propertiesInstance;
              
              var tTLValue = propertiesValue['TTL'];
              if (tTLValue !== null && tTLValue !== undefined) {
                var tTLInstance = tTLValue;
                propertiesInstance.ttl = tTLInstance;
              }
              
              var aRecordsArray = propertiesValue['ARecords'];
              if (aRecordsArray !== null && aRecordsArray !== undefined) {
                propertiesInstance.aRecords = [];
                for (var loweredIndex2 = 0; loweredIndex2 < aRecordsArray.length; loweredIndex2 = loweredIndex2 + 1) {
                  var aRecordsValue = aRecordsArray[loweredIndex2];
                  var aRecordInstance = {};
                  propertiesInstance.aRecords.push(aRecordInstance);
                  
                  var ipv4AddressValue = aRecordsValue['ipv4Address'];
                  if (ipv4AddressValue !== null && ipv4AddressValue !== undefined) {
                    var ipv4AddressInstance = ipv4AddressValue;
                    aRecordInstance.ipv4Address = ipv4AddressInstance;
                  }
                }
              }
              
              var aAAARecordsArray = propertiesValue['AAAARecords'];
              if (aAAARecordsArray !== null && aAAARecordsArray !== undefined) {
                propertiesInstance.aaaaRecords = [];
                for (var loweredIndex3 = 0; loweredIndex3 < aAAARecordsArray.length; loweredIndex3 = loweredIndex3 + 1) {
                  var aAAARecordsValue = aAAARecordsArray[loweredIndex3];
                  var aaaaRecordInstance = {};
                  propertiesInstance.aaaaRecords.push(aaaaRecordInstance);
                  
                  var ipv6AddressValue = aAAARecordsValue['ipv6Address'];
                  if (ipv6AddressValue !== null && ipv6AddressValue !== undefined) {
                    var ipv6AddressInstance = ipv6AddressValue;
                    aaaaRecordInstance.ipv6Address = ipv6AddressInstance;
                  }
                }
              }
              
              var mXRecordsArray = propertiesValue['MXRecords'];
              if (mXRecordsArray !== null && mXRecordsArray !== undefined) {
                propertiesInstance.mxRecords = [];
                for (var loweredIndex4 = 0; loweredIndex4 < mXRecordsArray.length; loweredIndex4 = loweredIndex4 + 1) {
                  var mXRecordsValue = mXRecordsArray[loweredIndex4];
                  var mxRecordInstance = {};
                  propertiesInstance.mxRecords.push(mxRecordInstance);
                  
                  var preferenceValue = mXRecordsValue['preference'];
                  if (preferenceValue !== null && preferenceValue !== undefined) {
                    var preferenceInstance = preferenceValue;
                    mxRecordInstance.preference = preferenceInstance;
                  }
                  
                  var exchangeValue = mXRecordsValue['exchange'];
                  if (exchangeValue !== null && exchangeValue !== undefined) {
                    var exchangeInstance = exchangeValue;
                    mxRecordInstance.exchange = exchangeInstance;
                  }
                }
              }
              
              var nSRecordsArray = propertiesValue['NSRecords'];
              if (nSRecordsArray !== null && nSRecordsArray !== undefined) {
                propertiesInstance.nsRecords = [];
                for (var loweredIndex5 = 0; loweredIndex5 < nSRecordsArray.length; loweredIndex5 = loweredIndex5 + 1) {
                  var nSRecordsValue = nSRecordsArray[loweredIndex5];
                  var nsRecordInstance = {};
                  propertiesInstance.nsRecords.push(nsRecordInstance);
                  
                  var nsdnameValue = nSRecordsValue['nsdname'];
                  if (nsdnameValue !== null && nsdnameValue !== undefined) {
                    var nsdnameInstance = nsdnameValue;
                    nsRecordInstance.nsdname = nsdnameInstance;
                  }
                }
              }
              
              var pTRRecordsArray = propertiesValue['PTRRecords'];
              if (pTRRecordsArray !== null && pTRRecordsArray !== undefined) {
                propertiesInstance.ptrRecords = [];
                for (var loweredIndex6 = 0; loweredIndex6 < pTRRecordsArray.length; loweredIndex6 = loweredIndex6 + 1) {
                  var pTRRecordsValue = pTRRecordsArray[loweredIndex6];
                  var ptrRecordInstance = {};
                  propertiesInstance.ptrRecords.push(ptrRecordInstance);
                  
                  var ptrdnameValue = pTRRecordsValue['ptrdname'];
                  if (ptrdnameValue !== null && ptrdnameValue !== undefined) {
                    var ptrdnameInstance = ptrdnameValue;
                    ptrRecordInstance.ptrdname = ptrdnameInstance;
                  }
                }
              }
              
              var sRVRecordsArray = propertiesValue['SRVRecords'];
              if (sRVRecordsArray !== null && sRVRecordsArray !== undefined) {
                propertiesInstance.srvRecords = [];
                for (var loweredIndex7 = 0; loweredIndex7 < sRVRecordsArray.length; loweredIndex7 = loweredIndex7 + 1) {
                  var sRVRecordsValue = sRVRecordsArray[loweredIndex7];
                  var srvRecordInstance = {};
                  propertiesInstance.srvRecords.push(srvRecordInstance);
                  
                  var priorityValue = sRVRecordsValue['priority'];
                  if (priorityValue !== null && priorityValue !== undefined) {
                    var priorityInstance = priorityValue;
                    srvRecordInstance.priority = priorityInstance;
                  }
                  
                  var weightValue = sRVRecordsValue['weight'];
                  if (weightValue !== null && weightValue !== undefined) {
                    var weightInstance = weightValue;
                    srvRecordInstance.weight = weightInstance;
                  }
                  
                  var portValue = sRVRecordsValue['port'];
                  if (portValue !== null && portValue !== undefined) {
                    var portInstance = portValue;
                    srvRecordInstance.port = portInstance;
                  }
                  
                  var targetValue = sRVRecordsValue['target'];
                  if (targetValue !== null && targetValue !== undefined) {
                    var targetInstance = targetValue;
                    srvRecordInstance.target = targetInstance;
                  }
                }
              }
              
              var tXTRecordsArray = propertiesValue['TXTRecords'];
              if (tXTRecordsArray !== null && tXTRecordsArray !== undefined) {
                propertiesInstance.txtRecords = [];
                for (var loweredIndex8 = 0; loweredIndex8 < tXTRecordsArray.length; loweredIndex8 = loweredIndex8 + 1) {
                  var tXTRecordsValue = tXTRecordsArray[loweredIndex8];
                  var txtRecordInstance = {};
                  propertiesInstance.txtRecords.push(txtRecordInstance);
                  
                  var valueValue2 = tXTRecordsValue['value'];
                  if (valueValue2 !== null && valueValue2 !== undefined) {
                    var valueInstance = valueValue2;
                    txtRecordInstance.value = valueInstance;
                  }
                }
              }
              
              var cNAMERecordValue = propertiesValue['CNAMERecord'];
              if (cNAMERecordValue !== null && cNAMERecordValue !== undefined) {
                var cNAMERecordInstance = {};
                propertiesInstance.cnameRecord = cNAMERecordInstance;
                
                var cnameValue = cNAMERecordValue['cname'];
                if (cnameValue !== null && cnameValue !== undefined) {
                  var cnameInstance = cnameValue;
                  cNAMERecordInstance.cname = cnameInstance;
                }
              }
              
              var sOARecordValue = propertiesValue['SOARecord'];
              if (sOARecordValue !== null && sOARecordValue !== undefined) {
                var sOARecordInstance = {};
                propertiesInstance.soaRecord = sOARecordInstance;
                
                var hostValue = sOARecordValue['host'];
                if (hostValue !== null && hostValue !== undefined) {
                  var hostInstance = hostValue;
                  sOARecordInstance.host = hostInstance;
                }
                
                var emailValue = sOARecordValue['email'];
                if (emailValue !== null && emailValue !== undefined) {
                  var emailInstance = emailValue;
                  sOARecordInstance.email = emailInstance;
                }
                
                var serialNumberValue = sOARecordValue['serialNumber'];
                if (serialNumberValue !== null && serialNumberValue !== undefined) {
                  var serialNumberInstance = serialNumberValue;
                  sOARecordInstance.serialNumber = serialNumberInstance;
                }
                
                var refreshTimeValue = sOARecordValue['refreshTime'];
                if (refreshTimeValue !== null && refreshTimeValue !== undefined) {
                  var refreshTimeInstance = refreshTimeValue;
                  sOARecordInstance.refreshTime = refreshTimeInstance;
                }
                
                var retryTimeValue = sOARecordValue['retryTime'];
                if (retryTimeValue !== null && retryTimeValue !== undefined) {
                  var retryTimeInstance = retryTimeValue;
                  sOARecordInstance.retryTime = retryTimeInstance;
                }
                
                var expireTimeValue = sOARecordValue['expireTime'];
                if (expireTimeValue !== null && expireTimeValue !== undefined) {
                  var expireTimeInstance = expireTimeValue;
                  sOARecordInstance.expireTime = expireTimeInstance;
                }
                
                var minimumTTLValue = sOARecordValue['minimumTTL'];
                if (minimumTTLValue !== null && minimumTTLValue !== undefined) {
                  var minimumTTLInstance = minimumTTLValue;
                  sOARecordInstance.minimumTtl = minimumTTLInstance;
                }
              }
            }
            
            var idValue = valueValue['id'];
            if (idValue !== null && idValue !== undefined) {
              var idInstance = idValue;
              recordSetInstance.id = idInstance;
            }
            
            var nameValue = valueValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              recordSetInstance.name = nameInstance;
            }
            
            var typeValue = valueValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              recordSetInstance.type = typeInstance;
            }
            
            var locationValue = valueValue['location'];
            if (locationValue !== null && locationValue !== undefined) {
              var locationInstance = locationValue;
              recordSetInstance.location = locationInstance;
            }
            
            var tagsSequenceElement = valueValue['tags'];
            if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
              for (var property in tagsSequenceElement) {
                var tagsKey = property;
                var tagsValue = tagsSequenceElement[property];
                recordSetInstance.tags[tagsKey] = tagsValue;
              }
            }
          }
        }
        
        var nextLinkValue = responseDoc['nextLink'];
        if (nextLinkValue !== null && nextLinkValue !== undefined) {
          var nextLinkInstance = nextLinkValue;
          result.nextLink = nextLinkInstance;
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return RecordSetOperations;
})();

var ZoneOperations = ( /** @lends ZoneOperations */ function() {
  /**
   * @class
   * Operations for managing DNS zones.
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the [DnsManagementClient] {@link
   * DnsManagementClient~DnsManagementClient}.
   * See [zones] {@link DnsManagementClient~DnsManagementClient#zones}.
   * Initializes a new instance of the ZoneOperations class.
   * @constructor
   * 
   * @param {DnsManagementClient} client Reference to the service client.
   */
  function ZoneOperations(client) {
    this.client = client;
  }
  
  /**
   * Creates a DNS zone within a resource group.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} zoneName The name of the zone without a terminating dot.
   * 
   * @param {ZoneCreateOrUpdateParameters} parameters Parameters supplied to
   * the CreateOrUpdate operation.
   * 
   * @param {Zone} parameters.zone Gets or sets information about the zone
   * being created or updated.
   * 
   * @param {string} [parameters.zone.eTag] Gets or sets the ETag of the zone
   * that is being updated, as received from a Get operation.
   * 
   * @param {ZoneProperties} [parameters.zone.properties] Gets or sets the
   * properties of the zone.
   * 
   * @param {number} [parameters.zone.properties.maxNumberOfRecordSets] Gets or
   * sets the maximum number of record sets that can be created in this zone.
   * 
   * @param {number} [parameters.zone.properties.numberOfRecordSets] Gets or
   * sets the current number of record sets in this zone.
   * 
   * @param {string} [parameters.zone.id] Gets or sets the ID of the resource.
   * 
   * @param {string} [parameters.zone.name] Gets or sets the name of the
   * resource.
   * 
   * @param {string} [parameters.zone.type] Gets or sets the type of the
   * resource.
   * 
   * @param {string} parameters.zone.location Gets or sets the location of the
   * resource.
   * 
   * @param {object} [parameters.zone.tags] Gets or sets the tags attached to
   * the resource.
   * 
   * @param {string} [parameters.ifNoneMatch] Gets or sets the If-None-Match
   * precondition. Set to '*' to force Create-If-Not-Exist. Other values will
   * be ignored.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ZoneOperations.prototype.createOrUpdate = function(resourceGroupName, zoneName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    if (parameters.zone === null || parameters.zone === undefined) {
      return callback(new Error('parameters.zone cannot be null.'));
    }
    if (parameters.zone.location === null || parameters.zone.location === undefined) {
      return callback(new Error('parameters.zone.location cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-05-04-preview');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (parameters.zone.eTag !== null && parameters.zone.eTag !== undefined) {
      httpRequest.headers['If-Match'] = parameters.zone.eTag;
    }
    if (parameters.ifNoneMatch !== null && parameters.ifNoneMatch !== undefined) {
      httpRequest.headers['If-None-Match'] = parameters.ifNoneMatch;
    }
    
    // Serialize Request
    var requestContent = null;
    var requestDoc = null;
    
    var zoneCreateOrUpdateParametersValue = {};
    requestDoc = zoneCreateOrUpdateParametersValue;
    
    if (parameters.zone.eTag !== null && parameters.zone.eTag !== undefined) {
      zoneCreateOrUpdateParametersValue['etag'] = parameters.zone.eTag;
    }
    
    if (parameters.zone.properties !== null && parameters.zone.properties !== undefined) {
      var propertiesValue = {};
      zoneCreateOrUpdateParametersValue['properties'] = propertiesValue;
      
      if (parameters.zone.properties.maxNumberOfRecordSets !== null && parameters.zone.properties.maxNumberOfRecordSets !== undefined) {
        propertiesValue['maxNumberOfRecordSets'] = parameters.zone.properties.maxNumberOfRecordSets;
      }
      
      if (parameters.zone.properties.numberOfRecordSets !== null && parameters.zone.properties.numberOfRecordSets !== undefined) {
        propertiesValue['numberOfRecordSets'] = parameters.zone.properties.numberOfRecordSets;
      }
    }
    
    if (parameters.zone.id !== null && parameters.zone.id !== undefined) {
      zoneCreateOrUpdateParametersValue['id'] = parameters.zone.id;
    }
    
    if (parameters.zone.name !== null && parameters.zone.name !== undefined) {
      zoneCreateOrUpdateParametersValue['name'] = parameters.zone.name;
    }
    
    if (parameters.zone.type !== null && parameters.zone.type !== undefined) {
      zoneCreateOrUpdateParametersValue['type'] = parameters.zone.type;
    }
    
    zoneCreateOrUpdateParametersValue['location'] = parameters.zone.location;
    
    if (parameters.zone.tags !== null && parameters.zone.tags !== undefined) {
      var tagsDictionary = {};
      for (var tagsKey in parameters.zone.tags) {
        var tagsValue = parameters.zone.tags[tagsKey];
        tagsDictionary[tagsKey] = tagsValue;
      }
      zoneCreateOrUpdateParametersValue['tags'] = tagsDictionary;
    }
    
    requestContent = JSON.stringify(requestDoc);
    httpRequest.body = requestContent;
    httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8');
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = {};
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var zoneInstance = { tags: {} };
        result.zone = zoneInstance;
        
        var etagValue = responseDoc['etag'];
        if (etagValue !== null && etagValue !== undefined) {
          var etagInstance = etagValue;
          zoneInstance.eTag = etagInstance;
        }
        
        var propertiesValue2 = responseDoc['properties'];
        if (propertiesValue2 !== null && propertiesValue2 !== undefined) {
          var propertiesInstance = {};
          zoneInstance.properties = propertiesInstance;
          
          var maxNumberOfRecordSetsValue = propertiesValue2['maxNumberOfRecordSets'];
          if (maxNumberOfRecordSetsValue !== null && maxNumberOfRecordSetsValue !== undefined) {
            var maxNumberOfRecordSetsInstance = maxNumberOfRecordSetsValue;
            propertiesInstance.maxNumberOfRecordSets = maxNumberOfRecordSetsInstance;
          }
          
          var numberOfRecordSetsValue = propertiesValue2['numberOfRecordSets'];
          if (numberOfRecordSetsValue !== null && numberOfRecordSetsValue !== undefined) {
            var numberOfRecordSetsInstance = numberOfRecordSetsValue;
            propertiesInstance.numberOfRecordSets = numberOfRecordSetsInstance;
          }
        }
        
        var idValue = responseDoc['id'];
        if (idValue !== null && idValue !== undefined) {
          var idInstance = idValue;
          zoneInstance.id = idInstance;
        }
        
        var nameValue = responseDoc['name'];
        if (nameValue !== null && nameValue !== undefined) {
          var nameInstance = nameValue;
          zoneInstance.name = nameInstance;
        }
        
        var typeValue = responseDoc['type'];
        if (typeValue !== null && typeValue !== undefined) {
          var typeInstance = typeValue;
          zoneInstance.type = typeInstance;
        }
        
        var locationValue = responseDoc['location'];
        if (locationValue !== null && locationValue !== undefined) {
          var locationInstance = locationValue;
          zoneInstance.location = locationInstance;
        }
        
        var tagsSequenceElement = responseDoc['tags'];
        if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
          for (var property in tagsSequenceElement) {
            var tagsKey2 = property;
            var tagsValue2 = tagsSequenceElement[property];
            zoneInstance.tags[tagsKey2] = tagsValue2;
          }
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Removes a DNS zone from a resource group.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} zoneName The name of the zone without a terminating dot.
   * 
   * @param {ZoneDeleteParameters} parameters The parameters supplied to delete
   * a zone
   * 
   * @param {string} [parameters.ifMatch] Gets or sets the If-Match
   * pre-condition. The delete operation will be performedonly if the ETag of
   * the zone on the server matches this value.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ZoneOperations.prototype.deleteMethod = function(resourceGroupName, zoneName, parameters, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    if (parameters === null || parameters === undefined) {
      return callback(new Error('parameters cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-05-04-preview');
    if (queryParameters.length > 0) {
      url2 = url2 + '?' + queryParameters.join('&');
    }
    var baseUrl = this.client.baseUri;
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl[baseUrl.length - 1] === '/') {
      baseUrl = baseUrl.substring(0, (baseUrl.length - 1) + 0);
    }
    if (url2[0] === '/') {
      url2 = url2.substring(1);
    }
    url2 = baseUrl + '/' + url2;
    url2 = url2.replace(' ', '%20');
    
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = url2;
    
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (parameters.ifMatch !== null && parameters.ifMatch !== undefined) {
      httpRequest.headers['If-Match'] = parameters.ifMatch;
    }
    
    // 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 >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      result = {};
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Gets a DNS zone.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {string} zoneName The name of the zone without a terminating dot.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ZoneOperations.prototype.get = function(resourceGroupName, zoneName, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    if (zoneName === null || zoneName === undefined) {
      return callback(new Error('zoneName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones/';
    url2 = url2 + encodeURIComponent(zoneName);
    var queryParameters = [];
    queryParameters.push('api-version=2015-05-04-preview');
    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['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = {};
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var zoneInstance = { tags: {} };
        result.zone = zoneInstance;
        
        var etagValue = responseDoc['etag'];
        if (etagValue !== null && etagValue !== undefined) {
          var etagInstance = etagValue;
          zoneInstance.eTag = etagInstance;
        }
        
        var propertiesValue = responseDoc['properties'];
        if (propertiesValue !== null && propertiesValue !== undefined) {
          var propertiesInstance = {};
          zoneInstance.properties = propertiesInstance;
          
          var maxNumberOfRecordSetsValue = propertiesValue['maxNumberOfRecordSets'];
          if (maxNumberOfRecordSetsValue !== null && maxNumberOfRecordSetsValue !== undefined) {
            var maxNumberOfRecordSetsInstance = maxNumberOfRecordSetsValue;
            propertiesInstance.maxNumberOfRecordSets = maxNumberOfRecordSetsInstance;
          }
          
          var numberOfRecordSetsValue = propertiesValue['numberOfRecordSets'];
          if (numberOfRecordSetsValue !== null && numberOfRecordSetsValue !== undefined) {
            var numberOfRecordSetsInstance = numberOfRecordSetsValue;
            propertiesInstance.numberOfRecordSets = numberOfRecordSetsInstance;
          }
        }
        
        var idValue = responseDoc['id'];
        if (idValue !== null && idValue !== undefined) {
          var idInstance = idValue;
          zoneInstance.id = idInstance;
        }
        
        var nameValue = responseDoc['name'];
        if (nameValue !== null && nameValue !== undefined) {
          var nameInstance = nameValue;
          zoneInstance.name = nameInstance;
        }
        
        var typeValue = responseDoc['type'];
        if (typeValue !== null && typeValue !== undefined) {
          var typeInstance = typeValue;
          zoneInstance.type = typeInstance;
        }
        
        var locationValue = responseDoc['location'];
        if (locationValue !== null && locationValue !== undefined) {
          var locationInstance = locationValue;
          zoneInstance.location = locationInstance;
        }
        
        var tagsSequenceElement = responseDoc['tags'];
        if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
          for (var property in tagsSequenceElement) {
            var tagsKey = property;
            var tagsValue = tagsSequenceElement[property];
            zoneInstance.tags[tagsKey] = tagsValue;
          }
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the DNS zones within a resource group.
   * 
   * @param {string} resourceGroupName The name of the resource group.
   * 
   * @param {ZoneListParameters} [parametersOrCallback] Query parameters. If
   * null is passed returns the default number of zones.
   * 
   * @param {string} [parametersOrCallback.top] Gets or sets the number of
   * elements to retrieve (first N elements).
   * 
   * @param {string} [parametersOrCallback.filter] Gets or sets the filter for
   * the records enumeration.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ZoneOperations.prototype.list = function(resourceGroupName, parametersOrCallback, callback) {
    var parameters = parametersOrCallback;
    if (_.isFunction(parameters)) {
      callback = parameters;
      parameters = null;
    }
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (resourceGroupName === null || resourceGroupName === undefined) {
      return callback(new Error('resourceGroupName cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + '/subscriptions/';
    if (this.client.credentials.subscriptionId !== null && this.client.credentials.subscriptionId !== undefined) {
      url2 = url2 + encodeURIComponent(this.client.credentials.subscriptionId);
    }
    url2 = url2 + '/resourceGroups/';
    url2 = url2 + encodeURIComponent(resourceGroupName);
    url2 = url2 + '/providers/';
    url2 = url2 + 'Microsoft.Network';
    url2 = url2 + '/dnszones';
    var queryParameters = [];
    if (parameters !== null && parameters !== undefined && parameters.top !== null && parameters.top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(parameters.top));
    }
    var odataFilter = [];
    if (parameters !== null && parameters !== undefined && parameters.filter !== null && parameters.filter !== undefined) {
      odataFilter.push(encodeURIComponent(parameters.filter));
    }
    if (odataFilter.length > 0) {
      queryParameters.push('$filter=' + odataFilter.join(null));
    }
    queryParameters.push('api-version=2015-05-04-preview');
    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['Content-Type'] = 'application/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = { zones: [] };
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var valueArray = responseDoc['value'];
        if (valueArray !== null && valueArray !== undefined) {
          for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
            var valueValue = valueArray[loweredIndex1];
            var zoneInstance = { tags: {} };
            result.zones.push(zoneInstance);
            
            var etagValue = valueValue['etag'];
            if (etagValue !== null && etagValue !== undefined) {
              var etagInstance = etagValue;
              zoneInstance.eTag = etagInstance;
            }
            
            var propertiesValue = valueValue['properties'];
            if (propertiesValue !== null && propertiesValue !== undefined) {
              var propertiesInstance = {};
              zoneInstance.properties = propertiesInstance;
              
              var maxNumberOfRecordSetsValue = propertiesValue['maxNumberOfRecordSets'];
              if (maxNumberOfRecordSetsValue !== null && maxNumberOfRecordSetsValue !== undefined) {
                var maxNumberOfRecordSetsInstance = maxNumberOfRecordSetsValue;
                propertiesInstance.maxNumberOfRecordSets = maxNumberOfRecordSetsInstance;
              }
              
              var numberOfRecordSetsValue = propertiesValue['numberOfRecordSets'];
              if (numberOfRecordSetsValue !== null && numberOfRecordSetsValue !== undefined) {
                var numberOfRecordSetsInstance = numberOfRecordSetsValue;
                propertiesInstance.numberOfRecordSets = numberOfRecordSetsInstance;
              }
            }
            
            var idValue = valueValue['id'];
            if (idValue !== null && idValue !== undefined) {
              var idInstance = idValue;
              zoneInstance.id = idInstance;
            }
            
            var nameValue = valueValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              zoneInstance.name = nameInstance;
            }
            
            var typeValue = valueValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              zoneInstance.type = typeInstance;
            }
            
            var locationValue = valueValue['location'];
            if (locationValue !== null && locationValue !== undefined) {
              var locationInstance = locationValue;
              zoneInstance.location = locationInstance;
            }
            
            var tagsSequenceElement = valueValue['tags'];
            if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
              for (var property in tagsSequenceElement) {
                var tagsKey = property;
                var tagsValue = tagsSequenceElement[property];
                zoneInstance.tags[tagsKey] = tagsValue;
              }
            }
          }
        }
        
        var nextLinkValue = responseDoc['nextLink'];
        if (nextLinkValue !== null && nextLinkValue !== undefined) {
          var nextLinkInstance = nextLinkValue;
          result.nextLink = nextLinkInstance;
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  /**
   * Lists the DNS zones within a resource group.
   * 
   * @param {string} nextLink NextLink from the previous successful call to
   * List operation.
   * 
   * @param {function} callback
   * 
   * @returns {Stream} The response stream.
   */
  ZoneOperations.prototype.listNext = function(nextLink, callback) {
    if (callback === null || callback === undefined) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    if (nextLink === null || nextLink === undefined) {
      return callback(new Error('nextLink cannot be null.'));
    }
    
    // Tracing
    
    // Construct URL
    var url2 = '';
    url2 = url2 + nextLink;
    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/json; charset=utf-8';
    
    // Send Request
    return this.client.pipeline(httpRequest, function (err, response, body) {
      if (err !== null && err !== undefined) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode >= 400) {
        var error = new Error(body);
        error.statusCode = response.statusCode;
        return callback(error);
      }
      
      // Create Result
      var result = null;
      // Deserialize Response
      var responseContent = body;
      result = { zones: [] };
      var responseDoc = null;
      if (responseContent) {
        responseDoc = JSON.parse(responseContent);
      }
      
      if (responseDoc !== null && responseDoc !== undefined) {
        var valueArray = responseDoc['value'];
        if (valueArray !== null && valueArray !== undefined) {
          for (var loweredIndex1 = 0; loweredIndex1 < valueArray.length; loweredIndex1 = loweredIndex1 + 1) {
            var valueValue = valueArray[loweredIndex1];
            var zoneInstance = { tags: {} };
            result.zones.push(zoneInstance);
            
            var etagValue = valueValue['etag'];
            if (etagValue !== null && etagValue !== undefined) {
              var etagInstance = etagValue;
              zoneInstance.eTag = etagInstance;
            }
            
            var propertiesValue = valueValue['properties'];
            if (propertiesValue !== null && propertiesValue !== undefined) {
              var propertiesInstance = {};
              zoneInstance.properties = propertiesInstance;
              
              var maxNumberOfRecordSetsValue = propertiesValue['maxNumberOfRecordSets'];
              if (maxNumberOfRecordSetsValue !== null && maxNumberOfRecordSetsValue !== undefined) {
                var maxNumberOfRecordSetsInstance = maxNumberOfRecordSetsValue;
                propertiesInstance.maxNumberOfRecordSets = maxNumberOfRecordSetsInstance;
              }
              
              var numberOfRecordSetsValue = propertiesValue['numberOfRecordSets'];
              if (numberOfRecordSetsValue !== null && numberOfRecordSetsValue !== undefined) {
                var numberOfRecordSetsInstance = numberOfRecordSetsValue;
                propertiesInstance.numberOfRecordSets = numberOfRecordSetsInstance;
              }
            }
            
            var idValue = valueValue['id'];
            if (idValue !== null && idValue !== undefined) {
              var idInstance = idValue;
              zoneInstance.id = idInstance;
            }
            
            var nameValue = valueValue['name'];
            if (nameValue !== null && nameValue !== undefined) {
              var nameInstance = nameValue;
              zoneInstance.name = nameInstance;
            }
            
            var typeValue = valueValue['type'];
            if (typeValue !== null && typeValue !== undefined) {
              var typeInstance = typeValue;
              zoneInstance.type = typeInstance;
            }
            
            var locationValue = valueValue['location'];
            if (locationValue !== null && locationValue !== undefined) {
              var locationInstance = locationValue;
              zoneInstance.location = locationInstance;
            }
            
            var tagsSequenceElement = valueValue['tags'];
            if (tagsSequenceElement !== null && tagsSequenceElement !== undefined) {
              for (var property in tagsSequenceElement) {
                var tagsKey = property;
                var tagsValue = tagsSequenceElement[property];
                zoneInstance.tags[tagsKey] = tagsValue;
              }
            }
          }
        }
        
        var nextLinkValue = responseDoc['nextLink'];
        if (nextLinkValue !== null && nextLinkValue !== undefined) {
          var nextLinkInstance = nextLinkValue;
          result.nextLink = nextLinkInstance;
        }
      }
      
      result.statusCode = statusCode;
      result.requestId = response.headers['x-ms-request-id'];
      
      return callback(null, result);
    });
  };
  
  return ZoneOperations;
})();
