Skip to content

Commit ecc83b7

Browse files
authored
feat(baremetal): add gpu in offer (#712)
1 parent 6e9559f commit ecc83b7

File tree

6 files changed

+124
-36
lines changed

6 files changed

+124
-36
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from .types import OSOSField
3838
from .types import CPU
3939
from .types import Disk
40+
from .types import GPU
4041
from .types import Memory
4142
from .types import OfferOptionOffer
4243
from .types import PersistentMemory
@@ -135,6 +136,7 @@
135136
"OSOSField",
136137
"CPU",
137138
"Disk",
139+
"GPU",
138140
"Memory",
139141
"OfferOptionOffer",
140142
"PersistentMemory",

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

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
RemoteAccessOption,
3232
CPU,
3333
Disk,
34+
GPU,
3435
Memory,
3536
OfferOptionOffer,
3637
PersistentMemory,
@@ -495,6 +496,25 @@ def unmarshal_Disk(data: Any) -> Disk:
495496
return Disk(**args)
496497

497498

499+
def unmarshal_GPU(data: Any) -> GPU:
500+
if not isinstance(data, dict):
501+
raise TypeError(
502+
"Unmarshalling the type 'GPU' failed as data isn't a dictionary."
503+
)
504+
505+
args: Dict[str, Any] = {}
506+
507+
field = data.get("name", None)
508+
if field is not None:
509+
args["name"] = field
510+
511+
field = data.get("vram", None)
512+
if field is not None:
513+
args["vram"] = field
514+
515+
return GPU(**args)
516+
517+
498518
def unmarshal_Memory(data: Any) -> Memory:
499519
if not isinstance(data, dict):
500520
raise TypeError(
@@ -679,6 +699,16 @@ def unmarshal_Offer(data: Any) -> Offer:
679699
if field is not None:
680700
args["enable"] = field
681701

702+
field = data.get("cpus", None)
703+
if field is not None:
704+
args["cpus"] = [unmarshal_CPU(v) for v in field] if field is not None else None
705+
706+
field = data.get("memories", None)
707+
if field is not None:
708+
args["memories"] = (
709+
[unmarshal_Memory(v) for v in field] if field is not None else None
710+
)
711+
682712
field = data.get("price_per_hour", None)
683713
if field is not None:
684714
args["price_per_hour"] = unmarshal_Money(field)
@@ -691,16 +721,6 @@ def unmarshal_Offer(data: Any) -> Offer:
691721
else:
692722
args["price_per_month"] = None
693723

694-
field = data.get("cpus", None)
695-
if field is not None:
696-
args["cpus"] = [unmarshal_CPU(v) for v in field] if field is not None else None
697-
698-
field = data.get("memories", None)
699-
if field is not None:
700-
args["memories"] = (
701-
[unmarshal_Memory(v) for v in field] if field is not None else None
702-
)
703-
704724
field = data.get("quota_name", None)
705725
if field is not None:
706726
args["quota_name"] = field
@@ -751,6 +771,10 @@ def unmarshal_Offer(data: Any) -> Offer:
751771
if field is not None:
752772
args["tags"] = field
753773

774+
field = data.get("gpus", None)
775+
if field is not None:
776+
args["gpus"] = [unmarshal_GPU(v) for v in field] if field is not None else None
777+
754778
field = data.get("fee", None)
755779
if field is not None:
756780
args["fee"] = unmarshal_Money(field)

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

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,19 @@ class Disk:
354354
"""
355355

356356

357+
@dataclass
358+
class GPU:
359+
name: str
360+
"""
361+
Name of the GPU.
362+
"""
363+
364+
vram: int
365+
"""
366+
Capacity of the vram in bytes.
367+
"""
368+
369+
357370
@dataclass
358371
class Memory:
359372
capacity: int
@@ -731,24 +744,24 @@ class Offer:
731744
Defines whether the offer is currently available.
732745
"""
733746

734-
price_per_hour: Optional[Money]
747+
cpus: List[CPU]
735748
"""
736-
Price of the offer for the next 60 minutes (a server order at 11h32 will be payed until 12h32).
749+
CPU specifications of the offer.
737750
"""
738751

739-
price_per_month: Optional[Money]
752+
memories: List[Memory]
740753
"""
741-
Monthly price of the offer, if subscribing on a monthly basis.
754+
Memory specifications of the offer.
742755
"""
743756

744-
cpus: List[CPU]
757+
price_per_hour: Optional[Money]
745758
"""
746-
CPU specifications of the offer.
759+
Price of the offer for the next 60 minutes (a server order at 11h32 will be payed until 12h32).
747760
"""
748761

749-
memories: List[Memory]
762+
price_per_month: Optional[Money]
750763
"""
751-
Memory specifications of the offer.
764+
Monthly price of the offer, if subscribing on a monthly basis.
752765
"""
753766

754767
quota_name: str
@@ -801,6 +814,11 @@ class Offer:
801814
Array of tags attached to the offer.
802815
"""
803816

817+
gpus: List[GPU]
818+
"""
819+
GPU specifications of the offer.
820+
"""
821+
804822
fee: Optional[Money]
805823
"""
806824
One time fee invoiced by Scaleway for the setup and activation of the server.

scaleway/scaleway/baremetal/v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from .types import OSOSField
3838
from .types import CPU
3939
from .types import Disk
40+
from .types import GPU
4041
from .types import Memory
4142
from .types import OfferOptionOffer
4243
from .types import PersistentMemory
@@ -135,6 +136,7 @@
135136
"OSOSField",
136137
"CPU",
137138
"Disk",
139+
"GPU",
138140
"Memory",
139141
"OfferOptionOffer",
140142
"PersistentMemory",

scaleway/scaleway/baremetal/v1/marshalling.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
RemoteAccessOption,
3232
CPU,
3333
Disk,
34+
GPU,
3435
Memory,
3536
OfferOptionOffer,
3637
PersistentMemory,
@@ -495,6 +496,25 @@ def unmarshal_Disk(data: Any) -> Disk:
495496
return Disk(**args)
496497

497498

499+
def unmarshal_GPU(data: Any) -> GPU:
500+
if not isinstance(data, dict):
501+
raise TypeError(
502+
"Unmarshalling the type 'GPU' failed as data isn't a dictionary."
503+
)
504+
505+
args: Dict[str, Any] = {}
506+
507+
field = data.get("name", None)
508+
if field is not None:
509+
args["name"] = field
510+
511+
field = data.get("vram", None)
512+
if field is not None:
513+
args["vram"] = field
514+
515+
return GPU(**args)
516+
517+
498518
def unmarshal_Memory(data: Any) -> Memory:
499519
if not isinstance(data, dict):
500520
raise TypeError(
@@ -679,6 +699,16 @@ def unmarshal_Offer(data: Any) -> Offer:
679699
if field is not None:
680700
args["enable"] = field
681701

702+
field = data.get("cpus", None)
703+
if field is not None:
704+
args["cpus"] = [unmarshal_CPU(v) for v in field] if field is not None else None
705+
706+
field = data.get("memories", None)
707+
if field is not None:
708+
args["memories"] = (
709+
[unmarshal_Memory(v) for v in field] if field is not None else None
710+
)
711+
682712
field = data.get("price_per_hour", None)
683713
if field is not None:
684714
args["price_per_hour"] = unmarshal_Money(field)
@@ -691,16 +721,6 @@ def unmarshal_Offer(data: Any) -> Offer:
691721
else:
692722
args["price_per_month"] = None
693723

694-
field = data.get("cpus", None)
695-
if field is not None:
696-
args["cpus"] = [unmarshal_CPU(v) for v in field] if field is not None else None
697-
698-
field = data.get("memories", None)
699-
if field is not None:
700-
args["memories"] = (
701-
[unmarshal_Memory(v) for v in field] if field is not None else None
702-
)
703-
704724
field = data.get("quota_name", None)
705725
if field is not None:
706726
args["quota_name"] = field
@@ -751,6 +771,10 @@ def unmarshal_Offer(data: Any) -> Offer:
751771
if field is not None:
752772
args["tags"] = field
753773

774+
field = data.get("gpus", None)
775+
if field is not None:
776+
args["gpus"] = [unmarshal_GPU(v) for v in field] if field is not None else None
777+
754778
field = data.get("fee", None)
755779
if field is not None:
756780
args["fee"] = unmarshal_Money(field)

scaleway/scaleway/baremetal/v1/types.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,19 @@ class Disk:
354354
"""
355355

356356

357+
@dataclass
358+
class GPU:
359+
name: str
360+
"""
361+
Name of the GPU.
362+
"""
363+
364+
vram: int
365+
"""
366+
Capacity of the vram in bytes.
367+
"""
368+
369+
357370
@dataclass
358371
class Memory:
359372
capacity: int
@@ -731,24 +744,24 @@ class Offer:
731744
Defines whether the offer is currently available.
732745
"""
733746

734-
price_per_hour: Optional[Money]
747+
cpus: List[CPU]
735748
"""
736-
Price of the offer for the next 60 minutes (a server order at 11h32 will be payed until 12h32).
749+
CPU specifications of the offer.
737750
"""
738751

739-
price_per_month: Optional[Money]
752+
memories: List[Memory]
740753
"""
741-
Monthly price of the offer, if subscribing on a monthly basis.
754+
Memory specifications of the offer.
742755
"""
743756

744-
cpus: List[CPU]
757+
price_per_hour: Optional[Money]
745758
"""
746-
CPU specifications of the offer.
759+
Price of the offer for the next 60 minutes (a server order at 11h32 will be payed until 12h32).
747760
"""
748761

749-
memories: List[Memory]
762+
price_per_month: Optional[Money]
750763
"""
751-
Memory specifications of the offer.
764+
Monthly price of the offer, if subscribing on a monthly basis.
752765
"""
753766

754767
quota_name: str
@@ -801,6 +814,11 @@ class Offer:
801814
Array of tags attached to the offer.
802815
"""
803816

817+
gpus: List[GPU]
818+
"""
819+
GPU specifications of the offer.
820+
"""
821+
804822
fee: Optional[Money]
805823
"""
806824
One time fee invoiced by Scaleway for the setup and activation of the server.

0 commit comments

Comments
 (0)