33import { APIResource } from '../core/resource' ;
44import * as Shared from './shared' ;
55import { APIPromise } from '../core/api-promise' ;
6+ import { OffsetPagination , type OffsetPaginationParams , PagePromise } from '../core/pagination' ;
67import { Stream } from '../core/streaming' ;
78import { buildHeaders } from '../internal/headers' ;
89import { RequestOptions } from '../internal/request-options' ;
@@ -58,6 +59,28 @@ export class Invocations extends APIResource {
5859 return this . _client . patch ( path `/invocations/${ id } ` , { body, ...options } ) ;
5960 }
6061
62+ /**
63+ * List invocations. Optionally filter by application name, action name, status,
64+ * deployment ID, or start time.
65+ *
66+ * @example
67+ * ```ts
68+ * // Automatically fetches more pages as needed.
69+ * for await (const invocationListResponse of client.invocations.list()) {
70+ * // ...
71+ * }
72+ * ```
73+ */
74+ list (
75+ query : InvocationListParams | null | undefined = { } ,
76+ options ?: RequestOptions ,
77+ ) : PagePromise < InvocationListResponsesOffsetPagination , InvocationListResponse > {
78+ return this . _client . getAPIList ( '/invocations' , OffsetPagination < InvocationListResponse > , {
79+ query,
80+ ...options ,
81+ } ) ;
82+ }
83+
6184 /**
6285 * Delete all browser sessions created within the specified invocation.
6386 *
@@ -97,6 +120,8 @@ export class Invocations extends APIResource {
97120 }
98121}
99122
123+ export type InvocationListResponsesOffsetPagination = OffsetPagination < InvocationListResponse > ;
124+
100125/**
101126 * An event representing the current state of an invocation.
102127 */
@@ -291,6 +316,55 @@ export interface InvocationUpdateResponse {
291316 status_reason ?: string ;
292317}
293318
319+ export interface InvocationListResponse {
320+ /**
321+ * ID of the invocation
322+ */
323+ id : string ;
324+
325+ /**
326+ * Name of the action invoked
327+ */
328+ action_name : string ;
329+
330+ /**
331+ * Name of the application
332+ */
333+ app_name : string ;
334+
335+ /**
336+ * RFC 3339 Nanoseconds timestamp when the invocation started
337+ */
338+ started_at : string ;
339+
340+ /**
341+ * Status of the invocation
342+ */
343+ status : 'queued' | 'running' | 'succeeded' | 'failed' ;
344+
345+ /**
346+ * RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
347+ * running)
348+ */
349+ finished_at ?: string | null ;
350+
351+ /**
352+ * Output produced by the action, rendered as a JSON string. This could be: string,
353+ * number, boolean, array, object, or null.
354+ */
355+ output ?: string ;
356+
357+ /**
358+ * Payload provided to the invocation. This is a string that can be parsed as JSON.
359+ */
360+ payload ?: string ;
361+
362+ /**
363+ * Status reason
364+ */
365+ status_reason ?: string ;
366+ }
367+
294368/**
295369 * Union type representing any invocation event.
296370 */
@@ -340,6 +414,34 @@ export interface InvocationUpdateParams {
340414 output ?: string ;
341415}
342416
417+ export interface InvocationListParams extends OffsetPaginationParams {
418+ /**
419+ * Filter results by action name.
420+ */
421+ action_name ?: string ;
422+
423+ /**
424+ * Filter results by application name.
425+ */
426+ app_name ?: string ;
427+
428+ /**
429+ * Filter results by deployment ID.
430+ */
431+ deployment_id ?: string ;
432+
433+ /**
434+ * Show invocations that have started since the given time (RFC timestamps or
435+ * durations like 5m).
436+ */
437+ since ?: string ;
438+
439+ /**
440+ * Filter results by invocation status.
441+ */
442+ status ?: 'queued' | 'running' | 'succeeded' | 'failed' ;
443+ }
444+
343445export interface InvocationFollowParams {
344446 /**
345447 * Show logs since the given time (RFC timestamps or durations like 5m).
@@ -353,9 +455,12 @@ export declare namespace Invocations {
353455 type InvocationCreateResponse as InvocationCreateResponse ,
354456 type InvocationRetrieveResponse as InvocationRetrieveResponse ,
355457 type InvocationUpdateResponse as InvocationUpdateResponse ,
458+ type InvocationListResponse as InvocationListResponse ,
356459 type InvocationFollowResponse as InvocationFollowResponse ,
460+ type InvocationListResponsesOffsetPagination as InvocationListResponsesOffsetPagination ,
357461 type InvocationCreateParams as InvocationCreateParams ,
358462 type InvocationUpdateParams as InvocationUpdateParams ,
463+ type InvocationListParams as InvocationListParams ,
359464 type InvocationFollowParams as InvocationFollowParams ,
360465 } ;
361466}
0 commit comments