Skip to content

Commit 6fb5de5

Browse files
committed
feat: update generated APIs
1 parent fb338d1 commit 6fb5de5

File tree

10 files changed

+450
-20
lines changed

10 files changed

+450
-20
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# If you have any remark or suggestion do not hesitate to open an issue.
33
from .types import InstanceStatus
44
from .content import INSTANCE_TRANSIENT_STATUSES
5+
from .types import ListDatabasesRequestOrderBy
56
from .types import ListInstancesRequestOrderBy
67
from .types import ListSnapshotsRequestOrderBy
78
from .types import ListUsersRequestOrderBy
@@ -20,6 +21,7 @@
2021
from .types import NodeTypeVolumeType
2122
from .types import UserRole
2223
from .types import EndpointSpec
24+
from .types import Database
2325
from .types import Instance
2426
from .types import NodeType
2527
from .types import Snapshot
@@ -36,6 +38,8 @@
3638
from .types import GetInstanceCertificateRequest
3739
from .types import GetInstanceRequest
3840
from .types import GetSnapshotRequest
41+
from .types import ListDatabasesRequest
42+
from .types import ListDatabasesResponse
3943
from .types import ListInstancesRequest
4044
from .types import ListInstancesResponse
4145
from .types import ListNodeTypesRequest
@@ -57,6 +61,7 @@
5761
__all__ = [
5862
"InstanceStatus",
5963
"INSTANCE_TRANSIENT_STATUSES",
64+
"ListDatabasesRequestOrderBy",
6065
"ListInstancesRequestOrderBy",
6166
"ListSnapshotsRequestOrderBy",
6267
"ListUsersRequestOrderBy",
@@ -75,6 +80,7 @@
7580
"NodeTypeVolumeType",
7681
"UserRole",
7782
"EndpointSpec",
83+
"Database",
7884
"Instance",
7985
"NodeType",
8086
"Snapshot",
@@ -91,6 +97,8 @@
9197
"GetInstanceCertificateRequest",
9298
"GetInstanceRequest",
9399
"GetSnapshotRequest",
100+
"ListDatabasesRequest",
101+
"ListDatabasesResponse",
94102
"ListInstancesRequest",
95103
"ListInstancesResponse",
96104
"ListNodeTypesRequest",

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
wait_for_resource_async,
1919
)
2020
from .types import (
21+
ListDatabasesRequestOrderBy,
2122
ListInstancesRequestOrderBy,
2223
ListSnapshotsRequestOrderBy,
2324
ListUsersRequestOrderBy,
@@ -26,9 +27,11 @@
2627
CreateInstanceRequest,
2728
CreateSnapshotRequest,
2829
CreateUserRequest,
30+
Database,
2931
Endpoint,
3032
EndpointSpec,
3133
Instance,
34+
ListDatabasesResponse,
3235
ListInstancesResponse,
3336
ListNodeTypesResponse,
3437
ListSnapshotsResponse,
@@ -56,6 +59,7 @@
5659
unmarshal_Instance,
5760
unmarshal_Snapshot,
5861
unmarshal_User,
62+
unmarshal_ListDatabasesResponse,
5963
unmarshal_ListInstancesResponse,
6064
unmarshal_ListNodeTypesResponse,
6165
unmarshal_ListSnapshotsResponse,
@@ -1269,6 +1273,91 @@ async def set_user_role(
12691273
self._throw_on_error(res)
12701274
return unmarshal_User(res.json())
12711275

1276+
async def list_databases(
1277+
self,
1278+
*,
1279+
instance_id: str,
1280+
region: Optional[ScwRegion] = None,
1281+
order_by: Optional[ListDatabasesRequestOrderBy] = None,
1282+
page: Optional[int] = None,
1283+
page_size: Optional[int] = None,
1284+
) -> ListDatabasesResponse:
1285+
"""
1286+
List databases in a Database Instance.
1287+
List all databases of a given Database Instance.
1288+
:param instance_id: UUID of the Database Instance.
1289+
:param region: Region to target. If none is passed will use default region from the config.
1290+
:param order_by: Criteria to use when requesting user listing.
1291+
:param page:
1292+
:param page_size:
1293+
:return: :class:`ListDatabasesResponse <ListDatabasesResponse>`
1294+
1295+
Usage:
1296+
::
1297+
1298+
result = await api.list_databases(
1299+
instance_id="example",
1300+
)
1301+
"""
1302+
1303+
param_region = validate_path_param(
1304+
"region", region or self.client.default_region
1305+
)
1306+
param_instance_id = validate_path_param("instance_id", instance_id)
1307+
1308+
res = self._request(
1309+
"GET",
1310+
f"/mongodb/v1/regions/{param_region}/instances/{param_instance_id}/databases",
1311+
params={
1312+
"order_by": order_by,
1313+
"page": page,
1314+
"page_size": page_size or self.client.default_page_size,
1315+
},
1316+
)
1317+
1318+
self._throw_on_error(res)
1319+
return unmarshal_ListDatabasesResponse(res.json())
1320+
1321+
async def list_databases_all(
1322+
self,
1323+
*,
1324+
instance_id: str,
1325+
region: Optional[ScwRegion] = None,
1326+
order_by: Optional[ListDatabasesRequestOrderBy] = None,
1327+
page: Optional[int] = None,
1328+
page_size: Optional[int] = None,
1329+
) -> List[Database]:
1330+
"""
1331+
List databases in a Database Instance.
1332+
List all databases of a given Database Instance.
1333+
:param instance_id: UUID of the Database Instance.
1334+
:param region: Region to target. If none is passed will use default region from the config.
1335+
:param order_by: Criteria to use when requesting user listing.
1336+
:param page:
1337+
:param page_size:
1338+
:return: :class:`List[Database] <List[Database]>`
1339+
1340+
Usage:
1341+
::
1342+
1343+
result = await api.list_databases_all(
1344+
instance_id="example",
1345+
)
1346+
"""
1347+
1348+
return await fetch_all_pages_async(
1349+
type=ListDatabasesResponse,
1350+
key="databases",
1351+
fetcher=self.list_databases,
1352+
args={
1353+
"instance_id": instance_id,
1354+
"region": region,
1355+
"order_by": order_by,
1356+
"page": page,
1357+
"page_size": page_size,
1358+
},
1359+
)
1360+
12721361
async def delete_endpoint(
12731362
self,
12741363
*,

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

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
Snapshot,
2020
UserRole,
2121
User,
22+
Database,
23+
ListDatabasesResponse,
2224
ListInstancesResponse,
2325
NodeTypeVolumeType,
2426
NodeType,
@@ -350,6 +352,42 @@ def unmarshal_User(data: Any) -> User:
350352
return User(**args)
351353

352354

355+
def unmarshal_Database(data: Any) -> Database:
356+
if not isinstance(data, dict):
357+
raise TypeError(
358+
"Unmarshalling the type 'Database' failed as data isn't a dictionary."
359+
)
360+
361+
args: Dict[str, Any] = {}
362+
363+
field = data.get("name", None)
364+
if field is not None:
365+
args["name"] = field
366+
367+
return Database(**args)
368+
369+
370+
def unmarshal_ListDatabasesResponse(data: Any) -> ListDatabasesResponse:
371+
if not isinstance(data, dict):
372+
raise TypeError(
373+
"Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary."
374+
)
375+
376+
args: Dict[str, Any] = {}
377+
378+
field = data.get("databases", None)
379+
if field is not None:
380+
args["databases"] = (
381+
[unmarshal_Database(v) for v in field] if field is not None else None
382+
)
383+
384+
field = data.get("total_count", None)
385+
if field is not None:
386+
args["total_count"] = field
387+
388+
return ListDatabasesResponse(**args)
389+
390+
353391
def unmarshal_ListInstancesResponse(data: Any) -> ListInstancesResponse:
354392
if not isinstance(data, dict):
355393
raise TypeError(
@@ -589,8 +627,16 @@ def marshal_EndpointSpec(
589627
output.update(
590628
resolve_one_of(
591629
[
592-
OneOfPossibility("public_network", request.public_network),
593-
OneOfPossibility("private_network", request.private_network),
630+
OneOfPossibility(
631+
param="public_network",
632+
value=request.public_network,
633+
marshal_func=marshal_EndpointSpecPublicNetworkDetails,
634+
),
635+
OneOfPossibility(
636+
param="private_network",
637+
value=request.private_network,
638+
marshal_func=marshal_EndpointSpecPrivateNetworkDetails,
639+
),
594640
]
595641
),
596642
)
@@ -731,8 +777,14 @@ def marshal_UserRole(
731777
output.update(
732778
resolve_one_of(
733779
[
734-
OneOfPossibility("database_name", request.database_name),
735-
OneOfPossibility("any_database", request.any_database),
780+
OneOfPossibility(
781+
param="database_name",
782+
value=request.database_name,
783+
marshal_func=None,
784+
),
785+
OneOfPossibility(
786+
param="any_database", value=request.any_database, marshal_func=None
787+
),
736788
]
737789
),
738790
)
@@ -821,7 +873,11 @@ def marshal_UpgradeInstanceRequest(
821873
output.update(
822874
resolve_one_of(
823875
[
824-
OneOfPossibility("volume_size_bytes", request.volume_size_bytes),
876+
OneOfPossibility(
877+
param="volume_size_bytes",
878+
value=request.volume_size_bytes,
879+
marshal_func=None,
880+
),
825881
]
826882
),
827883
)

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ def __str__(self) -> str:
3030
return str(self.value)
3131

3232

33+
class ListDatabasesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
34+
NAME_ASC = "name_asc"
35+
NAME_DESC = "name_desc"
36+
37+
def __str__(self) -> str:
38+
return str(self.value)
39+
40+
3341
class ListInstancesRequestOrderBy(str, Enum, metaclass=StrEnumMeta):
3442
CREATED_AT_ASC = "created_at_asc"
3543
CREATED_AT_DESC = "created_at_desc"
@@ -234,6 +242,11 @@ class EndpointSpec:
234242
private_network: Optional[EndpointSpecPrivateNetworkDetails]
235243

236244

245+
@dataclass
246+
class Database:
247+
name: str
248+
249+
237250
@dataclass
238251
class Instance:
239252
id: str
@@ -662,6 +675,41 @@ class GetSnapshotRequest:
662675
"""
663676

664677

678+
@dataclass
679+
class ListDatabasesRequest:
680+
instance_id: str
681+
"""
682+
UUID of the Database Instance.
683+
"""
684+
685+
region: Optional[ScwRegion]
686+
"""
687+
Region to target. If none is passed will use default region from the config.
688+
"""
689+
690+
order_by: Optional[ListDatabasesRequestOrderBy]
691+
"""
692+
Criteria to use when requesting user listing.
693+
"""
694+
695+
page: Optional[int]
696+
697+
page_size: Optional[int]
698+
699+
700+
@dataclass
701+
class ListDatabasesResponse:
702+
databases: List[Database]
703+
"""
704+
List of the databases.
705+
"""
706+
707+
total_count: int
708+
"""
709+
Total count of databases present on a Database Instance.
710+
"""
711+
712+
665713
@dataclass
666714
class ListInstancesRequest:
667715
region: Optional[ScwRegion]

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,16 @@ def marshal_EndpointSpec(
707707
output.update(
708708
resolve_one_of(
709709
[
710-
OneOfPossibility("public", request.public),
711-
OneOfPossibility("private_network", request.private_network),
710+
OneOfPossibility(
711+
param="public",
712+
value=request.public,
713+
marshal_func=marshal_EndpointSpecPublicDetails,
714+
),
715+
OneOfPossibility(
716+
param="private_network",
717+
value=request.private_network,
718+
marshal_func=marshal_EndpointSpecPrivateNetworkDetails,
719+
),
712720
]
713721
),
714722
)
@@ -862,8 +870,12 @@ def marshal_UserRole(
862870
output.update(
863871
resolve_one_of(
864872
[
865-
OneOfPossibility("database", request.database),
866-
OneOfPossibility("any_database", request.any_database),
873+
OneOfPossibility(
874+
param="database", value=request.database, marshal_func=None
875+
),
876+
OneOfPossibility(
877+
param="any_database", value=request.any_database, marshal_func=None
878+
),
867879
]
868880
),
869881
)
@@ -939,7 +951,9 @@ def marshal_UpgradeInstanceRequest(
939951
output.update(
940952
resolve_one_of(
941953
[
942-
OneOfPossibility("volume_size", request.volume_size),
954+
OneOfPossibility(
955+
param="volume_size", value=request.volume_size, marshal_func=None
956+
),
943957
]
944958
),
945959
)

0 commit comments

Comments
 (0)