Skip to content

Commit 7cf8fe3

Browse files
authored
feat(baremetal): add GetDefaultPartitioningRequest (#665)
1 parent be02cbe commit 7cf8fe3

File tree

8 files changed

+1596
-0
lines changed

8 files changed

+1596
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from .types import ListSettingsRequestOrderBy
99
from .types import OfferStock
1010
from .types import OfferSubscriptionPeriod
11+
from .types import SchemaFilesystemFormat
12+
from .types import SchemaLogicalVolumeType
13+
from .types import SchemaPartitionLabel
14+
from .types import SchemaPoolType
15+
from .types import SchemaRAIDLevel
1116
from .types import ServerBootType
1217
from .types import ServerInstallStatus
1318
from .content import SERVER_INSTALL_TRANSIENT_STATUSES
@@ -18,11 +23,21 @@
1823
from .types import ServerStatus
1924
from .content import SERVER_TRANSIENT_STATUSES
2025
from .types import SettingType
26+
from .types import SchemaLogicalVolume
27+
from .types import SchemaPartition
28+
from .types import SchemaVolumeGroup
29+
from .types import SchemaPool
30+
from .types import SchemaDisk
31+
from .types import SchemaFilesystem
32+
from .types import SchemaLVM
33+
from .types import SchemaRAID
34+
from .types import SchemaZFS
2135
from .types import CertificationOption
2236
from .types import LicenseOption
2337
from .types import PrivateNetworkOption
2438
from .types import PublicBandwidthOption
2539
from .types import RemoteAccessOption
40+
from .types import Schema
2641
from .types import OSOSField
2742
from .types import CPU
2843
from .types import Disk
@@ -48,6 +63,7 @@
4863
from .types import DeleteOptionServerRequest
4964
from .types import DeleteServerRequest
5065
from .types import GetBMCAccessRequest
66+
from .types import GetDefaultPartitioningSchemaRequest
5167
from .types import GetOSRequest
5268
from .types import GetOfferRequest
5369
from .types import GetOptionRequest
@@ -81,6 +97,7 @@
8197
from .types import UpdateIPRequest
8298
from .types import UpdateServerRequest
8399
from .types import UpdateSettingRequest
100+
from .types import ValidatePartitioningSchemaRequest
84101
from .api import BaremetalV1API
85102
from .api import BaremetalV1PrivateNetworkAPI
86103

@@ -93,6 +110,11 @@
93110
"ListSettingsRequestOrderBy",
94111
"OfferStock",
95112
"OfferSubscriptionPeriod",
113+
"SchemaFilesystemFormat",
114+
"SchemaLogicalVolumeType",
115+
"SchemaPartitionLabel",
116+
"SchemaPoolType",
117+
"SchemaRAIDLevel",
96118
"ServerBootType",
97119
"ServerInstallStatus",
98120
"SERVER_INSTALL_TRANSIENT_STATUSES",
@@ -103,11 +125,21 @@
103125
"ServerStatus",
104126
"SERVER_TRANSIENT_STATUSES",
105127
"SettingType",
128+
"SchemaLogicalVolume",
129+
"SchemaPartition",
130+
"SchemaVolumeGroup",
131+
"SchemaPool",
132+
"SchemaDisk",
133+
"SchemaFilesystem",
134+
"SchemaLVM",
135+
"SchemaRAID",
136+
"SchemaZFS",
106137
"CertificationOption",
107138
"LicenseOption",
108139
"PrivateNetworkOption",
109140
"PublicBandwidthOption",
110141
"RemoteAccessOption",
142+
"Schema",
111143
"OSOSField",
112144
"CPU",
113145
"Disk",
@@ -133,6 +165,7 @@
133165
"DeleteOptionServerRequest",
134166
"DeleteServerRequest",
135167
"GetBMCAccessRequest",
168+
"GetDefaultPartitioningSchemaRequest",
136169
"GetOSRequest",
137170
"GetOfferRequest",
138171
"GetOptionRequest",
@@ -166,6 +199,7 @@
166199
"UpdateIPRequest",
167200
"UpdateServerRequest",
168201
"UpdateSettingRequest",
202+
"ValidatePartitioningSchemaRequest",
169203
"BaremetalV1API",
170204
"BaremetalV1PrivateNetworkAPI",
171205
]

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

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
PrivateNetworkApiAddServerPrivateNetworkRequest,
4242
PrivateNetworkApiSetServerPrivateNetworksRequest,
4343
RebootServerRequest,
44+
Schema,
4445
Server,
4546
ServerEvent,
4647
ServerPrivateNetwork,
@@ -51,11 +52,13 @@
5152
UpdateIPRequest,
5253
UpdateServerRequest,
5354
UpdateSettingRequest,
55+
ValidatePartitioningSchemaRequest,
5456
)
5557
from .content import (
5658
SERVER_TRANSIENT_STATUSES,
5759
)
5860
from .marshalling import (
61+
unmarshal_Schema,
5962
unmarshal_IP,
6063
unmarshal_OS,
6164
unmarshal_Offer,
@@ -84,6 +87,7 @@
8487
marshal_UpdateIPRequest,
8588
marshal_UpdateServerRequest,
8689
marshal_UpdateSettingRequest,
90+
marshal_ValidatePartitioningSchemaRequest,
8791
)
8892

