UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

145 lines • 5.95 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import * as TailsAPI from "./tails.mjs"; import { BaseTails, Tails, } from "./tails.mjs"; import * as HistoryAPI from "./history/history.mjs"; import { BaseHistory, History } from "./history/history.mjs"; import { V4PagePaginationArray, } from "../../../../core/pagination.mjs"; import { multipartFormRequestOptions } from "../../../../internal/uploads.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export var BaseDeployments = /* @__PURE__ */ (() => { class BaseDeployments extends APIResource { /** * Create a Cloudflare Pages deployment from a Git branch or Direct Upload * manifest. Git repositories must already be authorized in Cloudflare Pages. * * @example * ```ts * const deployment = * await client.pages.projects.deployments.create( * 'this-is-my-project-01', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ create(projectName, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/pages/projects/${projectName}/deployments`, multipartFormRequestOptions({ body, ...options }, this._client))._thenUnwrap((obj) => obj.result); } /** * List the production or preview deployments for a Cloudflare Pages project. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const deployment of client.pages.projects.deployments.list( * 'this-is-my-project-01', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(projectName, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/pages/projects/${projectName}/deployments`, (V4PagePaginationArray), { query, ...options }); } /** * Remove a deployment from a Cloudflare Pages project. * * @example * ```ts * const deployment = * await client.pages.projects.deployments.delete( * 'f64788e9-fccd-4d4a-a28a-cb84f88f6e12', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * project_name: 'this-is-my-project-01', * }, * ); * ``` */ delete(deploymentID, params, options) { const { account_id, project_name, force } = params; return this._client.delete(path `/accounts/${account_id}/pages/projects/${project_name}/deployments/${deploymentID}`, { query: { force }, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieve the status and details of a Cloudflare Pages deployment. * * @example * ```ts * const deployment = * await client.pages.projects.deployments.get( * 'f64788e9-fccd-4d4a-a28a-cb84f88f6e12', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * project_name: 'this-is-my-project-01', * }, * ); * ``` */ get(deploymentID, params, options) { const { account_id, project_name } = params; return this._client.get(path `/accounts/${account_id}/pages/projects/${project_name}/deployments/${deploymentID}`, options)._thenUnwrap((obj) => obj.result); } /** * Retry a previous Cloudflare Pages deployment. * * @example * ```ts * const deployment = * await client.pages.projects.deployments.retry( * 'f64788e9-fccd-4d4a-a28a-cb84f88f6e12', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * project_name: 'this-is-my-project-01', * }, * ); * ``` */ retry(deploymentID, params, options) { const { account_id, project_name } = params; return this._client.post(path `/accounts/${account_id}/pages/projects/${project_name}/deployments/${deploymentID}/retry`, options)._thenUnwrap((obj) => obj.result); } /** * Roll back production to a previous successful Cloudflare Pages deployment. * * @example * ```ts * const deployment = * await client.pages.projects.deployments.rollback( * 'f64788e9-fccd-4d4a-a28a-cb84f88f6e12', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * project_name: 'this-is-my-project-01', * }, * ); * ``` */ rollback(deploymentID, params, options) { const { account_id, project_name } = params; return this._client.post(path `/accounts/${account_id}/pages/projects/${project_name}/deployments/${deploymentID}/rollback`, options)._thenUnwrap((obj) => obj.result); } } BaseDeployments._key = Object.freeze([ 'pages', 'projects', 'deployments', ]); return BaseDeployments; })(); export var Deployments = /* @__PURE__ */ (() => { class Deployments extends BaseDeployments { constructor() { super(...arguments); this.history = new HistoryAPI.History(this._client); this.tails = new TailsAPI.Tails(this._client); } } Deployments.History = History; Deployments.BaseHistory = BaseHistory; Deployments.Tails = Tails; Deployments.BaseTails = BaseTails; return Deployments; })(); //# sourceMappingURL=deployments.mjs.map