cloudflare
Version:
The official TypeScript library for the Cloudflare API
111 lines • 4.15 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 {
/**
* Attach a custom domain to a Cloudflare Pages project.
*
* @example
* ```ts
* const domain = await client.pages.projects.domains.create(
* 'this-is-my-project-01',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'example.com',
* },
* );
* ```
*/
create(projectName, params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/pages/projects/${projectName}/domains`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List the custom domains associated with a Cloudflare Pages project.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const domainListResponse of client.pages.projects.domains.list(
* 'this-is-my-project-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(projectName, params, options) {
const { account_id } = params;
return this._client.getAPIList(path `/accounts/${account_id}/pages/projects/${projectName}/domains`, (SinglePage), options);
}
/**
* Remove a custom domain from a Cloudflare Pages project.
*
* @example
* ```ts
* const domain = await client.pages.projects.domains.delete(
* 'example.com',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* project_name: 'this-is-my-project-01',
* },
* );
* ```
*/
delete(domainName, params, options) {
const { account_id, project_name } = params;
return this._client.delete(path `/accounts/${account_id}/pages/projects/${project_name}/domains/${domainName}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retry validation for a custom domain attached to a Cloudflare Pages project.
*
* @example
* ```ts
* const response = await client.pages.projects.domains.edit(
* 'example.com',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* project_name: 'this-is-my-project-01',
* },
* );
* ```
*/
edit(domainName, params, options) {
const { account_id, project_name } = params;
return this._client.patch(path `/accounts/${account_id}/pages/projects/${project_name}/domains/${domainName}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retrieve the configuration and validation status of a custom domain attached to
* a Cloudflare Pages project.
*
* @example
* ```ts
* const domain = await client.pages.projects.domains.get(
* 'example.com',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* project_name: 'this-is-my-project-01',
* },
* );
* ```
*/
get(domainName, params, options) {
const { account_id, project_name } = params;
return this._client.get(path `/accounts/${account_id}/pages/projects/${project_name}/domains/${domainName}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDomains._key = Object.freeze([
'pages',
'projects',
'domains',
]);
return BaseDomains;
})();
export class Domains extends BaseDomains {
}
//# sourceMappingURL=domains.mjs.map