UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

80 lines • 3.78 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as EventsAPI from "./events.mjs"; import { BaseEvents, Events } from "./events.mjs"; import * as StatusAPI from "./status.mjs"; import { BaseStatus, Status } from "./status.mjs"; import { SinglePage, V4PagePaginationArray, } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseInstances = /* @__PURE__ */ (() => { class BaseInstances extends APIResource { /** * Creates a new instance of a workflow, starting its execution. */ create(workflowName, params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/workflows/${workflowName}/instances`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists all instances of a workflow with their execution status. */ list(workflowName, params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/workflows/${workflowName}/instances`, (V4PagePaginationArray), { query, ...options }); } /** * Creates multiple workflow instances in a single batch operation. */ bulk(workflowName, params, options) { const { account_id, body } = params; return this._client.getAPIList(path `/accounts/${account_id}/workflows/${workflowName}/instances/batch`, (SinglePage), { body: body, method: 'post', ...options }); } /** * Retrieves logs and execution status for a specific workflow instance. */ get(instanceID, params, options) { const { account_id, workflow_name, ...query } = params; return this._client.get(path `/accounts/${account_id}/workflows/${workflow_name}/instances/${instanceID}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieves the full, untruncated output for a specific step on a workflow * instance. Returns a flat status-shaped JSON body with step `status` ('running' | * 'waiting' | 'complete' | 'errored'), `error` (nullable), and `output` (the step * value, or null while running/waiting/errored). When the step returned a * ReadableStream from step.do, the response is served as * 'application/octet-stream' with the raw bytes as the body instead of JSON. A * `status='running'` response with non-null `error` indicates the step is * currently retrying after a prior attempt failed. */ step(instanceID, params, options) { const { account_id, workflow_name, ...query } = params; return this._client.get(path `/accounts/${account_id}/workflows/${workflow_name}/instances/${instanceID}/step`, { query, ...options })._thenUnwrap((obj) => obj.result); } } BaseInstances._key = Object.freeze([ 'workflows', 'instances', ]); return BaseInstances; })(); export var Instances = /* @__PURE__ */ (() => { class Instances extends BaseInstances { constructor() { super(...arguments); this.status = new StatusAPI.Status(this._client); this.events = new EventsAPI.Events(this._client); } } Instances.Status = Status; Instances.BaseStatus = BaseStatus; Instances.Events = Events; Instances.BaseEvents = BaseEvents; return Instances; })(); //# sourceMappingURL=instances.mjs.map