Skip to content
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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
from .types import ListServersResponse
from .types import ListSettingsRequest
from .types import ListSettingsResponse
from .types import MigrateServerToMonthlyOfferRequest
from .types import PrivateNetworkApiAddServerPrivateNetworkRequest
from .types import PrivateNetworkApiDeleteServerPrivateNetworkRequest
from .types import PrivateNetworkApiListServerPrivateNetworksRequest
Expand Down Expand Up @@ -180,6 +181,7 @@
"ListServersResponse",
"ListSettingsRequest",
"ListSettingsResponse",
"MigrateServerToMonthlyOfferRequest",
"PrivateNetworkApiAddServerPrivateNetworkRequest",
"PrivateNetworkApiDeleteServerPrivateNetworkRequest",
"PrivateNetworkApiListServerPrivateNetworksRequest",
Expand Down
32 changes: 32 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,38 @@ async def delete_option_server(
self._throw_on_error(res)
return unmarshal_Server(res.json())

async def migrate_server_to_monthly_offer(
self,
*,
server_id: str,
zone: Optional[ScwZone] = None,
) -> Server:
"""
Migrate server offer.
Migrate server with hourly offer to monthly offer.
:param server_id: ID of the server.
:param zone: Zone to target. If none is passed will use default zone from the config.
:return: :class:`Server <Server>`

Usage:
::

result = await api.migrate_server_to_monthly_offer(
server_id="example",
)
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
param_server_id = validate_path_param("server_id", server_id)

res = self._request(
"POST",
f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/migrate-offer-monthly",
)

self._throw_on_error(res)
return unmarshal_Server(res.json())

async def list_offers(
self,
*,
Expand Down
1 change: 1 addition & 0 deletions scaleway-async/scaleway_async/baremetal/v1/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ServerStatus.DELETING,
ServerStatus.ORDERED,
ServerStatus.RESETTING,
ServerStatus.MIGRATING,
]
"""
Lists transient statutes of the enum :class:`ServerStatus <ServerStatus>`.
Expand Down
6 changes: 6 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ def unmarshal_Offer(data: Any) -> Offer:
else:
args["fee"] = None

field = data.get("monthly_offer_id", None)
if field is not None:
args["monthly_offer_id"] = field
else:
args["monthly_offer_id"] = None

return Offer(**args)


Expand Down
19 changes: 19 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class ServerStatus(str, Enum, metaclass=StrEnumMeta):
OUT_OF_STOCK = "out_of_stock"
ORDERED = "ordered"
RESETTING = "resetting"
MIGRATING = "migrating"

def __str__(self) -> str:
return str(self.value)
Expand Down Expand Up @@ -824,6 +825,11 @@ class Offer:
One time fee invoiced by Scaleway for the setup and activation of the server.
"""

monthly_offer_id: Optional[str]
"""
Exist only for hourly offers, to migrate to the monthly offer.
"""


@dataclass
class Option:
Expand Down Expand Up @@ -1589,6 +1595,19 @@ class ListSettingsResponse:
"""


@dataclass
class MigrateServerToMonthlyOfferRequest:
server_id: str
"""
ID of the server.
"""

zone: Optional[ScwZone]
"""
Zone to target. If none is passed will use default zone from the config.
"""


@dataclass
class PrivateNetworkApiAddServerPrivateNetworkRequest:
server_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/baremetal/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
from .types import ListServersResponse
from .types import ListSettingsRequest
from .types import ListSettingsResponse
from .types import MigrateServerToMonthlyOfferRequest
from .types import PrivateNetworkApiAddServerPrivateNetworkRequest
from .types import PrivateNetworkApiDeleteServerPrivateNetworkRequest
from .types import PrivateNetworkApiListServerPrivateNetworksRequest
Expand Down Expand Up @@ -180,6 +181,7 @@
"ListServersResponse",
"ListSettingsRequest",
"ListSettingsResponse",
"MigrateServerToMonthlyOfferRequest",
"PrivateNetworkApiAddServerPrivateNetworkRequest",
"PrivateNetworkApiDeleteServerPrivateNetworkRequest",
"PrivateNetworkApiListServerPrivateNetworksRequest",
Expand Down
32 changes: 32 additions & 0 deletions scaleway/scaleway/baremetal/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,38 @@ def delete_option_server(
self._throw_on_error(res)
return unmarshal_Server(res.json())

def migrate_server_to_monthly_offer(
self,
*,
server_id: str,
zone: Optional[ScwZone] = None,
) -> Server:
"""
Migrate server offer.
Migrate server with hourly offer to monthly offer.
:param server_id: ID of the server.
:param zone: Zone to target. If none is passed will use default zone from the config.
:return: :class:`Server <Server>`

Usage:
::

result = api.migrate_server_to_monthly_offer(
server_id="example",
)
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
param_server_id = validate_path_param("server_id", server_id)

res = self._request(
"POST",
f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/migrate-offer-monthly",
)

self._throw_on_error(res)
return unmarshal_Server(res.json())

def list_offers(
self,
*,
Expand Down
1 change: 1 addition & 0 deletions scaleway/scaleway/baremetal/v1/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ServerStatus.DELETING,
ServerStatus.ORDERED,
ServerStatus.RESETTING,
ServerStatus.MIGRATING,
]
"""
Lists transient statutes of the enum :class:`ServerStatus <ServerStatus>`.
Expand Down
6 changes: 6 additions & 0 deletions scaleway/scaleway/baremetal/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ def unmarshal_Offer(data: Any) -> Offer:
else:
args["fee"] = None

field = data.get("monthly_offer_id", None)
if field is not None:
args["monthly_offer_id"] = field
else:
args["monthly_offer_id"] = None

return Offer(**args)


Expand Down
19 changes: 19 additions & 0 deletions scaleway/scaleway/baremetal/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class ServerStatus(str, Enum, metaclass=StrEnumMeta):
OUT_OF_STOCK = "out_of_stock"
ORDERED = "ordered"
RESETTING = "resetting"
MIGRATING = "migrating"

def __str__(self) -> str:
return str(self.value)
Expand Down Expand Up @@ -824,6 +825,11 @@ class Offer:
One time fee invoiced by Scaleway for the setup and activation of the server.
"""

monthly_offer_id: Optional[str]
"""
Exist only for hourly offers, to migrate to the monthly offer.
"""


@dataclass
class Option:
Expand Down Expand Up @@ -1589,6 +1595,19 @@ class ListSettingsResponse:
"""


@dataclass
class MigrateServerToMonthlyOfferRequest:
server_id: str
"""
ID of the server.
"""

zone: Optional[ScwZone]
"""
Zone to target. If none is passed will use default zone from the config.
"""


@dataclass
class PrivateNetworkApiAddServerPrivateNetworkRequest:
server_id: str
Expand Down