// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { PageCursorURL, PagePromise } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; /** * Functions defined by the company */ export class Executions extends APIResource { /** * A list of function executions. * * - Requires: `API Tier 2` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( functionAPIName: string, query: ExecutionListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList( path`/functions/${functionAPIName}/executions/`, PageCursorURL, { query, ...options }, ); } /** * Create a new function execution. */ create( functionAPIName: string, body: ExecutionCreateParams, options?: RequestOptions, ): APIPromise { return this._client.post(path`/functions/${functionAPIName}/executions/`, { body, ...options }); } /** * Retrieve a specific function execution. */ retrieve( executionID: string, params: ExecutionRetrieveParams, options?: RequestOptions, ): APIPromise { const { function_api_name } = params; return this._client.get(path`/functions/${function_api_name}/executions/${executionID}/`, options); } /** * A list of function execution logs. * * - Requires: `API Tier 2` */ listLogs( executionID: string, params: ExecutionListLogsParams, options?: RequestOptions, ): APIPromise { const { function_api_name } = params; return this._client.get(path`/functions/${function_api_name}/executions/${executionID}/logs/`, options); } } export type FunctionExecutionsPageCursorURL = PageCursorURL; export interface FunctionExecution { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * The ID of the function this execution belongs to */ function_id: string; /** * The inputs of the execution */ inputs: unknown; /** * Record update date */ updated_at: string; /** * The end time of the execution */ finished_at?: string; /** * The outputs of the execution */ outputs?: unknown; /** * The start time of the execution */ started_at?: string; /** * The status of the execution */ status?: string; } export interface ExecutionListLogsResponse { results?: Array; } export namespace ExecutionListLogsResponse { export interface Result { /** * The log message */ message: string; /** * The sequence number of the log line */ sequence_num: number; /** * The log level */ level?: string; /** * Parameters associated with the log line */ params?: unknown; /** * The log timestamp */ timestamp?: string; } } export interface ExecutionListParams { order_by?: string; } export interface ExecutionCreateParams { /** * The inputs of the execution */ inputs: unknown; } export interface ExecutionRetrieveParams { /** * The API name of the function. */ function_api_name: string; } export interface ExecutionListLogsParams { /** * The API name of the function. */ function_api_name: string; } export declare namespace Executions { export { type FunctionExecution as FunctionExecution, type ExecutionListLogsResponse as ExecutionListLogsResponse, type FunctionExecutionsPageCursorURL as FunctionExecutionsPageCursorURL, type ExecutionListParams as ExecutionListParams, type ExecutionCreateParams as ExecutionCreateParams, type ExecutionRetrieveParams as ExecutionRetrieveParams, type ExecutionListLogsParams as ExecutionListLogsParams, }; }