UNPKG

@jesseditson/dnsimple

Version:

A Node.JS client for the DNSimple API.

512 lines (511 loc) 24.4 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.Registrar = void 0; const paginate_1 = require("./paginate"); class Registrar { constructor(_client) { this._client = _client; /** * Checks a domain name for availability. * * GET /{account}/registrar/domains/{domain}/check * * @see https://developer.dnsimple.com/v2/registrar/#checkDomain * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.checkDomain = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/check`, null, params); return method; })(); /** * Deprecated in favor of getDomainPrices. * * Retrieves the premium price for a premium domain. * * Please note that a premium price can be different for registration, renewal, transfer. By default this endpoint returns the premium price for registration. If you need to check a different price, you should specify it with the action param. * * GET /{account}/registrar/domains/{domain}/premium_price * * @see https://developer.dnsimple.com/v2/registrar/#getDomainPremiumPrice * * @param account The account id * @param domain The domain name or id * @param params Query parameters * @param params.action Optional action between "registration", "renewal", and "transfer". If omitted, it defaults to "registration". */ this.getDomainPremiumPrice = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/premium_price`, null, params); return method; })(); /** * Retrieve domain prices. * * GET /{account}/registrar/domains/{domain}/prices * * @see https://developer.dnsimple.com/v2/registrar/#getDomainPrices * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.getDomainPrices = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/prices`, null, params); return method; })(); /** * Registers a domain name. * * Your account must be active for this command to complete successfully. You will be automatically charged the registration fee upon successful registration, so please be careful with this command. * * POST /{account}/registrar/domains/{domain}/registrations * * @see https://developer.dnsimple.com/v2/registrar/#registerDomain * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.registerDomain = (() => { const method = (account, domain, data, params = {}) => this._client.request("POST", `/${account}/registrar/domains/${domain}/registrations`, data, params); return method; })(); /** * Retrieves the details of an existing domain registration. * * GET /{account}/registrar/domains/{domain}/registrations/{domainregistration} * * @see https://developer.dnsimple.com/v2/registrar/#getDomainRegistration * * @param account The account id * @param domain The domain name or id * @param domainregistration The domain registration id * @param params Query parameters */ this.getDomainRegistration = (() => { const method = (account, domain, domainregistration, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/registrations/${domainregistration}`, null, params); return method; })(); /** * Transfers a domain name from another registrar. * * Your account must be active for this command to complete successfully. You will be automatically charged the 1-year transfer fee upon successful transfer, so please be careful with this command. The transfer may take anywhere from a few minutes up to 7 days. * * POST /{account}/registrar/domains/{domain}/transfers * * @see https://developer.dnsimple.com/v2/registrar/#transferDomain * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.transferDomain = (() => { const method = (account, domain, data, params = {}) => this._client.request("POST", `/${account}/registrar/domains/${domain}/transfers`, data, params); return method; })(); /** * Retrieves the details of an existing domain transfer. * * GET /{account}/registrar/domains/{domain}/transfers/{domaintransfer} * * @see https://developer.dnsimple.com/v2/registrar/#getDomainTransfer * * @param account The account id * @param domain The domain name or id * @param domaintransfer The domain transfer id * @param params Query parameters */ this.getDomainTransfer = (() => { const method = (account, domain, domaintransfer, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/transfers/${domaintransfer}`, null, params); return method; })(); /** * Cancels an in progress domain transfer. * * DELETE /{account}/registrar/domains/{domain}/transfers/{domaintransfer} * * @see https://developer.dnsimple.com/v2/registrar/#cancelDomainTransfer * * @param account The account id * @param domain The domain name or id * @param domaintransfer The domain transfer id * @param params Query parameters */ this.cancelDomainTransfer = (() => { const method = (account, domain, domaintransfer, params = {}) => this._client.request("DELETE", `/${account}/registrar/domains/${domain}/transfers/${domaintransfer}`, null, params); return method; })(); /** * Explicitly renews a domain, if the registry supports this function. * * Your account must be active for this command to complete successfully. You will be automatically charged the renewal fee upon successful renewal, so please be careful with this command. * * POST /{account}/registrar/domains/{domain}/renewals * * @see https://developer.dnsimple.com/v2/registrar/#domainRenew * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.renewDomain = (() => { const method = (account, domain, data, params = {}) => this._client.request("POST", `/${account}/registrar/domains/${domain}/renewals`, data, params); return method; })(); /** * Retrieves the details of an existing domain renewal. * * GET /{account}/registrar/domains/{domain}/renewals/{domainrenewal} * * @see https://developer.dnsimple.com/v2/registrar/#getDomainRenewal * * @param account The account id * @param domain The domain name or id * @param domainrenewal The domain renewal id * @param params Query parameters */ this.getDomainRenewal = (() => { const method = (account, domain, domainrenewal, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/renewals/${domainrenewal}`, null, params); return method; })(); /** * Prepares a domain for transferring out. * * This will unlock a domain and send the authorization code to the domain's administrative contact. * * POST /{account}/registrar/domains/{domain}/authorize_transfer_out * * @see https://developer.dnsimple.com/v2/registrar/#authorizeDomainTransferOut * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.transferDomainOut = (() => { const method = (account, domain, params = {}) => this._client.request("POST", `/${account}/registrar/domains/${domain}/authorize_transfer_out`, null, params); return method; })(); /** * Lists the name servers for the domain. * * GET /{account}/registrar/domains/{domain}/delegation * * @see https://developer.dnsimple.com/v2/registrar/delegation/#getDomainDelegation * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.getDomainDelegation = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/delegation`, null, params); return method; })(); /** * Changes the domain name servers. * * PUT /{account}/registrar/domains/{domain}/delegation * * @see https://developer.dnsimple.com/v2/registrar/delegation/#changeDomainDelegation * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.changeDomainDelegation = (() => { const method = (account, domain, data, params = {}) => this._client.request("PUT", `/${account}/registrar/domains/${domain}/delegation`, data, params); return method; })(); /** * Delegate a domain to vanity name servers. * * PUT /{account}/registrar/domains/{domain}/delegation/vanity * * @see https://developer.dnsimple.com/v2/registrar/delegation/#changeDomainDelegationToVanity * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.changeDomainDelegationToVanity = (() => { const method = (account, domain, data, params = {}) => this._client.request("PUT", `/${account}/registrar/domains/${domain}/delegation/vanity`, data, params); return method; })(); /** * De-delegate a domain from vanity name servers. * * DELETE /{account}/registrar/domains/{domain}/delegation/vanity * * @see https://developer.dnsimple.com/v2/registrar/delegation/#changeDomainDelegationFromVanity * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.changeDomainDelegationFromVanity = (() => { const method = (account, domain, params = {}) => this._client.request("DELETE", `/${account}/registrar/domains/${domain}/delegation/vanity`, null, params); return method; })(); /** * Enables auto renewal for the domain. * * PUT /{account}/registrar/domains/{domain}/auto_renewal * * @see https://developer.dnsimple.com/v2/registrar/#enableDomainAutoRenewal * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.enableDomainAutoRenewal = (() => { const method = (account, domain, params = {}) => this._client.request("PUT", `/${account}/registrar/domains/${domain}/auto_renewal`, null, params); return method; })(); /** * Disables auto renewal for the domain. * * DELETE /{account}/registrar/domains/{domain}/auto_renewal * * @see https://developer.dnsimple.com/v2/registrar/#disableDomainAutoRenewal * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.disableDomainAutoRenewal = (() => { const method = (account, domain, params = {}) => this._client.request("DELETE", `/${account}/registrar/domains/${domain}/auto_renewal`, null, params); return method; })(); /** * Gets the whois privacy status for an existing domain. * * GET /{account}/registrar/domains/{domain}/whois_privacy * * @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#getWhoisPrivacy * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.getWhoisPrivacy = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/whois_privacy`, null, params); return method; })(); /** * Enables the WHOIS privacy for the domain. * * Note that if the WHOIS privacy is not purchased for the domain, enabling WHOIS privacy will cause the service to be purchased for a period of 1 year. If WHOIS privacy was previously purchased and disabled, then calling this will enable the WHOIS privacy. * * PUT /{account}/registrar/domains/{domain}/whois_privacy * * @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#enableWhoisPrivacy * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.enableWhoisPrivacy = (() => { const method = (account, domain, params = {}) => this._client.request("PUT", `/${account}/registrar/domains/${domain}/whois_privacy`, null, params); return method; })(); /** * Disables the WHOIS privacy for the domain. * * DELETE /{account}/registrar/domains/{domain}/whois_privacy * * @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#disableWhoisPrivacy * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.disableWhoisPrivacy = (() => { const method = (account, domain, params = {}) => this._client.request("DELETE", `/${account}/registrar/domains/${domain}/whois_privacy`, null, params); return method; })(); /** * Renews the WHOIS privacy for the domain. * * Note that if the WHOIS privacy was never purchased for the domain or if there is another renewal order in progress, renewing WHOIS privacy will return an error. * * POST /{account}/registrar/domains/{domain}/whois_privacy/renewals * * @see https://developer.dnsimple.com/v2/registrar/whois-privacy/#renewWhoisPrivacy * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.renewWhoisPrivacy = (() => { const method = (account, domain, params = {}) => this._client.request("POST", `/${account}/registrar/domains/${domain}/whois_privacy/renewals`, null, params); return method; })(); /** * List registrant changes in the account. * * This API is paginated. Call `listRegistrantChanges.iterateAll(account, params)` to get an asynchronous iterator over individual items across all pages. You can also use `await listRegistrantChanges.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}/registrar/registrant_changes * * @see https://developer.dnsimple.com/v2/registrar/#listRegistrantChanges * * @param account The account id * @param params Query parameters * @param params.sort Sort results. Default sorting is by id. * @param params.state Only include results with a state field exactly matching the given string * @param params.domain_id Only include results with a domain_id field exactly matching the given string * @param params.contact_id Only include results with a contact_id field exactly matching the given string */ this.listRegistrantChanges = (() => { const method = (account, params = {}) => this._client.request("GET", `/${account}/registrar/registrant_changes`, 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; })(); /** * Start registrant change. * * POST /{account}/registrar/registrant_changes * * @see https://developer.dnsimple.com/v2/registrar/#createRegistrantChange * * @param account The account id * @param params Query parameters */ this.createRegistrantChange = (() => { const method = (account, data, params = {}) => this._client.request("POST", `/${account}/registrar/registrant_changes`, data, params); return method; })(); /** * Retrieves the requirements of a registrant change. * * POST /{account}/registrar/registrant_changes/check * * @see https://developer.dnsimple.com/v2/registrar/#checkRegistrantChange * * @param account The account id * @param params Query parameters */ this.checkRegistrantChange = (() => { const method = (account, data, params = {}) => this._client.request("POST", `/${account}/registrar/registrant_changes/check`, data, params); return method; })(); /** * Retrieves the details of an existing registrant change. * * GET /{account}/registrar/registrant_changes/{registrantchange} * * @see https://developer.dnsimple.com/v2/registrar/#getRegistrantChange * * @param account The account id * @param registrantchange The registrant change id * @param params Query parameters */ this.getRegistrantChange = (() => { const method = (account, registrantchange, params = {}) => this._client.request("GET", `/${account}/registrar/registrant_changes/${registrantchange}`, null, params); return method; })(); /** * Cancel an ongoing registrant change from the account. * * DELETE /{account}/registrar/registrant_changes/{registrantchange} * * @see https://developer.dnsimple.com/v2/registrar/#deleteRegistrantChange * * @param account The account id * @param registrantchange The registrant change id * @param params Query parameters */ this.deleteRegistrantChange = (() => { const method = (account, registrantchange, params = {}) => this._client.request("DELETE", `/${account}/registrar/registrant_changes/${registrantchange}`, null, params); return method; })(); /** * Gets the transfer lock status for a domain. * * GET /{account}/registrar/domains/{domain}/transfer_lock * * @see https://developer.dnsimple.com/v2/registrar/#getDomainTransferLock * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.getDomainTransferLock = (() => { const method = (account, domain, params = {}) => this._client.request("GET", `/${account}/registrar/domains/${domain}/transfer_lock`, null, params); return method; })(); /** * Locks the domain to prevent unauthorized transfers. * * POST /{account}/registrar/domains/{domain}/transfer_lock * * @see https://developer.dnsimple.com/v2/registrar/#enableDomainTransferLock * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.enableDomainTransferLock = (() => { const method = (account, domain, params = {}) => this._client.request("POST", `/${account}/registrar/domains/${domain}/transfer_lock`, null, params); return method; })(); /** * Unlocks the domain to allow domain transfers. * * DELETE /{account}/registrar/domains/{domain}/transfer_lock * * @see https://developer.dnsimple.com/v2/registrar/#disableDomainTransferLock * * @param account The account id * @param domain The domain name or id * @param params Query parameters */ this.disableDomainTransferLock = (() => { const method = (account, domain, params = {}) => this._client.request("DELETE", `/${account}/registrar/domains/${domain}/transfer_lock`, null, params); return method; })(); } } exports.Registrar = Registrar;