cloudflare
Version:
The official TypeScript library for the Cloudflare API
116 lines • 4.41 kB
JavaScript
;
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 {
/**
* 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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}/domains`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/pages/projects/${project_name}/domains/${domainName}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDomains._key = Object.freeze([
'pages',
'projects',
'domains',
]);
return BaseDomains;
})();
exports.BaseDomains = BaseDomains;
class Domains extends BaseDomains {
}
exports.Domains = Domains;
//# sourceMappingURL=domains.js.map