feat: Return both id and name of children volume for snapshots
Return both id and name of children volume for snapshots Change-Id: I194e13a368d01178b5e4751a42f8f3e6d0faa4f1
This commit is contained in:
parent
22ea97f536
commit
40b30101c3
@ -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"])
|
||||
|
@ -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]",
|
||||
|
25
swagger.json
25
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": {
|
||||
|
Loading…
Reference in New Issue
Block a user