Skip to content
Open
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
36 changes: 24 additions & 12 deletions scaleway-async/scaleway_async/dedibox/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
unmarshal_ScwFile,
)
from scaleway_core.utils import (
OneOfPossibility,
WaitForOptions,
resolve_one_of,
validate_path_param,
fetch_all_pages_async,
wait_for_resource_async,
Expand Down Expand Up @@ -1735,31 +1737,33 @@ async def get_offer(
async def list_os(
self,
*,
server_id: int,
zone: Optional[ScwZone] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListOSRequestOrderBy] = None,
type_: Optional[OSType] = None,
server_id: Optional[int] = None,
project_id: Optional[str] = None,
offer_id: Optional[int] = None,
) -> ListOSResponse:
"""
List all available OS that can be install on a baremetal server.
:param server_id: Filter OS by compatible server ID.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param page: Page number.
:param page_size: Number of OS per page.
:param order_by: Order of the OS.
:param type_: Type of the OS.
:param server_id: Filter OS by compatible server ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:param project_id: Project ID.
:param offer_id: Filter OS by compatible offer ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:return: :class:`ListOSResponse <ListOSResponse>`

Usage:
::

result = await api.list_os(
server_id=1,
)
result = await api.list_os()
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
Expand All @@ -1772,8 +1776,13 @@ async def list_os(
"page": page,
"page_size": page_size or self.client.default_page_size,
"project_id": project_id or self.client.default_project_id,
"server_id": server_id,
"type": type_,
**resolve_one_of(
[
OneOfPossibility("offer_id", offer_id),
OneOfPossibility("server_id", server_id),
]
),
},
)

Expand All @@ -1783,45 +1792,48 @@ async def list_os(
async def list_os_all(
self,
*,
server_id: int,
zone: Optional[ScwZone] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListOSRequestOrderBy] = None,
type_: Optional[OSType] = None,
server_id: Optional[int] = None,
project_id: Optional[str] = None,
offer_id: Optional[int] = None,
) -> list[OS]:
"""
List all available OS that can be install on a baremetal server.
:param server_id: Filter OS by compatible server ID.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param page: Page number.
:param page_size: Number of OS per page.
:param order_by: Order of the OS.
:param type_: Type of the OS.
:param server_id: Filter OS by compatible server ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:param project_id: Project ID.
:param offer_id: Filter OS by compatible offer ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:return: :class:`list[OS] <list[OS]>`

Usage:
::

result = await api.list_os_all(
server_id=1,
)
result = await api.list_os_all()
"""

return await fetch_all_pages_async(
type=ListOSResponse,
key="os",
fetcher=self.list_os,
args={
"server_id": server_id,
"zone": zone,
"page": page,
"page_size": page_size,
"order_by": order_by,
"type_": type_,
"project_id": project_id,
"server_id": server_id,
"offer_id": offer_id,
},
)

Expand Down
9 changes: 4 additions & 5 deletions scaleway-async/scaleway_async/dedibox/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,11 +2943,6 @@ class ListIpsResponse:

@dataclass
class ListOSRequest:
server_id: int
"""
Filter OS by compatible server ID.
"""

zone: Optional[ScwZone] = None
"""
Zone to target. If none is passed will use default zone from the config.
Expand Down Expand Up @@ -2978,6 +2973,10 @@ class ListOSRequest:
Project ID.
"""

server_id: Optional[int] = 0

offer_id: Optional[int] = 0


@dataclass
class ListOSResponse:
Expand Down
36 changes: 24 additions & 12 deletions scaleway/scaleway/dedibox/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
unmarshal_ScwFile,
)
from scaleway_core.utils import (
OneOfPossibility,
WaitForOptions,
resolve_one_of,
validate_path_param,
fetch_all_pages,
wait_for_resource,
Expand Down Expand Up @@ -1731,31 +1733,33 @@ def get_offer(
def list_os(
self,
*,
server_id: int,
zone: Optional[ScwZone] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListOSRequestOrderBy] = None,
type_: Optional[OSType] = None,
server_id: Optional[int] = None,
project_id: Optional[str] = None,
offer_id: Optional[int] = None,
) -> ListOSResponse:
"""
List all available OS that can be install on a baremetal server.
:param server_id: Filter OS by compatible server ID.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param page: Page number.
:param page_size: Number of OS per page.
:param order_by: Order of the OS.
:param type_: Type of the OS.
:param server_id: Filter OS by compatible server ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:param project_id: Project ID.
:param offer_id: Filter OS by compatible offer ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:return: :class:`ListOSResponse <ListOSResponse>`

Usage:
::

result = api.list_os(
server_id=1,
)
result = api.list_os()
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
Expand All @@ -1768,8 +1772,13 @@ def list_os(
"page": page,
"page_size": page_size or self.client.default_page_size,
"project_id": project_id or self.client.default_project_id,
"server_id": server_id,
"type": type_,
**resolve_one_of(
[
OneOfPossibility("offer_id", offer_id),
OneOfPossibility("server_id", server_id),
]
),
},
)

Expand All @@ -1779,45 +1788,48 @@ def list_os(
def list_os_all(
self,
*,
server_id: int,
zone: Optional[ScwZone] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
order_by: Optional[ListOSRequestOrderBy] = None,
type_: Optional[OSType] = None,
server_id: Optional[int] = None,
project_id: Optional[str] = None,
offer_id: Optional[int] = None,
) -> list[OS]:
"""
List all available OS that can be install on a baremetal server.
:param server_id: Filter OS by compatible server ID.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param page: Page number.
:param page_size: Number of OS per page.
:param order_by: Order of the OS.
:param type_: Type of the OS.
:param server_id: Filter OS by compatible server ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:param project_id: Project ID.
:param offer_id: Filter OS by compatible offer ID.
One-Of ('offer'): at most one of 'server_id', 'offer_id' could be set.
:return: :class:`list[OS] <list[OS]>`

Usage:
::

result = api.list_os_all(
server_id=1,
)
result = api.list_os_all()
"""

return fetch_all_pages(
type=ListOSResponse,
key="os",
fetcher=self.list_os,
args={
"server_id": server_id,
"zone": zone,
"page": page,
"page_size": page_size,
"order_by": order_by,
"type_": type_,
"project_id": project_id,
"server_id": server_id,
"offer_id": offer_id,
},
)

Expand Down
9 changes: 4 additions & 5 deletions scaleway/scaleway/dedibox/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,11 +2943,6 @@ class ListIpsResponse:

@dataclass
class ListOSRequest:
server_id: int
"""
Filter OS by compatible server ID.
"""

zone: Optional[ScwZone] = None
"""
Zone to target. If none is passed will use default zone from the config.
Expand Down Expand Up @@ -2978,6 +2973,10 @@ class ListOSRequest:
Project ID.
"""

server_id: Optional[int] = 0

offer_id: Optional[int] = 0


@dataclass
class ListOSResponse:
Expand Down
Loading