diff --git a/scaleway-async/scaleway_async/applesilicon/v1alpha1/__init__.py b/scaleway-async/scaleway_async/applesilicon/v1alpha1/__init__.py index 5ea0fe91b..42bc8f208 100644 --- a/scaleway-async/scaleway_async/applesilicon/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/applesilicon/v1alpha1/__init__.py @@ -19,11 +19,14 @@ from .types import ServerTypeGPU from .types import ServerTypeMemory from .types import ServerTypeNetwork +from .types import BatchCreateServersRequestBatchInnerCreateServerRequest from .types import Server from .types import ConnectivityDiagnosticServerHealth from .types import ServerPrivateNetwork from .types import ServerType from .types import CommitmentTypeValue +from .types import BatchCreateServersRequest +from .types import BatchCreateServersResponse from .types import ConnectivityDiagnostic from .types import CreateServerRequest from .types import DeleteServerRequest @@ -72,11 +75,14 @@ "ServerTypeGPU", "ServerTypeMemory", "ServerTypeNetwork", + "BatchCreateServersRequestBatchInnerCreateServerRequest", "Server", "ConnectivityDiagnosticServerHealth", "ServerPrivateNetwork", "ServerType", "CommitmentTypeValue", + "BatchCreateServersRequest", + "BatchCreateServersResponse", "ConnectivityDiagnostic", "CreateServerRequest", "DeleteServerRequest", diff --git a/scaleway-async/scaleway_async/applesilicon/v1alpha1/api.py b/scaleway-async/scaleway_async/applesilicon/v1alpha1/api.py index 9ad901bdc..d72627a9a 100644 --- a/scaleway-async/scaleway_async/applesilicon/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/applesilicon/v1alpha1/api.py @@ -18,6 +18,9 @@ CommitmentType, ListServerPrivateNetworksRequestOrderBy, ListServersRequestOrderBy, + BatchCreateServersRequest, + BatchCreateServersRequestBatchInnerCreateServerRequest, + BatchCreateServersResponse, CommitmentTypeValue, ConnectivityDiagnostic, CreateServerRequest, @@ -46,6 +49,7 @@ unmarshal_Server, unmarshal_ServerPrivateNetwork, unmarshal_ServerType, + unmarshal_BatchCreateServersResponse, unmarshal_ConnectivityDiagnostic, unmarshal_ListOSResponse, unmarshal_ListServerPrivateNetworksResponse, @@ -53,6 +57,7 @@ unmarshal_ListServersResponse, unmarshal_SetServerPrivateNetworksResponse, unmarshal_StartConnectivityDiagnosticResponse, + marshal_BatchCreateServersRequest, marshal_CreateServerRequest, marshal_PrivateNetworkApiAddServerPrivateNetworkRequest, marshal_PrivateNetworkApiSetServerPrivateNetworksRequest, @@ -184,6 +189,66 @@ async def create_server( self._throw_on_error(res) return unmarshal_Server(res.json()) + async def batch_create_servers( + self, + *, + type_: str, + enable_vpc: bool, + public_bandwidth_bps: int, + zone: Optional[ScwZone] = None, + project_id: Optional[str] = None, + os_id: Optional[str] = None, + commitment_type: Optional[CommitmentType] = None, + requests: Optional[ + List[BatchCreateServersRequestBatchInnerCreateServerRequest] + ] = None, + ) -> BatchCreateServersResponse: + """ + Create multiple servers atomically. + Create multiple servers in the targeted zone specifying their configurations. If the request cannot entirely be fulfilled, no servers are created. + :param type_: Create servers of the given type. + :param enable_vpc: Activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API. + :param public_bandwidth_bps: Public bandwidth to configure for these servers. This defaults to the minimum bandwidth for the corresponding server type. For compatible server types, the bandwidth can be increased which incurs additional costs. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param project_id: Create servers in the given project ID. + :param os_id: Create servers & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. + :param commitment_type: Activate commitment for these servers. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. + :param requests: List of servers to create. + :return: :class:`BatchCreateServersResponse ` + + Usage: + :: + + result = await api.batch_create_servers( + type="example", + enable_vpc=False, + public_bandwidth_bps=1, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/apple-silicon/v1alpha1/zones/{param_zone}/batch-create-servers", + body=marshal_BatchCreateServersRequest( + BatchCreateServersRequest( + type_=type_, + enable_vpc=enable_vpc, + public_bandwidth_bps=public_bandwidth_bps, + zone=zone, + project_id=project_id, + os_id=os_id, + commitment_type=commitment_type, + requests=requests, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_BatchCreateServersResponse(res.json()) + async def list_servers( self, *, diff --git a/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py index b8f5ea4c4..eb23a6f6d 100644 --- a/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py @@ -17,6 +17,7 @@ ServerTypeMemory, ServerTypeNetwork, ServerType, + BatchCreateServersResponse, ConnectivityDiagnosticServerHealth, ConnectivityDiagnostic, ListOSResponse, @@ -25,6 +26,8 @@ ListServersResponse, SetServerPrivateNetworksResponse, StartConnectivityDiagnosticResponse, + BatchCreateServersRequestBatchInnerCreateServerRequest, + BatchCreateServersRequest, CreateServerRequest, PrivateNetworkApiAddServerPrivateNetworkRequest, PrivateNetworkApiSetServerPrivateNetworksRequest, @@ -417,6 +420,23 @@ def unmarshal_ServerType(data: Any) -> ServerType: return ServerType(**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 + ) + + return BatchCreateServersResponse(**args) + + def unmarshal_ConnectivityDiagnosticServerHealth( data: Any, ) -> ConnectivityDiagnosticServerHealth: @@ -619,6 +639,53 @@ def unmarshal_StartConnectivityDiagnosticResponse( return StartConnectivityDiagnosticResponse(**args) +def marshal_BatchCreateServersRequestBatchInnerCreateServerRequest( + request: BatchCreateServersRequestBatchInnerCreateServerRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + return output + + +def marshal_BatchCreateServersRequest( + request: BatchCreateServersRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + 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.public_bandwidth_bps is not None: + output["public_bandwidth_bps"] = request.public_bandwidth_bps + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.os_id is not None: + output["os_id"] = request.os_id + + if request.commitment_type is not None: + output["commitment_type"] = str(request.commitment_type) + + if request.requests is not None: + output["requests"] = [ + marshal_BatchCreateServersRequestBatchInnerCreateServerRequest( + item, defaults + ) + for item in request.requests + ] + + return output + + def marshal_CreateServerRequest( request: CreateServerRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py b/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py index 5adbcb259..8831b428f 100644 --- a/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py @@ -199,6 +199,11 @@ class ServerTypeNetwork: supported_bandwidth: List[int] +@dataclass +class BatchCreateServersRequestBatchInnerCreateServerRequest: + name: str + + @dataclass class Server: id: str @@ -423,6 +428,57 @@ class CommitmentTypeValue: commitment_type: CommitmentType +@dataclass +class BatchCreateServersRequest: + type_: str + """ + Create servers of the given type. + """ + + enable_vpc: bool + """ + Activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API. + """ + + public_bandwidth_bps: int + """ + Public bandwidth to configure for these servers. This defaults to the minimum bandwidth for the corresponding server type. For compatible server types, the bandwidth can be increased which incurs additional costs. + """ + + zone: Optional[ScwZone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + project_id: Optional[str] + """ + Create servers in the given project ID. + """ + + os_id: Optional[str] + """ + Create servers & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. + """ + + commitment_type: Optional[CommitmentType] + """ + Activate commitment for these servers. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. + """ + + requests: Optional[List[BatchCreateServersRequestBatchInnerCreateServerRequest]] + """ + List of servers to create. + """ + + +@dataclass +class BatchCreateServersResponse: + servers: List[Server] + """ + List of created servers. + """ + + @dataclass class ConnectivityDiagnostic: id: str diff --git a/scaleway/scaleway/applesilicon/v1alpha1/__init__.py b/scaleway/scaleway/applesilicon/v1alpha1/__init__.py index 5ea0fe91b..42bc8f208 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/__init__.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/__init__.py @@ -19,11 +19,14 @@ from .types import ServerTypeGPU from .types import ServerTypeMemory from .types import ServerTypeNetwork +from .types import BatchCreateServersRequestBatchInnerCreateServerRequest from .types import Server from .types import ConnectivityDiagnosticServerHealth from .types import ServerPrivateNetwork from .types import ServerType from .types import CommitmentTypeValue +from .types import BatchCreateServersRequest +from .types import BatchCreateServersResponse from .types import ConnectivityDiagnostic from .types import CreateServerRequest from .types import DeleteServerRequest @@ -72,11 +75,14 @@ "ServerTypeGPU", "ServerTypeMemory", "ServerTypeNetwork", + "BatchCreateServersRequestBatchInnerCreateServerRequest", "Server", "ConnectivityDiagnosticServerHealth", "ServerPrivateNetwork", "ServerType", "CommitmentTypeValue", + "BatchCreateServersRequest", + "BatchCreateServersResponse", "ConnectivityDiagnostic", "CreateServerRequest", "DeleteServerRequest", diff --git a/scaleway/scaleway/applesilicon/v1alpha1/api.py b/scaleway/scaleway/applesilicon/v1alpha1/api.py index 0046f76df..4eb2b67a5 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/api.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/api.py @@ -18,6 +18,9 @@ CommitmentType, ListServerPrivateNetworksRequestOrderBy, ListServersRequestOrderBy, + BatchCreateServersRequest, + BatchCreateServersRequestBatchInnerCreateServerRequest, + BatchCreateServersResponse, CommitmentTypeValue, ConnectivityDiagnostic, CreateServerRequest, @@ -46,6 +49,7 @@ unmarshal_Server, unmarshal_ServerPrivateNetwork, unmarshal_ServerType, + unmarshal_BatchCreateServersResponse, unmarshal_ConnectivityDiagnostic, unmarshal_ListOSResponse, unmarshal_ListServerPrivateNetworksResponse, @@ -53,6 +57,7 @@ unmarshal_ListServersResponse, unmarshal_SetServerPrivateNetworksResponse, unmarshal_StartConnectivityDiagnosticResponse, + marshal_BatchCreateServersRequest, marshal_CreateServerRequest, marshal_PrivateNetworkApiAddServerPrivateNetworkRequest, marshal_PrivateNetworkApiSetServerPrivateNetworksRequest, @@ -184,6 +189,66 @@ def create_server( self._throw_on_error(res) return unmarshal_Server(res.json()) + def batch_create_servers( + self, + *, + type_: str, + enable_vpc: bool, + public_bandwidth_bps: int, + zone: Optional[ScwZone] = None, + project_id: Optional[str] = None, + os_id: Optional[str] = None, + commitment_type: Optional[CommitmentType] = None, + requests: Optional[ + List[BatchCreateServersRequestBatchInnerCreateServerRequest] + ] = None, + ) -> BatchCreateServersResponse: + """ + Create multiple servers atomically. + Create multiple servers in the targeted zone specifying their configurations. If the request cannot entirely be fulfilled, no servers are created. + :param type_: Create servers of the given type. + :param enable_vpc: Activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API. + :param public_bandwidth_bps: Public bandwidth to configure for these servers. This defaults to the minimum bandwidth for the corresponding server type. For compatible server types, the bandwidth can be increased which incurs additional costs. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param project_id: Create servers in the given project ID. + :param os_id: Create servers & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. + :param commitment_type: Activate commitment for these servers. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. + :param requests: List of servers to create. + :return: :class:`BatchCreateServersResponse ` + + Usage: + :: + + result = api.batch_create_servers( + type="example", + enable_vpc=False, + public_bandwidth_bps=1, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/apple-silicon/v1alpha1/zones/{param_zone}/batch-create-servers", + body=marshal_BatchCreateServersRequest( + BatchCreateServersRequest( + type_=type_, + enable_vpc=enable_vpc, + public_bandwidth_bps=public_bandwidth_bps, + zone=zone, + project_id=project_id, + os_id=os_id, + commitment_type=commitment_type, + requests=requests, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_BatchCreateServersResponse(res.json()) + def list_servers( self, *, diff --git a/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py b/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py index b8f5ea4c4..eb23a6f6d 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py @@ -17,6 +17,7 @@ ServerTypeMemory, ServerTypeNetwork, ServerType, + BatchCreateServersResponse, ConnectivityDiagnosticServerHealth, ConnectivityDiagnostic, ListOSResponse, @@ -25,6 +26,8 @@ ListServersResponse, SetServerPrivateNetworksResponse, StartConnectivityDiagnosticResponse, + BatchCreateServersRequestBatchInnerCreateServerRequest, + BatchCreateServersRequest, CreateServerRequest, PrivateNetworkApiAddServerPrivateNetworkRequest, PrivateNetworkApiSetServerPrivateNetworksRequest, @@ -417,6 +420,23 @@ def unmarshal_ServerType(data: Any) -> ServerType: return ServerType(**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 + ) + + return BatchCreateServersResponse(**args) + + def unmarshal_ConnectivityDiagnosticServerHealth( data: Any, ) -> ConnectivityDiagnosticServerHealth: @@ -619,6 +639,53 @@ def unmarshal_StartConnectivityDiagnosticResponse( return StartConnectivityDiagnosticResponse(**args) +def marshal_BatchCreateServersRequestBatchInnerCreateServerRequest( + request: BatchCreateServersRequestBatchInnerCreateServerRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + return output + + +def marshal_BatchCreateServersRequest( + request: BatchCreateServersRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + 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.public_bandwidth_bps is not None: + output["public_bandwidth_bps"] = request.public_bandwidth_bps + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.os_id is not None: + output["os_id"] = request.os_id + + if request.commitment_type is not None: + output["commitment_type"] = str(request.commitment_type) + + if request.requests is not None: + output["requests"] = [ + marshal_BatchCreateServersRequestBatchInnerCreateServerRequest( + item, defaults + ) + for item in request.requests + ] + + return output + + def marshal_CreateServerRequest( request: CreateServerRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/applesilicon/v1alpha1/types.py b/scaleway/scaleway/applesilicon/v1alpha1/types.py index 5adbcb259..8831b428f 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/types.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/types.py @@ -199,6 +199,11 @@ class ServerTypeNetwork: supported_bandwidth: List[int] +@dataclass +class BatchCreateServersRequestBatchInnerCreateServerRequest: + name: str + + @dataclass class Server: id: str @@ -423,6 +428,57 @@ class CommitmentTypeValue: commitment_type: CommitmentType +@dataclass +class BatchCreateServersRequest: + type_: str + """ + Create servers of the given type. + """ + + enable_vpc: bool + """ + Activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API. + """ + + public_bandwidth_bps: int + """ + Public bandwidth to configure for these servers. This defaults to the minimum bandwidth for the corresponding server type. For compatible server types, the bandwidth can be increased which incurs additional costs. + """ + + zone: Optional[ScwZone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + project_id: Optional[str] + """ + Create servers in the given project ID. + """ + + os_id: Optional[str] + """ + Create servers & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. + """ + + commitment_type: Optional[CommitmentType] + """ + Activate commitment for these servers. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. + """ + + requests: Optional[List[BatchCreateServersRequestBatchInnerCreateServerRequest]] + """ + List of servers to create. + """ + + +@dataclass +class BatchCreateServersResponse: + servers: List[Server] + """ + List of created servers. + """ + + @dataclass class ConnectivityDiagnostic: id: str