cloudflare
Version:
The official TypeScript library for the Cloudflare API
86 lines • 4.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Instances = exports.BaseInstances = 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 EventsAPI = tslib_1.__importStar(require("./events.js"));
const events_1 = require("./events.js");
const StatusAPI = tslib_1.__importStar(require("./status.js"));
const status_1 = require("./status.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseInstances = /* @__PURE__ */ (() => {
class BaseInstances extends resource_1.APIResource {
/**
* Creates a new instance of a workflow, starting its execution.
*/
create(workflowName, params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.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((0, path_1.path) `/accounts/${account_id}/workflows/${workflowName}/instances`, (pagination_1.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((0, path_1.path) `/accounts/${account_id}/workflows/${workflowName}/instances/batch`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/workflows/${workflow_name}/instances/${instanceID}/step`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
}
BaseInstances._key = Object.freeze([
'workflows',
'instances',
]);
return BaseInstances;
})();
exports.BaseInstances = BaseInstances;
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_1.Status;
Instances.BaseStatus = status_1.BaseStatus;
Instances.Events = events_1.Events;
Instances.BaseEvents = events_1.BaseEvents;
return Instances;
})();
exports.Instances = Instances;
//# sourceMappingURL=instances.js.map