diff --git a/scaleway-async/scaleway_async/block/v1alpha1/api.py b/scaleway-async/scaleway_async/block/v1alpha1/api.py index 3b66bb20..82df9568 100644 --- a/scaleway-async/scaleway_async/block/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/block/v1alpha1/api.py @@ -9,6 +9,7 @@ ) from scaleway_core.utils import ( WaitForOptions, + random_name, validate_path_param, fetch_all_pages_async, wait_for_resource_async, @@ -231,8 +232,8 @@ async def list_volumes_all( async def create_volume( self, *, - name: str, zone: Optional[Zone] = None, + name: Optional[str] = None, perf_iops: Optional[int] = None, project_id: Optional[str] = None, from_empty: Optional[CreateVolumeRequestFromEmpty] = None, @@ -243,8 +244,8 @@ async def create_volume( Create a volume. To create a new volume from scratch, you must specify `from_empty` and the `size`. To create a volume from an existing snapshot, specify `from_snapshot` and the `snapshot_id` in the request payload instead, size is optional and can be specified if you need to extend the original size. The volume will take on the same volume class and underlying IOPS limitations as the original snapshot. - :param name: Name of the volume. :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name of the volume. :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. @@ -258,9 +259,7 @@ async def create_volume( Usage: :: - result = await api.create_volume( - name="example", - ) + result = await api.create_volume() """ param_zone = validate_path_param("zone", zone or self.client.default_zone) @@ -270,8 +269,8 @@ async def create_volume( f"/block/v1alpha1/zones/{param_zone}/volumes", body=marshal_CreateVolumeRequest( CreateVolumeRequest( - name=name, zone=zone, + name=name or random_name(prefix="vol"), project_id=project_id, tags=tags, from_empty=from_empty, @@ -610,8 +609,8 @@ async def create_snapshot( self, *, volume_id: str, - name: str, zone: Optional[Zone] = None, + name: Optional[str] = None, project_id: Optional[str] = None, tags: Optional[List[str]] = None, ) -> Snapshot: @@ -620,8 +619,8 @@ async def create_snapshot( 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 volume_id: UUID of the volume to snapshot. - :param name: Name of the snapshot. :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name of the snapshot. :param project_id: UUID of the project to which the volume and the snapshot belong. :param tags: List of tags assigned to the snapshot. :return: :class:`Snapshot ` @@ -631,7 +630,6 @@ async def create_snapshot( result = await api.create_snapshot( volume_id="example", - name="example", ) """ @@ -643,8 +641,8 @@ async def create_snapshot( body=marshal_CreateSnapshotRequest( CreateSnapshotRequest( volume_id=volume_id, - name=name, zone=zone, + name=name or random_name(prefix="snp"), project_id=project_id, tags=tags, ), diff --git a/scaleway-async/scaleway_async/block/v1alpha1/types.py b/scaleway-async/scaleway_async/block/v1alpha1/types.py index 44fc6cf7..b31bee48 100644 --- a/scaleway-async/scaleway_async/block/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/block/v1alpha1/types.py @@ -358,14 +358,14 @@ class CreateSnapshotRequest: UUID of the volume to snapshot. """ - name: str + zone: Optional[Zone] """ - Name of the snapshot. + Zone to target. If none is passed will use default zone from the config. """ - zone: Optional[Zone] + name: Optional[str] """ - Zone to target. If none is passed will use default zone from the config. + Name of the snapshot. """ project_id: Optional[str] @@ -381,14 +381,14 @@ class CreateSnapshotRequest: @dataclass class CreateVolumeRequest: - name: str + zone: Optional[Zone] """ - Name of the volume. + Zone to target. If none is passed will use default zone from the config. """ - zone: Optional[Zone] + name: Optional[str] """ - Zone to target. If none is passed will use default zone from the config. + Name of the volume. """ project_id: Optional[str] diff --git a/scaleway/scaleway/block/v1alpha1/api.py b/scaleway/scaleway/block/v1alpha1/api.py index 7d953dda..1fe86393 100644 --- a/scaleway/scaleway/block/v1alpha1/api.py +++ b/scaleway/scaleway/block/v1alpha1/api.py @@ -9,6 +9,7 @@ ) from scaleway_core.utils import ( WaitForOptions, + random_name, validate_path_param, fetch_all_pages, wait_for_resource, @@ -231,8 +232,8 @@ def list_volumes_all( def create_volume( self, *, - name: str, zone: Optional[Zone] = None, + name: Optional[str] = None, perf_iops: Optional[int] = None, project_id: Optional[str] = None, from_empty: Optional[CreateVolumeRequestFromEmpty] = None, @@ -243,8 +244,8 @@ def create_volume( Create a volume. To create a new volume from scratch, you must specify `from_empty` and the `size`. To create a volume from an existing snapshot, specify `from_snapshot` and the `snapshot_id` in the request payload instead, size is optional and can be specified if you need to extend the original size. The volume will take on the same volume class and underlying IOPS limitations as the original snapshot. - :param name: Name of the volume. :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name of the volume. :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. @@ -258,9 +259,7 @@ def create_volume( Usage: :: - result = api.create_volume( - name="example", - ) + result = api.create_volume() """ param_zone = validate_path_param("zone", zone or self.client.default_zone) @@ -270,8 +269,8 @@ def create_volume( f"/block/v1alpha1/zones/{param_zone}/volumes", body=marshal_CreateVolumeRequest( CreateVolumeRequest( - name=name, zone=zone, + name=name or random_name(prefix="vol"), project_id=project_id, tags=tags, from_empty=from_empty, @@ -608,8 +607,8 @@ def create_snapshot( self, *, volume_id: str, - name: str, zone: Optional[Zone] = None, + name: Optional[str] = None, project_id: Optional[str] = None, tags: Optional[List[str]] = None, ) -> Snapshot: @@ -618,8 +617,8 @@ def create_snapshot( 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 volume_id: UUID of the volume to snapshot. - :param name: Name of the snapshot. :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name of the snapshot. :param project_id: UUID of the project to which the volume and the snapshot belong. :param tags: List of tags assigned to the snapshot. :return: :class:`Snapshot ` @@ -629,7 +628,6 @@ def create_snapshot( result = api.create_snapshot( volume_id="example", - name="example", ) """ @@ -641,8 +639,8 @@ def create_snapshot( body=marshal_CreateSnapshotRequest( CreateSnapshotRequest( volume_id=volume_id, - name=name, zone=zone, + name=name or random_name(prefix="snp"), project_id=project_id, tags=tags, ), diff --git a/scaleway/scaleway/block/v1alpha1/types.py b/scaleway/scaleway/block/v1alpha1/types.py index 44fc6cf7..b31bee48 100644 --- a/scaleway/scaleway/block/v1alpha1/types.py +++ b/scaleway/scaleway/block/v1alpha1/types.py @@ -358,14 +358,14 @@ class CreateSnapshotRequest: UUID of the volume to snapshot. """ - name: str + zone: Optional[Zone] """ - Name of the snapshot. + Zone to target. If none is passed will use default zone from the config. """ - zone: Optional[Zone] + name: Optional[str] """ - Zone to target. If none is passed will use default zone from the config. + Name of the snapshot. """ project_id: Optional[str] @@ -381,14 +381,14 @@ class CreateSnapshotRequest: @dataclass class CreateVolumeRequest: - name: str + zone: Optional[Zone] """ - Name of the volume. + Zone to target. If none is passed will use default zone from the config. """ - zone: Optional[Zone] + name: Optional[str] """ - Zone to target. If none is passed will use default zone from the config. + Name of the volume. """ project_id: Optional[str]