cloudflare
Version:
The official TypeScript library for the Cloudflare API
143 lines • 5.93 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as InstancesAPI from "./instances.mjs";
import { BaseInstances, Instances as InstancesAPIInstances, } from "./instances.mjs";
import * as RolloutsAPI from "./rollouts.mjs";
import { BaseRollouts, Rollouts } from "./rollouts.mjs";
import * as VersionsAPI from "./versions.mjs";
import { BaseVersions, Versions, } from "./versions.mjs";
import { PageTokenPagination } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseApplications = /* @__PURE__ */ (() => {
class BaseApplications extends APIResource {
/**
* Create a Containers application.
*
* Use `scheduling_policy: "default"` for a scheduler-backed application. The
* Containers scheduler maintains the requested instance count and manages
* deployment configuration, placement, scaling, versions, and rollouts.
*
* Use `scheduling_policy: "durable_object"` for a Durable Object-managed
* application. Each Durable Object creates and manages the lifecycle of its
* container instance. Supply `name`, `scheduling_policy`, and `durable_objects`,
* with optional `configuration` and optional top-level `observability` settings.
* Deployment configuration, scaling, constraints, versions, and rollouts do not
* apply.
*
* @example
* ```ts
* const application =
* await client.containers.applications.create({
* account_id: 'account-123',
* configuration: { image: 'image' },
* instances: 0,
* max_instances: 0,
* name: 'name',
* scheduling_policy: 'default',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/containers/applications`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all the applications that are associated with your account.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const applicationListResponse of client.containers.applications.list(
* { account_id: 'account-123' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/containers/applications`, (PageTokenPagination), { query, ...options });
}
/**
* Deletes a single application by id.
*
* @example
* ```ts
* const application =
* await client.containers.applications.delete(
* 'application_id',
* { account_id: 'account-123' },
* );
* ```
*/
delete(applicationID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/containers/applications/${applicationID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Modifies a single application by id. Durable Object-managed application settings
* are published to runtime metadata without creating deployments or rollouts.
* Top-level `observability` for these applications supports only `logs.enabled`.
* The supported fields depend on the existing application's scheduling policy. For
* scheduler-backed applications, changes that replace instance deployment
* configuration, including the image, require a rollout.
*
* @example
* ```ts
* const response = await client.containers.applications.edit(
* 'application_id',
* { account_id: 'account-123' },
* );
* ```
*/
edit(applicationID, params, options) {
const { account_id, ...body } = params;
return this._client.patch(path `/accounts/${account_id}/containers/applications/${applicationID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Returns a single application by id.
*
* @example
* ```ts
* const application =
* await client.containers.applications.get(
* 'application_id',
* { account_id: 'account-123' },
* );
* ```
*/
get(applicationID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/containers/applications/${applicationID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseApplications._key = Object.freeze([
'containers',
'applications',
]);
return BaseApplications;
})();
export var Applications = /* @__PURE__ */ (() => {
class Applications extends BaseApplications {
constructor() {
super(...arguments);
this.instances = new InstancesAPI.Instances(this._client);
this.rollouts = new RolloutsAPI.Rollouts(this._client);
this.versions = new VersionsAPI.Versions(this._client);
}
}
Applications.Instances = InstancesAPIInstances;
Applications.BaseInstances = BaseInstances;
Applications.Rollouts = Rollouts;
Applications.BaseRollouts = BaseRollouts;
Applications.Versions = Versions;
Applications.BaseVersions = BaseVersions;
return Applications;
})();
//# sourceMappingURL=applications.mjs.map