Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(block): improve arguments configuration #753

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions scaleway-async/scaleway_async/block/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
)
from scaleway_core.utils import (
WaitForOptions,
random_name,
validate_path_param,
fetch_all_pages_async,
wait_for_resource_async,
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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 <Snapshot>`
Expand All @@ -631,7 +630,6 @@ async def create_snapshot(

result = await api.create_snapshot(
volume_id="example",
name="example",
)
"""

Expand All @@ -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,
),
Expand Down
16 changes: 8 additions & 8 deletions scaleway-async/scaleway_async/block/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
18 changes: 8 additions & 10 deletions scaleway/scaleway/block/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
)
from scaleway_core.utils import (
WaitForOptions,
random_name,
validate_path_param,
fetch_all_pages,
wait_for_resource,
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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 <Snapshot>`
Expand All @@ -629,7 +628,6 @@ def create_snapshot(

result = api.create_snapshot(
volume_id="example",
name="example",
)
"""

Expand All @@ -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,
),
Expand Down
16 changes: 8 additions & 8 deletions scaleway/scaleway/block/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down