cloudflare
Version:
The official TypeScript library for the Cloudflare API
108 lines • 4.18 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { V4PagePagination } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseDeployments = /* @__PURE__ */ (() => {
class BaseDeployments extends APIResource {
/**
* Deployments configure how
* [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions)
* are deployed to traffic. A deployment can consist of multiple versions of a
* Worker.
*
* @example
* ```ts
* const deployment =
* await client.workers.scripts.deployments.create(
* 'this-is_my_script-01',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* strategy: 'percentage',
* versions: [
* {
* percentage: 100,
* version_id:
* '023e105f-2a42-4f8b-a1c1-73f6a2a30c0f',
* },
* ],
* },
* );
* ```
*/
create(scriptName, params, options) {
const { account_id, force, ...body } = params;
return this._client.post(path `/accounts/${account_id}/workers/scripts/${scriptName}/deployments`, {
query: { force },
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* List Worker deployments. The first deployment in the list is the latest
* deployment actively serving traffic.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const deploymentListResponse of client.workers.scripts.deployments.list(
* 'this-is_my_script-01',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(scriptName, params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/workers/scripts/${scriptName}/deployments`, (V4PagePagination), { query, ...options });
}
/**
* Delete a Worker Deployment. The latest deployment, which is actively serving
* traffic, cannot be deleted. All other deployments can be deleted.
*
* @example
* ```ts
* const deployment =
* await client.workers.scripts.deployments.delete(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* script_name: 'this-is_my_script-01',
* },
* );
* ```
*/
delete(deploymentID, params, options) {
const { account_id, script_name } = params;
return this._client.delete(path `/accounts/${account_id}/workers/scripts/${script_name}/deployments/${deploymentID}`, options);
}
/**
* Get information about a Worker Deployment.
*
* @example
* ```ts
* const deployment =
* await client.workers.scripts.deployments.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* {
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* script_name: 'this-is_my_script-01',
* },
* );
* ```
*/
get(deploymentID, params, options) {
const { account_id, script_name } = params;
return this._client.get(path `/accounts/${account_id}/workers/scripts/${script_name}/deployments/${deploymentID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseDeployments._key = Object.freeze([
'workers',
'scripts',
'deployments',
]);
return BaseDeployments;
})();
export class Deployments extends BaseDeployments {
}
//# sourceMappingURL=deployments.mjs.map