refactor: Refactor the extension schemas

1. remove prefix ext
2. update the swagger file
3. add more detailed info for schemas field

Change-Id: I08f30087e8889d772db3da09a92f1e9390d10dbe
This commit is contained in:
zhu.boxiang 2022-07-14 13:43:52 +08:00
parent 4d9b577007
commit 6ca007c1d0
4 changed files with 1103 additions and 1043 deletions

File diff suppressed because it is too large Load Diff

View File

@ -49,13 +49,13 @@ List Servers.
- The `name` is to support for fuzzy queries.
""",
responses={
200: {"model": schemas.ExtListServersResponse},
200: {"model": schemas.ServersResponse},
400: {"model": schemas.BadRequestMessage},
401: {"model": schemas.UnauthorizedMessage},
403: {"model": schemas.ForbiddenMessage},
500: {"model": schemas.InternalServerErrorMessage},
},
response_model=schemas.ExtListServersResponse,
response_model=schemas.ServersResponse,
status_code=status.HTTP_200_OK,
response_description="OK",
)
@ -68,8 +68,8 @@ async def list_servers(
),
limit: int = Query(None, gt=constants.EXTENSION_API_LIMIT_GT),
marker: str = None,
sort_dirs: schemas.ExtSortDir = None,
sort_keys: List[schemas.ExtServerSortKey] = Query(None),
sort_dirs: schemas.SortDir = None,
sort_keys: List[schemas.ServerSortKey] = Query(None),
all_projects: bool = None,
project_id: str = Query(
None,
@ -80,11 +80,11 @@ async def list_servers(
description="Only works when the all_projects filter is also specified.",
),
name: str = None,
status: schemas.ExtServerStatus = None,
status: schemas.ServerStatus = None,
host: str = Query(None, description="It will be ignored for non-admin user."),
flavor_id: str = None,
uuid: str = Query(None, description="UUID of server."),
) -> schemas.ExtListServersResponse:
) -> schemas.ServersResponse:
"""Extension List Servers.
:param profile: Profile object include token, role and so on,
@ -96,9 +96,9 @@ async def list_servers(
:param marker: Marker object to fetch, defaults to None
:type marker: str, optional
:param sort_dirs: Sort order, defaults to None
:type sort_dirs: schemas.ExtSortDir, optional
:type sort_dirs: schemas.SortDir, optional
:param sort_keys: Sort keys, defaults to Query(None)
:type sort_keys: List[schemas.ExtServerSortKey], optional
:type sort_keys: List[schemas.ServerSortKey], optional
:param all_projects: All projects to fetch, defaults to None
:type all_projects: bool, optional
:param project_id: Filter by id of project which server belongs to,
@ -112,7 +112,7 @@ async def list_servers(
:param name: Filter by server name, defaults to None
:type name: str, optional
:param status: Filter by server status, defaults to None
:type status: schemas.ExtServerStatus, optional
:type status: schemas.ServerStatus, optional
:param host: Filter by host which server is located at,
defaults to Query(None, description="It will be ignored for non-admin user.")
:type host: str, optional
@ -122,7 +122,7 @@ async def list_servers(
:type uuid: str, optional
:raises HTTPException: HTTP Exception
:return: Server List
:rtype: schemas.ExtListServersResponse
:rtype: schemas.ServersResponse
"""
if all_projects:
assert_system_admin_or_reader(
@ -280,13 +280,13 @@ List Recycle Servers.
- The `name` is to support for fuzzy queries.
""",
responses={
200: {"model": schemas.ExtListRecycleServersResponse},
200: {"model": schemas.RecycleServersResponse},
400: {"model": schemas.BadRequestMessage},
401: {"model": schemas.UnauthorizedMessage},
403: {"model": schemas.ForbiddenMessage},
500: {"model": schemas.InternalServerErrorMessage},
},
response_model=schemas.ExtListRecycleServersResponse,
response_model=schemas.RecycleServersResponse,
status_code=status.HTTP_200_OK,
response_description="OK",
)
@ -299,8 +299,8 @@ async def list_recycle_servers(
),
limit: int = Query(None, gt=constants.EXTENSION_API_LIMIT_GT),
marker: str = None,
sort_dirs: schemas.ExtSortDir = None,
sort_keys: List[schemas.ExtRecycleServerSortKey] = Query(None),
sort_dirs: schemas.SortDir = None,
sort_keys: List[schemas.RecycleServerSortKey] = Query(None),
all_projects: bool = None,
project_id: str = Query(
None,
@ -312,7 +312,7 @@ async def list_recycle_servers(
),
name: str = None,
uuid: str = Query(None, description="UUID of recycle server."),
) -> schemas.ExtListRecycleServersResponse:
) -> schemas.RecycleServersResponse:
"""Extension List Recycle Servers.
:param profile: Profile object include token, role and so on,
@ -324,9 +324,9 @@ async def list_recycle_servers(
:param marker: Marker object to fetch, defaults to None
:type marker: str, optional
:param sort_dirs: Sort order, defaults to None
:type sort_dirs: schemas.ExtSortDir, optional
:type sort_dirs: schemas.SortDir, optional
:param sort_keys: Sort keys, defaults to Query(None)
:type sort_keys: List[schemas.ExtServerSortKey], optional
:type sort_keys: List[schemas.RecycleServerSortKey], optional
:param all_projects: All projects to fetch, defaults to None
:type all_projects: bool, optional
:param project_id: Filter by id of project which recycle server belongs to,
@ -344,7 +344,7 @@ async def list_recycle_servers(
:type uuid: str, optional
:raises HTTPException: HTTP Exception
:return: Recycle server list
:rtype: schemas.ExtListRecycleServersResponse
:rtype: schemas.RecycleServersResponse
"""
if all_projects:
@ -503,12 +503,12 @@ async def list_recycle_servers(
"/extension/volumes",
description="List Volumes.",
responses={
200: {"model": schemas.ExtListVolumesResponse},
200: {"model": schemas.VolumesResponse},
401: {"model": schemas.UnauthorizedMessage},
403: {"model": schemas.ForbiddenMessage},
500: {"model": schemas.InternalServerErrorMessage},
},
response_model=schemas.ExtListVolumesResponse,
response_model=schemas.VolumesResponse,
status_code=status.HTTP_200_OK,
response_description="OK",
)
@ -521,16 +521,16 @@ async def list_volumes(
),
limit: int = Query(None, gt=constants.EXTENSION_API_LIMIT_GT),
marker: str = None,
sort_dirs: schemas.ExtSortDir = None,
sort_keys: List[schemas.ExtVolumeSortKey] = Query(None),
sort_dirs: schemas.SortDir = None,
sort_keys: List[schemas.VolumeSortKey] = Query(None),
all_projects: bool = None,
project_id: str = None,
name: str = None,
multiattach: bool = None,
status: schemas.ExtVolumeStatus = None,
status: schemas.VolumeStatus = None,
bootable: bool = None,
uuid: List[str] = Query(None, description="UUID of volume."),
) -> schemas.ExtListVolumesResponse:
) -> schemas.VolumesResponse:
"""Extension List Volumes.
:param profile: Profile object include token, role and so on,
@ -542,9 +542,9 @@ async def list_volumes(
:param marker: Marker object to fetch, defaults to None
:type marker: str, optional
:param sort_dirs: Sort order, defaults to None
:type sort_dirs: schemas.ExtSortDir, optional
:type sort_dirs: schemas.SortDir, optional
:param sort_keys: Sort keys, defaults to Query(None)
:type sort_keys: List[schemas.ExtServerSortKey], optional
:type sort_keys: List[schemas.VolumeSortKey], optional
:param all_projects: All projects to fetch, defaults to None
:type all_projects: bool, optional
:param project_id: Filter by id of project which volume belongs to,
@ -556,14 +556,14 @@ async def list_volumes(
defaults to None
:type multiattach: bool, optional
:param status: Filter by volume status, defaults to None
:type status: schemas.ExtVolumeStatus, optional
:type status: schemas.VolumeStatus, optional
:type bootable: Filter by bootable that server be used to create an instance quickly.
:type bootable: bool, optional
:param uuid: Filter by list uuid,
defaults to Query(None, description="UUID of volume.")
:type uuid: List[str], optional
:return: Volume list
:rtype: schemas.ExtListVolumesResponse
:rtype: schemas.VolumesResponse
"""
if all_projects:
assert_system_admin_or_reader(
@ -699,12 +699,12 @@ async def list_volumes(
"/extension/volume_snapshots",
description="List Volume Snapshots.",
responses={
200: {"model": schemas.ExtListVolumeSnapshotsResponse},
200: {"model": schemas.VolumeSnapshotsResponse},
401: {"model": schemas.UnauthorizedMessage},
403: {"model": schemas.ForbiddenMessage},
500: {"model": schemas.InternalServerErrorMessage},
},
response_model=schemas.ExtListVolumeSnapshotsResponse,
response_model=schemas.VolumeSnapshotsResponse,
status_code=status.HTTP_200_OK,
response_description="OK",
)
@ -717,14 +717,14 @@ async def list_volume_snapshots(
),
limit: int = Query(None, gt=constants.EXTENSION_API_LIMIT_GT),
marker: str = None,
sort_dirs: schemas.ExtSortDir = None,
sort_keys: List[schemas.ExtVolumeSnapshotSortKey] = Query(None),
sort_dirs: schemas.SortDir = None,
sort_keys: List[schemas.VolumeSnapshotSortKey] = Query(None),
all_projects: bool = None,
project_id: str = None,
name: str = None,
status: schemas.ExtVolumeSnapshotStatus = None,
status: schemas.VolumeSnapshotStatus = None,
volume_id: str = None,
) -> schemas.ExtListVolumeSnapshotsResponse:
) -> schemas.VolumeSnapshotsResponse:
"""Extension List Volume Snapshots.
:param profile: Profile object include token, role and so on,
@ -736,9 +736,9 @@ async def list_volume_snapshots(
:param marker: Marker object to fetch, defaults to None
:type marker: str, optional
:param sort_dirs: Sort order, defaults to None
:type sort_dirs: schemas.ExtSortDir, optional
:type sort_dirs: schemas.SortDir, optional
:param sort_keys: Sort keys, defaults to Query(None)
:type sort_keys: List[schemas.ExtServerSortKey], optional
:type sort_keys: List[schemas.VolumeSnapshotSortKey], optional
:param all_projects: All projects to fetch, defaults to None
:type all_projects: bool, optional
:param project_id: Filter by id of project which volume snapshots belongs to,
@ -747,11 +747,11 @@ async def list_volume_snapshots(
:param name: Filter by volume snapshot name, defaults to None
:type name: str, optional
:param status: Filter by volume snapshot status, defaults to None
:type status: schemas.ExtVolumeSnapshotStatus, optional
:type status: schemas.VolumeSnapshotStatus, optional
:param volume_id: Filter by volume id, defaults to None
:type volume_id: str, optional
:return: Volume snapshot list
:rtype: schemas.ExtListVolumeSnapshotsResponse
:rtype: schemas.VolumeSnapshotsResponse
"""
if all_projects:
assert_system_admin_or_reader(
@ -877,7 +877,7 @@ async def list_volume_snapshots(
403: {"model": schemas.ForbiddenMessage},
500: {"model": schemas.InternalServerErrorMessage},
},
response_model=schemas.ExtListPortsResponse,
response_model=schemas.PortsResponse,
status_code=status.HTTP_200_OK,
response_description="OK",
)
@ -890,18 +890,18 @@ async def list_ports(
),
limit: int = Query(None, gt=constants.EXTENSION_API_LIMIT_GT),
marker: str = None,
sort_dirs: schemas.ExtSortDir = None,
sort_keys: List[schemas.ExtPortSortKey] = Query(None),
sort_dirs: schemas.SortDir = None,
sort_keys: List[schemas.PortSortKey] = Query(None),
all_projects: bool = None,
project_id: str = None,
name: str = None,
status: schemas.ExtPortStatus = None,
status: schemas.PortStatus = None,
network_name: str = None,
network_id: str = None,
device_id: str = None,
device_owner: List[schemas.ExtPortDeviceOwner] = Query(None),
device_owner: List[schemas.PortDeviceOwner] = Query(None),
uuid: List[str] = Query(None, description="UUID of port."),
) -> schemas.ExtListPortsResponse:
) -> schemas.PortsResponse:
"""Extension List Ports.
:param profile: Profile object include token, role and so on,
@ -913,7 +913,7 @@ async def list_ports(
:param marker: Marker object to fetch, defaults to None
:type marker: str, optional
:param sort_dirs: Sort order, defaults to None
:type sort_dirs: schemas.ExtSortDir, optional
:type sort_dirs: schemas.SortDir, optional
:param sort_keys: Sort keys, defaults to Query(None)
:type sort_keys: List[schemas.ExtServerSortKey], optional
:param all_projects: All projects to fetch, defaults to None
@ -924,7 +924,7 @@ async def list_ports(
:param name: Filter by port name, defaults to None
:type name: str, optional
:param status: Filter by port status, defaults to None
:type status: schemas.ExtPortStatus, optional
:type status: schemas.PortStatus, optional
:param network_name: Filter by name of network, defaults to None
:type network_name: str, optional
:param network_id: Filter by id of network, defaults to None
@ -932,12 +932,12 @@ async def list_ports(
:param device_id: Filter by id of device, defaults to None
:type device_id: str, optional
:param device_owner: Filter by device owner, defaults to Query(None)
:type device_owner: List[schemas.ExtPortDeviceOwner], optional
:type device_owner: List[schemas.PortDeviceOwner], optional
:param uuid: Filter by list uuid,
defaults to Query(None, description="UUID of port.")
:type uuid: List[str], optional
:return: Port list
:rtype: schemas.ExtListPortsResponse
:rtype: schemas.PortsResponse
"""
current_session = await generate_session(profile=profile)
@ -1062,11 +1062,11 @@ async def list_ports(
"/extension/compute-services",
description="List compute services.",
responses={
200: {"model": schemas.ExtListComputeServicesResponse},
200: {"model": schemas.ComputeServicesResponse},
401: {"model": schemas.UnauthorizedMessage},
500: {"model": schemas.InternalServerErrorMessage},
},
response_model=schemas.ExtListComputeServicesResponse,
response_model=schemas.ComputeServicesResponse,
status_code=status.HTTP_200_OK,
response_description="OK",
response_model_exclude_none=True,
@ -1080,7 +1080,7 @@ async def compute_services(
),
binary: str = None,
host: str = None,
) -> schemas.ExtListComputeServicesResponse:
) -> schemas.ComputeServicesResponse:
"""Extension List Compute Services.
:param profile: Profile object include token, role and so on,
@ -1091,7 +1091,7 @@ async def compute_services(
:param host: Filter by host name, defaults to None
:type host: str, optional
:return: Compute service list
:rtype: schemas.ExtListComputeServicesResponse
:rtype: schemas.ComputeServicesResponse
"""
assert_system_admin_or_reader(
profile=profile,

View File

@ -24,23 +24,23 @@ from .common import (
)
from .contrib import KeystoneEndpoints
from .extension import (
ExtListComputeServicesResponse,
ExtListPortsResponse,
ExtListRecycleServersResponse,
ExtListServersResponse,
ExtListVolumeSnapshotsResponse,
ExtListVolumesResponse,
ExtPortDeviceOwner,
ExtPortSortKey,
ExtPortStatus,
ExtRecycleServerSortKey,
ExtServerSortKey,
ExtServerStatus,
ExtSortDir,
ExtVolumeSnapshotSortKey,
ExtVolumeSnapshotStatus,
ExtVolumeSortKey,
ExtVolumeStatus,
ComputeServicesResponse,
PortDeviceOwner,
PortSortKey,
PortsResponse,
PortStatus,
RecycleServerSortKey,
RecycleServersResponse,
ServerSortKey,
ServersResponse,
ServerStatus,
SortDir,
VolumeSnapshotSortKey,
VolumeSnapshotsResponse,
VolumeSnapshotStatus,
VolumeSortKey,
VolumesResponse,
VolumeStatus,
)
from .login import Credential, Payload, Profile
from .policy import Policies, PoliciesRules

View File

@ -26,7 +26,7 @@ VOLUME_SNAPSHOTS_LIST_DOCS_LINKS = "https://docs.openstack.org/api-ref/block-sto
PORTS_LIST_DOCS_LINKS = "https://docs.openstack.org/api-ref/network/v2/index.html?expanded=list-ports-detail#list-ports" # noqa
class ExtServerStatus(str, Enum):
class ServerStatus(str, Enum):
ACTIVE = "ACTIVE"
BUILD = "BUILD"
# DELETED = "DELETED"
@ -52,7 +52,7 @@ class ExtServerStatus(str, Enum):
return self.value
class ExtVolumeStatus(str, Enum):
class VolumeStatus(str, Enum):
creating = "creating"
available = "available"
reserved = "reserved"
@ -78,7 +78,7 @@ class ExtVolumeStatus(str, Enum):
return self.value
class ExtVolumeSnapshotStatus(str, Enum):
class VolumeSnapshotStatus(str, Enum):
CREATING = "CREATING"
AVAILABLE = "AVAILABLE"
# BACKING_UP = "BACKING_UP"
@ -93,7 +93,7 @@ class ExtVolumeSnapshotStatus(str, Enum):
return self.value
class ExtPortStatus(str, Enum):
class PortStatus(str, Enum):
ACTIVE = "ACTIVE"
DOWN = "DOWN"
BUILD = "BUILD"
@ -104,7 +104,7 @@ class ExtPortStatus(str, Enum):
return self.value
class ExtPortDeviceOwner(str, Enum):
class PortDeviceOwner(str, Enum):
null = ""
# prefix compute
compute_nova = "compute:nova"
@ -126,7 +126,7 @@ class ExtPortDeviceOwner(str, Enum):
return self.value
class ExtSortDir(str, Enum):
class SortDir(str, Enum):
desc = "desc"
asc = "asc"
@ -134,7 +134,7 @@ class ExtSortDir(str, Enum):
return self.value
class ExtServerSortKey(str, Enum):
class ServerSortKey(str, Enum):
uuid = "uuid"
display_name = "display_name"
vm_state = "vm_state"
@ -147,7 +147,7 @@ class ExtServerSortKey(str, Enum):
return self.value
class ExtRecycleServerSortKey(str, Enum):
class RecycleServerSortKey(str, Enum):
uuid = "uuid"
display_name = "display_name"
updated_at = "updated_at"
@ -157,7 +157,7 @@ class ExtRecycleServerSortKey(str, Enum):
return self.value
class ExtVolumeSortKey(str, Enum):
class VolumeSortKey(str, Enum):
id = "id"
name = "name"
size = "size"
@ -169,7 +169,7 @@ class ExtVolumeSortKey(str, Enum):
return self.value
class ExtVolumeSnapshotSortKey(str, Enum):
class VolumeSnapshotSortKey(str, Enum):
id = "id"
name = "name"
status = "status"
@ -179,7 +179,7 @@ class ExtVolumeSnapshotSortKey(str, Enum):
return self.value
class ExtPortSortKey(str, Enum):
class PortSortKey(str, Enum):
id = "id"
name = "name"
mac_address = "mac_address"
@ -190,27 +190,27 @@ class ExtPortSortKey(str, Enum):
return self.value
class ExtFlavor(BaseModel):
ephemeral: Optional[int]
ram: Optional[int]
original_name: Optional[str]
vcpus: Optional[int]
extra_specs: Optional[Dict[str, Any]]
swap: Optional[int]
disk: Optional[int]
class FlavorInServer(BaseModel):
ephemeral: Optional[int] = Field(None, description="Ephemeral disk size in GB")
ram: Optional[int] = Field(None, description="RAM size in MB")
original_name: Optional[str] = Field(None, description="Original flavor name")
vcpus: Optional[int] = Field(None, description="Number of vCPUs")
extra_specs: Optional[Dict[str, Any]] = Field(None, description="Extra specs")
swap: Optional[int] = Field(None, description="Swap size in MB")
disk: Optional[int] = Field(None, description="Disk size in GB")
class ExtListServersBaseResponse(BaseModel):
id: UUID4
class ServersResponseBase(BaseModel):
id: UUID4 = Field(..., alias="Server ID")
origin_data: Dict[str, Any] = Field(
description=f"The origin_data is the same like the response of {SERVERS_LIST_DOCS_LINKS}",
)
project_name: Optional[str]
image: Optional[UUID4]
image_name: Optional[str]
image_os_distro: Optional[str]
fixed_addresses: Optional[List]
floating_addresses: Optional[List]
project_name: Optional[str] = Field(None, description="Project name")
image: Optional[UUID4] = Field(None, description="Image ID")
image_name: Optional[str] = Field(None, description="Image name")
image_os_distro: Optional[str] = Field(None, description="Image OS distro")
fixed_addresses: Optional[List] = Field(None, description="Fixed addresses")
floating_addresses: Optional[List] = Field(None, description="Floating addresses")
name: Optional[str] = Field(
description="Will be removed, please use origin_data[name]",
@ -232,7 +232,7 @@ class ExtListServersBaseResponse(BaseModel):
description="Will be removed, please use origin_data[flavor][original_name]",
deprecated=True,
)
flavor_info: Optional[ExtFlavor] = Field(
flavor_info: Optional[FlavorInServer] = Field(
description="Will be removed, please use origin_data[flavor]",
deprecated=True,
)
@ -270,23 +270,23 @@ class ExtListServersBaseResponse(BaseModel):
)
class ExtListServersResponse(BaseModel):
servers: List[ExtListServersBaseResponse]
class ServersResponse(BaseModel):
servers: List[ServersResponseBase] = Field(..., description="Servers list")
class ExtListRecycleServersBaseResponse(BaseModel):
id: UUID4
class RecycleServersResponseBase(BaseModel):
id: UUID4 = Field(..., description="Recycle server id")
origin_data: Dict[str, Any] = Field(
description=f"The origin_data is the same like the response of {SERVERS_LIST_DOCS_LINKS}",
)
project_name: Optional[str]
image: Optional[UUID4]
image_name: Optional[str]
image_os_distro: Optional[str]
fixed_addresses: Optional[List]
floating_addresses: Optional[List]
deleted_at: Optional[str]
reclaim_timestamp: float
project_name: Optional[str] = Field(None, description="Project name")
image: Optional[UUID4] = Field(None, description="Image id")
image_name: Optional[str] = Field(None, description="Image name")
image_os_distro: Optional[str] = Field(None, description="Image os distro")
fixed_addresses: Optional[List] = Field(None, description="Fixed addresses")
floating_addresses: Optional[List] = Field(None, description="Floating addresses")
deleted_at: Optional[str] = Field(None, description="Deleted at")
reclaim_timestamp: float = Field(..., description="Reclaim timestamp")
name: Optional[str] = Field(
description="Will be removed, please use origin_data[name]",
@ -308,7 +308,7 @@ class ExtListRecycleServersBaseResponse(BaseModel):
description="Will be removed, please use origin_data[flavor][original_name]",
deprecated=True,
)
flavor_info: Optional[ExtFlavor] = Field(
flavor_info: Optional[FlavorInServer] = Field(
description="Will be removed, please use origin_data[flavor]",
deprecated=True,
)
@ -318,24 +318,26 @@ class ExtListRecycleServersBaseResponse(BaseModel):
)
class ExtListRecycleServersResponse(BaseModel):
recycle_servers: List[ExtListRecycleServersBaseResponse]
class RecycleServersResponse(BaseModel):
recycle_servers: List[RecycleServersResponseBase] = Field(
..., description="Recycle servers list"
)
class VolumeAttachment(BaseModel):
id: str
device: Optional[str]
server_id: Optional[str]
server_name: Optional[str]
id: str = Field(..., description="Volume attachment id")
device: Optional[str] = Field(None, description="Device name")
server_id: Optional[str] = Field(None, description="Server id")
server_name: Optional[str] = Field(None, description="Server name")
class ExtListVolumesBaseResponse(BaseModel):
id: UUID4
class VolumesResponseBase(BaseModel):
id: UUID4 = Field(..., description="Volume ID")
origin_data: Dict[str, Any] = Field(
description=f"The origin_data is the same like the response of {VOLUMES_LIST_DOCS_LINKS}",
)
project_name: Optional[str]
attachments: Optional[List[VolumeAttachment]]
project_name: Optional[str] = Field(None, description="Project name")
attachments: Optional[List[VolumeAttachment]] = Field(None, description="Volume attachments")
name: Optional[str] = Field(
description="Will be removed, please use origin_data[name]",
@ -391,20 +393,20 @@ class ExtListVolumesBaseResponse(BaseModel):
)
class ExtListVolumesResponse(BaseModel):
count: int = 0
volumes: List[ExtListVolumesBaseResponse]
class VolumesResponse(BaseModel):
count: Optional[int] = Field(0, description="Count of volumes")
volumes: List[VolumesResponseBase] = Field(..., description="Volumes list")
class ExtListVolumeSnapshotsBaseResponse(BaseModel):
id: str
class VolumeSnapshotsResponseBase(BaseModel):
id: str = Field(..., description="Snapshot ID")
origin_data: Dict[str, Any] = Field(
description=f"The origin_data is the same like the response of {VOLUME_SNAPSHOTS_LIST_DOCS_LINKS}", # noqa
)
project_name: Optional[str]
host: Optional[str]
volume_name: Optional[str]
child_volumes: Optional[List]
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")
name: Optional[str] = Field(
description="Will be removed, please use origin_data[name]",
@ -436,20 +438,22 @@ class ExtListVolumeSnapshotsBaseResponse(BaseModel):
)
class ExtListVolumeSnapshotsResponse(BaseModel):
count: int = 0
volume_snapshots: List[ExtListVolumeSnapshotsBaseResponse]
class VolumeSnapshotsResponse(BaseModel):
count: Optional[int] = Field(0, description="Count of volume snapshots")
volume_snapshots: List[VolumeSnapshotsResponseBase] = Field(
..., description="Volume snapshots list"
)
class ExtListPortsBaseResponse(BaseModel):
id: str
class PortsResponseBase(BaseModel):
id: str = Field(..., description="Port ID")
origin_data: Dict[str, Any] = Field(
description=f"The origin_data is the same like the response of {PORTS_LIST_DOCS_LINKS}", # noqa
)
server_name: Optional[str]
network_name: Optional[str]
ipv4: Optional[List]
ipv6: Optional[List]
server_name: Optional[str] = Field(None, description="Server name")
network_name: Optional[str] = Field(None, description="Network name")
ipv4: Optional[List] = Field(None, description="IPv4 addresses")
ipv6: Optional[List] = Field(None, description="IPv6 addresses")
name: Optional[str] = Field(
description="Will be removed, please use origin_data[name]",
@ -505,21 +509,21 @@ class ExtListPortsBaseResponse(BaseModel):
)
class ExtListPortsResponse(BaseModel):
ports: List[ExtListPortsBaseResponse]
class PortsResponse(BaseModel):
ports: List[PortsResponseBase] = Field(..., description="Ports list")
class ExtListComputeServicesBaseResponse(BaseModel):
id: Optional[str]
binary: str
disabled_reason: Optional[str]
host: str
state: Optional[str]
status: str
updated_at: Optional[str]
forced_down: Optional[bool]
zone: Optional[str]
class ComputeServicesResponseBase(BaseModel):
id: Optional[str] = Field(None, description="Service id")
binary: str = Field(..., description="Service binary")
disabled_reason: Optional[str] = Field(None, description="Disabled reason")
host: str = Field(..., description="Host name")
state: Optional[str] = Field(None, description="Service state")
status: str = Field(..., description="Service status")
updated_at: Optional[str] = Field(None, description="Updated at")
forced_down: Optional[bool] = Field(None, description="Forced down")
zone: Optional[str] = Field(None, description="Zone")
class ExtListComputeServicesResponse(BaseModel):
services: List[ExtListComputeServicesBaseResponse]
class ComputeServicesResponse(BaseModel):
services: List[ComputeServicesResponseBase] = Field(..., description="Services list")