Skip to content

Commit 89b755a

Browse files
feat(api): add GET deployments endpoint
1 parent 5f60c0f commit 89b755a

File tree

9 files changed

+130
-32
lines changed

9 files changed

+130
-32
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: 16
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ff8ccba8b5409eaa1128df9027582cb63f66e8accd75e511f70b7c27ef26c9ae.yml
3-
openapi_spec_hash: 1dbacc339695a7c78718f90f791d3f01
4-
config_hash: b8e1fff080fbaa22656ab0a57b591777
1+
configured_endpoints: 17
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2eeb61205775c5997abf8154cd6f6fe81a1e83870eff10050b17ed415aa7860b.yml
3+
openapi_spec_hash: 63405add4a3f53718f8183cbb8c1a22f
4+
config_hash: 00ec9df250b9dc077f8d3b93a442d252

api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Types:
44

5+
- <code><a href="./src/resources/shared.ts">AppAction</a></code>
56
- <code><a href="./src/resources/shared.ts">ErrorDetail</a></code>
67
- <code><a href="./src/resources/shared.ts">ErrorEvent</a></code>
78
- <code><a href="./src/resources/shared.ts">ErrorModel</a></code>
@@ -15,12 +16,14 @@ Types:
1516
- <code><a href="./src/resources/deployments.ts">DeploymentStateEvent</a></code>
1617
- <code><a href="./src/resources/deployments.ts">DeploymentCreateResponse</a></code>
1718
- <code><a href="./src/resources/deployments.ts">DeploymentRetrieveResponse</a></code>
19+
- <code><a href="./src/resources/deployments.ts">DeploymentListResponse</a></code>
1820
- <code><a href="./src/resources/deployments.ts">DeploymentFollowResponse</a></code>
1921

2022
Methods:
2123

2224
- <code title="post /deployments">client.deployments.<a href="./src/resources/deployments.ts">create</a>({ ...params }) -> DeploymentCreateResponse</code>
2325
- <code title="get /deployments/{id}">client.deployments.<a href="./src/resources/deployments.ts">retrieve</a>(id) -> DeploymentRetrieveResponse</code>
26+
- <code title="get /deployments">client.deployments.<a href="./src/resources/deployments.ts">list</a>({ ...params }) -> DeploymentListResponse</code>
2427
- <code title="get /deployments/{id}/events">client.deployments.<a href="./src/resources/deployments.ts">follow</a>(id, { ...params }) -> DeploymentFollowResponse</code>
2528

2629
# Apps

src/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import {
3030
DeploymentCreateResponse,
3131
DeploymentFollowParams,
3232
DeploymentFollowResponse,
33+
DeploymentListParams,
34+
DeploymentListResponse,
3335
DeploymentRetrieveResponse,
3436
DeploymentStateEvent,
3537
Deployments,
@@ -789,8 +791,10 @@ export declare namespace Kernel {
789791
type DeploymentStateEvent as DeploymentStateEvent,
790792
type DeploymentCreateResponse as DeploymentCreateResponse,
791793
type DeploymentRetrieveResponse as DeploymentRetrieveResponse,
794+
type DeploymentListResponse as DeploymentListResponse,
792795
type DeploymentFollowResponse as DeploymentFollowResponse,
793796
type DeploymentCreateParams as DeploymentCreateParams,
797+
type DeploymentListParams as DeploymentListParams,
794798
type DeploymentFollowParams as DeploymentFollowParams,
795799
};
796800

@@ -817,6 +821,7 @@ export declare namespace Kernel {
817821
type BrowserDeleteParams as BrowserDeleteParams,
818822
};
819823

824+
export type AppAction = API.AppAction;
820825
export type ErrorDetail = API.ErrorDetail;
821826
export type ErrorEvent = API.ErrorEvent;
822827
export type ErrorModel = API.ErrorModel;

src/resources/apps/apps.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from '../../core/resource';
4+
import * as Shared from '../shared';
45
import * as DeploymentsAPI from './deployments';
56
import {
67
DeploymentCreateParams,
@@ -39,6 +40,11 @@ export namespace AppListResponse {
3940
*/
4041
id: string;
4142

43+
/**
44+
* List of actions available on the app
45+
*/
46+
actions: Array<Shared.AppAction>;
47+
4248
/**
4349
* Name of the application
4450
*/
@@ -49,6 +55,11 @@ export namespace AppListResponse {
4955
*/
5056
deployment: string;
5157

58+
/**
59+
* Environment variables configured for this app version
60+
*/
61+
env_vars: { [key: string]: string };
62+
5263
/**
5364
* Deployment region code
5465
*/
@@ -58,11 +69,6 @@ export namespace AppListResponse {
5869
* Version label for the application
5970
*/
6071
version: string;
61-
62-
/**
63-
* Environment variables configured for this app version
64-
*/
65-
env_vars?: { [key: string]: string };
6672
}
6773
}
6874

src/resources/apps/deployments.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,13 @@ export namespace DeploymentCreateResponse {
7272
/**
7373
* List of actions available on the app
7474
*/
75-
actions: Array<App.Action>;
75+
actions: Array<Shared.AppAction>;
7676

7777
/**
7878
* Name of the app
7979
*/
8080
name: string;
8181
}
82-
83-
export namespace App {
84-
export interface Action {
85-
/**
86-
* Name of the action
87-
*/
88-
name: string;
89-
}
90-
}
9182
}
9283

9384
/**

src/resources/deployments.ts

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ export class Deployments extends APIResource {
3838
return this._client.get(path`/deployments/${id}`, options);
3939
}
4040

41+
/**
42+
* List deployments. Optionally filter by application name.
43+
*
44+
* @example
45+
* ```ts
46+
* const deployments = await client.deployments.list();
47+
* ```
48+
*/
49+
list(
50+
query: DeploymentListParams | null | undefined = {},
51+
options?: RequestOptions,
52+
): APIPromise<DeploymentListResponse> {
53+
return this._client.get('/deployments', { query, ...options });
54+
}
55+
4156
/**
4257
* Establishes a Server-Sent Events (SSE) stream that delivers real-time logs and
4358
* status updates for a deployment. The stream terminates automatically once the
@@ -219,6 +234,55 @@ export interface DeploymentRetrieveResponse {
219234
updated_at?: string | null;
220235
}
221236

237+
export type DeploymentListResponse = Array<DeploymentListResponse.DeploymentListResponseItem>;
238+
239+
export namespace DeploymentListResponse {
240+
/**
241+
* Deployment record information.
242+
*/
243+
export interface DeploymentListResponseItem {
244+
/**
245+
* Unique identifier for the deployment
246+
*/
247+
id: string;
248+
249+
/**
250+
* Timestamp when the deployment was created
251+
*/
252+
created_at: string;
253+
254+
/**
255+
* Deployment region code
256+
*/
257+
region: 'aws.us-east-1a';
258+
259+
/**
260+
* Current status of the deployment
261+
*/
262+
status: 'queued' | 'in_progress' | 'running' | 'failed' | 'stopped';
263+
264+
/**
265+
* Relative path to the application entrypoint
266+
*/
267+
entrypoint_rel_path?: string;
268+
269+
/**
270+
* Environment variables configured for this deployment
271+
*/
272+
env_vars?: { [key: string]: string };
273+
274+
/**
275+
* Status reason
276+
*/
277+
status_reason?: string;
278+
279+
/**
280+
* Timestamp when the deployment was last updated
281+
*/
282+
updated_at?: string | null;
283+
}
284+
}
285+
222286
/**
223287
* Union type representing any deployment event.
224288
*/
@@ -242,7 +306,7 @@ export namespace DeploymentFollowResponse {
242306
/**
243307
* List of actions available on the app
244308
*/
245-
actions: Array<AppVersionSummaryEvent.Action>;
309+
actions: Array<Shared.AppAction>;
246310

247311
/**
248312
* Name of the application
@@ -274,18 +338,6 @@ export namespace DeploymentFollowResponse {
274338
*/
275339
env_vars?: { [key: string]: string };
276340
}
277-
278-
export namespace AppVersionSummaryEvent {
279-
/**
280-
* An action available on the app
281-
*/
282-
export interface Action {
283-
/**
284-
* Name of the action
285-
*/
286-
name: string;
287-
}
288-
}
289341
}
290342

