Skip to content

Commit 3dba7b8

Browse files
authored
feat(apple_silicon): introduce monthly commitment handling (#856)
1 parent edbd519 commit 3dba7b8

File tree

8 files changed

+256
-62
lines changed

8 files changed

+256
-62
lines changed

scaleway-async/scaleway_async/applesilicon/v1alpha1/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
3+
from .types import CommitmentType
34
from .types import ConnectivityDiagnosticActionType
45
from .types import ConnectivityDiagnosticDiagnosticStatus
56
from .types import ListServerPrivateNetworksRequestOrderBy
@@ -17,10 +18,12 @@
1718
from .types import ServerTypeGPU
1819
from .types import ServerTypeMemory
1920
from .types import ServerTypeNetwork
21+
from .types import Commitment
2022
from .types import ConnectivityDiagnosticServerHealth
2123
from .types import ServerPrivateNetwork
2224
from .types import ServerType
2325
from .types import Server
26+
from .types import CommitmentTypeValue
2427
from .types import ConnectivityDiagnostic
2528
from .types import CreateServerRequest
2629
from .types import DeleteServerRequest
@@ -50,6 +53,7 @@
5053
from .api import ApplesiliconV1Alpha1PrivateNetworkAPI
5154

5255
__all__ = [
56+
"CommitmentType",
5357
"ConnectivityDiagnosticActionType",
5458
"ConnectivityDiagnosticDiagnosticStatus",
5559
"ListServerPrivateNetworksRequestOrderBy",
@@ -67,10 +71,12 @@
6771
"ServerTypeGPU",
6872
"ServerTypeMemory",
6973
"ServerTypeNetwork",
74+
"Commitment",
7075
"ConnectivityDiagnosticServerHealth",
7176
"ServerPrivateNetwork",
7277
"ServerType",
7378
"Server",
79+
"CommitmentTypeValue",
7480
"ConnectivityDiagnostic",
7581
"CreateServerRequest",
7682
"DeleteServerRequest",

scaleway-async/scaleway_async/applesilicon/v1alpha1/api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
wait_for_resource_async,
1616
)
1717
from .types import (
18+
CommitmentType,
1819
ListServerPrivateNetworksRequestOrderBy,
1920
ListServersRequestOrderBy,
21+
CommitmentTypeValue,
2022
ConnectivityDiagnostic,
2123
CreateServerRequest,
2224
ListOSResponse,
@@ -133,6 +135,7 @@ async def create_server(
133135
name: Optional[str] = None,
134136
project_id: Optional[str] = None,
135137
os_id: Optional[str] = None,
138+
commitment_type: Optional[CommitmentType] = None,
136139
) -> Server:
137140
"""
138141
Create a server.
@@ -143,6 +146,7 @@ async def create_server(
143146
:param name: Create a server with this given name.
144147
:param project_id: Create a server in the given project ID.
145148
:param os_id: Create a server & 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.
149+
:param commitment_type: Activate commitment for this server. If not specified, there is a 24h commitment due to Apple licensing. It can be updated with the Update Server request. Available commitment depends on server type.
146150
:return: :class:`Server <Server>`
147151
148152
Usage:
@@ -167,6 +171,7 @@ async def create_server(
167171
name=name or random_name(prefix="as"),
168172
project_id=project_id,
169173
os_id=os_id,
174+
commitment_type=commitment_type,
170175
),
171176
self.client,
172177
),
@@ -449,6 +454,7 @@ async def update_server(
449454
name: Optional[str] = None,
450455
schedule_deletion: Optional[bool] = None,
451456
enable_vpc: Optional[bool] = None,
457+
commitment_type: Optional[CommitmentTypeValue] = None,
452458
) -> Server:
453459
"""
454460
Update a server.
@@ -458,6 +464,7 @@ async def update_server(
458464
:param name: Updated name for your server.
459465
:param schedule_deletion: Specify whether the server should be flagged for automatic deletion.
460466
:param enable_vpc: Activate or deactivate Private Network support for this server.
467+
:param commitment_type: Change commitment. Use 'none' to automatically cancel a renewing commitment.
461468
:return: :class:`Server <Server>`
462469
463470
Usage:
@@ -481,6 +488,7 @@ async def update_server(
481488
name=name,
482489
schedule_deletion=schedule_deletion,
483490
enable_vpc=enable_vpc,
491+
commitment_type=commitment_type,
484492
),
485493
self.client,
486494
),

scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ServerTypeMemory,
1616
ServerTypeNetwork,
1717
ServerType,
18+
Commitment,
1819
Server,
1920
ConnectivityDiagnosticServerHealth,
2021
ConnectivityDiagnostic,
@@ -29,6 +30,7 @@
2930
PrivateNetworkApiSetServerPrivateNetworksRequest,
3031
ReinstallServerRequest,
3132
StartConnectivityDiagnosticRequest,
33+
CommitmentTypeValue,
3234
UpdateServerRequest,
3335
)
3436

@@ -285,6 +287,25 @@ def unmarshal_ServerType(data: Any) -> ServerType:
285287
return ServerType(**args)
286288

287289

290+
def unmarshal_Commitment(data: Any) -> Commitment:
291+
if not isinstance(data, dict):
292+
raise TypeError(
293+
"Unmarshalling the type 'Commitment' failed as data isn't a dictionary."
294+
)
295+
296+
args: Dict[str, Any] = {}
297+
298+
field = data.get("type", None)
299+
if field is not None:
300+
args["type_"] = field
301+
302+
field = data.get("cancelled", None)
303+
if field is not None:
304+
args["cancelled"] = field
305+
306+
return Commitment(**args)
307+
308+
288309
def unmarshal_Server(data: Any) -> Server:
289310
if not isinstance(data, dict):
290311
raise TypeError(
@@ -337,22 +358,6 @@ def unmarshal_Server(data: Any) -> Server:
337358
if field is not None:
338359
args["status"] = field
339360

340-
field = data.get("deletion_scheduled", None)
341-
if field is not None:
342-
args["deletion_scheduled"] = field
343-
344-
field = data.get("zone", None)
345-
if field is not None:
346-
args["zone"] = field
347-
348-
field = data.get("delivered", None)
349-
if field is not None:
350-
args["delivered"] = field
351-
352-
field = data.get("vpc_status", None)
353-
if field is not None:
354-
args["vpc_status"] = field
355-
356361
field = data.get("os", None)
357362
if field is not None:
358363
args["os"] = unmarshal_OS(field)
@@ -379,6 +384,28 @@ def unmarshal_Server(data: Any) -> Server:
379384
else:
380385
args["deletable_at"] = None
381386

387+
field = data.get("deletion_scheduled", None)
388+
if field is not None:
389+
args["deletion_scheduled"] = field
390+
391+
field = data.get("zone", None)
392+
if field is not None:
393+
args["zone"] = field
394+
395+
field = data.get("delivered", None)
396+
if field is not None:
397+
args["delivered"] = field
398+
399+
field = data.get("vpc_status", None)
400+
if field is not None:
401+
args["vpc_status"] = field
402+
403+
field = data.get("commitment", None)
404+
if field is not None:
405+
args["commitment"] = unmarshal_Commitment(field)
406+
else:
407+
args["commitment"] = None
408+
382409
return Server(**args)
383410

384411

@@ -605,6 +632,9 @@ def marshal_CreateServerRequest(
605632
if request.os_id is not None:
606633
output["os_id"] = request.os_id
607634

635+
if request.commitment_type is not None:
636+
output["commitment_type"] = str(request.commitment_type)
637+
608638
return output
609639

610640

@@ -661,6 +691,18 @@ def marshal_StartConnectivityDiagnosticRequest(
661691
return output
662692

663693

694+
def marshal_CommitmentTypeValue(
695+
request: CommitmentTypeValue,
696+
defaults: ProfileDefaults,
697+
) -> Dict[str, Any]:
698+
output: Dict[str, Any] = {}
699+
700+
if request.commitment_type is not None:
701+
output["commitment_type"] = str(request.commitment_type)
702+
703+
return output
704+
705+
664706
def marshal_UpdateServerRequest(
665707
request: UpdateServerRequest,
666708
defaults: ProfileDefaults,
@@ -676,4 +718,9 @@ def marshal_UpdateServerRequest(
676718
if request.enable_vpc is not None:
677719
output["enable_vpc"] = request.enable_vpc
678720

721+
if request.commitment_type is not None:
722+
output["commitment_type"] = marshal_CommitmentTypeValue(
723+
request.commitment_type, defaults
724+
)
725+
679726
return output

scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
)
1616

1717

18+
class CommitmentType(str, Enum, metaclass=StrEnumMeta):
19+
DURATION_24H = "duration_24h"
20+
RENEWED_MONTHLY = "renewed_monthly"
21+
NONE = "none"
22+
23+
def __str__(self) -> str:
24+
return str(self.value)
25+
26+
1827
class ConnectivityDiagnosticActionType(str, Enum, metaclass=StrEnumMeta):
1928
REBOOT_SERVER = "reboot_server"
2029
REINSTALL_SERVER = "reinstall_server"
@@ -181,6 +190,13 @@ class ServerTypeNetwork:
181190
public_bandwidth_bps: int
182191

183192

193+
@dataclass
194+
class Commitment:
195+
type_: CommitmentType
196+
197+
cancelled: bool
198+
199+
184200
@dataclass
185201
class ConnectivityDiagnosticServerHealth:
186202
is_server_alive: bool
@@ -349,6 +365,26 @@ class Server:
349365
Current status of the server.
350366
"""
351367

368+
os: Optional[OS]
369+
"""
370+
Initially installed OS, this does not necessarily reflect the current OS version.
371+
"""
372+
373+
created_at: Optional[datetime]
374+
"""
375+
Date on which the server was created.
376+
"""
377+
378+
updated_at: Optional[datetime]
379+
"""
380+
Date on which the server was last updated.
381+
"""
382+
383+
deletable_at: Optional[datetime]
384+
"""
385+
Date from which the server can be deleted.
386+
"""
387+
352388
deletion_scheduled: bool
353389
"""
354390
Set to true to mark the server for automatic deletion depending on `deletable_at` date. Set to false to cancel an existing deletion schedule. Leave unset otherwise.
@@ -369,25 +405,15 @@ class Server:
369405
Activation status of optional Private Network feature support for this server.
370406
"""
371407

372-
os: Optional[OS]
408+
commitment: Optional[Commitment]
373409
"""
374-
Initially installed OS, this does not necessarily reflect the current OS version.
410+
Commitment scheme applied to this server.
375411
"""
376412

377-
created_at: Optional[datetime]
378-
"""
379-
Date on which the server was created.
380-
"""
381413

382-
updated_at: Optional[datetime]
383-
"""
384-
Date on which the server was last updated.
385-
"""
386-
387-
deletable_at: Optional[datetime]
388-
"""
389-
Date from which the server can be deleted.
390-
"""
414+
@dataclass
415+
class CommitmentTypeValue:
416+
commitment_type: CommitmentType
391417

392418

393419
@dataclass
@@ -437,6 +463,11 @@ class CreateServerRequest:
437463
Create a server & 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.
438464
"""
439465

466+
commitment_type: Optional[CommitmentType]
467+
"""
468+
Activate commitment for this server. If not specified, there is a 24h commitment due to Apple licensing. It can be updated with the Update Server request. Available commitment depends on server type.
469+
"""
470+
440471

441472
@dataclass
442473
class DeleteServerRequest:
@@ -806,3 +837,8 @@ class UpdateServerRequest:
806837
"""
807838
Activate or deactivate Private Network support for this server.
808839
"""
840+
841+
commitment_type: Optional[CommitmentTypeValue]
842+
"""
843+
Change commitment. Use 'none' to automatically cancel a renewing commitment.
844+
"""

scaleway/scaleway/applesilicon/v1alpha1/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
3+
from .types import CommitmentType
34
from .types import ConnectivityDiagnosticActionType
45
from .types import ConnectivityDiagnosticDiagnosticStatus
56
from .types import ListServerPrivateNetworksRequestOrderBy
@@ -17,10 +18,12 @@
1718
from .types import ServerTypeGPU
1819
from .types import ServerTypeMemory
1920
from .types import ServerTypeNetwork
21+
from .types import Commitment
2022
from .types import ConnectivityDiagnosticServerHealth
2123
from .types import ServerPrivateNetwork
2224
from .types import ServerType
2325
from .types import Server
26+
from .types import CommitmentTypeValue
2427
from .types import ConnectivityDiagnostic
2528
from .types import CreateServerRequest
2629
from .types import DeleteServerRequest
@@ -50,6 +53,7 @@
5053
from .api import ApplesiliconV1Alpha1PrivateNetworkAPI
5154

5255
__all__ = [
56+
"CommitmentType",
5357
"ConnectivityDiagnosticActionType",
5458
"ConnectivityDiagnosticDiagnosticStatus",
5559
"ListServerPrivateNetworksRequestOrderBy",
@@ -67,10 +71,12 @@
6771
"ServerTypeGPU",
6872
"ServerTypeMemory",
6973
"ServerTypeNetwork",
74+
"Commitment",
7075
"ConnectivityDiagnosticServerHealth",
7176
"ServerPrivateNetwork",
7277
"ServerType",
7378
"Server",
79+
"CommitmentTypeValue",
7480
"ConnectivityDiagnostic",
7581
"CreateServerRequest",
7682
"DeleteServerRequest",

0 commit comments

Comments
 (0)