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
4 changes: 4 additions & 0 deletions scaleway-async/scaleway_async/instance/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
from .types import GetSecurityGroupResponse
from .types import GetSecurityGroupRuleRequest
from .types import GetSecurityGroupRuleResponse
from .types import GetServerCompatibleTypesRequest
from .types import GetServerRequest
from .types import GetServerResponse
from .types import GetServerTypesAvailabilityRequest
Expand Down Expand Up @@ -167,6 +168,7 @@
from .types import PlanBlockMigrationRequest
from .types import ServerActionRequest
from .types import ServerActionResponse
from .types import ServerCompatibleTypes
from .types import SetImageRequest
from .types import SetPlacementGroupRequest
from .types import SetPlacementGroupResponse
Expand Down Expand Up @@ -324,6 +326,7 @@
"GetSecurityGroupResponse",
"GetSecurityGroupRuleRequest",
"GetSecurityGroupRuleResponse",
"GetServerCompatibleTypesRequest",
"GetServerRequest",
"GetServerResponse",
"GetServerTypesAvailabilityRequest",
Expand Down Expand Up @@ -363,6 +366,7 @@
"PlanBlockMigrationRequest",
"ServerActionRequest",
"ServerActionResponse",
"ServerCompatibleTypes",
"SetImageRequest",
"SetPlacementGroupRequest",
"SetPlacementGroupResponse",
Expand Down
39 changes: 39 additions & 0 deletions scaleway-async/scaleway_async/instance/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
ServerActionRequest,
ServerActionRequestVolumeBackupTemplate,
ServerActionResponse,
ServerCompatibleTypes,
ServerIp,
ServerIpv6,
ServerLocation,
Expand Down Expand Up @@ -189,6 +190,7 @@
unmarshal_ListVolumesTypesResponse,
unmarshal_MigrationPlan,
unmarshal_ServerActionResponse,
unmarshal_ServerCompatibleTypes,
unmarshal_SetPlacementGroupResponse,
unmarshal_SetPlacementGroupServersResponse,
unmarshal_SetSecurityGroupRulesResponse,
Expand Down Expand Up @@ -1036,6 +1038,43 @@ async def delete_server_user_data(

self._throw_on_error(res)

async def get_server_compatible_types(
self,
*,
server_id: str,
zone: Optional[ScwZone] = None,
) -> ServerCompatibleTypes:
"""
Get Instance compatible types.
Get compatible commercial types that can be used to update the Instance. The compatibility of an Instance offer is based on:
* the CPU architecture
* the OS type
* the required l_ssd storage size
* the required scratch storage size
If the specified Instance offer is flagged as end of service, the best compatible offer is the first returned.
:param server_id: UUID of the Instance you want to get.
:param zone: Zone to target. If none is passed will use default zone from the config.
:return: :class:`ServerCompatibleTypes <ServerCompatibleTypes>`

Usage:
::

result = await api.get_server_compatible_types(
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(
"GET",
f"/instance/v1/zones/{param_zone}/servers/{param_server_id}/compatible-types",
)

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

async def attach_server_volume(
self,
*,
Expand Down
20 changes: 20 additions & 0 deletions scaleway-async/scaleway_async/instance/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
ListVolumesTypesResponse,
MigrationPlan,
ServerActionResponse,
ServerCompatibleTypes,
SetPlacementGroupResponse,
SetPlacementGroupServersResponse,
SetSecurityGroupRulesResponse,
Expand Down Expand Up @@ -2151,6 +2152,10 @@ def unmarshal_ServerType(data: Any) -> ServerType:
if field is not None:
args["baremetal"] = field

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

field = data.get("per_volume_constraint", None)
if field is not None:
args["per_volume_constraint"] = unmarshal_ServerTypeVolumeConstraintsByType(
Expand Down Expand Up @@ -2391,6 +2396,21 @@ def unmarshal_ServerActionResponse(data: Any) -> ServerActionResponse:
return ServerActionResponse(**args)


def unmarshal_ServerCompatibleTypes(data: Any) -> ServerCompatibleTypes:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'ServerCompatibleTypes' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

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

return ServerCompatibleTypes(**args)


def unmarshal_SetPlacementGroupResponse(data: Any) -> SetPlacementGroupResponse:
if not isinstance(data, dict):
raise TypeError(
Expand Down
26 changes: 26 additions & 0 deletions scaleway-async/scaleway_async/instance/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,11 @@ class ServerType:
True if it is a baremetal Instance.
"""

end_of_service: bool
"""
True if this Instance type has reached end of service.
"""

per_volume_constraint: Optional[ServerTypeVolumeConstraintsByType]
"""
Additional volume constraints.
Expand Down Expand Up @@ -2277,6 +2282,19 @@ class GetSecurityGroupRuleResponse:
rule: Optional[SecurityGroupRule]


@dataclass
class GetServerCompatibleTypesRequest:
server_id: str
"""
UUID of the Instance you want to get.
"""

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


@dataclass
class GetServerRequest:
server_id: str
Expand Down Expand Up @@ -3005,6 +3023,14 @@ class ServerActionResponse:
task: Optional[Task]


@dataclass
class ServerCompatibleTypes:
compatible_types: List[str]
"""
Instance compatible types.
"""


@dataclass
class SetImageRequest:
zone: Optional[ScwZone]
Expand Down
4 changes: 4 additions & 0 deletions scaleway/scaleway/instance/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
from .types import GetSecurityGroupResponse
from .types import GetSecurityGroupRuleRequest
from .types import GetSecurityGroupRuleResponse
from .types import GetServerCompatibleTypesRequest
from .types import GetServerRequest
from .types import GetServerResponse
from .types import GetServerTypesAvailabilityRequest
Expand Down Expand Up @@ -167,6 +168,7 @@
from .types import PlanBlockMigrationRequest
from .types import ServerActionRequest
from .types import ServerActionResponse
from .types import ServerCompatibleTypes
from .types import SetImageRequest
from .types import SetPlacementGroupRequest
from .types import SetPlacementGroupResponse
Expand Down Expand Up @@ -324,6 +326,7 @@
"GetSecurityGroupResponse",
"GetSecurityGroupRuleRequest",
"GetSecurityGroupRuleResponse",
"GetServerCompatibleTypesRequest",
"GetServerRequest",
"GetServerResponse",
"GetServerTypesAvailabilityRequest",
Expand Down Expand Up @@ -363,6 +366,7 @@
"PlanBlockMigrationRequest",
"ServerActionRequest",
"ServerActionResponse",
"ServerCompatibleTypes",
"SetImageRequest",
"SetPlacementGroupRequest",
"SetPlacementGroupResponse",
Expand Down
39 changes: 39 additions & 0 deletions scaleway/scaleway/instance/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
ServerActionRequest,
ServerActionRequestVolumeBackupTemplate,
ServerActionResponse,
ServerCompatibleTypes,
ServerIp,
ServerIpv6,
ServerLocation,
Expand Down Expand Up @@ -189,6 +190,7 @@
unmarshal_ListVolumesTypesResponse,
unmarshal_MigrationPlan,
unmarshal_ServerActionResponse,
unmarshal_ServerCompatibleTypes,
unmarshal_SetPlacementGroupResponse,
unmarshal_SetPlacementGroupServersResponse,
unmarshal_SetSecurityGroupRulesResponse,
Expand Down Expand Up @@ -1036,6 +1038,43 @@ def delete_server_user_data(

self._throw_on_error(res)

def get_server_compatible_types(
self,
*,
server_id: str,
zone: Optional[ScwZone] = None,
) -> ServerCompatibleTypes:
"""
Get Instance compatible types.
Get compatible commercial types that can be used to update the Instance. The compatibility of an Instance offer is based on:
* the CPU architecture
* the OS type
* the required l_ssd storage size
* the required scratch storage size
If the specified Instance offer is flagged as end of service, the best compatible offer is the first returned.
:param server_id: UUID of the Instance you want to get.
:param zone: Zone to target. If none is passed will use default zone from the config.
:return: :class:`ServerCompatibleTypes <ServerCompatibleTypes>`
Usage:
::
result = api.get_server_compatible_types(
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(
"GET",
f"/instance/v1/zones/{param_zone}/servers/{param_server_id}/compatible-types",
)

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

def attach_server_volume(
self,
*,
Expand Down
20 changes: 20 additions & 0 deletions scaleway/scaleway/instance/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
ListVolumesTypesResponse,
MigrationPlan,
ServerActionResponse,
ServerCompatibleTypes,
SetPlacementGroupResponse,
SetPlacementGroupServersResponse,
SetSecurityGroupRulesResponse,
Expand Down Expand Up @@ -2151,6 +2152,10 @@ def unmarshal_ServerType(data: Any) -> ServerType:
if field is not None:
args["baremetal"] = field

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

field = data.get("per_volume_constraint", None)
if field is not None:
args["per_volume_constraint"] = unmarshal_ServerTypeVolumeConstraintsByType(
Expand Down Expand Up @@ -2391,6 +2396,21 @@ def unmarshal_ServerActionResponse(data: Any) -> ServerActionResponse:
return ServerActionResponse(**args)


def unmarshal_ServerCompatibleTypes(data: Any) -> ServerCompatibleTypes:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'ServerCompatibleTypes' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

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

return ServerCompatibleTypes(**args)


def unmarshal_SetPlacementGroupResponse(data: Any) -> SetPlacementGroupResponse:
if not isinstance(data, dict):
raise TypeError(
Expand Down
26 changes: 26 additions & 0 deletions scaleway/scaleway/instance/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,11 @@ class ServerType:
True if it is a baremetal Instance.
"""

end_of_service: bool
"""
True if this Instance type has reached end of service.
"""

per_volume_constraint: Optional[ServerTypeVolumeConstraintsByType]
"""
Additional volume constraints.
Expand Down Expand Up @@ -2277,6 +2282,19 @@ class GetSecurityGroupRuleResponse:
rule: Optional[SecurityGroupRule]


@dataclass
class GetServerCompatibleTypesRequest:
server_id: str
"""
UUID of the Instance you want to get.
"""

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


@dataclass
class GetServerRequest:
server_id: str
Expand Down Expand Up @@ -3005,6 +3023,14 @@ class ServerActionResponse:
task: Optional[Task]


@dataclass
class ServerCompatibleTypes:
compatible_types: List[str]
"""
Instance compatible types.
"""


@dataclass
class SetImageRequest:
zone: Optional[ScwZone]
Expand Down