Skip to content

feat(api): Snapshot complete CRUD + enhanced SnapshotInfo - #3457

Open
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:feat/snapshot-crud-enhanced-info
Open

feat(api): Snapshot complete CRUD + enhanced SnapshotInfo#3457
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:feat/snapshot-crud-enhanced-info

Conversation

@AdaAibaby

@AdaAibaby AdaAibaby commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3456
Depends on #3441 (must merge first — this branch includes the fork endpoint commit as its parent)

  • GET /snapshots/{snapshotID} — retrieve a single snapshot by ID or alias (404 if not found/not owned)
  • DELETE /snapshots/{snapshotID} — soft-delete a snapshot template and release its aliases (204 on success)
  • Enhanced SnapshotInfo — adds cpuCount, memoryMB, diskSizeMB, createdAt to both the new GET endpoint and the existing list endpoint

No new DB queries: all fields come from the existing ListTeamSnapshotTemplates row.

Changes

File Change
spec/openapi.yml Add GET/DELETE /snapshots/{snapshotID} paths; add 4 fields to SnapshotInfo schema
api/internal/api/api.gen.go Update SnapshotInfo struct; add server/client interface methods, request builders, response parsers, and gin routes for both new endpoints
handlers/snapshot_get.go New handler — alias resolution → ListTeamSnapshotTemplates (limit 1) → JSON response
handlers/snapshot_delete.go New handler — alias resolution → softDeleteTemplate reuse → cache invalidation
handlers/snapshot_template_list.go Populate 4 new SnapshotInfo fields in the list mapper

Test plan

  • GET /snapshots/{snapshotID} returns 200 with all fields populated
  • GET /snapshots/{snapshotID} returns 404 for unknown snapshot
  • DELETE /snapshots/{snapshotID} returns 204 and removes snapshot
  • GET after DELETE returns 404
  • Other snapshots unaffected after a targeted DELETE
  • GET /snapshots list now includes cpuCount, memoryMB, diskSizeMB, createdAt

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0af41b0c51

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/api/internal/handlers/snapshot_fork.go Outdated
Comment thread packages/api/internal/handlers/snapshot_fork.go Outdated
Comment thread spec/openapi.yml
@AdaAibaby
AdaAibaby force-pushed the feat/snapshot-crud-enhanced-info branch 2 times, most recently from 184cf5e to 2d1abe0 Compare July 30, 2026 06:44
@jakubno
jakubno requested a review from ben-fornefeld as a code owner August 3, 2026 13:31
- Add GET /snapshots/{snapshotID}: returns SnapshotInfo for a single snapshot
- Add DELETE /snapshots/{snapshotID}: soft-deletes a snapshot template (reuses
  softDeleteTemplate, invalidates template cache)
- Extend SnapshotInfo with cpuCount, memoryMB, diskSizeMB, createdAt fields
- Update GET /snapshots list to populate the new fields
- Update spec/openapi.yml and regenerate api.gen.go accordingly

Closes e2b-dev#3456
… create response

POST /sandboxes/{id}/snapshots was returning zero values for the four new
required SnapshotInfo fields. Populate them from the source sandbox, which
already has VCpu, RamMB, TotalDiskSizeMB in memory at the point of return.
@AdaAibaby
AdaAibaby force-pushed the feat/snapshot-crud-enhanced-info branch from 2d1abe0 to b23c42f Compare August 4, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(api): Snapshot complete CRUD + enhanced SnapshotInfo

2 participants