Skip to content

Commit b552d1d

Browse files
scaleway-botyfodil
andauthored
feat(apple_silicon): add CI-CD runner installation APIs (#1258)
Co-authored-by: Yacine Fodil <[email protected]>
1 parent d45ba66 commit b552d1d

File tree

8 files changed

+418
-4
lines changed

8 files changed

+418
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
from .types import ConnectivityDiagnosticDiagnosticStatus
66
from .types import ListServerPrivateNetworksRequestOrderBy
77
from .types import ListServersRequestOrderBy
8+
from .types import RunnerConfigurationProvider
89
from .types import ServerPrivateNetworkServerStatus
910
from .content import SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES
1011
from .types import ServerPrivateNetworkStatus
1112
from .content import SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES
1213
from .types import ServerStatus
1314
from .content import SERVER_TRANSIENT_STATUSES
1415
from .types import ServerTypeStock
16+
from .types import OSSupportedServerType
1517
from .types import Commitment
1618
from .types import OS
19+
from .types import RunnerConfiguration
1720
from .types import ServerTypeCPU
1821
from .types import ServerTypeDisk
1922
from .types import ServerTypeGPU
@@ -62,15 +65,18 @@
6265
"ConnectivityDiagnosticDiagnosticStatus",
6366
"ListServerPrivateNetworksRequestOrderBy",
6467
"ListServersRequestOrderBy",
68+
"RunnerConfigurationProvider",
6569
"ServerPrivateNetworkServerStatus",
6670
"SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES",
6771
"ServerPrivateNetworkStatus",
6872
"SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES",
6973
"ServerStatus",
7074
"SERVER_TRANSIENT_STATUSES",
7175
"ServerTypeStock",
76+
"OSSupportedServerType",
7277
"Commitment",
7378
"OS",
79+
"RunnerConfiguration",
7480
"ServerTypeCPU",
7581
"ServerTypeDisk",
7682
"ServerTypeGPU",

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
PrivateNetworkApiAddServerPrivateNetworkRequest,
3333
PrivateNetworkApiSetServerPrivateNetworksRequest,
3434
ReinstallServerRequest,
35+
RunnerConfiguration,
3536
Server,
3637
ServerPrivateNetwork,
3738
ServerType,
@@ -142,6 +143,7 @@ async def create_server(
142143
project_id: Optional[str] = None,
143144
os_id: Optional[str] = None,
144145
commitment_type: Optional[CommitmentType] = None,
146+
runner_configuration: Optional[RunnerConfiguration] = None,
145147
) -> Server:
146148
"""
147149
Create a server.
@@ -154,6 +156,7 @@ async def create_server(
154156
:param project_id: Create a server in the given project ID.
155157
: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.
156158
:param commitment_type: Activate commitment for this server. 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.
159+
:param runner_configuration: Specify the configuration to install an optional CICD runner on the server during installation.
157160
:return: :class:`Server <Server>`
158161
159162
Usage:
@@ -181,6 +184,7 @@ async def create_server(
181184
project_id=project_id,
182185
os_id=os_id,
183186
commitment_type=commitment_type,
187+
runner_configuration=runner_configuration,
184188
),
185189
self.client,
186190
),
@@ -638,13 +642,15 @@ async def reinstall_server(
638642
server_id: str,
639643
zone: Optional[ScwZone] = None,
640644
os_id: Optional[str] = None,
645+
runner_configuration: Optional[RunnerConfiguration] = None,
641646
) -> Server:
642647
"""
643648
Reinstall a server.
644649
Reinstall an existing Apple silicon server (specified by its server ID) from a new image (OS). All the data on the disk is deleted and all configuration is reset to the defailt configuration values of the image (OS).
645650
:param server_id: UUID of the server you want to reinstall.
646651
:param zone: Zone to target. If none is passed will use default zone from the config.
647652
:param os_id: Reinstall the server with the target OS, when no os_id provided the default OS for the server type is used.
653+
:param runner_configuration: Specify the configuration to install an optional CICD runner on the server during installation.
648654
:return: :class:`Server <Server>`
649655
650656
Usage:
@@ -666,6 +672,7 @@ async def reinstall_server(
666672
server_id=server_id,
667673
zone=zone,
668674
os_id=os_id,
675+
runner_configuration=runner_configuration,
669676
),
670677
self.client,
671678
),

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

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
ServerPrivateNetworkStatus,
1212
ServerStatus,
1313
ServerTypeStock,
14+
OSSupportedServerType,
1415
OS,
1516
Commitment,
17+
RunnerConfiguration,
1618
Server,
1719
ServerPrivateNetwork,
1820
ServerTypeCPU,
@@ -43,6 +45,29 @@
4345
)
4446

4547