8993

@@ -709,6 +713,87 @@ async def list_server_events_all(
709713
},
710714
)
711715

716+
async def get_default_partitioning_schema(
717+
self,
718+
*,
719+
offer_id: str,
720+
os_id: str,
721+
zone: Optional[Zone] = None,
722+
) -> Schema:
723+
"""
724+
Get default partitioning schema.
725+
Get the default partitioning schema for the given offer ID and OS ID.
726+
:param offer_id: ID of the offer.
727+
:param os_id: ID of the OS.
728+
:param zone: Zone to target. If none is passed will use default zone from the config.
729+
:return: :class:`Schema <Schema>`
730+
731+
Usage:
732+
::
733+
734+
result = await api.get_default_partitioning_schema(
735+
offer_id="example",
736+
os_id="example",
737+
)
738+
"""
739+
740+
param_zone = validate_path_param("zone", zone or self.client.default_zone)
741+
742+
res = self._request(
743+
"GET",
744+
f"/baremetal/v1/zones/{param_zone}/partitioning-schemas/default",
745+
params={
746+
"offer_id": offer_id,
747+
"os_id": os_id,
748+
},
749+
)
750+
751+
self._throw_on_error(res)
752+
return unmarshal_Schema(res.json())
753+
754+
async def validate_partitioning_schema(
755+
self,
756+
*,
757+
offer_id: str,
758+
os_id: str,
759+
zone: Optional[Zone] = None,
760+
partitioning_schema: Optional[Schema] = None,
761+
) -> None:
762+
"""
763+
Validate client partitioning schema.
764+
Validate the incoming partitioning schema from a user before installing the server. Return default ErrorCode if invalid.
765+
:param offer_id: Offer ID of the server.
766+
:param os_id: OS ID.
767+
:param zone: Zone to target. If none is passed will use default zone from the config.
768+
:param partitioning_schema: Partitioning schema.
769+
770+
Usage:
771+
::
772+
773+
result = await api.validate_partitioning_schema(
774+
offer_id="example",
775+
os_id="example",
776+
)
777+
"""
778+
779+
param_zone = validate_path_param("zone", zone or self.client.default_zone)
780+
781+
res = self._request(
782+
"POST",
783+
f"/baremetal/v1/zones/{param_zone}/partitioning-schemas/validate",
784+
body=marshal_ValidatePartitioningSchemaRequest(
785+
ValidatePartitioningSchemaRequest(
786+
offer_id=offer_id,
787+
os_id=os_id,
788+
zone=zone,
789+
partitioning_schema=partitioning_schema,
790+
),
791+
self.client,
792+
),
793+
)
794+
795+
self._throw_on_error(res)
796+
712797
async def start_bmc_access(
713798
self,
714799
*,

0 commit comments

Comments
 (0)