azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
1,105 lines (985 loc) • 141 kB
JavaScript
/* 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 = {};