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
6 changes: 6 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .types import OfferOptionOffer
from .types import PersistentMemory
from .types import RaidController
from .types import BatchCreateServersRequestServerConfig
from .types import CreateServerRequest
from .types import Server
from .types import OS
Expand All @@ -57,6 +58,8 @@
from .types import Setting
from .types import AddOptionServerRequest
from .types import BMCAccess
from .types import BatchCreateServersRequest
from .types import BatchCreateServersResponse
from .types import DeleteOptionServerRequest
from .types import DeleteServerRequest
from .types import GetBMCAccessRequest
Expand Down Expand Up @@ -147,6 +150,7 @@
"OfferOptionOffer",
"PersistentMemory",
"RaidController",
"BatchCreateServersRequestServerConfig",
"CreateServerRequest",
"Server",
"OS",
Expand All @@ -157,6 +161,8 @@
"Setting",
"AddOptionServerRequest",
"BMCAccess",
"BatchCreateServersRequest",
"BatchCreateServersResponse",
"DeleteOptionServerRequest",
"DeleteServerRequest",
"GetBMCAccessRequest",
Expand Down
44 changes: 44 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
ServerBootType,
AddOptionServerRequest,
BMCAccess,
BatchCreateServersRequest,
BatchCreateServersRequestServerConfig,
BatchCreateServersResponse,
CreateServerRequest,
CreateServerRequestInstall,
GetServerMetricsResponse,
Expand Down Expand Up @@ -68,6 +71,7 @@
unmarshal_ServerPrivateNetwork,
unmarshal_Setting,
unmarshal_BMCAccess,
unmarshal_BatchCreateServersResponse,
unmarshal_GetServerMetricsResponse,
unmarshal_ListOSResponse,
unmarshal_ListOffersResponse,
Expand All @@ -79,6 +83,7 @@
unmarshal_SetServerPrivateNetworksResponse,
marshal_CreateServerRequest,
marshal_AddOptionServerRequest,
marshal_BatchCreateServersRequest,
marshal_InstallServerRequest,
marshal_PrivateNetworkApiAddServerPrivateNetworkRequest,
marshal_PrivateNetworkApiSetServerPrivateNetworksRequest,
Expand Down Expand Up @@ -346,6 +351,45 @@ async def create_server(
self._throw_on_error(res)
return unmarshal_Server(res.json())

async def batch_create_servers(
self,
*,
zone: Optional[ScwZone] = None,
common_configuration: Optional[CreateServerRequest] = None,
servers: Optional[list[BatchCreateServersRequestServerConfig]] = None,
) -> BatchCreateServersResponse:
"""
Create multiple Elastic Metal servers.
Create multiple new Elastic Metal servers. Once the servers are created, proceed with the [installation of an OS](#post-3e949e).
:param zone: Zone to target. If none is passed will use default zone from the config.
:param common_configuration: Configuration wanted for the servers to create.
:param servers: List of servers to create.
:return: :class:`BatchCreateServersResponse <BatchCreateServersResponse>`

Usage:
::

result = await api.batch_create_servers()
"""

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

res = self._request(
"POST",
f"/baremetal/v1/zones/{param_zone}/batch-create-servers",
body=marshal_BatchCreateServersRequest(
BatchCreateServersRequest(
zone=zone,
common_configuration=common_configuration,
servers=servers,
),
self.client,
),
)

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

async def update_server(
self,
*,
Expand Down
60 changes: 60 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
ServerPrivateNetwork,
Setting,
BMCAccess,
BatchCreateServersResponse,
GetServerMetricsResponse,
ListOSResponse,
ListOffersResponse,
Expand All @@ -70,6 +71,8 @@
CreateServerRequestInstall,
CreateServerRequest,
AddOptionServerRequest,
BatchCreateServersRequestServerConfig,
BatchCreateServersRequest,
InstallServerRequest,
PrivateNetworkApiAddServerPrivateNetworkRequest,
PrivateNetworkApiSetServerPrivateNetworksRequest,
Expand Down Expand Up @@ -1482,6 +1485,25 @@ def unmarshal_BMCAccess(data: Any) -> BMCAccess:
return BMCAccess(**args)


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

args: dict[str, Any] = {}

field = data.get("servers", None)
if field is not None:
args["servers"] = (
[unmarshal_Server(v) for v in field] if field is not None else None
)
else:
args["servers"] = None

return BatchCreateServersResponse(**args)


def unmarshal_GetServerMetricsResponse(data: Any) -> GetServerMetricsResponse:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -1967,6 +1989,44 @@ def marshal_AddOptionServerRequest(
return output


def marshal_BatchCreateServersRequestServerConfig(
request: BatchCreateServersRequestServerConfig,
defaults: ProfileDefaults,
) -> dict[str, Any]:
output: dict[str, Any] = {}

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

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

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

return output


def marshal_BatchCreateServersRequest(
request: BatchCreateServersRequest,
defaults: ProfileDefaults,
) -> dict[str, Any]:
output: dict[str, Any] = {}

if request.common_configuration is not None:
output["common_configuration"] = marshal_CreateServerRequest(
request.common_configuration, defaults
)

if request.servers is not None:
output["servers"] = [
marshal_BatchCreateServersRequestServerConfig(item, defaults)
for item in request.servers
]

return output


def marshal_InstallServerRequest(
request: InstallServerRequest,
defaults: ProfileDefaults,
Expand Down
32 changes: 32 additions & 0 deletions scaleway-async/scaleway_async/baremetal/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,13 @@ class RaidController:
raid_level: list[str]


@dataclass
class BatchCreateServersRequestServerConfig:
hostname: str
description: str
tags: list[str]


@dataclass
class CreateServerRequest:
offer_id: str
Expand Down Expand Up @@ -1159,6 +1166,31 @@ class BMCAccess:
"""


@dataclass
class BatchCreateServersRequest:
zone: Optional[ScwZone] = None
"""
Zone to target. If none is passed will use default zone from the config.
"""

common_configuration: Optional[CreateServerRequest] = None
"""
Configuration wanted for the servers to create.
"""

servers: Optional[list[BatchCreateServersRequestServerConfig]] = field(
default_factory=list
)
"""
List of servers to create.
"""


@dataclass
class BatchCreateServersResponse:
servers: list[Server]


@dataclass
class DeleteOptionServerRequest:
server_id: str
Expand Down
6 changes: 6 additions & 0 deletions scaleway/scaleway/baremetal/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from .types import OfferOptionOffer
from .types import PersistentMemory
from .types import RaidController
from .types import BatchCreateServersRequestServerConfig
from .types import CreateServerRequest
from .types import Server
from .types import OS
Expand All @@ -57,6 +58,8 @@
from .types import Setting
from .types import AddOptionServerRequest
from .types import BMCAccess
from .types import BatchCreateServersRequest
from .types import BatchCreateServersResponse
from .types import DeleteOptionServerRequest
from .types import DeleteServerRequest
from .types import GetBMCAccessRequest
Expand Down Expand Up @@ -147,6 +150,7 @@
"OfferOptionOffer",
"PersistentMemory",
"RaidController",
"BatchCreateServersRequestServerConfig",
"CreateServerRequest",
"Server",
"OS",
Expand All @@ -157,6 +161,8 @@
"Setting",
"AddOptionServerRequest",
"BMCAccess",
"BatchCreateServersRequest",
"BatchCreateServersResponse",
"DeleteOptionServerRequest",
"DeleteServerRequest",
"GetBMCAccessRequest",
Expand Down
44 changes: 44 additions & 0 deletions scaleway/scaleway/baremetal/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
ServerBootType,
AddOptionServerRequest,
BMCAccess,
BatchCreateServersRequest,
BatchCreateServersRequestServerConfig,
BatchCreateServersResponse,
CreateServerRequest,
CreateServerRequestInstall,
GetServerMetricsResponse,
Expand Down Expand Up @@ -68,6 +71,7 @@
unmarshal_ServerPrivateNetwork,
unmarshal_Setting,
unmarshal_BMCAccess,
unmarshal_BatchCreateServersResponse,
unmarshal_GetServerMetricsResponse,
unmarshal_ListOSResponse,
unmarshal_ListOffersResponse,
Expand All @@ -79,6 +83,7 @@
unmarshal_SetServerPrivateNetworksResponse,
marshal_CreateServerRequest,
marshal_AddOptionServerRequest,
marshal_BatchCreateServersRequest,
marshal_InstallServerRequest,
marshal_PrivateNetworkApiAddServerPrivateNetworkRequest,
marshal_PrivateNetworkApiSetServerPrivateNetworksRequest,
Expand Down Expand Up @@ -346,6 +351,45 @@ def create_server(
self._throw_on_error(res)
return unmarshal_Server(res.json())

def batch_create_servers(
self,
*,
zone: Optional[ScwZone] = None,
common_configuration: Optional[CreateServerRequest] = None,
servers: Optional[list[BatchCreateServersRequestServerConfig]] = None,
) -> BatchCreateServersResponse:
"""
Create multiple Elastic Metal servers.
Create multiple new Elastic Metal servers. Once the servers are created, proceed with the [installation of an OS](#post-3e949e).
:param zone: Zone to target. If none is passed will use default zone from the config.
:param common_configuration: Configuration wanted for the servers to create.
:param servers: List of servers to create.
:return: :class:`BatchCreateServersResponse <BatchCreateServersResponse>`

Usage:
::

result = api.batch_create_servers()
"""

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

res = self._request(
"POST",
f"/baremetal/v1/zones/{param_zone}/batch-create-servers",
body=marshal_BatchCreateServersRequest(
BatchCreateServersRequest(
zone=zone,
common_configuration=common_configuration,
servers=servers,
),
self.client,
),
)

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

def update_server(
self,
*,
Expand Down
Loading
Loading