-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinvocations.ts
More file actions
228 lines (194 loc) · 4.76 KB
/
invocations.ts
File metadata and controls
228 lines (194 loc) · 4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// 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 { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Invocations extends APIResource {
/**
* Invoke an action.
*
* @example
* ```ts
* const invocation = await client.apps.invocations.create({
* action_name: 'analyze',
* app_name: 'my-app',
* version: '1.0.0',
* });
* ```
*/
create(body: InvocationCreateParams, options?: RequestOptions): APIPromise<InvocationCreateResponse> {
return this._client.post('/invocations', { body, ...options });
}
/**
* Get details about an invocation's status and output.
*
* @example
* ```ts
* const invocation = await client.apps.invocations.retrieve(
* 'rr33xuugxj9h0bkf1rdt2bet',
* );
* ```
*/
retrieve(id: string, options?: RequestOptions): APIPromise<InvocationRetrieveResponse> {
return this._client.get(path`/invocations/${id}`, options);
}
/**
* Update an invocation's status or output.
*
* @example
* ```ts
* const invocation = await client.apps.invocations.update(
* 'id',
* { status: 'succeeded' },
* );
* ```
*/
update(
id: string,
body: InvocationUpdateParams,
options?: RequestOptions,
): APIPromise<InvocationUpdateResponse> {
return this._client.patch(path`/invocations/${id}`, { body, ...options });
}
}
export interface InvocationCreateResponse {
/**
* ID of the invocation
*/
id: string;
/**
* Status of the invocation
*/
status: 'queued' | 'running' | 'succeeded' | 'failed';
/**
* The return value of the action that was invoked, rendered as a JSON string. This
* could be: string, number, boolean, array, object, or null.
*/
output?: string;
/**
* Status reason
*/
status_reason?: string;
}
export interface InvocationRetrieveResponse {
/**
* ID of the invocation
*/
id: string;
/**
* Name of the action invoked
*/
action_name: string;
/**
* Name of the application
*/
app_name: string;
/**
* RFC 3339 Nanoseconds timestamp when the invocation started
*/
started_at: string;
/**
* Status of the invocation
*/
status: 'queued' | 'running' | 'succeeded' | 'failed';
/**
* RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
* running)
*/
finished_at?: string | null;
/**
* Output produced by the action, rendered as a JSON string. This could be: string,
* number, boolean, array, object, or null.
*/
output?: string;
/**
* Payload provided to the invocation. This is a string that can be parsed as JSON.
*/
payload?: string;
/**
* Status reason
*/
status_reason?: string;
}
export interface InvocationUpdateResponse {
/**
* ID of the invocation
*/
id: string;
/**
* Name of the action invoked
*/
action_name: string;
/**
* Name of the application
*/
app_name: string;
/**
* RFC 3339 Nanoseconds timestamp when the invocation started
*/
started_at: string;
/**
* Status of the invocation
*/
status: 'queued' | 'running' | 'succeeded' | 'failed';
/**
* RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
* running)
*/
finished_at?: string | null;
/**
* Output produced by the action, rendered as a JSON string. This could be: string,
* number, boolean, array, object, or null.
*/
output?: string;
/**
* Payload provided to the invocation. This is a string that can be parsed as JSON.
*/
payload?: string;
/**
* Status reason
*/
status_reason?: string;
}
export interface InvocationCreateParams {
/**
* Name of the action to invoke
*/
action_name: string;
/**
* Name of the application
*/
app_name: string;
/**
* Version of the application
*/
version: string;
/**
* If true, invoke asynchronously. When set, the API responds 202 Accepted with
* status "queued".
*/
async?: boolean;
/**
* Input data for the action, sent as a JSON string.
*/
payload?: string;
}
export interface InvocationUpdateParams {
/**
* New status for the invocation.
*/
status: 'succeeded' | 'failed';
/**
* Updated output of the invocation rendered as JSON string.
*/
output?: string;
}
export declare namespace Invocations {
export {
type InvocationCreateResponse as InvocationCreateResponse,
type InvocationRetrieveResponse as InvocationRetrieveResponse,
type InvocationUpdateResponse as InvocationUpdateResponse,
type InvocationCreateParams as InvocationCreateParams,
type InvocationUpdateParams as InvocationUpdateParams,
};
}