diff --git a/skyline_apiserver/api/v1/extension.py b/skyline_apiserver/api/v1/extension.py index efc8fee..de109dd 100644 --- a/skyline_apiserver/api/v1/extension.py +++ b/skyline_apiserver/api/v1/extension.py @@ -862,7 +862,9 @@ async def list_volume_snapshots( child_volumes: Dict[str, Any] = {} for volume in volumes_from_snapshot: child_volumes.setdefault(volume.snapshot_id, []) - child_volumes[volume.snapshot_id].append(volume.name) + child_volumes[volume.snapshot_id].append( + {"volume_id": volume.id, "volume_name": volume.name} + ) for snapshot in result: snapshot["project_name"] = proj_mappings.get(snapshot["project_id"]) diff --git a/skyline_apiserver/schemas/extension.py b/skyline_apiserver/schemas/extension.py index f93d4ca..093de07 100644 --- a/skyline_apiserver/schemas/extension.py +++ b/skyline_apiserver/schemas/extension.py @@ -398,6 +398,13 @@ class VolumesResponse(BaseModel): volumes: List[VolumesResponseBase] = Field(..., description="Volumes list") +class VolumeSnapshotChildVolume(BaseModel): + volume_id: str = Field( + None, description="ID of volume", example="00000000-0000-0000-0000-000000000000" + ) + volume_name: str = Field(None, description="Name of volume", example="child-volume-demo") + + class VolumeSnapshotsResponseBase(BaseModel): id: str = Field(..., description="Snapshot ID") origin_data: Dict[str, Any] = Field( @@ -405,8 +412,10 @@ class VolumeSnapshotsResponseBase(BaseModel): ) project_name: Optional[str] = Field(None, description="Project name") host: Optional[str] = Field(None, description="Host name") - volume_name: Optional[str] = Field(None, description="Volume name") - child_volumes: Optional[List] = Field(None, description="Child volumes") + volume_name: Optional[str] = Field(None, description="Name of volume", example="volume-demo") + child_volumes: Optional[List[VolumeSnapshotChildVolume]] = Field( + None, description="Child volumes" + ) name: Optional[str] = Field( description="Will be removed, please use origin_data[name]", diff --git a/swagger.json b/swagger.json index 9c67007..b0b5aa9 100644 --- a/swagger.json +++ b/swagger.json @@ -3442,6 +3442,24 @@ } } }, + "VolumeSnapshotChildVolume": { + "title": "VolumeSnapshotChildVolume", + "type": "object", + "properties": { + "volume_id": { + "title": "Volume Id", + "type": "string", + "description": "ID of volume", + "example": "00000000-0000-0000-0000-000000000000" + }, + "volume_name": { + "title": "Volume Name", + "type": "string", + "description": "Name of volume", + "example": "child-volume-demo" + } + } + }, "VolumeSnapshotSortKey": { "title": "VolumeSnapshotSortKey", "enum": [ @@ -3519,12 +3537,15 @@ "volume_name": { "title": "Volume Name", "type": "string", - "description": "Volume name" + "description": "Name of volume", + "example": "volume-demo" }, "child_volumes": { "title": "Child Volumes", "type": "array", - "items": {}, + "items": { + "$ref": "#/components/schemas/VolumeSnapshotChildVolume" + }, "description": "Child volumes" }, "name": {