Skip to content

Commit 45d7a44

Browse files
committed
Add sandbox operations
1 parent 8c5cc1c commit 45d7a44

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/api/types.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,33 @@ export interface VersionedModuleAliasesPaginatedResult {
416416
data?: VersionedModuleAlias[];
417417
}
418418

419+
/**
420+
* Sandboxes
421+
*/
422+
export interface CreateSandboxInput {
423+
imageId: string;
424+
name?: string;
425+
metadata?: Record<string, string>;
426+
timeoutMs?: number;
427+
publicHttpPorts?: number[];
428+
publicHttpPortsBasicAuth?: string;
429+
}
430+
431+
export interface Sandbox {
432+
id: string;
433+
name: string;
434+
grpcServerUrl?: string;
435+
grpcApiKey?: string;
436+
imageId: string;
437+
publicHttpPorts?: number[];
438+
metadata?: Record<string, string>;
439+
timeoutAt: string;
440+
}
441+
442+
export interface UpdateSandboxTimeoutInput {
443+
timeoutMs: number;
444+
}
445+
419446
/**
420447
* Storage
421448
*/

src/api/yepcodeApi.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ import {
3838
ServiceAccountInput,
3939
ServiceAccount,
4040
ServiceAccountsListResult,
41+
Sandbox,
42+
CreateSandboxInput,
43+
UpdateSandboxTimeoutInput,
4144
} from "./types";
4245
import { Readable } from "stream";
4346

@@ -622,6 +625,21 @@ export class YepCodeApi {
622625
return this.request("DELETE", `/variables/${id}`);
623626
}
624627

628+
async createSandbox(data: CreateSandboxInput): Promise<Sandbox> {
629+
return this.request("POST", "/sandboxes", { data });
630+
}
631+
632+
async updateSandboxTimeout(
633+
id: string,
634+
data: UpdateSandboxTimeoutInput
635+
): Promise<Sandbox> {
636+
return this.request("POST", `/sandboxes/${id}`, { data });
637+
}
638+
639+
async killSandbox(id: string): Promise<Sandbox> {
640+
return this.request("POST", `/sandboxes/${id}/kill`, {});
641+
}
642+
625643
async getModules(
626644
params: {
627645
keywords?: string;

0 commit comments

Comments
 (0)