@azure/arm-dns
Version:
A generated SDK for DnsManagementClient.
439 lines • 16.9 kB
JavaScript
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { __asyncDelegator, __asyncGenerator, __asyncValues, __await, __awaiter } from "tslib";
import { setContinuationToken } from "../pagingHelper";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { LroEngine } from "@azure/core-lro";
import { LroImpl } from "../lroImpl";
/// <reference lib="esnext.asynciterable" />
/** Class containing Zones operations. */
export class ZonesImpl {
/**
* Initialize a new instance of the class Zones class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Lists the DNS zones within a resource group.
* @param resourceGroupName The name of the resource group.
* @param options The options parameters.
*/
listByResourceGroup(resourceGroupName, options) {
const iter = this.listByResourceGroupPagingAll(resourceGroupName, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings) => {
if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listByResourceGroupPagingPage(resourceGroupName, options, settings);
}
};
}
listByResourceGroupPagingPage(resourceGroupName, options, settings) {
return __asyncGenerator(this, arguments, function* listByResourceGroupPagingPage_1() {
let result;
let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
if (!continuationToken) {
result = yield __await(this._listByResourceGroup(resourceGroupName, options));
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
while (continuationToken) {
result = yield __await(this._listByResourceGroupNext(resourceGroupName, continuationToken, options));
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
});
}
listByResourceGroupPagingAll(resourceGroupName, options) {
return __asyncGenerator(this, arguments, function* listByResourceGroupPagingAll_1() {
var e_1, _a;
try {
for (var _b = __asyncValues(this.listByResourceGroupPagingPage(resourceGroupName, options)), _c; _c = yield __await(_b.next()), !_c.done;) {
const page = _c.value;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
}
finally { if (e_1) throw e_1.error; }
}
});
}
/**
* Lists the DNS zones in all resource groups in a subscription.
* @param options The options parameters.
*/
list(options) {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings) => {
if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listPagingPage(options, settings);
}
};
}
listPagingPage(options, settings) {
return __asyncGenerator(this, arguments, function* listPagingPage_1() {
let result;
let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
if (!continuationToken) {
result = yield __await(this._list(options));
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
while (continuationToken) {
result = yield __await(this._listNext(continuationToken, options));
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield yield __await(page);
}
});
}
listPagingAll(options) {
return __asyncGenerator(this, arguments, function* listPagingAll_1() {
var e_2, _a;
try {
for (var _b = __asyncValues(this.listPagingPage(options)), _c; _c = yield __await(_b.next()), !_c.done;) {
const page = _c.value;
yield __await(yield* __asyncDelegator(__asyncValues(page)));
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b));
}
finally { if (e_2) throw e_2.error; }
}
});
}
/**
* Creates or updates a DNS zone. Does not modify DNS records within the zone.
* @param resourceGroupName The name of the resource group.
* @param zoneName The name of the DNS zone (without a terminating dot).
* @param parameters Parameters supplied to the CreateOrUpdate operation.
* @param options The options parameters.
*/
createOrUpdate(resourceGroupName, zoneName, parameters, options) {
return this.client.sendOperationRequest({ resourceGroupName, zoneName, parameters, options }, createOrUpdateOperationSpec);
}
/**
* Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot
* be undone.
* @param resourceGroupName The name of the resource group.
* @param zoneName The name of the DNS zone (without a terminating dot).
* @param options The options parameters.
*/
beginDelete(resourceGroupName, zoneName, options) {
return __awaiter(this, void 0, void 0, function* () {
const directSendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () {
return this.client.sendOperationRequest(args, spec);
});
const sendOperation = (args, spec) => __awaiter(this, void 0, void 0, function* () {
var _a;
let currentRawResponse = undefined;
const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
const callback = (rawResponse, flatResponse) => {
currentRawResponse = rawResponse;
providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse);
};
const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) });
const flatResponse = yield directSendOperation(updatedArgs, spec);
return {
flatResponse,
rawResponse: {
statusCode: currentRawResponse.status,
body: currentRawResponse.parsedBody,
headers: currentRawResponse.headers.toJSON()
}
};
});
const lro = new LroImpl(sendOperation, { resourceGroupName, zoneName, options }, deleteOperationSpec);
const poller = new LroEngine(lro, {
resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs
});
yield poller.poll();
return poller;
});
}
/**
* Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot
* be undone.
* @param resourceGroupName The name of the resource group.
* @param zoneName The name of the DNS zone (without a terminating dot).
* @param options The options parameters.
*/
beginDeleteAndWait(resourceGroupName, zoneName, options) {
return __awaiter(this, void 0, void 0, function* () {
const poller = yield this.beginDelete(resourceGroupName, zoneName, options);
return poller.pollUntilDone();
});
}
/**
* Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone.
* @param resourceGroupName The name of the resource group.
* @param zoneName The name of the DNS zone (without a terminating dot).
* @param options The options parameters.
*/
get(resourceGroupName, zoneName, options) {
return this.client.sendOperationRequest({ resourceGroupName, zoneName, options }, getOperationSpec);
}
/**
* Updates a DNS zone. Does not modify DNS records within the zone.
* @param resourceGroupName The name of the resource group.
* @param zoneName The name of the DNS zone (without a terminating dot).
* @param parameters Parameters supplied to the Update operation.
* @param options The options parameters.
*/
update(resourceGroupName, zoneName, parameters, options) {
return this.client.sendOperationRequest({ resourceGroupName, zoneName, parameters, options }, updateOperationSpec);
}
/**
* Lists the DNS zones within a resource group.
* @param resourceGroupName The name of the resource group.
* @param options The options parameters.
*/
_listByResourceGroup(resourceGroupName, options) {
return this.client.sendOperationRequest({ resourceGroupName, options }, listByResourceGroupOperationSpec);
}
/**
* Lists the DNS zones in all resource groups in a subscription.
* @param options The options parameters.
*/
_list(options) {
return this.client.sendOperationRequest({ options }, listOperationSpec);
}
/**
* ListByResourceGroupNext
* @param resourceGroupName The name of the resource group.
* @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method.
* @param options The options parameters.
*/
_listByResourceGroupNext(resourceGroupName, nextLink, options) {
return this.client.sendOperationRequest({ resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec);
}
/**
* ListNext
* @param nextLink The nextLink from the previous successful call to the List method.
* @param options The options parameters.
*/
_listNext(nextLink, options) {
return this.client.sendOperationRequest({ nextLink, options }, listNextOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const createOrUpdateOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.Zone
},
201: {
bodyMapper: Mappers.Zone
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.parameters1,
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.resourceGroupName,
Parameters.zoneName,
Parameters.subscriptionId
],
headerParameters: [
Parameters.contentType,
Parameters.accept,
Parameters.ifMatch,
Parameters.ifNoneMatch
],
mediaType: "json",
serializer
};
const deleteOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}",
httpMethod: "DELETE",
responses: {
200: {},
201: {},
202: {},
204: {},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.resourceGroupName,
Parameters.zoneName,
Parameters.subscriptionId
],
headerParameters: [Parameters.accept, Parameters.ifMatch],
serializer
};
const getOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.Zone
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.resourceGroupName,
Parameters.zoneName,
Parameters.subscriptionId
],
headerParameters: [Parameters.accept],
serializer
};
const updateOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}",
httpMethod: "PATCH",
responses: {
200: {
bodyMapper: Mappers.Zone
},
default: {
bodyMapper: Mappers.CloudError
}
},
requestBody: Parameters.parameters2,
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.resourceGroupName,
Parameters.zoneName,
Parameters.subscriptionId
],
headerParameters: [
Parameters.contentType,
Parameters.accept,
Parameters.ifMatch
],
mediaType: "json",
serializer
};
const listByResourceGroupOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ZoneListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion, Parameters.top],
urlParameters: [
Parameters.$host,
Parameters.resourceGroupName,
Parameters.subscriptionId
],
headerParameters: [Parameters.accept],
serializer
};
const listOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ZoneListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion, Parameters.top],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const listByResourceGroupNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ZoneListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion, Parameters.top],
urlParameters: [
Parameters.$host,
Parameters.resourceGroupName,
Parameters.subscriptionId,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
const listNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.ZoneListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion, Parameters.top],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.nextLink
],
headerParameters: [Parameters.accept],
serializer
};
//# sourceMappingURL=zones.js.map