@jesseditson/dnsimple
Version:
A Node.JS client for the DNSimple API.
285 lines (284 loc) • 13.3 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __asyncValues = (this && this.__asyncValues) || function (o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Zones = void 0;
const paginate_1 = require("./paginate");
class Zones {
constructor(_client) {
this._client = _client;
/**
* Activate DNS resolution for the zone in the account.
*
* PUT /{account}/zones/{zone}/activation
*
* @see https://developer.dnsimple.com/v2/zones/#activateZoneService
*
* @param account The account id
* @param zone The zone name
*/
this.activateDns = (() => {
const method = (account, zone, params = {}) => this._client.request("PUT", `/${account}/zones/${zone}/activation`, null, params);
return method;
})();
/**
* Deativate DNS resolution for the zone in the account.
*
* DELETE /{account}/zones/{zone}/activation
*
* @see https://developer.dnsimple.com/v2/zones/#deactivateZoneService
*
* @param account The account id
* @param zone The zone name
*/
this.deactivateDns = (() => {
const method = (account, zone, params = {}) => this._client.request("DELETE", `/${account}/zones/${zone}/activation`, null, params);
return method;
})();
/**
* Lists the zones in the account.
*
* This API is paginated. Call `listZones.iterateAll(account, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listZones.collectAll(account, params)` to quickly retrieve all items across all pages into an array. We suggest using `iterateAll` when possible, as `collectAll` will make all requests at once, which may increase latency and trigger rate limits.
*
* GET /{account}/zones
*
* @see https://developer.dnsimple.com/v2/zones/#listZones
*
* @param account The account id
* @param params Query parameters
* @param params.name_like Only include results with a name field containing the given string
* @param params.sort Sort results. Default sorting is by name ascending.
*/
this.listZones = (() => {
const method = (account, params = {}) => this._client.request("GET", `/${account}/zones`, null, params);
method.iterateAll = (account, params = {}) => (0, paginate_1.paginate)((page) => method(account, Object.assign(Object.assign({}, params), { page })));
method.collectAll = (account, params = {}) => __awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
const items = [];
try {
for (var _d = true, _e = __asyncValues(method.iterateAll(account, params)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
_c = _f.value;
_d = false;
try {
const item = _c;
items.push(item);
}
finally {
_d = true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
}
finally { if (e_1) throw e_1.error; }
}
return items;
});
return method;
})();
/**
* Retrieves the details of an existing zone.
*
* GET /{account}/zones/{zone}
*
* @see https://developer.dnsimple.com/v2/zones/#getZone
*
* @param account The account id
* @param zone The zone name
* @param params Query parameters
*/
this.getZone = (() => {
const method = (account, zone, params = {}) => this._client.request("GET", `/${account}/zones/${zone}`, null, params);
return method;
})();
/**
* Download the zonefile for an existing zone.
*
* GET /{account}/zones/{zone}/file
*
* @see https://developer.dnsimple.com/v2/zones/#getZoneFile
*
* @param account The account id
* @param zone The zone name
* @param params Query parameters
*/
this.getZoneFile = (() => {
const method = (account, zone, params = {}) => this._client.request("GET", `/${account}/zones/${zone}/file`, null, params);
return method;
})();
/**
* Checks if a zone is fully distributed to all our name servers across the globe.
*
* GET /{account}/zones/{zone}/distribution
*
* @see https://developer.dnsimple.com/v2/zones/#checkZoneDistribution
*
* @param account The account id
* @param zone The zone name
* @param params Query parameters
*/
this.checkZoneDistribution = (() => {
const method = (account, zone, params = {}) => this._client.request("GET", `/${account}/zones/${zone}/distribution`, null, params);
return method;
})();
/**
* Updates the zone's NS records
*
* PUT /{account}/zones/{zone}/ns_records
*
* @see https://developer.dnsimple.com/v2/zones/#updateZoneNsRecords
*
* @param account The account id
* @param zone The zone name
* @param params Query parameters
*/
this.updateZoneNsRecords = (() => {
const method = (account, zone, data, params = {}) => this._client.request("PUT", `/${account}/zones/${zone}/ns_records`, data, params);
return method;
})();
/**
* Lists the records for a zone.
*
* This API is paginated. Call `listZoneRecords.iterateAll(account, zone, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listZoneRecords.collectAll(account, zone, params)` to quickly retrieve all items across all pages into an array. We suggest using `iterateAll` when possible, as `collectAll` will make all requests at once, which may increase latency and trigger rate limits.
*
* GET /{account}/zones/{zone}/records
*
* @see https://developer.dnsimple.com/v2/zones/#listZoneRecords
*
* @param account The account id
* @param zone The zone name
* @param params Query parameters
* @param params.name_like Only include results with a name field containing the given string
* @param params.name Only include results with a name field exactly matching the given string
* @param params.type Only include results with a type field exactly matching the given string
* @param params.sort Sort results. Default sorting is by name ascending.
*/
this.listZoneRecords = (() => {
const method = (account, zone, params = {}) => this._client.request("GET", `/${account}/zones/${zone}/records`, null, params);
method.iterateAll = (account, zone, params = {}) => (0, paginate_1.paginate)((page) => method(account, zone, Object.assign(Object.assign({}, params), { page })));
method.collectAll = (account, zone, params = {}) => __awaiter(this, void 0, void 0, function* () {
var _a, e_2, _b, _c;
const items = [];
try {
for (var _d = true, _e = __asyncValues(method.iterateAll(account, zone, params)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
_c = _f.value;
_d = false;
try {
const item = _c;
items.push(item);
}
finally {
_d = true;
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
}
finally { if (e_2) throw e_2.error; }
}
return items;
});
return method;
})();
/**
* Creates a new zone record.
*
* POST /{account}/zones/{zone}/records
*
* @see https://developer.dnsimple.com/v2/zones/#createZoneRecord
*
* @param account The account id
* @param zone The zone name
* @param params Query parameters
*/
this.createZoneRecord = (() => {
const method = (account, zone, data, params = {}) => this._client.request("POST", `/${account}/zones/${zone}/records`, data, params);
return method;
})();
/**
* Retrieves the details of an existing zone record.
*
* GET /{account}/zones/{zone}/records/{zonerecord}
*
* @see https://developer.dnsimple.com/v2/zones/#getZoneRecord
*
* @param account The account id
* @param zone The zone name
* @param zonerecord The zone record id
* @param params Query parameters
*/
this.getZoneRecord = (() => {
const method = (account, zone, zonerecord, params = {}) => this._client.request("GET", `/${account}/zones/${zone}/records/${zonerecord}`, null, params);
return method;
})();
/**
* Updates the zone record details.
*
* PATCH /{account}/zones/{zone}/records/{zonerecord}
*
* @see https://developer.dnsimple.com/v2/zones/#updateZoneRecord
*
* @param account The account id
* @param zone The zone name
* @param zonerecord The zone record id
* @param params Query parameters
*/
this.updateZoneRecord = (() => {
const method = (account, zone, zonerecord, data, params = {}) => this._client.request("PATCH", `/${account}/zones/${zone}/records/${zonerecord}`, data, params);
return method;
})();
/**
* Permanently deletes a zone record.
*
* DELETE /{account}/zones/{zone}/records/{zonerecord}
*
* @see https://developer.dnsimple.com/v2/zones/#deleteZoneRecord
*
* @param account The account id
* @param zone The zone name
* @param zonerecord The zone record id
* @param params Query parameters
*/
this.deleteZoneRecord = (() => {
const method = (account, zone, zonerecord, params = {}) => this._client.request("DELETE", `/${account}/zones/${zone}/records/${zonerecord}`, null, params);
return method;
})();
/**
* Checks if a zone record is fully distributed to all our name servers across the globe.
*
* GET /{account}/zones/{zone}/records/{zonerecord}/distribution
*
* @see https://developer.dnsimple.com/v2/zones/#checkZoneRecordDistribution
*
* @param account The account id
* @param zone The zone name
* @param zonerecord The zone record id
* @param params Query parameters
*/
this.checkZoneRecordDistribution = (() => {
const method = (account, zone, zonerecord, params = {}) => this._client.request("GET", `/${account}/zones/${zone}/records/${zonerecord}/distribution`, null, params);
return method;
})();
}
}
exports.Zones = Zones;
;