Skip to content

Commit a9f7545

Browse files
authored
feat(baremetal): add OptionType and ExtraOptionVars (#654)
1 parent a455ce0 commit a9f7545

File tree

6 files changed

+448
-2
lines changed

6 files changed

+448
-2
lines changed

scaleway-async/scaleway_async/baremetal/v1/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
from .types import ServerStatus
1919
from .content import SERVER_TRANSIENT_STATUSES
2020
from .types import SettingType
21+
from .types import CertificationOption
22+
from .types import LicenseOption
23+
from .types import PrivateNetworkOption
24+
from .types import PublicBandwidthOption
25+
from .types import RemoteAccessOption
2126
from .types import OSOSField
2227
from .types import CPU
2328
from .types import Disk
@@ -98,6 +103,11 @@
98103
"ServerStatus",
99104
"SERVER_TRANSIENT_STATUSES",
100105
"SettingType",
106+
"CertificationOption",
107+
"LicenseOption",
108+
"PrivateNetworkOption",
109+
"PublicBandwidthOption",
110+
"RemoteAccessOption",
101111
"OSOSField",
102112
"CPU",
103113
"Disk",

scaleway-async/scaleway_async/baremetal/v1/marshalling.py

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
IP,
1818
OSOSField,
1919
OS,
20+
CertificationOption,
21+
LicenseOption,
22+
PrivateNetworkOption,
23+
PublicBandwidthOption,
24+
RemoteAccessOption,
2025
CPU,
2126
Disk,
2227
Memory,
@@ -190,6 +195,69 @@ def unmarshal_OS(data: Any) -> OS:
190195
return OS(**args)
191196

192197

198+
def unmarshal_CertificationOption(data: Any) -> CertificationOption:
199+
if not isinstance(data, dict):
200+
raise TypeError(
201+
"Unmarshalling the type 'CertificationOption' failed as data isn't a dictionary."
202+
)
203+
204+
args: Dict[str, Any] = {}
205+
206+
return CertificationOption(**args)
207+
208+
209+
def unmarshal_LicenseOption(data: Any) -> LicenseOption:
210+
if not isinstance(data, dict):
211+
raise TypeError(
212+
"Unmarshalling the type 'LicenseOption' failed as data isn't a dictionary."
213+
)
214+
215+
args: Dict[str, Any] = {}
216+
217+
field = data.get("os_id", None)
218+
if field is not None:
219+
args["os_id"] = field
220+
221+
return LicenseOption(**args)
222+
223+
224+
def unmarshal_PrivateNetworkOption(data: Any) -> PrivateNetworkOption:
225+
if not isinstance(data, dict):
226+
raise TypeError(
227+
"Unmarshalling the type 'PrivateNetworkOption' failed as data isn't a dictionary."
228+
)
229+
230+
args: Dict[str, Any] = {}
231+
232+
return PrivateNetworkOption(**args)
233+
234+
235+
def unmarshal_PublicBandwidthOption(data: Any) -> PublicBandwidthOption:
236+
if not isinstance(data, dict):
237+
raise TypeError(
238+
"Unmarshalling the type 'PublicBandwidthOption' failed as data isn't a dictionary."
239+
)
240+
241+
args: Dict[str, Any] = {}
242+
243+
field = data.get("bandwidth_in_bps", None)
244+
if field is not None:
245+
args["bandwidth_in_bps"] = field
246+
247+
return PublicBandwidthOption(**args)
248+
249+
250+
def unmarshal_RemoteAccessOption(data: Any) -> RemoteAccessOption:
251+
if not isinstance(data, dict):
252+
raise TypeError(
253+
"Unmarshalling the type 'RemoteAccessOption' failed as data isn't a dictionary."
254+
)
255+
256+
args: Dict[str, Any] = {}
257+
258+
return RemoteAccessOption(**args)
259+
260+
193261
def unmarshal_CPU(data: Any) -> CPU:
194262
if not isinstance(data, dict):
195263
raise TypeError(
@@ -307,6 +375,36 @@ def unmarshal_OfferOptionOffer(data: Any) -> OfferOptionOffer:
307375
else:
308376
args["os_id"] = None
309377

378+
field = data.get("license", None)
379+
if field is not None:
380+
args["license"] = unmarshal_LicenseOption(field)
381+
else:
382+
args["license"] = None
383+
384+
field = data.get("public_bandwidth", None)
385+
if field is not None:
386+
args["public_bandwidth"] = unmarshal_PublicBandwidthOption(field)
387+
else:
388+
args["public_bandwidth"] = None
389+
390+
field = data.get("private_network", None)
391+
if field is not None:
392+
args["private_network"] = unmarshal_PrivateNetworkOption(field)
393+
else:
394+
args["private_network"] = None
395+
396+
field = data.get("remote_access", None)
397+
if field is not None:
398+
args["remote_access"] = unmarshal_RemoteAccessOption(field)
399+
else:
400+
args["remote_access"] = None
401+
402+
field = data.get("certification", None)
403+
if field is not None:
404+
args["certification"] = unmarshal_CertificationOption(field)
405+
else:
406+
args["certification"] = None
407+
310408
return OfferOptionOffer(**args)
311409

312410

@@ -495,6 +593,36 @@ def unmarshal_Option(data: Any) -> Option:
495593
if field is not None:
496594
args["manageable"] = field
497595

596+
field = data.get("license", None)
597+
if field is not None:
598+
args["license"] = unmarshal_LicenseOption(field)
599+
else:
600+
args["license"] = None
601+
602+
field = data.get("public_bandwidth", None)
603+
if field is not None:
604+
args["public_bandwidth"] = unmarshal_PublicBandwidthOption(field)
605+
else:
606+
args["public_bandwidth"] = None
607+
608+
field = data.get("private_network", None)
609+
if field is not None:
610+
args["private_network"] = unmarshal_PrivateNetworkOption(field)
611+
else:
612+
args["private_network"] = None
613+
614+
field = data.get("remote_access", None)
615+
if field is not None:
616+
args["remote_access"] = unmarshal_RemoteAccessOption(field)
617+
else:
618+
args["remote_access"] = None
619+
620+
field = data.get("certification", None)
621+
if field is not None:
622+
args["certification"] = unmarshal_CertificationOption(field)
623+
else:
624+
args["certification"] = None
625+
498626
return Option(**args)
499627

500628

@@ -616,6 +744,36 @@ def unmarshal_ServerOption(data: Any) -> ServerOption:
616744
else:
617745
args["expires_at"] = None
618746

747+
field = data.get("license", None)
748+
if field is not None:
749+
args["license"] = unmarshal_LicenseOption(field)
750+
else:
751+
args["license"] = None
752+
753+
field = data.get("public_bandwidth", None)
754+
if field is not None:
755+
args["public_bandwidth"] = unmarshal_PublicBandwidthOption(field)
756+
else:
757+
args["public_bandwidth"] = None
758+
759+
field = data.get("private_network", None)
760+
if field is not None:
761+
args["private_network"] = unmarshal_PrivateNetworkOption(field)
762+
else:
763+
args["private_network"] = None
764+
765+
field = data.get("remote_access", None)
766+
if field is not None:
767+
args["remote_access"] = unmarshal_RemoteAccessOption(field)
768+
else:
769+
args["remote_access"] = None
770+
771+
field = data.get("certification", None)
772+
if field is not None:
773+
args["certification"] = unmarshal_CertificationOption(field)
774+
else:
775+
args["certification"] = None
776+
619777
return ServerOption(**args)
620778

621779

scaleway-async/scaleway_async/baremetal/v1/types.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,31 @@ def __str__(self) -> str:
165165
return str(self.value)
166166

167167

168+
@dataclass
169+
class CertificationOption:
170+
pass
171+
172+
173+
@dataclass
174+
class LicenseOption:
175+
os_id: str
176+
177+
178+
@dataclass
179+
class PrivateNetworkOption:
180+
pass
181+
182+
183+
@dataclass
184+
class PublicBandwidthOption:
185+
bandwidth_in_bps: int
186+
187+
188+
@dataclass
189+
class RemoteAccessOption:
190+
pass
191+
192+
168193
@dataclass
169194
class OSOSField:
170195
editable: bool
@@ -273,9 +298,19 @@ class OfferOptionOffer:
273298

274299
os_id: Optional[str]
275300
"""
276-
ID of the OS linked to the option.
301+
Deprecated, use LicenseOptionVars.os_id instead.
277302
"""
278303

304+
license: Optional[LicenseOption]
305+
306+
public_bandwidth: Optional[PublicBandwidthOption]
307+
308+
private_network: Optional[PrivateNetworkOption]
309+
310+
remote_access: Optional[RemoteAccessOption]
311+
312+
certification: Optional[CertificationOption]
313+
279314

280315
@dataclass
281316
class PersistentMemory:
@@ -400,6 +435,16 @@ class ServerOption:
400435
Auto expiration date for compatible options.
401436
"""
402437

438+
license: Optional[LicenseOption]
439+
440+
public_bandwidth: Optional[PublicBandwidthOption]
441+
442+
private_network: Optional[PrivateNetworkOption]
443+
444+
remote_access: Optional[RemoteAccessOption]
445+
446+
certification: Optional[CertificationOption]
447+
403448

404449
@dataclass
405450
class ServerRescueServer:
@@ -655,6 +700,16 @@ class Option:
655700
Defines whether the option is manageable (could be added or removed).
656701
"""
657702

703+
license: Optional[LicenseOption]
704+
705+
public_bandwidth: Optional[PublicBandwidthOption]
706+
707+
private_network: Optional[PrivateNetworkOption]
708+
709+
remote_access: Optional[RemoteAccessOption]
710+
711+
certification: Optional[CertificationOption]
712+
658713

659714
@dataclass
660715
class ServerEvent:

scaleway/scaleway/baremetal/v1/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
from .types import ServerStatus
1919
from .content import SERVER_TRANSIENT_STATUSES
2020
from .types import SettingType
21+
from .types import CertificationOption
22+
from .types import LicenseOption
23+
from .types import PrivateNetworkOption
24+
from .types import PublicBandwidthOption
25+
from .types import RemoteAccessOption
2126
from .types import OSOSField
2227
from .types import CPU
2328
from .types import Disk
@@ -98,6 +103,11 @@
98103
"ServerStatus",
99104
"SERVER_TRANSIENT_STATUSES",
100105
"SettingType",
106+
"CertificationOption",
107+
"LicenseOption",
108+
"PrivateNetworkOption",
109+
"PublicBandwidthOption",
110+
"RemoteAccessOption",
101111
"OSOSField",
102112
"CPU",
103113
"Disk",

0 commit comments

Comments
 (0)