From a5e6f9cdfa5165196f78435ec81fe07540052c2b Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 27 Sep 2023 14:23:21 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/block/__init__.py | 2 + .../scaleway_async/block/v1alpha1/__init__.py | 51 ++ .../scaleway_async/block/v1alpha1/api.py | 699 ++++++++++++++++ .../scaleway_async/block/v1alpha1/content.py | 37 + .../block/v1alpha1/marshalling.py | 462 +++++++++++ .../scaleway_async/block/v1alpha1/types.py | 770 ++++++++++++++++++ scaleway/scaleway/block/__init__.py | 2 + scaleway/scaleway/block/v1alpha1/__init__.py | 51 ++ scaleway/scaleway/block/v1alpha1/api.py | 697 ++++++++++++++++ scaleway/scaleway/block/v1alpha1/content.py | 37 + .../scaleway/block/v1alpha1/marshalling.py | 462 +++++++++++ scaleway/scaleway/block/v1alpha1/types.py | 770 ++++++++++++++++++ 12 files changed, 4040 insertions(+) create mode 100644 scaleway-async/scaleway_async/block/__init__.py create mode 100644 scaleway-async/scaleway_async/block/v1alpha1/__init__.py create mode 100644 scaleway-async/scaleway_async/block/v1alpha1/api.py create mode 100644 scaleway-async/scaleway_async/block/v1alpha1/content.py create mode 100644 scaleway-async/scaleway_async/block/v1alpha1/marshalling.py create mode 100644 scaleway-async/scaleway_async/block/v1alpha1/types.py create mode 100644 scaleway/scaleway/block/__init__.py create mode 100644 scaleway/scaleway/block/v1alpha1/__init__.py create mode 100644 scaleway/scaleway/block/v1alpha1/api.py create mode 100644 scaleway/scaleway/block/v1alpha1/content.py create mode 100644 scaleway/scaleway/block/v1alpha1/marshalling.py create mode 100644 scaleway/scaleway/block/v1alpha1/types.py diff --git a/scaleway-async/scaleway_async/block/__init__.py b/scaleway-async/scaleway_async/block/__init__.py new file mode 100644 index 000000000..8b74a5ed7 --- /dev/null +++ b/scaleway-async/scaleway_async/block/__init__.py @@ -0,0 +1,2 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. diff --git a/scaleway-async/scaleway_async/block/v1alpha1/__init__.py b/scaleway-async/scaleway_async/block/v1alpha1/__init__.py new file mode 100644 index 000000000..0330371ac --- /dev/null +++ b/scaleway-async/scaleway_async/block/v1alpha1/__init__.py @@ -0,0 +1,51 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import ListSnapshotsRequestOrderBy +from .types import ListVolumesRequestOrderBy +from .types import ReferenceStatus +from .types import ReferenceType +from .types import SnapshotStatus +from .types import StorageClass +from .types import VolumeStatus +from .types import CreateVolumeRequestFromEmpty +from .types import CreateVolumeRequestFromSnapshot +from .types import ListSnapshotsResponse +from .types import ListVolumeTypesResponse +from .types import ListVolumesResponse +from .types import Reference +from .types import Snapshot +from .types import SnapshotParentVolume +from .types import SnapshotSummary +from .types import Volume +from .types import VolumeSpecifications +from .types import VolumeType +from .content import REFERENCE_TRANSIENT_STATUSES +from .content import SNAPSHOT_TRANSIENT_STATUSES +from .content import VOLUME_TRANSIENT_STATUSES +from .api import BlockV1Alpha1API + +__all__ = [ + "ListSnapshotsRequestOrderBy", + "ListVolumesRequestOrderBy", + "ReferenceStatus", + "ReferenceType", + "SnapshotStatus", + "StorageClass", + "VolumeStatus", + "CreateVolumeRequestFromEmpty", + "CreateVolumeRequestFromSnapshot", + "ListSnapshotsResponse", + "ListVolumeTypesResponse", + "ListVolumesResponse", + "Reference", + "Snapshot", + "SnapshotParentVolume", + "SnapshotSummary", + "Volume", + "VolumeSpecifications", + "VolumeType", + "REFERENCE_TRANSIENT_STATUSES", + "SNAPSHOT_TRANSIENT_STATUSES", + "VOLUME_TRANSIENT_STATUSES", + "BlockV1Alpha1API", +] diff --git a/scaleway-async/scaleway_async/block/v1alpha1/api.py b/scaleway-async/scaleway_async/block/v1alpha1/api.py new file mode 100644 index 000000000..2ad59e0b8 --- /dev/null +++ b/scaleway-async/scaleway_async/block/v1alpha1/api.py @@ -0,0 +1,699 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Awaitable, List, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Zone, +) +from scaleway_core.utils import ( + WaitForOptions, + fetch_all_pages_async, + validate_path_param, + wait_for_resource_async, +) +from .types import ( + ListSnapshotsRequestOrderBy, + ListVolumesRequestOrderBy, + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + ListSnapshotsResponse, + ListVolumeTypesResponse, + ListVolumesResponse, + Snapshot, + SnapshotSummary, + Volume, + VolumeType, + CreateVolumeRequest, + UpdateVolumeRequest, + CreateSnapshotRequest, + UpdateSnapshotRequest, +) +from .content import ( + SNAPSHOT_TRANSIENT_STATUSES, + VOLUME_TRANSIENT_STATUSES, +) +from .marshalling import ( + marshal_CreateSnapshotRequest, + marshal_CreateVolumeRequest, + marshal_UpdateSnapshotRequest, + marshal_UpdateVolumeRequest, + unmarshal_Volume, + unmarshal_ListSnapshotsResponse, + unmarshal_ListVolumeTypesResponse, + unmarshal_ListVolumesResponse, + unmarshal_Snapshot, +) + + +class BlockV1Alpha1API(API): + """ + Scaleway Block Storage (SBS) API. + + This API allows you to use and manage your Block Storage volumes. + Scaleway Block Storage (SBS) API. + """ + + async def list_volume_types( + self, + *, + zone: Optional[Zone] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListVolumeTypesResponse: + """ + List volume types. + List all available volume types in a specified zone. The volume types listed are ordered by name in ascending order. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :return: :class:`ListVolumeTypesResponse ` + + Usage: + :: + + result = await api.list_volume_types() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/volume-types", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVolumeTypesResponse(res.json()) + + async def list_volume_types_all( + self, + *, + zone: Optional[Zone] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[VolumeType]: + """ + List volume types. + List all available volume types in a specified zone. The volume types listed are ordered by name in ascending order. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :return: :class:`List[ListVolumeTypesResponse] ` + + Usage: + :: + + result = await api.list_volume_types_all() + """ + + return await fetch_all_pages_async( + type=ListVolumeTypesResponse, + key="volume_types", + fetcher=self.list_volume_types, + args={ + "zone": zone, + "page": page, + "page_size": page_size, + }, + ) + + async def list_volumes( + self, + *, + zone: Optional[Zone] = None, + order_by: ListVolumesRequestOrderBy = ListVolumesRequestOrderBy.CREATED_AT_ASC, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + product_resource_id: Optional[str] = None, + ) -> ListVolumesResponse: + """ + List volumes. + List all existing volumes in a specified zone. By default, the volume listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned volumes. + :param project_id: Only list volumes of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param name: Filter the return volumes by their names. + :param product_resource_id: Filter by a Product Resource Id linked to this volume (such as an Instance Server Id). + :return: :class:`ListVolumesResponse ` + + Usage: + :: + + result = await api.list_volumes() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/volumes", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "product_resource_id": product_resource_id, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVolumesResponse(res.json()) + + async def list_volumes_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListVolumesRequestOrderBy] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + product_resource_id: Optional[str] = None, + ) -> List[Volume]: + """ + List volumes. + List all existing volumes in a specified zone. By default, the volume listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned volumes. + :param project_id: Only list volumes of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param name: Filter the return volumes by their names. + :param product_resource_id: Filter by a Product Resource Id linked to this volume (such as an Instance Server Id). + :return: :class:`List[ListVolumesResponse] ` + + Usage: + :: + + result = await api.list_volumes_all() + """ + + return await fetch_all_pages_async( + type=ListVolumesResponse, + key="volumes", + fetcher=self.list_volumes, + args={ + "zone": zone, + "order_by": order_by, + "project_id": project_id, + "page": page, + "page_size": page_size, + "name": name, + "product_resource_id": product_resource_id, + }, + ) + + async def create_volume( + self, + *, + name: str, + zone: Optional[Zone] = None, + perf_iops: Optional[int] = None, + project_id: Optional[str] = None, + from_empty: Optional[CreateVolumeRequestFromEmpty] = None, + from_snapshot: Optional[CreateVolumeRequestFromSnapshot] = None, + tags: Optional[List[str]] = None, + ) -> Volume: + """ + Create a new empty volume by specifying the `size`. + To create a volume from an existing snapshot, specify the `snapshot_id` in the request payload instead, size is optional and can be specified if you need to extend the original size. + In that case the created volume will have the same volume class (and underlying IOPS limitations) as the originating snapshot. + You can specify the desired performance of the volume by setting `requirements` accordingly. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name of the volume you want to create. + :param perf_iops: The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + + One-of ('requirements'): at most one of 'perf_iops' could be set. + :param project_id: UUID of the project the volume belongs to. + :param from_empty: Create a new and empty volume. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + :param from_snapshot: Create a volume from an existing snapshot. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + :param tags: List of tags assigned to the volume. + :return: :class:`Volume ` + + Usage: + :: + + result = await api.create_volume(name="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/block/v1alpha1/zones/{param_zone}/volumes", + body=marshal_CreateVolumeRequest( + CreateVolumeRequest( + name=name, + zone=zone, + perf_iops=perf_iops, + project_id=project_id, + from_empty=from_empty, + from_snapshot=from_snapshot, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Volume(res.json()) + + async def get_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + ) -> Volume: + """ + Get a volume. + Retrieve technical information about a specific volume. Details such as size, type, and status are returned in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume you want to get. + :return: :class:`Volume ` + + Usage: + :: + + result = await api.get_volume(volume_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_volume_id = validate_path_param("volume_id", volume_id) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/volumes/{param_volume_id}", + ) + + self._throw_on_error(res) + return unmarshal_Volume(res.json()) + + async def wait_for_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + options: Optional[WaitForOptions[Volume, Union[bool, Awaitable[bool]]]] = None, + ) -> Volume: + """ + Waits for :class:`Volume ` to be in a final state. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume you want to get. + :param options: The options for the waiter + :return: :class:`Volume ` + + Usage: + :: + + result = api.wait_for_volume(volume_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in VOLUME_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_volume, + options=options, + args={ + "volume_id": volume_id, + "zone": zone, + }, + ) + + async def delete_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + ) -> Optional[None]: + """ + Delete a detached volume. + You must specify the `volume_id` of the volume you want to delete. The volume must not be in the `in_use` status. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume. + + Usage: + :: + + result = await api.delete_volume(volume_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_volume_id = validate_path_param("volume_id", volume_id) + + res = self._request( + "DELETE", + f"/block/v1alpha1/zones/{param_zone}/volumes/{param_volume_id}", + ) + + self._throw_on_error(res) + return None + + async def update_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + name: Optional[str] = None, + size: Optional[int] = None, + tags: Optional[List[str]] = None, + perf_iops: Optional[int] = None, + ) -> Volume: + """ + Update a volume. + Update technical details about a volume, such as its name, tags, or its new size and `volume_type` (within the same Block Storage class). + You can only resize a volume to a larger size. It is not possible for now to change your Block Storage Class. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume. + :param name: When defined, is the new name of the volume. + :param size: Optional field for growing a volume (size must be equal or larger than the current one). + Size in bytes of the volume, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the minimum and maximum allowed size. + :param tags: List of tags assigned to the volume. + :param perf_iops: The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + The selected value must be available on the Storage Class where is currently located the volume. + :return: :class:`Volume ` + + Usage: + :: + + result = await api.update_volume(volume_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_volume_id = validate_path_param("volume_id", volume_id) + + res = self._request( + "PATCH", + f"/block/v1alpha1/zones/{param_zone}/volumes/{param_volume_id}", + body=marshal_UpdateVolumeRequest( + UpdateVolumeRequest( + volume_id=volume_id, + zone=zone, + name=name, + size=size, + tags=tags, + perf_iops=perf_iops, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Volume(res.json()) + + async def list_snapshots( + self, + *, + zone: Optional[Zone] = None, + order_by: ListSnapshotsRequestOrderBy = ListSnapshotsRequestOrderBy.CREATED_AT_ASC, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + volume_id: Optional[str] = None, + name: Optional[str] = None, + ) -> ListSnapshotsResponse: + """ + List all snapshots. + List all available snapshots in a specified zone. By default, the snapshots listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned snapshots. + :param project_id: Only list snapshots of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param volume_id: Filter the return snapshots by the volume it belongs to. + :param name: Filter the return snapshots by their names. + :return: :class:`ListSnapshotsResponse ` + + Usage: + :: + + result = await api.list_snapshots() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/snapshots", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "volume_id": volume_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListSnapshotsResponse(res.json()) + + async def list_snapshots_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListSnapshotsRequestOrderBy] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + volume_id: Optional[str] = None, + name: Optional[str] = None, + ) -> List[SnapshotSummary]: + """ + List all snapshots. + List all available snapshots in a specified zone. By default, the snapshots listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned snapshots. + :param project_id: Only list snapshots of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param volume_id: Filter the return snapshots by the volume it belongs to. + :param name: Filter the return snapshots by their names. + :return: :class:`List[ListSnapshotsResponse] ` + + Usage: + :: + + result = await api.list_snapshots_all() + """ + + return await fetch_all_pages_async( + type=ListSnapshotsResponse, + key="snapshots", + fetcher=self.list_snapshots, + args={ + "zone": zone, + "order_by": order_by, + "project_id": project_id, + "page": page, + "page_size": page_size, + "volume_id": volume_id, + "name": name, + }, + ) + + async def get_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + ) -> Snapshot: + """ + Get a snapshot. + Retrieve technical information about a specific snapshot. Details such as size, volume type, and status are returned in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + :return: :class:`Snapshot ` + + Usage: + :: + + result = await api.get_snapshot(snapshot_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/snapshots/{param_snapshot_id}", + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + async def wait_for_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + options: Optional[ + WaitForOptions[Snapshot, Union[bool, Awaitable[bool]]] + ] = None, + ) -> Snapshot: + """ + Waits for :class:`Snapshot ` to be in a final state. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + :param options: The options for the waiter + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.wait_for_snapshot(snapshot_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in SNAPSHOT_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_snapshot, + options=options, + args={ + "snapshot_id": snapshot_id, + "zone": zone, + }, + ) + + async def create_snapshot( + self, + *, + volume_id: str, + name: str, + zone: Optional[Zone] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Snapshot: + """ + Create a snapshot of a volume. + To create a snapshot, the volume must be in the `in_use` or the `available` status. + If your volume is in a transient state, you need to wait until the end of the current operation. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume from which creates a snpashot. + :param name: Name of the snapshot. + :param project_id: UUID of the project the volume and the snapshot belong to. + :param tags: List of tags assigned to the snapshot. + :return: :class:`Snapshot ` + + Usage: + :: + + result = await api.create_snapshot( + volume_id="example", + name="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/block/v1alpha1/zones/{param_zone}/snapshots", + body=marshal_CreateSnapshotRequest( + CreateSnapshotRequest( + volume_id=volume_id, + name=name, + zone=zone, + project_id=project_id, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + async def delete_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + ) -> Optional[None]: + """ + Delete a snapshot. + You must specify the `snapshot_id` of the snapshot you want to delete. The snapshot must not be in use. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + + Usage: + :: + + result = await api.delete_snapshot(snapshot_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "DELETE", + f"/block/v1alpha1/zones/{param_zone}/snapshots/{param_snapshot_id}", + ) + + self._throw_on_error(res) + return None + + async def update_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Snapshot: + """ + Update a snapshot. + Update name or tags of the snapshot. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + :param name: When defined, is the name of the snapshot. + :param tags: List of tags assigned to the snapshot. + :return: :class:`Snapshot ` + + Usage: + :: + + result = await api.update_snapshot(snapshot_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "PATCH", + f"/block/v1alpha1/zones/{param_zone}/snapshots/{param_snapshot_id}", + body=marshal_UpdateSnapshotRequest( + UpdateSnapshotRequest( + snapshot_id=snapshot_id, + zone=zone, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) diff --git a/scaleway-async/scaleway_async/block/v1alpha1/content.py b/scaleway-async/scaleway_async/block/v1alpha1/content.py new file mode 100644 index 000000000..9508197af --- /dev/null +++ b/scaleway-async/scaleway_async/block/v1alpha1/content.py @@ -0,0 +1,37 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + ReferenceStatus, + SnapshotStatus, + VolumeStatus, +) + + +REFERENCE_TRANSIENT_STATUSES: List[ReferenceStatus] = [ + ReferenceStatus.ATTACHING, + ReferenceStatus.DETACHING, + ReferenceStatus.SNAPSHOTTING, +] +""" +Lists transient statutes of the enum :class:`ReferenceStatus `. +""" + +SNAPSHOT_TRANSIENT_STATUSES: List[SnapshotStatus] = [ + SnapshotStatus.CREATING, + SnapshotStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`SnapshotStatus `. +""" + +VOLUME_TRANSIENT_STATUSES: List[VolumeStatus] = [ + VolumeStatus.CREATING, + VolumeStatus.DELETING, + VolumeStatus.RESIZING, + VolumeStatus.SNAPSHOTTING, +] +""" +Lists transient statutes of the enum :class:`VolumeStatus `. +""" diff --git a/scaleway-async/scaleway_async/block/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/block/v1alpha1/marshalling.py new file mode 100644 index 000000000..4b10d6cf3 --- /dev/null +++ b/scaleway-async/scaleway_async/block/v1alpha1/marshalling.py @@ -0,0 +1,462 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + unmarshal_Money, +) +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from dateutil import parser +from .types import ( + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + ListSnapshotsResponse, + ListVolumeTypesResponse, + ListVolumesResponse, + Reference, + Snapshot, + SnapshotParentVolume, + SnapshotSummary, + Volume, + VolumeSpecifications, + VolumeType, + CreateVolumeRequest, + UpdateVolumeRequest, + CreateSnapshotRequest, + UpdateSnapshotRequest, +) + + +def unmarshal_Reference(data: Any) -> Reference: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Reference' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("product_resource_id", None) + args["product_resource_id"] = field + + field = data.get("product_resource_type", None) + args["product_resource_type"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("type", None) + args["type_"] = field + + return Reference(**args) + + +def unmarshal_SnapshotParentVolume(data: Any) -> SnapshotParentVolume: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("type", None) + args["type_"] = field + + return SnapshotParentVolume(**args) + + +def unmarshal_VolumeSpecifications(data: Any) -> VolumeSpecifications: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("class", None) + args["class_"] = field + + field = data.get("perf_iops", None) + args["perf_iops"] = field + + return VolumeSpecifications(**args) + + +def unmarshal_SnapshotSummary(data: Any) -> SnapshotSummary: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'SnapshotSummary' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("class", None) + args["class_"] = field + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("parent_volume", None) + args["parent_volume"] = ( + unmarshal_SnapshotParentVolume(field) if field is not None else None + ) + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("size", None) + args["size"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("tags", None) + args["tags"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("zone", None) + args["zone"] = field + + return SnapshotSummary(**args) + + +def unmarshal_Volume(data: Any) -> Volume: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Volume' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("parent_snapshot_id", None) + args["parent_snapshot_id"] = field + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("references", None) + args["references"] = ( + [unmarshal_Reference(v) for v in field] if field is not None else None + ) + + field = data.get("size", None) + args["size"] = field + + field = data.get("specs", None) + args["specs"] = unmarshal_VolumeSpecifications(field) if field is not None else None + + field = data.get("status", None) + args["status"] = field + + field = data.get("tags", None) + args["tags"] = field + + field = data.get("type", None) + args["type_"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("zone", None) + args["zone"] = field + + return Volume(**args) + + +def unmarshal_VolumeType(data: Any) -> VolumeType: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'VolumeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pricing", None) + args["pricing"] = unmarshal_Money(field) if field is not None else None + + field = data.get("snapshot_pricing", None) + args["snapshot_pricing"] = unmarshal_Money(field) if field is not None else None + + field = data.get("specs", None) + args["specs"] = unmarshal_VolumeSpecifications(field) if field is not None else None + + field = data.get("type", None) + args["type_"] = field + + return VolumeType(**args) + + +def unmarshal_ListSnapshotsResponse(data: Any) -> ListSnapshotsResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("snapshots", None) + args["snapshots"] = ( + [unmarshal_SnapshotSummary(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + return ListSnapshotsResponse(**args) + + +def unmarshal_ListVolumeTypesResponse(data: Any) -> ListVolumeTypesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListVolumeTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("volume_types", None) + args["volume_types"] = ( + [unmarshal_VolumeType(v) for v in field] if field is not None else None + ) + + return ListVolumeTypesResponse(**args) + + +def unmarshal_ListVolumesResponse(data: Any) -> ListVolumesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListVolumesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("volumes", None) + args["volumes"] = ( + [unmarshal_Volume(v) for v in field] if field is not None else None + ) + + return ListVolumesResponse(**args) + + +def unmarshal_Snapshot(data: Any) -> Snapshot: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Snapshot' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("class", None) + args["class_"] = field + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("parent_volume", None) + args["parent_volume"] = ( + unmarshal_SnapshotParentVolume(field) if field is not None else None + ) + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("references", None) + args["references"] = ( + [unmarshal_Reference(v) for v in field] if field is not None else None + ) + + field = data.get("size", None) + args["size"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("tags", None) + args["tags"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("zone", None) + args["zone"] = field + + return Snapshot(**args) + + +def marshal_CreateVolumeRequestFromEmpty( + request: CreateVolumeRequestFromEmpty, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.size is not None: + output["size"] = request.size + + return output + + +def marshal_CreateVolumeRequestFromSnapshot( + request: CreateVolumeRequestFromSnapshot, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.size is not None: + output["size"] = request.size + + if request.snapshot_id is not None: + output["snapshot_id"] = request.snapshot_id + + return output + + +def marshal_CreateSnapshotRequest( + request: CreateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.volume_id is not None: + output["volume_id"] = request.volume_id + + return output + + +def marshal_CreateVolumeRequest( + request: CreateVolumeRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + "from_empty", + marshal_CreateVolumeRequestFromEmpty(request.from_empty, defaults) + if request.from_empty is not None + else None, + ), + OneOfPossibility( + "from_snapshot", + marshal_CreateVolumeRequestFromSnapshot( + request.from_snapshot, defaults + ) + if request.from_snapshot is not None + else None, + ), + ] + ), + ) + output.update( + resolve_one_of( + [ + OneOfPossibility( + "perf_iops", + request.perf_iops if request.perf_iops is not None else None, + ), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateSnapshotRequest( + request: UpdateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateVolumeRequest( + request: UpdateVolumeRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.perf_iops is not None: + output["perf_iops"] = request.perf_iops + + if request.size is not None: + output["size"] = request.size + + if request.tags is not None: + output["tags"] = request.tags + + return output diff --git a/scaleway-async/scaleway_async/block/v1alpha1/types.py b/scaleway-async/scaleway_async/block/v1alpha1/types.py new file mode 100644 index 000000000..7c68a2084 --- /dev/null +++ b/scaleway-async/scaleway_async/block/v1alpha1/types.py @@ -0,0 +1,770 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Money, + Zone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class ListSnapshotsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListVolumesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ReferenceStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + ATTACHING = "attaching" + ATTACHED = "attached" + DETACHING = "detaching" + DETACHED = "detached" + SNAPSHOTTING = "snapshotting" + ERROR = "error" + + def __str__(self) -> str: + return str(self.value) + + +class ReferenceType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + LINK = "link" + EXCLUSIVE = "exclusive" + READ_ONLY = "read_only" + + def __str__(self) -> str: + return str(self.value) + + +class SnapshotStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + AVAILABLE = "available" + ERROR = "error" + DELETING = "deleting" + DELETED = "deleted" + IN_USE = "in_use" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class StorageClass(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STORAGE_CLASS = "unknown_storage_class" + UNSPECIFIED = "unspecified" + BSSD = "bssd" + SBS = "sbs" + + def __str__(self) -> str: + return str(self.value) + + +class VolumeStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + AVAILABLE = "available" + IN_USE = "in_use" + DELETING = "deleting" + DELETED = "deleted" + RESIZING = "resizing" + ERROR = "error" + SNAPSHOTTING = "snapshotting" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class CreateVolumeRequestFromEmpty: + """ + Create volume request. from empty. + """ + + size: int + """ + Volume size in bytes, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the minimum and maximum allowed size. + """ + + +@dataclass +class CreateVolumeRequestFromSnapshot: + """ + Create volume request. from snapshot. + """ + + size: Optional[int] + """ + Volume size in bytes, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the allowed minimum and maximum allowed size. + Size is optional and is used only if a resize of the volume is requested, otherwise original snapshot size will be used. + """ + + snapshot_id: str + """ + Source snapshot from which create a volume. + """ + + +@dataclass +class ListSnapshotsResponse: + """ + List snapshots response. + """ + + snapshots: List[SnapshotSummary] + """ + Paginated returned list of snapshots. + """ + + total_count: int + """ + Total number of snpashots in the project. + """ + + +@dataclass +class ListVolumeTypesResponse: + """ + List volume types response. + """ + + volume_types: List[VolumeType] + """ + Paginated returned list of volume-types. + """ + + total_count: int + """ + Total number of volume-types currently available in stock. + """ + + +@dataclass +class ListVolumesResponse: + """ + List volumes response. + """ + + volumes: List[Volume] + """ + Paginated returned list of volumes. + """ + + total_count: int + """ + Total number of volumes in the project. + """ + + +@dataclass +class Reference: + """ + Reference. + """ + + id: str + """ + UUID of the reference. + """ + + product_resource_type: str + """ + Type of the resoruce the reference is associated (else snapshot or volume). + """ + + product_resource_id: str + """ + UUID of the volume or the snapshot it refers to (according to the product_resource_type). + """ + + created_at: Optional[datetime] + """ + Creation date of the reference. + """ + + type_: ReferenceType + """ + Type of the reference (link, exclusive, read_only). + """ + + status: ReferenceStatus + """ + Status of the reference (attaching, attached, detaching). + """ + + +@dataclass +class Snapshot: + """ + Snapshot. + """ + + id: str + """ + UUID of the snapshot. + """ + + name: str + """ + Name of the snapshot. + """ + + parent_volume: Optional[SnapshotParentVolume] + """ + Informations about the parent volume. + If the parent volume has been deleted, value is null. + """ + + size: int + """ + Size in bytes of the snapshot. + """ + + project_id: str + """ + UUID of the project the snapshot belongs to. + """ + + created_at: Optional[datetime] + """ + Creation date of the snapshot. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the properties of a snapshot. + """ + + references: List[Reference] + """ + List of the references to the snapshot. + """ + + status: SnapshotStatus + """ + Current status of the snapshot (available, in_use, ...). + """ + + tags: List[str] + """ + List of tags assigned to the volume. + """ + + zone: Zone + """ + Snapshot zone. + """ + + class_: StorageClass + """ + Storage class of the snapshot. + """ + + +@dataclass +class SnapshotParentVolume: + """ + Snapshot. parent volume. + """ + + id: str + """ + Volume ID on which the snapshot is based. + """ + + name: str + """ + Name of the parent volume from which the snapshot has been taken. + """ + + type_: str + """ + Volume type of the parent volume from which the snapshot has been taken. + """ + + status: VolumeStatus + """ + Current status the parent volume from which the snapshot has been taken. + """ + + +@dataclass +class SnapshotSummary: + """ + Snapshot summary. + """ + + id: str + """ + UUID of the snapshot. + """ + + name: str + """ + Name of the snapshot. + """ + + parent_volume: Optional[SnapshotParentVolume] + """ + Information about the parent volume. + If the parent volume has been deleted, value is null. + """ + + size: int + """ + Size in bytes of the snapshot. + """ + + project_id: str + """ + UUID of the project the snapshot belongs to. + """ + + created_at: Optional[datetime] + """ + Creation date of the snapshot. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the properties of a snapshot. + """ + + status: SnapshotStatus + """ + Current status of the snapshot (available, in_use, ...). + """ + + tags: List[str] + """ + List of tags assigned to the volume. + """ + + zone: Zone + """ + Snapshot zone. + """ + + class_: StorageClass + """ + Storage class of the snapshot. + """ + + +@dataclass +class Volume: + """ + Volume. + """ + + id: str + """ + UUID of the volume. + """ + + name: str + """ + Name of the volume. + """ + + type_: str + """ + Type of the volume. + """ + + size: int + """ + Volume size in bytes. + """ + + project_id: str + """ + UUID of the project the volume belongs to. + """ + + created_at: Optional[datetime] + """ + Creation date of the volume. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the properties of a volume. + """ + + references: List[Reference] + """ + List of the references to the volume. + """ + + parent_snapshot_id: Optional[str] + """ + When a volume is created from a snapshot, is the UUID of the snapshot from which the volume has been created. + """ + + status: VolumeStatus + """ + Current status of the volume (available, in_use, ...). + """ + + tags: List[str] + """ + List of tags assigned to the volume. + """ + + zone: Zone + """ + Volume zone. + """ + + specs: Optional[VolumeSpecifications] + """ + Volume specifications of the volume. + """ + + +@dataclass +class VolumeSpecifications: + """ + Volume specifications. + """ + + perf_iops: Optional[int] + """ + The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + """ + + class_: StorageClass + """ + The storage class of the volume. + """ + + +@dataclass +class VolumeType: + """ + Volume type. + """ + + type_: str + """ + Internal type of the volume. + """ + + pricing: Optional[Money] + """ + Price of the volume billed in GB/hour. + """ + + snapshot_pricing: Optional[Money] + """ + Price of the snapshot billed in GB/hour. + """ + + specs: Optional[VolumeSpecifications] + """ + Volume specifications of the volume type. + """ + + +@dataclass +class ListVolumeTypesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + +@dataclass +class ListVolumesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListVolumesRequestOrderBy] + """ + Sort order of the returned volumes. + """ + + project_id: Optional[str] + """ + Only list volumes of this project ID. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + name: Optional[str] + """ + Filter the return volumes by their names. + """ + + product_resource_id: Optional[str] + """ + Filter by a Product Resource Id linked to this volume (such as an Instance Server Id). + """ + + +@dataclass +class CreateVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + name: str + """ + Name of the volume you want to create. + """ + + perf_iops: Optional[int] + """ + The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + + One-of ('requirements'): at most one of 'perf_iops' could be set. + """ + + project_id: Optional[str] + """ + UUID of the project the volume belongs to. + """ + + from_empty: Optional[CreateVolumeRequestFromEmpty] + """ + Create a new and empty volume. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + """ + + from_snapshot: Optional[CreateVolumeRequestFromSnapshot] + """ + Create a volume from an existing snapshot. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the volume. + """ + + +@dataclass +class GetVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume you want to get. + """ + + +@dataclass +class DeleteVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume. + """ + + +@dataclass +class UpdateVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume. + """ + + name: Optional[str] + """ + When defined, is the new name of the volume. + """ + + size: Optional[int] + """ + Optional field for growing a volume (size must be equal or larger than the current one). + Size in bytes of the volume, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the minimum and maximum allowed size. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the volume. + """ + + perf_iops: Optional[int] + """ + The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + The selected value must be available on the Storage Class where is currently located the volume. + """ + + +@dataclass +class ListSnapshotsRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListSnapshotsRequestOrderBy] + """ + Sort order of the returned snapshots. + """ + + project_id: Optional[str] + """ + Only list snapshots of this project ID. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + volume_id: Optional[str] + """ + Filter the return snapshots by the volume it belongs to. + """ + + name: Optional[str] + """ + Filter the return snapshots by their names. + """ + + +@dataclass +class GetSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + snapshot_id: str + """ + UUID of the snapshot. + """ + + +@dataclass +class CreateSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume from which creates a snpashot. + """ + + name: str + """ + Name of the snapshot. + """ + + project_id: Optional[str] + """ + UUID of the project the volume and the snapshot belong to. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the snapshot. + """ + + +@dataclass +class DeleteSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + snapshot_id: str + """ + UUID of the snapshot. + """ + + +@dataclass +class UpdateSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + snapshot_id: str + """ + UUID of the snapshot. + """ + + name: Optional[str] + """ + When defined, is the name of the snapshot. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the snapshot. + """ diff --git a/scaleway/scaleway/block/__init__.py b/scaleway/scaleway/block/__init__.py new file mode 100644 index 000000000..8b74a5ed7 --- /dev/null +++ b/scaleway/scaleway/block/__init__.py @@ -0,0 +1,2 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. diff --git a/scaleway/scaleway/block/v1alpha1/__init__.py b/scaleway/scaleway/block/v1alpha1/__init__.py new file mode 100644 index 000000000..0330371ac --- /dev/null +++ b/scaleway/scaleway/block/v1alpha1/__init__.py @@ -0,0 +1,51 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import ListSnapshotsRequestOrderBy +from .types import ListVolumesRequestOrderBy +from .types import ReferenceStatus +from .types import ReferenceType +from .types import SnapshotStatus +from .types import StorageClass +from .types import VolumeStatus +from .types import CreateVolumeRequestFromEmpty +from .types import CreateVolumeRequestFromSnapshot +from .types import ListSnapshotsResponse +from .types import ListVolumeTypesResponse +from .types import ListVolumesResponse +from .types import Reference +from .types import Snapshot +from .types import SnapshotParentVolume +from .types import SnapshotSummary +from .types import Volume +from .types import VolumeSpecifications +from .types import VolumeType +from .content import REFERENCE_TRANSIENT_STATUSES +from .content import SNAPSHOT_TRANSIENT_STATUSES +from .content import VOLUME_TRANSIENT_STATUSES +from .api import BlockV1Alpha1API + +__all__ = [ + "ListSnapshotsRequestOrderBy", + "ListVolumesRequestOrderBy", + "ReferenceStatus", + "ReferenceType", + "SnapshotStatus", + "StorageClass", + "VolumeStatus", + "CreateVolumeRequestFromEmpty", + "CreateVolumeRequestFromSnapshot", + "ListSnapshotsResponse", + "ListVolumeTypesResponse", + "ListVolumesResponse", + "Reference", + "Snapshot", + "SnapshotParentVolume", + "SnapshotSummary", + "Volume", + "VolumeSpecifications", + "VolumeType", + "REFERENCE_TRANSIENT_STATUSES", + "SNAPSHOT_TRANSIENT_STATUSES", + "VOLUME_TRANSIENT_STATUSES", + "BlockV1Alpha1API", +] diff --git a/scaleway/scaleway/block/v1alpha1/api.py b/scaleway/scaleway/block/v1alpha1/api.py new file mode 100644 index 000000000..d28ebab6a --- /dev/null +++ b/scaleway/scaleway/block/v1alpha1/api.py @@ -0,0 +1,697 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Zone, +) +from scaleway_core.utils import ( + WaitForOptions, + fetch_all_pages, + validate_path_param, + wait_for_resource, +) +from .types import ( + ListSnapshotsRequestOrderBy, + ListVolumesRequestOrderBy, + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + ListSnapshotsResponse, + ListVolumeTypesResponse, + ListVolumesResponse, + Snapshot, + SnapshotSummary, + Volume, + VolumeType, + CreateVolumeRequest, + UpdateVolumeRequest, + CreateSnapshotRequest, + UpdateSnapshotRequest, +) +from .content import ( + SNAPSHOT_TRANSIENT_STATUSES, + VOLUME_TRANSIENT_STATUSES, +) +from .marshalling import ( + marshal_CreateSnapshotRequest, + marshal_CreateVolumeRequest, + marshal_UpdateSnapshotRequest, + marshal_UpdateVolumeRequest, + unmarshal_Volume, + unmarshal_ListSnapshotsResponse, + unmarshal_ListVolumeTypesResponse, + unmarshal_ListVolumesResponse, + unmarshal_Snapshot, +) + + +class BlockV1Alpha1API(API): + """ + Scaleway Block Storage (SBS) API. + + This API allows you to use and manage your Block Storage volumes. + Scaleway Block Storage (SBS) API. + """ + + def list_volume_types( + self, + *, + zone: Optional[Zone] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListVolumeTypesResponse: + """ + List volume types. + List all available volume types in a specified zone. The volume types listed are ordered by name in ascending order. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :return: :class:`ListVolumeTypesResponse ` + + Usage: + :: + + result = api.list_volume_types() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/volume-types", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVolumeTypesResponse(res.json()) + + def list_volume_types_all( + self, + *, + zone: Optional[Zone] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[VolumeType]: + """ + List volume types. + List all available volume types in a specified zone. The volume types listed are ordered by name in ascending order. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :return: :class:`List[ListVolumeTypesResponse] ` + + Usage: + :: + + result = api.list_volume_types_all() + """ + + return fetch_all_pages( + type=ListVolumeTypesResponse, + key="volume_types", + fetcher=self.list_volume_types, + args={ + "zone": zone, + "page": page, + "page_size": page_size, + }, + ) + + def list_volumes( + self, + *, + zone: Optional[Zone] = None, + order_by: ListVolumesRequestOrderBy = ListVolumesRequestOrderBy.CREATED_AT_ASC, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + product_resource_id: Optional[str] = None, + ) -> ListVolumesResponse: + """ + List volumes. + List all existing volumes in a specified zone. By default, the volume listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned volumes. + :param project_id: Only list volumes of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param name: Filter the return volumes by their names. + :param product_resource_id: Filter by a Product Resource Id linked to this volume (such as an Instance Server Id). + :return: :class:`ListVolumesResponse ` + + Usage: + :: + + result = api.list_volumes() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/volumes", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "product_resource_id": product_resource_id, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVolumesResponse(res.json()) + + def list_volumes_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListVolumesRequestOrderBy] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + product_resource_id: Optional[str] = None, + ) -> List[Volume]: + """ + List volumes. + List all existing volumes in a specified zone. By default, the volume listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned volumes. + :param project_id: Only list volumes of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param name: Filter the return volumes by their names. + :param product_resource_id: Filter by a Product Resource Id linked to this volume (such as an Instance Server Id). + :return: :class:`List[ListVolumesResponse] ` + + Usage: + :: + + result = api.list_volumes_all() + """ + + return fetch_all_pages( + type=ListVolumesResponse, + key="volumes", + fetcher=self.list_volumes, + args={ + "zone": zone, + "order_by": order_by, + "project_id": project_id, + "page": page, + "page_size": page_size, + "name": name, + "product_resource_id": product_resource_id, + }, + ) + + def create_volume( + self, + *, + name: str, + zone: Optional[Zone] = None, + perf_iops: Optional[int] = None, + project_id: Optional[str] = None, + from_empty: Optional[CreateVolumeRequestFromEmpty] = None, + from_snapshot: Optional[CreateVolumeRequestFromSnapshot] = None, + tags: Optional[List[str]] = None, + ) -> Volume: + """ + Create a new empty volume by specifying the `size`. + To create a volume from an existing snapshot, specify the `snapshot_id` in the request payload instead, size is optional and can be specified if you need to extend the original size. + In that case the created volume will have the same volume class (and underlying IOPS limitations) as the originating snapshot. + You can specify the desired performance of the volume by setting `requirements` accordingly. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name of the volume you want to create. + :param perf_iops: The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + + One-of ('requirements'): at most one of 'perf_iops' could be set. + :param project_id: UUID of the project the volume belongs to. + :param from_empty: Create a new and empty volume. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + :param from_snapshot: Create a volume from an existing snapshot. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + :param tags: List of tags assigned to the volume. + :return: :class:`Volume ` + + Usage: + :: + + result = api.create_volume(name="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/block/v1alpha1/zones/{param_zone}/volumes", + body=marshal_CreateVolumeRequest( + CreateVolumeRequest( + name=name, + zone=zone, + perf_iops=perf_iops, + project_id=project_id, + from_empty=from_empty, + from_snapshot=from_snapshot, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Volume(res.json()) + + def get_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + ) -> Volume: + """ + Get a volume. + Retrieve technical information about a specific volume. Details such as size, type, and status are returned in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume you want to get. + :return: :class:`Volume ` + + Usage: + :: + + result = api.get_volume(volume_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_volume_id = validate_path_param("volume_id", volume_id) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/volumes/{param_volume_id}", + ) + + self._throw_on_error(res) + return unmarshal_Volume(res.json()) + + def wait_for_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + options: Optional[WaitForOptions[Volume, bool]] = None, + ) -> Volume: + """ + Waits for :class:`Volume ` to be in a final state. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume you want to get. + :param options: The options for the waiter + :return: :class:`Volume ` + + Usage: + :: + + result = api.wait_for_volume(volume_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in VOLUME_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_volume, + options=options, + args={ + "volume_id": volume_id, + "zone": zone, + }, + ) + + def delete_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + ) -> Optional[None]: + """ + Delete a detached volume. + You must specify the `volume_id` of the volume you want to delete. The volume must not be in the `in_use` status. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume. + + Usage: + :: + + result = api.delete_volume(volume_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_volume_id = validate_path_param("volume_id", volume_id) + + res = self._request( + "DELETE", + f"/block/v1alpha1/zones/{param_zone}/volumes/{param_volume_id}", + ) + + self._throw_on_error(res) + return None + + def update_volume( + self, + *, + volume_id: str, + zone: Optional[Zone] = None, + name: Optional[str] = None, + size: Optional[int] = None, + tags: Optional[List[str]] = None, + perf_iops: Optional[int] = None, + ) -> Volume: + """ + Update a volume. + Update technical details about a volume, such as its name, tags, or its new size and `volume_type` (within the same Block Storage class). + You can only resize a volume to a larger size. It is not possible for now to change your Block Storage Class. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume. + :param name: When defined, is the new name of the volume. + :param size: Optional field for growing a volume (size must be equal or larger than the current one). + Size in bytes of the volume, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the minimum and maximum allowed size. + :param tags: List of tags assigned to the volume. + :param perf_iops: The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + The selected value must be available on the Storage Class where is currently located the volume. + :return: :class:`Volume ` + + Usage: + :: + + result = api.update_volume(volume_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_volume_id = validate_path_param("volume_id", volume_id) + + res = self._request( + "PATCH", + f"/block/v1alpha1/zones/{param_zone}/volumes/{param_volume_id}", + body=marshal_UpdateVolumeRequest( + UpdateVolumeRequest( + volume_id=volume_id, + zone=zone, + name=name, + size=size, + tags=tags, + perf_iops=perf_iops, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Volume(res.json()) + + def list_snapshots( + self, + *, + zone: Optional[Zone] = None, + order_by: ListSnapshotsRequestOrderBy = ListSnapshotsRequestOrderBy.CREATED_AT_ASC, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + volume_id: Optional[str] = None, + name: Optional[str] = None, + ) -> ListSnapshotsResponse: + """ + List all snapshots. + List all available snapshots in a specified zone. By default, the snapshots listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned snapshots. + :param project_id: Only list snapshots of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param volume_id: Filter the return snapshots by the volume it belongs to. + :param name: Filter the return snapshots by their names. + :return: :class:`ListSnapshotsResponse ` + + Usage: + :: + + result = api.list_snapshots() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/snapshots", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "volume_id": volume_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListSnapshotsResponse(res.json()) + + def list_snapshots_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListSnapshotsRequestOrderBy] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + volume_id: Optional[str] = None, + name: Optional[str] = None, + ) -> List[SnapshotSummary]: + """ + List all snapshots. + List all available snapshots in a specified zone. By default, the snapshots listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Sort order of the returned snapshots. + :param project_id: Only list snapshots of this project ID. + :param page: Positive integer to choose the page to return. + :param page_size: Positive integer lower or equal to 100 to select the number of items to return. + :param volume_id: Filter the return snapshots by the volume it belongs to. + :param name: Filter the return snapshots by their names. + :return: :class:`List[ListSnapshotsResponse] ` + + Usage: + :: + + result = api.list_snapshots_all() + """ + + return fetch_all_pages( + type=ListSnapshotsResponse, + key="snapshots", + fetcher=self.list_snapshots, + args={ + "zone": zone, + "order_by": order_by, + "project_id": project_id, + "page": page, + "page_size": page_size, + "volume_id": volume_id, + "name": name, + }, + ) + + def get_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + ) -> Snapshot: + """ + Get a snapshot. + Retrieve technical information about a specific snapshot. Details such as size, volume type, and status are returned in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.get_snapshot(snapshot_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "GET", + f"/block/v1alpha1/zones/{param_zone}/snapshots/{param_snapshot_id}", + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + def wait_for_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + options: Optional[WaitForOptions[Snapshot, bool]] = None, + ) -> Snapshot: + """ + Waits for :class:`Snapshot ` to be in a final state. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + :param options: The options for the waiter + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.wait_for_snapshot(snapshot_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in SNAPSHOT_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_snapshot, + options=options, + args={ + "snapshot_id": snapshot_id, + "zone": zone, + }, + ) + + def create_snapshot( + self, + *, + volume_id: str, + name: str, + zone: Optional[Zone] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Snapshot: + """ + Create a snapshot of a volume. + To create a snapshot, the volume must be in the `in_use` or the `available` status. + If your volume is in a transient state, you need to wait until the end of the current operation. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param volume_id: UUID of the volume from which creates a snpashot. + :param name: Name of the snapshot. + :param project_id: UUID of the project the volume and the snapshot belong to. + :param tags: List of tags assigned to the snapshot. + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.create_snapshot( + volume_id="example", + name="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/block/v1alpha1/zones/{param_zone}/snapshots", + body=marshal_CreateSnapshotRequest( + CreateSnapshotRequest( + volume_id=volume_id, + name=name, + zone=zone, + project_id=project_id, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + def delete_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + ) -> Optional[None]: + """ + Delete a snapshot. + You must specify the `snapshot_id` of the snapshot you want to delete. The snapshot must not be in use. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + + Usage: + :: + + result = api.delete_snapshot(snapshot_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "DELETE", + f"/block/v1alpha1/zones/{param_zone}/snapshots/{param_snapshot_id}", + ) + + self._throw_on_error(res) + return None + + def update_snapshot( + self, + *, + snapshot_id: str, + zone: Optional[Zone] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Snapshot: + """ + Update a snapshot. + Update name or tags of the snapshot. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param snapshot_id: UUID of the snapshot. + :param name: When defined, is the name of the snapshot. + :param tags: List of tags assigned to the snapshot. + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.update_snapshot(snapshot_id="example") + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "PATCH", + f"/block/v1alpha1/zones/{param_zone}/snapshots/{param_snapshot_id}", + body=marshal_UpdateSnapshotRequest( + UpdateSnapshotRequest( + snapshot_id=snapshot_id, + zone=zone, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) diff --git a/scaleway/scaleway/block/v1alpha1/content.py b/scaleway/scaleway/block/v1alpha1/content.py new file mode 100644 index 000000000..9508197af --- /dev/null +++ b/scaleway/scaleway/block/v1alpha1/content.py @@ -0,0 +1,37 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + ReferenceStatus, + SnapshotStatus, + VolumeStatus, +) + + +REFERENCE_TRANSIENT_STATUSES: List[ReferenceStatus] = [ + ReferenceStatus.ATTACHING, + ReferenceStatus.DETACHING, + ReferenceStatus.SNAPSHOTTING, +] +""" +Lists transient statutes of the enum :class:`ReferenceStatus `. +""" + +SNAPSHOT_TRANSIENT_STATUSES: List[SnapshotStatus] = [ + SnapshotStatus.CREATING, + SnapshotStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`SnapshotStatus `. +""" + +VOLUME_TRANSIENT_STATUSES: List[VolumeStatus] = [ + VolumeStatus.CREATING, + VolumeStatus.DELETING, + VolumeStatus.RESIZING, + VolumeStatus.SNAPSHOTTING, +] +""" +Lists transient statutes of the enum :class:`VolumeStatus `. +""" diff --git a/scaleway/scaleway/block/v1alpha1/marshalling.py b/scaleway/scaleway/block/v1alpha1/marshalling.py new file mode 100644 index 000000000..4b10d6cf3 --- /dev/null +++ b/scaleway/scaleway/block/v1alpha1/marshalling.py @@ -0,0 +1,462 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + unmarshal_Money, +) +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from dateutil import parser +from .types import ( + CreateVolumeRequestFromEmpty, + CreateVolumeRequestFromSnapshot, + ListSnapshotsResponse, + ListVolumeTypesResponse, + ListVolumesResponse, + Reference, + Snapshot, + SnapshotParentVolume, + SnapshotSummary, + Volume, + VolumeSpecifications, + VolumeType, + CreateVolumeRequest, + UpdateVolumeRequest, + CreateSnapshotRequest, + UpdateSnapshotRequest, +) + + +def unmarshal_Reference(data: Any) -> Reference: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Reference' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("product_resource_id", None) + args["product_resource_id"] = field + + field = data.get("product_resource_type", None) + args["product_resource_type"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("type", None) + args["type_"] = field + + return Reference(**args) + + +def unmarshal_SnapshotParentVolume(data: Any) -> SnapshotParentVolume: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'SnapshotParentVolume' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("type", None) + args["type_"] = field + + return SnapshotParentVolume(**args) + + +def unmarshal_VolumeSpecifications(data: Any) -> VolumeSpecifications: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'VolumeSpecifications' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("class", None) + args["class_"] = field + + field = data.get("perf_iops", None) + args["perf_iops"] = field + + return VolumeSpecifications(**args) + + +def unmarshal_SnapshotSummary(data: Any) -> SnapshotSummary: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'SnapshotSummary' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("class", None) + args["class_"] = field + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("parent_volume", None) + args["parent_volume"] = ( + unmarshal_SnapshotParentVolume(field) if field is not None else None + ) + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("size", None) + args["size"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("tags", None) + args["tags"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("zone", None) + args["zone"] = field + + return SnapshotSummary(**args) + + +def unmarshal_Volume(data: Any) -> Volume: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Volume' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("parent_snapshot_id", None) + args["parent_snapshot_id"] = field + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("references", None) + args["references"] = ( + [unmarshal_Reference(v) for v in field] if field is not None else None + ) + + field = data.get("size", None) + args["size"] = field + + field = data.get("specs", None) + args["specs"] = unmarshal_VolumeSpecifications(field) if field is not None else None + + field = data.get("status", None) + args["status"] = field + + field = data.get("tags", None) + args["tags"] = field + + field = data.get("type", None) + args["type_"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("zone", None) + args["zone"] = field + + return Volume(**args) + + +def unmarshal_VolumeType(data: Any) -> VolumeType: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'VolumeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pricing", None) + args["pricing"] = unmarshal_Money(field) if field is not None else None + + field = data.get("snapshot_pricing", None) + args["snapshot_pricing"] = unmarshal_Money(field) if field is not None else None + + field = data.get("specs", None) + args["specs"] = unmarshal_VolumeSpecifications(field) if field is not None else None + + field = data.get("type", None) + args["type_"] = field + + return VolumeType(**args) + + +def unmarshal_ListSnapshotsResponse(data: Any) -> ListSnapshotsResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("snapshots", None) + args["snapshots"] = ( + [unmarshal_SnapshotSummary(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + args["total_count"] = field + + return ListSnapshotsResponse(**args) + + +def unmarshal_ListVolumeTypesResponse(data: Any) -> ListVolumeTypesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListVolumeTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("volume_types", None) + args["volume_types"] = ( + [unmarshal_VolumeType(v) for v in field] if field is not None else None + ) + + return ListVolumeTypesResponse(**args) + + +def unmarshal_ListVolumesResponse(data: Any) -> ListVolumesResponse: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'ListVolumesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + args["total_count"] = field + + field = data.get("volumes", None) + args["volumes"] = ( + [unmarshal_Volume(v) for v in field] if field is not None else None + ) + + return ListVolumesResponse(**args) + + +def unmarshal_Snapshot(data: Any) -> Snapshot: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'Snapshot' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("class", None) + args["class_"] = field + + field = data.get("created_at", None) + args["created_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("id", None) + args["id"] = field + + field = data.get("name", None) + args["name"] = field + + field = data.get("parent_volume", None) + args["parent_volume"] = ( + unmarshal_SnapshotParentVolume(field) if field is not None else None + ) + + field = data.get("project_id", None) + args["project_id"] = field + + field = data.get("references", None) + args["references"] = ( + [unmarshal_Reference(v) for v in field] if field is not None else None + ) + + field = data.get("size", None) + args["size"] = field + + field = data.get("status", None) + args["status"] = field + + field = data.get("tags", None) + args["tags"] = field + + field = data.get("updated_at", None) + args["updated_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("zone", None) + args["zone"] = field + + return Snapshot(**args) + + +def marshal_CreateVolumeRequestFromEmpty( + request: CreateVolumeRequestFromEmpty, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.size is not None: + output["size"] = request.size + + return output + + +def marshal_CreateVolumeRequestFromSnapshot( + request: CreateVolumeRequestFromSnapshot, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.size is not None: + output["size"] = request.size + + if request.snapshot_id is not None: + output["snapshot_id"] = request.snapshot_id + + return output + + +def marshal_CreateSnapshotRequest( + request: CreateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.volume_id is not None: + output["volume_id"] = request.volume_id + + return output + + +def marshal_CreateVolumeRequest( + request: CreateVolumeRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + "from_empty", + marshal_CreateVolumeRequestFromEmpty(request.from_empty, defaults) + if request.from_empty is not None + else None, + ), + OneOfPossibility( + "from_snapshot", + marshal_CreateVolumeRequestFromSnapshot( + request.from_snapshot, defaults + ) + if request.from_snapshot is not None + else None, + ), + ] + ), + ) + output.update( + resolve_one_of( + [ + OneOfPossibility( + "perf_iops", + request.perf_iops if request.perf_iops is not None else None, + ), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateSnapshotRequest( + request: UpdateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateVolumeRequest( + request: UpdateVolumeRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.perf_iops is not None: + output["perf_iops"] = request.perf_iops + + if request.size is not None: + output["size"] = request.size + + if request.tags is not None: + output["tags"] = request.tags + + return output diff --git a/scaleway/scaleway/block/v1alpha1/types.py b/scaleway/scaleway/block/v1alpha1/types.py new file mode 100644 index 000000000..7c68a2084 --- /dev/null +++ b/scaleway/scaleway/block/v1alpha1/types.py @@ -0,0 +1,770 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Money, + Zone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class ListSnapshotsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListVolumesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ReferenceStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + ATTACHING = "attaching" + ATTACHED = "attached" + DETACHING = "detaching" + DETACHED = "detached" + SNAPSHOTTING = "snapshotting" + ERROR = "error" + + def __str__(self) -> str: + return str(self.value) + + +class ReferenceType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + LINK = "link" + EXCLUSIVE = "exclusive" + READ_ONLY = "read_only" + + def __str__(self) -> str: + return str(self.value) + + +class SnapshotStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + AVAILABLE = "available" + ERROR = "error" + DELETING = "deleting" + DELETED = "deleted" + IN_USE = "in_use" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class StorageClass(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STORAGE_CLASS = "unknown_storage_class" + UNSPECIFIED = "unspecified" + BSSD = "bssd" + SBS = "sbs" + + def __str__(self) -> str: + return str(self.value) + + +class VolumeStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + AVAILABLE = "available" + IN_USE = "in_use" + DELETING = "deleting" + DELETED = "deleted" + RESIZING = "resizing" + ERROR = "error" + SNAPSHOTTING = "snapshotting" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class CreateVolumeRequestFromEmpty: + """ + Create volume request. from empty. + """ + + size: int + """ + Volume size in bytes, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the minimum and maximum allowed size. + """ + + +@dataclass +class CreateVolumeRequestFromSnapshot: + """ + Create volume request. from snapshot. + """ + + size: Optional[int] + """ + Volume size in bytes, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the allowed minimum and maximum allowed size. + Size is optional and is used only if a resize of the volume is requested, otherwise original snapshot size will be used. + """ + + snapshot_id: str + """ + Source snapshot from which create a volume. + """ + + +@dataclass +class ListSnapshotsResponse: + """ + List snapshots response. + """ + + snapshots: List[SnapshotSummary] + """ + Paginated returned list of snapshots. + """ + + total_count: int + """ + Total number of snpashots in the project. + """ + + +@dataclass +class ListVolumeTypesResponse: + """ + List volume types response. + """ + + volume_types: List[VolumeType] + """ + Paginated returned list of volume-types. + """ + + total_count: int + """ + Total number of volume-types currently available in stock. + """ + + +@dataclass +class ListVolumesResponse: + """ + List volumes response. + """ + + volumes: List[Volume] + """ + Paginated returned list of volumes. + """ + + total_count: int + """ + Total number of volumes in the project. + """ + + +@dataclass +class Reference: + """ + Reference. + """ + + id: str + """ + UUID of the reference. + """ + + product_resource_type: str + """ + Type of the resoruce the reference is associated (else snapshot or volume). + """ + + product_resource_id: str + """ + UUID of the volume or the snapshot it refers to (according to the product_resource_type). + """ + + created_at: Optional[datetime] + """ + Creation date of the reference. + """ + + type_: ReferenceType + """ + Type of the reference (link, exclusive, read_only). + """ + + status: ReferenceStatus + """ + Status of the reference (attaching, attached, detaching). + """ + + +@dataclass +class Snapshot: + """ + Snapshot. + """ + + id: str + """ + UUID of the snapshot. + """ + + name: str + """ + Name of the snapshot. + """ + + parent_volume: Optional[SnapshotParentVolume] + """ + Informations about the parent volume. + If the parent volume has been deleted, value is null. + """ + + size: int + """ + Size in bytes of the snapshot. + """ + + project_id: str + """ + UUID of the project the snapshot belongs to. + """ + + created_at: Optional[datetime] + """ + Creation date of the snapshot. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the properties of a snapshot. + """ + + references: List[Reference] + """ + List of the references to the snapshot. + """ + + status: SnapshotStatus + """ + Current status of the snapshot (available, in_use, ...). + """ + + tags: List[str] + """ + List of tags assigned to the volume. + """ + + zone: Zone + """ + Snapshot zone. + """ + + class_: StorageClass + """ + Storage class of the snapshot. + """ + + +@dataclass +class SnapshotParentVolume: + """ + Snapshot. parent volume. + """ + + id: str + """ + Volume ID on which the snapshot is based. + """ + + name: str + """ + Name of the parent volume from which the snapshot has been taken. + """ + + type_: str + """ + Volume type of the parent volume from which the snapshot has been taken. + """ + + status: VolumeStatus + """ + Current status the parent volume from which the snapshot has been taken. + """ + + +@dataclass +class SnapshotSummary: + """ + Snapshot summary. + """ + + id: str + """ + UUID of the snapshot. + """ + + name: str + """ + Name of the snapshot. + """ + + parent_volume: Optional[SnapshotParentVolume] + """ + Information about the parent volume. + If the parent volume has been deleted, value is null. + """ + + size: int + """ + Size in bytes of the snapshot. + """ + + project_id: str + """ + UUID of the project the snapshot belongs to. + """ + + created_at: Optional[datetime] + """ + Creation date of the snapshot. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the properties of a snapshot. + """ + + status: SnapshotStatus + """ + Current status of the snapshot (available, in_use, ...). + """ + + tags: List[str] + """ + List of tags assigned to the volume. + """ + + zone: Zone + """ + Snapshot zone. + """ + + class_: StorageClass + """ + Storage class of the snapshot. + """ + + +@dataclass +class Volume: + """ + Volume. + """ + + id: str + """ + UUID of the volume. + """ + + name: str + """ + Name of the volume. + """ + + type_: str + """ + Type of the volume. + """ + + size: int + """ + Volume size in bytes. + """ + + project_id: str + """ + UUID of the project the volume belongs to. + """ + + created_at: Optional[datetime] + """ + Creation date of the volume. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the properties of a volume. + """ + + references: List[Reference] + """ + List of the references to the volume. + """ + + parent_snapshot_id: Optional[str] + """ + When a volume is created from a snapshot, is the UUID of the snapshot from which the volume has been created. + """ + + status: VolumeStatus + """ + Current status of the volume (available, in_use, ...). + """ + + tags: List[str] + """ + List of tags assigned to the volume. + """ + + zone: Zone + """ + Volume zone. + """ + + specs: Optional[VolumeSpecifications] + """ + Volume specifications of the volume. + """ + + +@dataclass +class VolumeSpecifications: + """ + Volume specifications. + """ + + perf_iops: Optional[int] + """ + The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + """ + + class_: StorageClass + """ + The storage class of the volume. + """ + + +@dataclass +class VolumeType: + """ + Volume type. + """ + + type_: str + """ + Internal type of the volume. + """ + + pricing: Optional[Money] + """ + Price of the volume billed in GB/hour. + """ + + snapshot_pricing: Optional[Money] + """ + Price of the snapshot billed in GB/hour. + """ + + specs: Optional[VolumeSpecifications] + """ + Volume specifications of the volume type. + """ + + +@dataclass +class ListVolumeTypesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + +@dataclass +class ListVolumesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListVolumesRequestOrderBy] + """ + Sort order of the returned volumes. + """ + + project_id: Optional[str] + """ + Only list volumes of this project ID. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + name: Optional[str] + """ + Filter the return volumes by their names. + """ + + product_resource_id: Optional[str] + """ + Filter by a Product Resource Id linked to this volume (such as an Instance Server Id). + """ + + +@dataclass +class CreateVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + name: str + """ + Name of the volume you want to create. + """ + + perf_iops: Optional[int] + """ + The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + + One-of ('requirements'): at most one of 'perf_iops' could be set. + """ + + project_id: Optional[str] + """ + UUID of the project the volume belongs to. + """ + + from_empty: Optional[CreateVolumeRequestFromEmpty] + """ + Create a new and empty volume. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + """ + + from_snapshot: Optional[CreateVolumeRequestFromSnapshot] + """ + Create a volume from an existing snapshot. + + One-of ('from_'): at most one of 'from_empty', 'from_snapshot' could be set. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the volume. + """ + + +@dataclass +class GetVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume you want to get. + """ + + +@dataclass +class DeleteVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume. + """ + + +@dataclass +class UpdateVolumeRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume. + """ + + name: Optional[str] + """ + When defined, is the new name of the volume. + """ + + size: Optional[int] + """ + Optional field for growing a volume (size must be equal or larger than the current one). + Size in bytes of the volume, with a granularity of 1 GB (10^9 bytes). + Must be compliant with the minimum and maximum allowed size. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the volume. + """ + + perf_iops: Optional[int] + """ + The maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). + The selected value must be available on the Storage Class where is currently located the volume. + """ + + +@dataclass +class ListSnapshotsRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListSnapshotsRequestOrderBy] + """ + Sort order of the returned snapshots. + """ + + project_id: Optional[str] + """ + Only list snapshots of this project ID. + """ + + page: Optional[int] + """ + Positive integer to choose the page to return. + """ + + page_size: Optional[int] + """ + Positive integer lower or equal to 100 to select the number of items to return. + """ + + volume_id: Optional[str] + """ + Filter the return snapshots by the volume it belongs to. + """ + + name: Optional[str] + """ + Filter the return snapshots by their names. + """ + + +@dataclass +class GetSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + snapshot_id: str + """ + UUID of the snapshot. + """ + + +@dataclass +class CreateSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + volume_id: str + """ + UUID of the volume from which creates a snpashot. + """ + + name: str + """ + Name of the snapshot. + """ + + project_id: Optional[str] + """ + UUID of the project the volume and the snapshot belong to. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the snapshot. + """ + + +@dataclass +class DeleteSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + snapshot_id: str + """ + UUID of the snapshot. + """ + + +@dataclass +class UpdateSnapshotRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + snapshot_id: str + """ + UUID of the snapshot. + """ + + name: Optional[str] + """ + When defined, is the name of the snapshot. + """ + + tags: Optional[List[str]] + """ + List of tags assigned to the snapshot. + """