cloudflare
Version:
The official TypeScript library for the Cloudflare API
151 lines • 6.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deployments = exports.BaseDeployments = void 0;
const tslib_1 = require("../../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../../core/resource.js");
const TailsAPI = tslib_1.__importStar(require("./tails.js"));
const tails_1 = require("./tails.js");
const HistoryAPI = tslib_1.__importStar(require("./history/history.js"));
const history_1 = require("./history/history.js");
const pagination_1 = require("../../../../core/pagination.js");
const uploads_1 = require("../../../../internal/uploads.js");
const path_1 = require("../../../../internal/utils/path.js");
var BaseDeployments = /* @__PURE__ */ (() => {
class BaseDeployments extends resource_1.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((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}/deployments`, (0, uploads_1.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((0, path_1.path) `/accounts/${account_id}/pages/projects/${projectName}/deployments`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.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((0, path_1.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;
})();
exports.BaseDeployments = BaseDeployments;
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_1.History;
Deployments.BaseHistory = history_1.BaseHistory;
Deployments.Tails = tails_1.Tails;
Deployments.BaseTails = tails_1.BaseTails;
return Deployments;
})();
exports.Deployments = Deployments;
//# sourceMappingURL=deployments.js.map