UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

149 lines • 6.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Applications = exports.BaseApplications = 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 InstancesAPI = tslib_1.__importStar(require("./instances.js")); const instances_1 = require("./instances.js"); const RolloutsAPI = tslib_1.__importStar(require("./rollouts.js")); const rollouts_1 = require("./rollouts.js"); const VersionsAPI = tslib_1.__importStar(require("./versions.js")); const versions_1 = require("./versions.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseApplications = /* @__PURE__ */ (() => { class BaseApplications extends resource_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/containers/applications`, (pagination_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/containers/applications/${applicationID}`, options)._thenUnwrap((obj) => obj.result); } } BaseApplications._key = Object.freeze([ 'containers', 'applications', ]); return BaseApplications; })(); exports.BaseApplications = BaseApplications; 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 = instances_1.Instances; Applications.BaseInstances = instances_1.BaseInstances; Applications.Rollouts = rollouts_1.Rollouts; Applications.BaseRollouts = rollouts_1.BaseRollouts; Applications.Versions = versions_1.Versions; Applications.BaseVersions = versions_1.BaseVersions; return Applications; })(); exports.Applications = Applications; //# sourceMappingURL=applications.js.map