Add snapshot description support (#3094)

Pass the description when creating a snapshot instead of silently
dropping it, and add a PUT endpoint to edit the description later.
An empty description resets to the default text. Also accept an
optional description in the MCP snapshot_create tool.
This commit is contained in:
Guobin Yue authored and GitHub committed 2026-11-16 14:24:20 +01:00
1 parent fe51feec66
commit 8411392233
9 files changed
+148 -11

No files matched your search

+19 -1
View File
@@ -67,7 +67,7 @@ async def create_snapshot(
Required privilege: Snapshot.Allocate
"""
snapshot = await project.snapshot(snapshot_data.name)
snapshot = await project.snapshot(snapshot_data.name, snapshot_data.description)
return snapshot.asdict()
@@ -88,6 +88,24 @@ def get_snapshots(project: Project = Depends(dep_project)) -> List[schemas.Snaps
return [s.asdict() for s in sorted(snapshots, key=lambda s: (s.created_at, s.name))]
@router.put(
"/{snapshot_id}",
response_model=schemas.Snapshot,
dependencies=[Depends(has_privilege("Snapshot.Allocate"))],
)
async def update_snapshot(
snapshot_data: schemas.SnapshotUpdate, snapshot_id: UUID, project: Project = Depends(dep_project)
) -> schemas.Snapshot:
"""
Update a snapshot, for example its description.
Required privilege: Snapshot.Allocate
"""
snapshot = project.update_snapshot(str(snapshot_id), snapshot_data.description)
return snapshot.asdict()
@router.delete(
"/{snapshot_id}", status_code=status.HTTP_204_NO_CONTENT, dependencies=[Depends(has_privilege("Snapshot.Allocate"))]
)