291343
export interface DeploymentCreateParams {
@@ -321,6 +373,13 @@ export interface DeploymentCreateParams {
321373
version?: string;
322374
}
323375

376+
export interface DeploymentListParams {
377+
/**
378+
* Filter results by application name.
379+
*/
380+
app_name?: string;
381+
}
382+
324383
export interface DeploymentFollowParams {
325384
/**
326385
* Show logs since the given time (RFC timestamps or durations like 5m).
@@ -333,8 +392,10 @@ export declare namespace Deployments {
333392
type DeploymentStateEvent as DeploymentStateEvent,
334393
type DeploymentCreateResponse as DeploymentCreateResponse,
335394
type DeploymentRetrieveResponse as DeploymentRetrieveResponse,
395+
type DeploymentListResponse as DeploymentListResponse,
336396
type DeploymentFollowResponse as DeploymentFollowResponse,
337397
type DeploymentCreateParams as DeploymentCreateParams,
398+
type DeploymentListParams as DeploymentListParams,
338399
type DeploymentFollowParams as DeploymentFollowParams,
339400
};
340401
}

src/resources/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export {
1616
type DeploymentStateEvent,
1717
type DeploymentCreateResponse,
1818
type DeploymentRetrieveResponse,
19+
type DeploymentListResponse,
1920
type DeploymentFollowResponse,
2021
type DeploymentCreateParams,
22+
type DeploymentListParams,
2123
type DeploymentFollowParams,
2224
} from './deployments';
2325
export {

src/resources/shared.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
/**
4+
* An action available on the app
5+
*/
6+
export interface AppAction {
7+
/**
8+
* Name of the action
9+
*/
10+
name: string;
11+
}
12+
313
export interface ErrorDetail {
414
/**
515
* Lower-level error code providing more specific detail

tests/api-resources/deployments.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ describe('resource deployments', () => {
4747
expect(dataAndResponse.response).toBe(rawResponse);
4848
});
4949

50+
// skipped: tests are disabled for the time being
51+
test.skip('list', async () => {
52+
const responsePromise = client.deployments.list();
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('list: request options and params are passed correctly', async () => {
64+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
65+
await expect(
66+
client.deployments.list({ app_name: 'app_name' }, { path: '/_stainless_unknown_path' }),
67+
).rejects.toThrow(Kernel.NotFoundError);
68+
});
69+
5070
// skipped: currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail
5171
test.skip('follow', async () => {
5272
const responsePromise = client.deployments.follow('id');

0 commit comments

Comments
 (0)