Skip to content

Commit

Permalink
feat(apple_silicon): define management of server options (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Dec 24, 2024
1 parent d3f5fcd commit 2bdbb0d
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from .types import ConnectivityDiagnosticActionType
from .types import ConnectivityDiagnosticDiagnosticStatus
from .types import ListServersRequestOrderBy
from .types import ServerPrivateNetworkStatus
from .content import SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES
from .types import ServerStatus
from .content import SERVER_TRANSIENT_STATUSES
from .types import ServerTypeStock
Expand Down Expand Up @@ -39,6 +41,8 @@
"ConnectivityDiagnosticActionType",
"ConnectivityDiagnosticDiagnosticStatus",
"ListServersRequestOrderBy",
"ServerPrivateNetworkStatus",
"SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES",
"ServerStatus",
"SERVER_TRANSIENT_STATUSES",
"ServerTypeStock",
Expand Down
7 changes: 7 additions & 0 deletions scaleway-async/scaleway_async/applesilicon/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ async def create_server(
self,
*,
type_: str,
enable_vpc: bool,
zone: Optional[Zone] = None,
name: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -125,6 +126,7 @@ async def create_server(
Create a server.
Create a new server in the targeted zone, specifying its configuration including name and type.
:param type_: Create a server of the given type.
:param enable_vpc: Activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param name: Create a server with this given name.
:param project_id: Create a server in the given project ID.
Expand All @@ -136,6 +138,7 @@ async def create_server(
result = await api.create_server(
type="example",
enable_vpc=False,
)
"""

Expand All @@ -147,6 +150,7 @@ async def create_server(
body=marshal_CreateServerRequest(
CreateServerRequest(
type_=type_,
enable_vpc=enable_vpc,
zone=zone,
name=name or random_name(prefix="as"),
project_id=project_id,
Expand Down Expand Up @@ -432,6 +436,7 @@ async def update_server(
zone: Optional[Zone] = None,
name: Optional[str] = None,
schedule_deletion: Optional[bool] = None,
enable_vpc: Optional[bool] = None,
) -> Server:
"""
Update a server.
Expand All @@ -440,6 +445,7 @@ async def update_server(
:param zone: Zone to target. If none is passed will use default zone from the config.
:param name: Updated name for your server.
:param schedule_deletion: Specify whether the server should be flagged for automatic deletion.
:param enable_vpc: Activate or deactivate Private Network support for this server.
:return: :class:`Server <Server>`
Usage:
Expand All @@ -462,6 +468,7 @@ async def update_server(
zone=zone,
name=name,
schedule_deletion=schedule_deletion,
enable_vpc=enable_vpc,
),
self.client,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
from typing import List

from .types import (
ServerPrivateNetworkStatus,
ServerStatus,
)

SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES: List[ServerPrivateNetworkStatus] = [
ServerPrivateNetworkStatus.VPC_UPDATING,
]
"""
Lists transient statutes of the enum :class:`ServerPrivateNetworkStatus <ServerPrivateNetworkStatus>`.
"""
SERVER_TRANSIENT_STATUSES: List[ServerStatus] = [
ServerStatus.STARTING,
ServerStatus.REBOOTING,
Expand Down
10 changes: 10 additions & 0 deletions scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def unmarshal_Server(data: Any) -> Server:
if field is not None:
args["delivered"] = field

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

field = data.get("os", None)
if field is not None:
args["os"] = unmarshal_OS(field)
Expand Down Expand Up @@ -485,6 +489,9 @@ def marshal_CreateServerRequest(
if request.type_ is not None:
output["type"] = request.type_

if request.enable_vpc is not None:
output["enable_vpc"] = request.enable_vpc

if request.name is not None:
output["name"] = request.name

Expand Down Expand Up @@ -533,4 +540,7 @@ def marshal_UpdateServerRequest(
if request.schedule_deletion is not None:
output["schedule_deletion"] = request.schedule_deletion

if request.enable_vpc is not None:
output["enable_vpc"] = request.enable_vpc

return output
25 changes: 25 additions & 0 deletions scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def __str__(self) -> str:
return str(self.value)


class ServerPrivateNetworkStatus(str, Enum, metaclass=StrEnumMeta):
VPC_UNKNOWN_STATUS = "vpc_unknown_status"
VPC_ENABLED = "vpc_enabled"
VPC_UPDATING = "vpc_updating"
VPC_DISABLED = "vpc_disabled"

def __str__(self) -> str:
return str(self.value)


class ServerStatus(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_STATUS = "unknown_status"
STARTING = "starting"
Expand Down Expand Up @@ -284,6 +294,11 @@ class Server:
Set to true once the server has completed its provisioning steps and is ready to use. Some OS configurations might require a reinstallation of the server before delivery depending on the available stock. A reinstallation after the initial delivery will not change this flag and can be tracked using the server status.
"""

vpc_status: ServerPrivateNetworkStatus
"""
Activation status of optional Private Network feature support for this server.
"""

os: Optional[OS]
"""
Initially installed OS, this does not necessarily reflect the current OS version.
Expand Down Expand Up @@ -327,6 +342,11 @@ class CreateServerRequest:
Create a server of the given type.
"""

enable_vpc: bool
"""
Activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API.
"""

zone: Optional[Zone]
"""
Zone to target. If none is passed will use default zone from the config.
Expand Down Expand Up @@ -580,3 +600,8 @@ class UpdateServerRequest:
"""
Specify whether the server should be flagged for automatic deletion.
"""

enable_vpc: Optional[bool]
"""
Activate or deactivate Private Network support for this server.
"""
4 changes: 4 additions & 0 deletions scaleway/scaleway/applesilicon/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from .types import ConnectivityDiagnosticActionType
from .types import ConnectivityDiagnosticDiagnosticStatus
from .types import ListServersRequestOrderBy
from .types import ServerPrivateNetworkStatus
from .content import SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES
from .types import ServerStatus
from .content import SERVER_TRANSIENT_STATUSES
from .types import ServerTypeStock
Expand Down Expand Up @@ -39,6 +41,8 @@
"ConnectivityDiagnosticActionType",
"ConnectivityDiagnosticDiagnosticStatus",
"ListServersRequestOrderBy",
"ServerPrivateNetworkStatus",
"SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES",
"ServerStatus",
"SERVER_TRANSIENT_STATUSES",
"ServerTypeStock",
Expand Down
7 changes: 7 additions & 0 deletions scaleway/scaleway/applesilicon/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def create_server(
self,
*,
type_: str,
enable_vpc: bool,
zone: Optional[Zone] = None,
name: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -125,6 +126,7 @@ def create_server(
Create a server.
Create a new server in the targeted zone, specifying its configuration including name and type.
:param type_: Create a server of the given type.
:param enable_vpc: Activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param name: Create a server with this given name.
:param project_id: Create a server in the given project ID.
Expand All @@ -136,6 +138,7 @@ def create_server(
result = api.create_server(
type="example",
enable_vpc=False,
)
"""

Expand All @@ -147,6 +150,7 @@ def create_server(
body=marshal_CreateServerRequest(
CreateServerRequest(
type_=type_,
enable_vpc=enable_vpc,
zone=zone,
name=name or random_name(prefix="as"),
project_id=project_id,
Expand Down Expand Up @@ -432,6 +436,7 @@ def update_server(
zone: Optional[Zone] = None,
name: Optional[str] = None,
schedule_deletion: Optional[bool] = None,
enable_vpc: Optional[bool] = None,
) -> Server:
"""
Update a server.
Expand All @@ -440,6 +445,7 @@ def update_server(
:param zone: Zone to target. If none is passed will use default zone from the config.
:param name: Updated name for your server.
:param schedule_deletion: Specify whether the server should be flagged for automatic deletion.
:param enable_vpc: Activate or deactivate Private Network support for this server.
:return: :class:`Server <Server>`
Usage:
Expand All @@ -462,6 +468,7 @@ def update_server(
zone=zone,
name=name,
schedule_deletion=schedule_deletion,
enable_vpc=enable_vpc,
),
self.client,
),
Expand Down
7 changes: 7 additions & 0 deletions scaleway/scaleway/applesilicon/v1alpha1/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
from typing import List

from .types import (
ServerPrivateNetworkStatus,
ServerStatus,
)

SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES: List[ServerPrivateNetworkStatus] = [
ServerPrivateNetworkStatus.VPC_UPDATING,
]
"""
Lists transient statutes of the enum :class:`ServerPrivateNetworkStatus <ServerPrivateNetworkStatus>`.
"""
SERVER_TRANSIENT_STATUSES: List[ServerStatus] = [
ServerStatus.STARTING,
ServerStatus.REBOOTING,
Expand Down
10 changes: 10 additions & 0 deletions scaleway/scaleway/applesilicon/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def unmarshal_Server(data: Any) -> Server:
if field is not None:
args["delivered"] = field

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

field = data.get("os", None)
if field is not None:
args["os"] = unmarshal_OS(field)
Expand Down Expand Up @@ -485,6 +489,9 @@ def marshal_CreateServerRequest(
if request.type_ is not None:
output["type"] = request.type_

if request.enable_vpc is not None:
output["enable_vpc"] = request.enable_vpc

if request.name is not None:
output["name"] = request.name

Expand Down Expand Up @@ -533,4 +540,7 @@ def marshal_UpdateServerRequest(
if request.schedule_deletion is not None:
output["schedule_deletion"] = request.schedule_deletion

if request.enable_vpc is not None:
output["enable_vpc"] = request.enable_vpc

return output
25 changes: 25 additions & 0 deletions scaleway/scaleway/applesilicon/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def __str__(self) -> str:
return str(self.value)


class ServerPrivateNetworkStatus(str, Enum, metaclass=StrEnumMeta):
VPC_UNKNOWN_STATUS = "vpc_unknown_status"
VPC_ENABLED = "vpc_enabled"
VPC_UPDATING = "vpc_updating"
VPC_DISABLED = "vpc_disabled"

def __str__(self) -> str:
return str(self.value)


class ServerStatus(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_STATUS = "unknown_status"
STARTING = "starting"
Expand Down Expand Up @@ -284,6 +294,11 @@ class Server:
Set to true once the server has completed its provisioning steps and is ready to use. Some OS configurations might require a reinstallation of the server before delivery depending on the available stock. A reinstallation after the initial delivery will not change this flag and can be tracked using the server status.
"""

vpc_status: ServerPrivateNetworkStatus
"""
Activation status of optional Private Network feature support for this server.
"""

os: Optional[OS]
"""
Initially installed OS, this does not necessarily reflect the current OS version.
Expand Down Expand Up @@ -327,6 +342,11 @@ class CreateServerRequest:
Create a server of the given type.
"""

enable_vpc: bool
"""
Activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API.
"""

zone: Optional[Zone]
"""
Zone to target. If none is passed will use default zone from the config.
Expand Down Expand Up @@ -580,3 +600,8 @@ class UpdateServerRequest:
"""
Specify whether the server should be flagged for automatic deletion.
"""

enable_vpc: Optional[bool]
"""
Activate or deactivate Private Network support for this server.
"""

0 comments on commit 2bdbb0d

Please sign in to comment.