UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

85 lines • 3.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Domains = exports.BaseDomains = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseDomains = /* @__PURE__ */ (() => { class BaseDomains extends resource_1.APIResource { /** * Attaches a domain that routes traffic to a Worker. * * @example * ```ts * const domain = await client.workers.domains.update({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * hostname: 'app.example.com', * service: 'my-worker', * }); * ``` */ update(params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/workers/domains`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Lists all Worker domains for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const domainListResponse of client.workers.domains.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/workers/domains`, (pagination_1.SinglePage), { query, ...options }); } /** * Detaches a domain from a Worker. Both the Worker and all of its previews are no * longer routable using this domain. * * @example * ```ts * const domain = await client.workers.domains.delete( * 'dbe10b4bc17c295377eabd600e1787fd', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(domainID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/workers/domains/${domainID}`, options); } /** * Gets information about a Worker domain. * * @example * ```ts * const domain = await client.workers.domains.get( * 'dbe10b4bc17c295377eabd600e1787fd', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(domainID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/workers/domains/${domainID}`, options)._thenUnwrap((obj) => obj.result); } } BaseDomains._key = Object.freeze([ 'workers', 'domains', ]); return BaseDomains; })(); exports.BaseDomains = BaseDomains; class Domains extends BaseDomains { } exports.Domains = Domains; //# sourceMappingURL=domains.js.map