UNPKG

dnsimple

Version:

A Node.JS client for the DNSimple API.

414 lines (413 loc) 20.3 kB
"use strict"; 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.Domains = void 0; const paginate_1 = require("./paginate"); class Domains { constructor(_client) { this._client = _client; /** * Lists the domains in the account. * * This API is paginated. Call `listDomains.iterateAll(account, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listDomains.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}/domains * * @see https://developer.dnsimple.com/v2/domains/#listDomains * * @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.registrant_id Only include results with the registrant_id field matching the given value * @param params.sort Sort results. Default sorting is ascending by name. */ this.listDomains = (() => { const method = (account, params = {}) => this._client.request("GET", `/${account}/domains`, null, params); method.iterateAll = (account, params = {}) => (0, paginate_1.paginate)((page) => method(account, Object.assign(Object.assign({}, params), { page }))); method.collectAll = (account_1, ...args_1) => __awaiter(this, [account_1, ...args_1], void 0, function* (account, params = {}) { 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; _d = true) { _c = _f.value; _d = false; const item = _c; items.push(item); } } 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; })(); /** * Creates a domain and the corresponding zone into the account. * * POST /{account}/domains * * @see https://developer.dnsimple.com/v2/domains/#createDomain * * @param account The account id * @param params Query parameters */ this.createDomain = (() => { const method = (account, data, params = {}) => this._client.request("POST", `/${account}/domains`, data, params); return method; })(); /** * Retrieves the details of an existing domain. * * GET /{account}/domains/{domain} * * @see https://developer.dnsimple.com/v2/domains/#getDomain * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.getDomain = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/domains/${domain}`, null, params); return method; })(); /** * Permanently deletes a domain from the account. * * DELETE /{account}/domains/{domain} * * @see https://developer.dnsimple.com/v2/domains/#deleteDomain * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.deleteDomain = (() => { const method = (account, domain, params = {}) => this._client.request("DELETE", `/${account}/domains/${domain}`, null, params); return method; })(); /** * Gets the DNSSEC status for an existing domain. * * GET /{account}/domains/{domain}/dnssec * * @see https://developer.dnsimple.com/v2/domains/dnssec/#getDomainDnssec * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.getDnssec = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/domains/${domain}/dnssec`, null, params); return method; })(); /** * Enables DNSSEC for the domain. * * It will enable signing of the zone. If the domain is registered with DNSimple, it will also add the DS record to the corresponding registry. * * POST /{account}/domains/{domain}/dnssec * * @see https://developer.dnsimple.com/v2/domains/dnssec/#enableDomainDnssec * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.enableDnssec = (() => { const method = (account, domain, params = {}) => this._client.request("POST", `/${account}/domains/${domain}/dnssec`, null, params); return method; })(); /** * Disables DNSSEC for the domain. * * It will disable signing of the zone. If the domain is registered with DNSimple, it will also remove the DS record at the registry corresponding to the disabled DNSSEC signing. * * DELETE /{account}/domains/{domain}/dnssec * * @see https://developer.dnsimple.com/v2/domains/dnssec/#disableDomainDnssec * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.disableDnssec = (() => { const method = (account, domain, params = {}) => this._client.request("DELETE", `/${account}/domains/${domain}/dnssec`, null, params); return method; })(); /** * Lists the DS records for the domain. * * This API is paginated. Call `listDelegationSignerRecords.iterateAll(account, domain, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listDelegationSignerRecords.collectAll(account, domain, 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}/domains/{domain}/ds_records * * @see https://developer.dnsimple.com/v2/domains/dnssec/#listDomainDelegationSignerRecords * * @param account The account id * @param domain The domain name or id * @param params Query parameters * @param params.sort Sort results. Default sorting is by id. */ this.listDelegationSignerRecords = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/domains/${domain}/ds_records`, null, params); method.iterateAll = (account, domain, params = {}) => (0, paginate_1.paginate)((page) => method(account, domain, Object.assign(Object.assign({}, params), { page }))); method.collectAll = (account_1, domain_1, ...args_1) => __awaiter(this, [account_1, domain_1, ...args_1], void 0, function* (account, domain, params = {}) { var _a, e_2, _b, _c; const items = []; try { for (var _d = true, _e = __asyncValues(method.iterateAll(account, domain, params)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const item = _c; items.push(item); } } 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; })(); /** * Adds a DS record to the domain. * * POST /{account}/domains/{domain}/ds_records * * @see https://developer.dnsimple.com/v2/domains/dnssec/#createDomainDelegationSignerRecord * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.createDelegationSignerRecord = (() => { const method = (account, domain, data, params = {}) => this._client.request("POST", `/${account}/domains/${domain}/ds_records`, data, params); return method; })(); /** * Retrieves the details of an existing DS record. * * GET /{account}/domains/{domain}/ds_records/{ds} * * @see https://developer.dnsimple.com/v2/domains/dnssec/#getDomainDelegationSignerRecord * * @param account The account id * @param domain The domain name or id * @param ds The delegation signer record id * @param params Query parameters */ this.getDelegationSignerRecord = (() => { const method = (account, domain, ds, params = {}) => this._client.request("GET", `/${account}/domains/${domain}/ds_records/${ds}`, null, params); return method; })(); /** * Removes a DS record from the domain. * * DELETE /{account}/domains/{domain}/ds_records/{ds} * * @see https://developer.dnsimple.com/v2/domains/dnssec/#deleteDomainDelegationSignerRecord * * @param account The account id * @param domain The domain name or id * @param ds The delegation signer record id * @param params Query parameters */ this.deleteDelegationSignerRecord = (() => { const method = (account, domain, ds, params = {}) => this._client.request("DELETE", `/${account}/domains/${domain}/ds_records/${ds}`, null, params); return method; })(); /** * Lists email forwards for the domain. * * This API is paginated. Call `listEmailForwards.iterateAll(account, domain, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listEmailForwards.collectAll(account, domain, 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}/domains/{domain}/email_forwards * * @see https://developer.dnsimple.com/v2/domains/email-forwards/#listEmailForwards * * @param account The account id * @param domain The domain name or id * @param params Query parameters * @param params.sort Sort results. Default sorting is by id. */ this.listEmailForwards = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/domains/${domain}/email_forwards`, null, params); method.iterateAll = (account, domain, params = {}) => (0, paginate_1.paginate)((page) => method(account, domain, Object.assign(Object.assign({}, params), { page }))); method.collectAll = (account_1, domain_1, ...args_1) => __awaiter(this, [account_1, domain_1, ...args_1], void 0, function* (account, domain, params = {}) { var _a, e_3, _b, _c; const items = []; try { for (var _d = true, _e = __asyncValues(method.iterateAll(account, domain, params)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const item = _c; items.push(item); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); } finally { if (e_3) throw e_3.error; } } return items; }); return method; })(); /** * Creates a new email forward for the domain. * * POST /{account}/domains/{domain}/email_forwards * * @see https://developer.dnsimple.com/v2/domains/email-forwards/#createEmailForward * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.createEmailForward = (() => { const method = (account, domain, data, params = {}) => this._client.request("POST", `/${account}/domains/${domain}/email_forwards`, data, params); return method; })(); /** * Retrieves the details of an existing email forward. * * GET /{account}/domains/{domain}/email_forwards/{emailforward} * * @see https://developer.dnsimple.com/v2/domains/email-forwards/#getEmailForward * * @param account The account id * @param domain The domain name or id * @param emailforward The email forward id * @param params Query parameters */ this.getEmailForward = (() => { const method = (account, domain, emailforward, params = {}) => this._client.request("GET", `/${account}/domains/${domain}/email_forwards/${emailforward}`, null, params); return method; })(); /** * Permanently deletes an email forward. * * DELETE /{account}/domains/{domain}/email_forwards/{emailforward} * * @see https://developer.dnsimple.com/v2/domains/email-forwards/#deleteEmailForward * * @param account The account id * @param domain The domain name or id * @param emailforward The email forward id * @param params Query parameters */ this.deleteEmailForward = (() => { const method = (account, domain, emailforward, params = {}) => this._client.request("DELETE", `/${account}/domains/${domain}/email_forwards/${emailforward}`, null, params); return method; })(); /** * Initiates a pust of a domain to another DNSimple account. * * POST /{account}/domains/{domain}/pushes * * @see https://developer.dnsimple.com/v2/domains/pushes/#initiateDomainPush * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.initiatePush = (() => { const method = (account, domain, data, params = {}) => this._client.request("POST", `/${account}/domains/${domain}/pushes`, data, params); return method; })(); /** * List pending pushes for the target account. * * This API is paginated. Call `listPushes.iterateAll(account, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listPushes.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}/pushes * * @see https://developer.dnsimple.com/v2/domains/pushes/#listPushes * * @param account The account id * @param params Query parameters */ this.listPushes = (() => { const method = (account, params = {}) => this._client.request("GET", `/${account}/pushes`, null, params); method.iterateAll = (account, params = {}) => (0, paginate_1.paginate)((page) => method(account, Object.assign(Object.assign({}, params), { page }))); method.collectAll = (account_1, ...args_1) => __awaiter(this, [account_1, ...args_1], void 0, function* (account, params = {}) { var _a, e_4, _b, _c; const items = []; try { for (var _d = true, _e = __asyncValues(method.iterateAll(account, params)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const item = _c; items.push(item); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); } finally { if (e_4) throw e_4.error; } } return items; }); return method; })(); /** * Accepts a push to the target account. * * POST /{account}/pushes/{push} * * @see https://developer.dnsimple.com/v2/domains/pushes/#acceptPush * * @param account The account id * @param push The push id * @param params Query parameters */ this.acceptPush = (() => { const method = (account, push, data, params = {}) => this._client.request("POST", `/${account}/pushes/${push}`, data, params); return method; })(); /** * Rejects a push to the target account. * * DELETE /{account}/pushes/{push} * * @see https://developer.dnsimple.com/v2/domains/pushes/#rejectPush * * @param account The account id * @param push The push id * @param params Query parameters */ this.rejectPush = (() => { const method = (account, push, params = {}) => this._client.request("DELETE", `/${account}/pushes/${push}`, null, params); return method; })(); } } exports.Domains = Domains;