48+
def unmarshal_OSSupportedServerType(data: Any) -> OSSupportedServerType:
49+
if not isinstance(data, dict):
50+
raise TypeError(
51+
"Unmarshalling the type 'OSSupportedServerType' failed as data isn't a dictionary."
52+
)
53+
54+
args: dict[str, Any] = {}
55+
56+
field = data.get("server_type", None)
57+
if field is not None:
58+
args["server_type"] = field
59+
else:
60+
args["server_type"] = None
61+
62+
field = data.get("fast_delivery_available", None)
63+
if field is not None:
64+
args["fast_delivery_available"] = field
65+
else:
66+
args["fast_delivery_available"] = None
67+
68+
return OSSupportedServerType(**args)
69+
70+
4671
def unmarshal_OS(data: Any) -> OS:
4772
if not isinstance(data, dict):
4873
raise TypeError(
@@ -99,6 +124,34 @@ def unmarshal_OS(data: Any) -> OS:
99124
else:
100125
args["xcode_version"] = None
101126

127+
field = data.get("release_notes_url", None)
128+
if field is not None:
129+
args["release_notes_url"] = field
130+
else:
131+
args["release_notes_url"] = None
132+
133+
field = data.get("description", None)
134+
if field is not None:
135+
args["description"] = field
136+
else:
137+
args["description"] = None
138+
139+
field = data.get("tags", None)
140+
if field is not None:
141+
args["tags"] = field
142+
else:
143+
args["tags"] = []
144+
145+
field = data.get("supported_server_types", None)
146+
if field is not None:
147+
args["supported_server_types"] = (
148+
[unmarshal_OSSupportedServerType(v) for v in field]
149+
if field is not None
150+
else None
151+
)
152+
else:
153+
args["supported_server_types"] = []
154+
102155
field = data.get("compatible_server_types", None)
103156
if field is not None:
104157
args["compatible_server_types"] = field
@@ -131,6 +184,41 @@ def unmarshal_Commitment(data: Any) -> Commitment:
131184
return Commitment(**args)
132185

133186

187+
def unmarshal_RunnerConfiguration(data: Any) -> RunnerConfiguration:
188+
if not isinstance(data, dict):
189+
raise TypeError(
190+
"Unmarshalling the type 'RunnerConfiguration' failed as data isn't a dictionary."
191+
)
192+
193+
args: dict[str, Any] = {}
194+
195+
field = data.get("name", None)
196+
if field is not None:
197+
args["name"] = field
198+
else:
199+
args["name"] = None
200+
201+
field = data.get("url", None)
202+
if field is not None:
203+
args["url"] = field
204+
else:
205+
args["url"] = None
206+
207+
field = data.get("token", None)
208+
if field is not None:
209+
args["token"] = field
210+
else:
211+
args["token"] = None
212+
213+
field = data.get("provider", None)
214+
if field is not None:
215+
args["provider"] = field
216+
else:
217+
args["provider"] = None
218+
219+
return RunnerConfiguration(**args)
220+
221+
134222
def unmarshal_Server(data: Any) -> Server:
135223
if not isinstance(data, dict):
136224
raise TypeError(
@@ -261,12 +349,24 @@ def unmarshal_Server(data: Any) -> Server:
261349
else:
262350
args["public_bandwidth_bps"] = 0
263351

352+
field = data.get("tags", None)
353+
if field is not None:
354+
args["tags"] = field
355+
else:
356+
args["tags"] = []
357+
264358
field = data.get("commitment", None)
265359
if field is not None:
266360
args["commitment"] = unmarshal_Commitment(field)
267361
else:
268362
args["commitment"] = None
269363

364+
field = data.get("runner_configuration", None)
365+
if field is not None:
366+
args["runner_configuration"] = unmarshal_RunnerConfiguration(field)
367+
else:
368+
args["runner_configuration"] = None
369+
270370
return Server(**args)
271371

272372

@@ -864,6 +964,27 @@ def marshal_BatchCreateServersRequest(
864964
return output
865965

866966

967+
def marshal_RunnerConfiguration(
968+
request: RunnerConfiguration,
969+
defaults: ProfileDefaults,
970+
) -> dict[str, Any]:
971+
output: dict[str, Any] = {}
972+
973+
if request.name is not None:
974+
output["name"] = request.name
975+
976+
if request.url is not None:
977+
output["url"] = request.url
978+
979+
if request.token is not None:
980+
output["token"] = request.token
981+
982+
if request.provider is not None:
983+
output["provider"] = request.provider
984+
985+
return output
986+
987+
867988
def marshal_CreateServerRequest(
868989
request: CreateServerRequest,
869990
defaults: ProfileDefaults,
@@ -893,6 +1014,11 @@ def marshal_CreateServerRequest(
8931014
if request.commitment_type is not None:
8941015
output["commitment_type"] = request.commitment_type
8951016

1017+
if request.runner_configuration is not None:
1018+
output["runner_configuration"] = marshal_RunnerConfiguration(
1019+
request.runner_configuration, defaults
1020+
)
1021+
8961022
return output
8971023

8981024

@@ -934,6 +1060,11 @@ def marshal_ReinstallServerRequest(
9341060
if request.os_id is not None:
9351061
output["os_id"] = request.os_id
9361062

1063+
if request.runner_configuration is not None:
1064+
output["runner_configuration"] = marshal_RunnerConfiguration(
1065+
request.runner_configuration, defaults
1066+
)
1067+
9371068
return output
9381069

9391070

0 commit comments

Comments
 (0)