Skip to content

Commit 388285f

Browse files
authored
feat(document_db): align proto with rdb proto (#399)
1 parent abf3bf2 commit 388285f

File tree

8 files changed

+268
-20
lines changed

8 files changed

+268
-20
lines changed

scaleway-async/scaleway_async/document_db/v1beta1/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .types import Permission
1919
from .types import ReadReplicaStatus
2020
from .types import SnapshotStatus
21+
from .types import StorageClass
2122
from .types import VolumeType
2223
from .types import ACLRule
2324
from .types import ACLRuleRequest
@@ -67,7 +68,9 @@
6768
from .types import SetInstanceACLRulesResponse
6869
from .types import SetInstanceSettingsResponse
6970
from .types import Snapshot
71+
from .types import SnapshotVolumeType
7072
from .types import UpgradableVersion
73+
from .types import UpgradeInstanceRequestMajorUpgradeWorkflow
7174
from .types import User
7275
from .types import Volume
7376
from .content import INSTANCE_LOG_TRANSIENT_STATUSES
@@ -96,6 +99,7 @@
9699
"Permission",
97100
"ReadReplicaStatus",
98101
"SnapshotStatus",
102+
"StorageClass",
99103
"VolumeType",
100104
"ACLRule",
101105
"ACLRuleRequest",
@@ -145,7 +149,9 @@
145149
"SetInstanceACLRulesResponse",
146150
"SetInstanceSettingsResponse",
147151
"Snapshot",
152+
"SnapshotVolumeType",
148153
"UpgradableVersion",
154+
"UpgradeInstanceRequestMajorUpgradeWorkflow",
149155
"User",
150156
"Volume",
151157
"INSTANCE_LOG_TRANSIENT_STATUSES",

scaleway-async/scaleway_async/document_db/v1beta1/api.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
SetInstanceACLRulesResponse,
5959
SetInstanceSettingsResponse,
6060
Snapshot,
61+
UpgradeInstanceRequestMajorUpgradeWorkflow,
6162
User,
6263
UpgradeInstanceRequest,
6364
CreateInstanceRequest,
@@ -312,6 +313,9 @@ async def upgrade_instance(
312313
volume_size: Optional[int] = None,
313314
volume_type: Optional[VolumeType] = None,
314315
upgradable_version_id: Optional[str] = None,
316+
major_upgrade_workflow: Optional[
317+
UpgradeInstanceRequestMajorUpgradeWorkflow
318+
] = None,
315319
) -> Instance:
316320
"""
317321
Upgrade a Database Instance.
@@ -320,20 +324,23 @@ async def upgrade_instance(
320324
:param instance_id: UUID of the Database Instance you want to upgrade.
321325
:param node_type: Node type of the Database Instance you want to upgrade to.
322326
323-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
327+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
324328
:param enable_ha: Defines whether or not High Availability should be enabled on the Database Instance.
325329
326-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
330+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
327331
:param volume_size: Increase your Block volume size.
328332
329-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
333+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
330334
:param volume_type: Change your Database Instance storage type.
331335
332-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
336+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
333337
:param upgradable_version_id: Update your database engine to a newer version.
334338
This will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade.
335339
336-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
340+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
341+
:param major_upgrade_workflow: Upgrade your database engine to a new major version including instance endpoints.
342+
343+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
337344
:return: :class:`Instance <Instance>`
338345
339346
Usage:
@@ -359,6 +366,7 @@ async def upgrade_instance(
359366
volume_size=volume_size,
360367
volume_type=volume_type,
361368
upgradable_version_id=upgradable_version_id,
369+
major_upgrade_workflow=major_upgrade_workflow,
362370
),
363371
self.client,
364372
),

scaleway-async/scaleway_async/document_db/v1beta1/marshalling.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
SetInstanceACLRulesResponse,
6464
SetInstanceSettingsResponse,
6565
Snapshot,
66+
SnapshotVolumeType,
6667
UpgradableVersion,
68+
UpgradeInstanceRequestMajorUpgradeWorkflow,
6769
User,
6870
Volume,
6971
UpgradeInstanceRequest,
@@ -365,6 +367,9 @@ def unmarshal_NodeTypeVolumeType(data: Any) -> NodeTypeVolumeType:
365367
field = data.get("chunk_size", None)
366368
args["chunk_size"] = field
367369

370+
field = data.get("class", None)
371+
args["class_"] = field
372+
368373
field = data.get("description", None)
369374
args["description"] = field
370375

@@ -408,6 +413,23 @@ def unmarshal_ReadReplica(data: Any) -> ReadReplica:
408413
return ReadReplica(**args)
409414

410415

416+
def unmarshal_SnapshotVolumeType(data: Any) -> SnapshotVolumeType:
417+
if type(data) is not dict:
418+
raise TypeError(
419+
f"Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary."
420+
)
421+
422+
args: Dict[str, Any] = {}
423+
424+
field = data.get("class", None)
425+
args["class_"] = field
426+
427+
field = data.get("type", None)
428+
args["type_"] = field
429+
430+
return SnapshotVolumeType(**args)
431+
432+
411433
def unmarshal_UpgradableVersion(data: Any) -> UpgradableVersion:
412434
if type(data) is not dict:
413435
raise TypeError(
@@ -439,6 +461,9 @@ def unmarshal_Volume(data: Any) -> Volume:
439461

440462
args: Dict[str, Any] = {}
441463

464+
field = data.get("class", None)
465+
args["class_"] = field
466+
442467
field = data.get("size", None)
443468
args["size"] = field
444469

@@ -785,6 +810,11 @@ def unmarshal_Snapshot(data: Any) -> Snapshot:
785810
field = data.get("updated_at", None)
786811
args["updated_at"] = parser.isoparse(field) if type(field) is str else field
787812

813+
field = data.get("volume_type", None)
814+
args["volume_type"] = (
815+
unmarshal_SnapshotVolumeType(field) if field is not None else None
816+
)
817+
788818
return Snapshot(**args)
789819

790820

@@ -1300,6 +1330,21 @@ def marshal_ReadReplicaEndpointSpec(
13001330
return output
13011331

13021332

1333+
def marshal_UpgradeInstanceRequestMajorUpgradeWorkflow(
1334+
request: UpgradeInstanceRequestMajorUpgradeWorkflow,
1335+
defaults: ProfileDefaults,
1336+
) -> Dict[str, Any]:
1337+
output: Dict[str, Any] = {}
1338+
1339+
if request.upgradable_version_id is not None:
1340+
output["upgradable_version_id"] = request.upgradable_version_id
1341+
1342+
if request.with_endpoints is not None:
1343+
output["with_endpoints"] = request.with_endpoints
1344+
1345+
return output
1346+
1347+
13031348
def marshal_AddInstanceACLRulesRequest(
13041349
request: AddInstanceACLRulesRequest,
13051350
defaults: ProfileDefaults,
@@ -1709,6 +1754,14 @@ def marshal_UpgradeInstanceRequest(
17091754
if request.upgradable_version_id is not None
17101755
else None,
17111756
),
1757+
OneOfPossibility(
1758+
"major_upgrade_workflow",
1759+
marshal_UpgradeInstanceRequestMajorUpgradeWorkflow(
1760+
request.major_upgrade_workflow, defaults
1761+
)
1762+
if request.major_upgrade_workflow is not None
1763+
else None,
1764+
),
17121765
]
17131766
),
17141767
)

scaleway-async/scaleway_async/document_db/v1beta1/types.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,21 @@ def __str__(self) -> str:
216216
return str(self.value)
217217

218218

219+
class StorageClass(str, Enum, metaclass=StrEnumMeta):
220+
UNKNOWN_STORAGE_CLASS = "unknown_storage_class"
221+
LSSD = "lssd"
222+
BSSD = "bssd"
223+
SBS = "sbs"
224+
225+
def __str__(self) -> str:
226+
return str(self.value)
227+
228+
219229
class VolumeType(str, Enum, metaclass=StrEnumMeta):
220230
LSSD = "lssd"
221231
BSSD = "bssd"
232+
SBS_5K = "sbs_5k"
233+
SBS_15K = "sbs_15k"
222234

223235
def __str__(self) -> str:
224236
return str(self.value)
@@ -1150,6 +1162,11 @@ class NodeTypeVolumeType:
11501162
Minimum increment level for a Block Storage volume size.
11511163
"""
11521164

1165+
class_: StorageClass
1166+
"""
1167+
The storage class of the volume.
1168+
"""
1169+
11531170

11541171
@dataclass
11551172
class Privilege:
@@ -1342,12 +1359,24 @@ class Snapshot:
13421359
Source node type.
13431360
"""
13441361

1362+
volume_type: Optional[SnapshotVolumeType]
1363+
"""
1364+
Type of volume where data is stored (lssd, bssd or sbs).
1365+
"""
1366+
13451367
region: Region
13461368
"""
13471369
Region of this snapshot.
13481370
"""
13491371

13501372

1373+
@dataclass
1374+
class SnapshotVolumeType:
1375+
type_: VolumeType
1376+
1377+
class_: StorageClass
1378+
1379+
13511380
@dataclass
13521381
class UpgradableVersion:
13531382
id: str
@@ -1359,6 +1388,25 @@ class UpgradableVersion:
13591388
minor_version: str
13601389

13611390

1391+
@dataclass
1392+
class UpgradeInstanceRequestMajorUpgradeWorkflow:
1393+
"""
1394+
Upgrade instance request. major upgrade workflow.
1395+
"""
1396+
1397+
upgradable_version_id: str
1398+
"""
1399+
Update your database engine to a newer version.
1400+
This will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade.
1401+
"""
1402+
1403+
with_endpoints: bool
1404+
"""
1405+
Include endpoint during the migration.
1406+
At the end of the migration procedure this option let you migrate all your database endpoint to the upgraded instance.
1407+
"""
1408+
1409+
13621410
@dataclass
13631411
class User:
13641412
"""
@@ -1382,6 +1430,8 @@ class Volume:
13821430

13831431
size: int
13841432

1433+
class_: StorageClass
1434+
13851435

13861436
@dataclass
13871437
class ListDatabaseEnginesRequest:
@@ -1438,36 +1488,43 @@ class UpgradeInstanceRequest:
14381488
"""
14391489
Node type of the Database Instance you want to upgrade to.
14401490
1441-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
1491+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
14421492
"""
14431493

14441494
enable_ha: Optional[bool]
14451495
"""
14461496
Defines whether or not High Availability should be enabled on the Database Instance.
14471497
1448-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
1498+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
14491499
"""
14501500

14511501
volume_size: Optional[int]
14521502
"""
14531503
Increase your Block volume size.
14541504
1455-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
1505+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
14561506
"""
14571507

14581508
volume_type: Optional[VolumeType]
14591509
"""
14601510
Change your Database Instance storage type.
14611511
1462-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
1512+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
14631513
"""
14641514

14651515
upgradable_version_id: Optional[str]
14661516
"""
14671517
Update your database engine to a newer version.
14681518
This will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade.
14691519
1470-
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id' could be set.
1520+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
1521+
"""
1522+
1523+
major_upgrade_workflow: Optional[UpgradeInstanceRequestMajorUpgradeWorkflow]
1524+
"""
1525+
Upgrade your database engine to a new major version including instance endpoints.
1526+
1527+
One-of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow' could be set.
14711528
"""
14721529

14731530

scaleway/scaleway/document_db/v1beta1/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .types import Permission
1919
from .types import ReadReplicaStatus
2020
from .types import SnapshotStatus
21+
from .types import StorageClass
2122
from .types import VolumeType
2223
from .types import ACLRule
2324
from .types import ACLRuleRequest
@@ -67,7 +68,9 @@
6768
from .types import SetInstanceACLRulesResponse
6869
from .types import SetInstanceSettingsResponse
6970
from .types import Snapshot
71+
from .types import SnapshotVolumeType
7072
from .types import UpgradableVersion
73+
from .types import UpgradeInstanceRequestMajorUpgradeWorkflow
7174
from .types import User
7275
from .types import Volume
7376
from .content import INSTANCE_LOG_TRANSIENT_STATUSES
@@ -96,6 +99,7 @@
9699
"Permission",
97100
"ReadReplicaStatus",
98101
"SnapshotStatus",
102+
"StorageClass",
99103
"VolumeType",
100104
"ACLRule",
101105
"ACLRuleRequest",
@@ -145,7 +149,9 @@
145149
"SetInstanceACLRulesResponse",
146150
"SetInstanceSettingsResponse",
147151
"Snapshot",
152+
"SnapshotVolumeType",
148153
"UpgradableVersion",
154+
"UpgradeInstanceRequestMajorUpgradeWorkflow",
149155
"User",
150156
"Volume",
151157
"INSTANCE_LOG_TRANSIENT_STATUSES",

0 commit comments

Comments
 (0)