diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.ts index f45e19c13..619b5aede 100644 --- a/packages/js-sdk/src/api/schema.gen.ts +++ b/packages/js-sdk/src/api/schema.gen.ts @@ -152,6 +152,11 @@ export interface paths { sandboxID: components["parameters"]["sandboxID"]; }; }; + requestBody: { + content: { + "application/json": components["schemas"]["ResumedSandbox"]; + }; + }; responses: { /** @description The sandbox was resumed successfully */ 201: { @@ -375,6 +380,14 @@ export interface components { */ timeout?: number; }; + ResumedSandbox: { + /** + * Format: int32 + * @description Time to live for the sandbox in seconds. + * @default 15 + */ + timeout?: number; + }; RunningSandbox: { /** @description Alias of the template */ alias?: string; diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts index 9d58617aa..1faa4018e 100644 --- a/packages/js-sdk/src/sandbox/index.ts +++ b/packages/js-sdk/src/sandbox/index.ts @@ -220,9 +220,9 @@ export class Sandbox extends SandboxApi { static async resume( this: S, sandboxId: string, - opts?: Pick + opts?: Pick ): Promise> { - const id = await Sandbox.resumeSandbox(sandboxId, opts) + const id = await Sandbox.resumeSandbox(sandboxId, opts?.timeoutMs ?? this.defaultSandboxTimeoutMs, opts) return this.connect(id, opts) } diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts index 66a0c284d..2f9ab8f17 100644 --- a/packages/js-sdk/src/sandbox/sandboxApi.ts +++ b/packages/js-sdk/src/sandbox/sandboxApi.ts @@ -187,6 +187,7 @@ export class SandboxApi { protected static async resumeSandbox( sandboxId: string, + timeoutMs: number, opts?: SandboxApiOpts ): Promise { const config = new ConnectionConfig(opts) @@ -198,6 +199,9 @@ export class SandboxApi { sandboxID: sandboxId, }, }, + body: { + timeout: this.timeoutToSeconds(timeoutMs), + }, }) if (res.error?.code === 404) { diff --git a/spec/openapi.yml b/spec/openapi.yml index 2da660055..412c2e564 100644 --- a/spec/openapi.yml +++ b/spec/openapi.yml @@ -216,6 +216,15 @@ components: envVars: $ref: "#/components/schemas/EnvVars" + ResumedSandbox: + properties: + timeout: + type: integer + format: int32 + minimum: 0 + default: 15 + description: Time to live for the sandbox in seconds. + Template: required: - templateID @@ -471,6 +480,12 @@ paths: - ApiKeyAuth: [] parameters: - $ref: "#/components/parameters/sandboxID" + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ResumedSandbox" responses: "201": description: The sandbox was resumed successfully