Skip to content

Commit 4c5b6b6

Browse files
feat(api): update via SDK Studio
1 parent ef27cbe commit 4c5b6b6

File tree

6 files changed

+118
-4
lines changed

6 files changed

+118
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 10
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3edc7a0eef4a0d4495782efbdb0d9b777a55aee058dab119f90de56019441326.yml
3-
openapi_spec_hash: dff0b1efa1c1614cf770ed8327cefab2
4-
config_hash: cb04a4d88ee9f530b303ca57ff7090b3
1+
configured_endpoints: 11
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-64ccdff4ca5d73d79d89e817fe83ccfd3d529696df3e6818c3c75e586ae00801.yml
3+
openapi_spec_hash: 21c7b8757fc0cc9415cda1bc06251de6
4+
config_hash: b3fcacd707da56b21d31ce0baf4fb87d

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ Types:
2626

2727
- <code><a href="./src/resources/apps/invocations.ts">InvocationCreateResponse</a></code>
2828
- <code><a href="./src/resources/apps/invocations.ts">InvocationRetrieveResponse</a></code>
29+
- <code><a href="./src/resources/apps/invocations.ts">InvocationUpdateResponse</a></code>
2930

3031
Methods:
3132

3233
- <code title="post /invocations">client.apps.invocations.<a href="./src/resources/apps/invocations.ts">create</a>({ ...params }) -> InvocationCreateResponse</code>
3334
- <code title="get /invocations/{id}">client.apps.invocations.<a href="./src/resources/apps/invocations.ts">retrieve</a>(id) -> InvocationRetrieveResponse</code>
35+
- <code title="patch /invocations/{id}">client.apps.invocations.<a href="./src/resources/apps/invocations.ts">update</a>(id, { ...params }) -> InvocationUpdateResponse</code>
3436

3537
# Browsers
3638

src/resources/apps/apps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
InvocationCreateParams,
1414
InvocationCreateResponse,
1515
InvocationRetrieveResponse,
16+
InvocationUpdateParams,
17+
InvocationUpdateResponse,
1618
Invocations,
1719
} from './invocations';
1820
import { APIPromise } from '../../core/api-promise';
@@ -99,6 +101,8 @@ export declare namespace Apps {
99101
Invocations as Invocations,
100102
type InvocationCreateResponse as InvocationCreateResponse,
101103
type InvocationRetrieveResponse as InvocationRetrieveResponse,
104+
type InvocationUpdateResponse as InvocationUpdateResponse,
102105
type InvocationCreateParams as InvocationCreateParams,
106+
type InvocationUpdateParams as InvocationUpdateParams,
103107
};
104108
}

src/resources/apps/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ export {
1111
Invocations,
1212
type InvocationCreateResponse,
1313
type InvocationRetrieveResponse,
14+
type InvocationUpdateResponse,
1415
type InvocationCreateParams,
16+
type InvocationUpdateParams,
1517
} from './invocations';

src/resources/apps/invocations.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ export class Invocations extends APIResource {
3535
retrieve(id: string, options?: RequestOptions): APIPromise<InvocationRetrieveResponse> {
3636
return this._client.get(path`/invocations/${id}`, options);
3737
}
38+
39+
/**
40+
* Update invocation status or output
41+
*
42+
* @example
43+
* ```ts
44+
* const invocation = await client.apps.invocations.update(
45+
* 'id',
46+
* { status: 'succeeded' },
47+
* );
48+
* ```
49+
*/
50+
update(
51+
id: string,
52+
body: InvocationUpdateParams,
53+
options?: RequestOptions,
54+
): APIPromise<InvocationUpdateResponse> {
55+
return this._client.patch(path`/invocations/${id}`, { body, ...options });
56+
}
3857
}
3958

4059
export interface InvocationCreateResponse {
@@ -109,6 +128,55 @@ export interface InvocationRetrieveResponse {
109128
status_reason?: string;
110129
}
111130

131+
export interface InvocationUpdateResponse {
132+
/**
133+
* ID of the invocation
134+
*/
135+
id: string;
136+
137+
/**
138+
* Name of the action invoked
139+
*/
140+
action_name: string;
141+
142+
/**
143+
* Name of the application
144+
*/
145+
app_name: string;
146+
147+
/**
148+
* RFC 3339 Nanoseconds timestamp when the invocation started
149+
*/
150+
started_at: string;
151+
152+
/**
153+
* Status of the invocation
154+
*/
155+
status: 'queued' | 'running' | 'succeeded' | 'failed';
156+
157+
/**
158+
* RFC 3339 Nanoseconds timestamp when the invocation finished (null if still
159+
* running)
160+
*/
161+
finished_at?: string | null;
162+
163+
/**
164+
* Output produced by the action, rendered as a JSON string. This could be: string,
165+
* number, boolean, array, object, or null.
166+
*/
167+
output?: string;
168+
169+
/**
170+
* Payload provided to the invocation. This is a string that can be parsed as JSON.
171+
*/
172+
payload?: string;
173+
174+
/**
175+
* Status reason
176+
*/
177+
status_reason?: string;
178+
}
179+
112180
export interface InvocationCreateParams {
113181
/**
114182
* Name of the action to invoke
@@ -125,16 +193,36 @@ export interface InvocationCreateParams {
125193
*/
126194
version: string;
127195

196+
/**
197+
* If true, invoke asynchronously. When set, the API responds 202 Accepted with
198+
* status "queued".
199+
*/
200+
async?: boolean;
201+
128202
/**
129203
* Input data for the action, sent as a JSON string.
130204
*/
131205
payload?: string;
132206
}
133207

208+
export interface InvocationUpdateParams {
209+
/**
210+
* New status for the invocation.
211+
*/
212+
status: 'succeeded' | 'failed';
213+
214+
/**
215+
* Updated output of the invocation rendered as JSON string.
216+
*/
217+
output?: string;
218+
}
219+
134220
export declare namespace Invocations {
135221
export {
136222
type InvocationCreateResponse as InvocationCreateResponse,
137223
type InvocationRetrieveResponse as InvocationRetrieveResponse,
224+
type InvocationUpdateResponse as InvocationUpdateResponse,
138225
type InvocationCreateParams as InvocationCreateParams,
226+
type InvocationUpdateParams as InvocationUpdateParams,
139227
};
140228
}

tests/api-resources/apps/invocations.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('resource invocations', () => {
3030
action_name: 'analyze',
3131
app_name: 'my-app',
3232
version: '1.0.0',
33+
async: true,
3334
payload: '{"data":"example input"}',
3435
});
3536
});
@@ -45,4 +46,21 @@ describe('resource invocations', () => {
4546
expect(dataAndResponse.data).toBe(response);
4647
expect(dataAndResponse.response).toBe(rawResponse);
4748
});
49+
50+
// skipped: tests are disabled for the time being
51+
test.skip('update: only required params', async () => {
52+
const responsePromise = client.apps.invocations.update('id', { status: 'succeeded' });
53+
const rawResponse = await responsePromise.asResponse();
54+
expect(rawResponse).toBeInstanceOf(Response);
55+
const response = await responsePromise;
56+
expect(response).not.toBeInstanceOf(Response);
57+
const dataAndResponse = await responsePromise.withResponse();
58+
expect(dataAndResponse.data).toBe(response);
59+
expect(dataAndResponse.response).toBe(rawResponse);
60+
});
61+
62+
// skipped: tests are disabled for the time being
63+
test.skip('update: required and optional params', async () => {
64+
const response = await client.apps.invocations.update('id', { status: 'succeeded', output: 'output' });
65+
});
4866
});

0 commit comments

Comments
 (0)