cloudflare
Version:
The official TypeScript library for the Cloudflare API
80 lines • 2.94 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { SinglePage } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseDomains = /* @__PURE__ */ (() => {
class BaseDomains extends 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(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(path `/accounts/${account_id}/workers/domains`, (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(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(path `/accounts/${account_id}/workers/domains/${domainID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDomains._key = Object.freeze([
'workers',
'domains',
]);
return BaseDomains;
})();
export class Domains extends BaseDomains {
}
//# sourceMappingURL=domains.mjs.map