Skip to content

Commit 0977b05

Browse files
authored
feat(specs): sandbox snapshot specs (opensandbox-group#721)
1 parent 3c3d8fa commit 0977b05

4 files changed

Lines changed: 337 additions & 30 deletions

File tree

sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/infrastructure/adapters/converter/SandboxModelConverter.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ internal object SandboxModelConverter {
298298
entrypoint = this.entrypoint,
299299
expiresAt = this.expiresAt,
300300
createdAt = this.createdAt,
301-
image = this.image.toImageSpec(),
301+
image =
302+
requireNotNull(this.image) {
303+
"Sandbox image is missing from API response. Snapshot-based sandbox responses are not supported by this SDK yet."
304+
}.toImageSpec(),
302305
platform = this.platform?.toDomainPlatformSpec(),
303306
status = this.status.toSandboxStatus(),
304307
metadata = metadata,

specs/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,27 @@ This directory contains OpenAPI specification documents for the OpenSandbox proj
1010

1111
**Sandbox Lifecycle Management API**
1212

13-
Defines the complete lifecycle interfaces for creating, managing, and destroying sandbox environments directly from container images.
13+
Defines the complete lifecycle interfaces for creating, managing, and destroying sandbox environments from container images or snapshots.
1414

1515
**Core Features:**
1616
- **Sandbox Management**: Create, list, query, and delete sandbox instances with metadata filters and pagination
1717
- **State Control**: Pause and resume sandbox execution
1818
- **Lifecycle States**: Supports transitions across Pending → Running → Pausing → Paused → Stopping → Terminated, and error handling with `Failed`
19-
- **Resource & Runtime Configuration**: Specify CPU/memory/GPU resource limits, required `entrypoint`, environment variables, and opaque `extensions`
19+
- **Resource & Runtime Configuration**: Specify CPU/memory/GPU resource limits, image startup `entrypoint`, environment variables, and opaque `extensions`
2020
- **Image Support**: Create sandboxes from public or private registries, including registry auth
2121
- **Timeout Management**: Mandatory `timeout` on creation with explicit renewal via API
2222
- **Endpoint Access**: Retrieve public access endpoints for services running inside sandboxes
23+
- **Snapshot Management**: Create snapshots from sandboxes, list snapshots, and delete snapshots
2324

2425
**Main Endpoints (base path `/v1`):**
25-
- `POST /sandboxes` - Create a sandbox from an image with timeout and resource limits
26+
- `POST /sandboxes` - Create a sandbox from an image or snapshot with timeout and resource limits
2627
- `GET /sandboxes` - List sandboxes with state/metadata filters and pagination
27-
- `GET /sandboxes/{sandboxId}` - Get full sandbox details (including image and entrypoint)
28+
- `GET /sandboxes/{sandboxId}` - Get full sandbox details (including startup source and entrypoint)
2829
- `DELETE /sandboxes/{sandboxId}` - Delete a sandbox
30+
- `POST /sandboxes/{sandboxId}/snapshots` - Create a snapshot from a sandbox
31+
- `GET /snapshots` - List snapshots with optional sandbox filtering and pagination
32+
- `GET /snapshots/{snapshotId}` - Get snapshot state and metadata
33+
- `DELETE /snapshots/{snapshotId}` - Delete a snapshot
2934
- `POST /sandboxes/{sandboxId}/pause` - Pause a sandbox (asynchronous)
3035
- `POST /sandboxes/{sandboxId}/resume` - Resume a paused sandbox
3136
- `POST /sandboxes/{sandboxId}/renew-expiration` - Renew sandbox expiration (TTL)

specs/README_zh.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,27 @@
1010

1111
**沙箱生命周期管理 API**
1212

13-
定义了沙箱环境的创建、管理和销毁的完整生命周期接口,并可直接从容器镜像启动
13+
定义了沙箱环境的创建、管理和销毁的完整生命周期接口,可从容器镜像创建或从快照恢复
1414

1515
**核心功能:**
1616
- **沙箱管理**:创建、列表、查询、删除沙箱实例,支持元数据过滤与分页
1717
- **状态控制**:暂停 (Pause)、恢复 (Resume) 沙箱执行
1818
- **生命周期**:支持 Pending → Running → Pausing → Paused → Stopping → Terminated,并包含错误态 `Failed`
19-
- **资源与运行时配置**:指定 CPU/内存/GPU 资源限制、必填 `entrypoint`、环境变量,以及自定义 `extensions`
19+
- **资源与运行时配置**:指定 CPU/内存/GPU 资源限制、镜像启动 `entrypoint`、环境变量,以及自定义 `extensions`
2020
- **镜像支持**:从公共或私有镜像仓库创建沙箱,支持私有仓库认证
2121
- **超时管理**:创建时必填 `timeout`,并可通过 API 续期
2222
- **端点访问**:获取沙箱内服务的公共访问端点
23+
- **快照管理**:从沙箱创建快照、列出快照、删除快照
2324

2425
**主要端点(基础路径 `/v1`):**
25-
- `POST /sandboxes` - 从镜像创建沙箱,设置超时与资源限制
26+
- `POST /sandboxes` - 从镜像或快照创建沙箱,设置超时与资源限制
2627
- `GET /sandboxes` - 列出沙箱,支持状态/元数据过滤与分页
27-
- `GET /sandboxes/{sandboxId}` - 获取完整沙箱详情(包含镜像与 entrypoint)
28+
- `GET /sandboxes/{sandboxId}` - 获取完整沙箱详情(包含启动来源与 entrypoint)
2829
- `DELETE /sandboxes/{sandboxId}` - 删除沙箱
30+
- `POST /sandboxes/{sandboxId}/snapshots` - 从沙箱创建快照
31+
- `GET /snapshots` - 列出快照,支持按沙箱过滤与分页
32+
- `GET /snapshots/{snapshotId}` - 获取快照状态与元数据
33+
- `DELETE /snapshots/{snapshotId}` - 删除快照
2934
- `POST /sandboxes/{sandboxId}/pause` - 异步暂停沙箱
3035
- `POST /sandboxes/{sandboxId}/resume` - 恢复已暂停的沙箱
3136
- `POST /sandboxes/{sandboxId}/renew-expiration` - 续期沙箱 TTL

0 commit comments

Comments
 (0)