|
2 | 2 |
|
3 | 3 | import { APIResource } from '../../resource'; |
4 | 4 | import { isRequestOptions } from '../../core'; |
| 5 | +import { APIPromise } from '../../core'; |
5 | 6 | import * as Core from '../../core'; |
6 | 7 | import * as Shared from '../shared'; |
7 | 8 | import * as DiskSnapshotsAPI from './disk-snapshots'; |
@@ -32,6 +33,7 @@ import { |
32 | 33 | DiskSnapshotsCursorIDPage, |
33 | 34 | type DiskSnapshotsCursorIDPageParams, |
34 | 35 | } from '../../pagination'; |
| 36 | +import { Stream } from '../../streaming'; |
35 | 37 | import { type Response } from '../../_shims/index'; |
36 | 38 | import { |
37 | 39 | longPollUntil, |
@@ -538,6 +540,19 @@ export class Devboxes extends APIResource { |
538 | 540 | }); |
539 | 541 | } |
540 | 542 |
|
| 543 | + /** |
| 544 | + * Subscribe, via server-sent events, to pending infrastructure evictions for every |
| 545 | + * Devbox in the account. On connect the stream emits one event per Devbox that |
| 546 | + * currently has a pending eviction, then one event as each further eviction is |
| 547 | + * scheduled. Best-effort and advisory: a Devbox stays running until its deadline, |
| 548 | + * and delivery is not guaranteed. |
| 549 | + */ |
| 550 | + watchEvictions(options?: Core.RequestOptions): APIPromise<Stream<DevboxEvictionEventView>> { |
| 551 | + return this._client.get('/v1/devboxes/evictions/watch', { ...options, stream: true }) as APIPromise< |
| 552 | + Stream<DevboxEvictionEventView> |
| 553 | + >; |
| 554 | + } |
| 555 | + |
541 | 556 | /** |
542 | 557 | * Write UTF-8 string contents to a file at path on the Devbox. Note for large |
543 | 558 | * files (larger than 100MB), the upload_file endpoint must be used. |
@@ -619,6 +634,19 @@ export interface DevboxAsyncExecutionDetailView { |
619 | 634 | stdout_truncated?: boolean | null; |
620 | 635 | } |
621 | 636 |
|
| 637 | +export interface DevboxEvictionEventView { |
| 638 | + /** |
| 639 | + * The ID of the Devbox with a pending eviction. |
| 640 | + */ |
| 641 | + devbox_id: string; |
| 642 | + |
| 643 | + /** |
| 644 | + * Unix timestamp (milliseconds) after which the Devbox will be suspended. Advisory |
| 645 | + * and best-effort. |
| 646 | + */ |
| 647 | + eviction_deadline_ms: number; |
| 648 | +} |
| 649 | + |
622 | 650 | export interface DevboxExecutionDetailView { |
623 | 651 | /** |
624 | 652 | * Devbox id where command was executed. |
@@ -1539,6 +1567,7 @@ Devboxes.Executions = Executions; |
1539 | 1567 | export declare namespace Devboxes { |
1540 | 1568 | export { |
1541 | 1569 | type DevboxAsyncExecutionDetailView as DevboxAsyncExecutionDetailView, |
| 1570 | + type DevboxEvictionEventView as DevboxEvictionEventView, |
1542 | 1571 | type DevboxExecutionDetailView as DevboxExecutionDetailView, |
1543 | 1572 | type DevboxKillExecutionRequest as DevboxKillExecutionRequest, |
1544 | 1573 | type DevboxListView as DevboxListView, |
|
0 commit comments