Skip to content

Commit 8f5978d

Browse files
authored
feat(mongodb): add support for generated instance name (#706)
1 parent c62d41f commit 8f5978d

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313
from scaleway_core.utils import (
1414
WaitForOptions,
15+
random_name,
1516
validate_path_param,
1617
fetch_all_pages_async,
1718
wait_for_resource_async,
@@ -391,29 +392,29 @@ async def wait_for_instance(
391392
async def create_instance(
392393
self,
393394
*,
394-
name: str,
395395
version: str,
396396
node_number: int,
397397
node_type: str,
398398
user_name: str,
399399
password: str,
400400
region: Optional[Region] = None,
401401
project_id: Optional[str] = None,
402+
name: Optional[str] = None,
402403
tags: Optional[List[str]] = None,
403404
volume: Optional[CreateInstanceRequestVolumeDetails] = None,
404405
endpoints: Optional[List[EndpointSpec]] = None,
405406
) -> Instance:
406407
"""
407408
Create a MongoDB™ Database Instance.
408409
Create a new MongoDB™ Database Instance.
409-
:param name: Name of the Database Instance.
410410
:param version: Version of the MongoDB™ engine.
411411
:param node_number: Number of node to use for the Database Instance.
412412
:param node_type: Type of node to use for the Database Instance.
413413
:param user_name: Username created when the Database Instance is created.
414414
:param password: Password of the initial user.
415415
:param region: Region to target. If none is passed will use default region from the config.
416416
:param project_id: The Project ID on which the Database Instance will be created.
417+
:param name: Name of the Database Instance.
417418
:param tags: Tags to apply to the Database Instance.
418419
:param volume: Instance volume information.
419420
:param endpoints: One or multiple EndpointSpec used to expose your Database Instance.
@@ -423,7 +424,6 @@ async def create_instance(
423424
::
424425
425426
result = await api.create_instance(
426-
name="example",
427427
version="example",
428428
node_number=1,
429429
node_type="example",
@@ -441,14 +441,14 @@ async def create_instance(
441441
f"/mongodb/v1alpha1/regions/{param_region}/instances",
442442
body=marshal_CreateInstanceRequest(
443443
CreateInstanceRequest(
444-
name=name,
445444
version=version,
446445
node_number=node_number,
447446
node_type=node_type,
448447
user_name=user_name,
449448
password=password,
450449
region=region,
451450
project_id=project_id,
451+
name=name or random_name(prefix="mgdb"),
452452
tags=tags,
453453
volume=volume,
454454
endpoints=endpoints,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,6 @@ def marshal_CreateInstanceRequest(
656656
) -> Dict[str, Any]:
657657
output: Dict[str, Any] = {}
658658

659-
if request.name is not None:
660-
output["name"] = request.name
661-
662659
if request.version is not None:
663660
output["version"] = request.version
664661

@@ -677,6 +674,9 @@ def marshal_CreateInstanceRequest(
677674
if request.project_id is not None:
678675
output["project_id"] = request.project_id or defaults.default_project_id
679676

677+
if request.name is not None:
678+
output["name"] = request.name
679+
680680
if request.tags is not None:
681681
output["tags"] = request.tags
682682

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,6 @@ class RestoreSnapshotRequestVolumeDetails:
513513

514514
@dataclass
515515
class CreateInstanceRequest:
516-
name: str
517-
"""
518-
Name of the Database Instance.
519-
"""
520-
521516
version: str
522517
"""
523518
Version of the MongoDB™ engine.
@@ -553,6 +548,11 @@ class CreateInstanceRequest:
553548
The Project ID on which the Database Instance will be created.
554549
"""
555550

551+
name: Optional[str]
552+
"""
553+
Name of the Database Instance.
554+
"""
555+
556556
tags: Optional[List[str]]
557557
"""
558558
Tags to apply to the Database Instance.

scaleway/scaleway/mongodb/v1alpha1/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313
from scaleway_core.utils import (
1414
WaitForOptions,
15+
random_name,
1516
validate_path_param,
1617
fetch_all_pages,
1718
wait_for_resource,
@@ -389,29 +390,29 @@ def wait_for_instance(
389390
def create_instance(
390391
self,
391392
*,
392-
name: str,
393393
version: str,
394394
node_number: int,
395395
node_type: str,
396396
user_name: str,
397397
password: str,
398398
region: Optional[Region] = None,
399399
project_id: Optional[str] = None,
400+
name: Optional[str] = None,
400401
tags: Optional[List[str]] = None,
401402
volume: Optional[CreateInstanceRequestVolumeDetails] = None,
402403
endpoints: Optional[List[EndpointSpec]] = None,
403404
) -> Instance:
404405
"""
405406
Create a MongoDB™ Database Instance.
406407
Create a new MongoDB™ Database Instance.
407-
:param name: Name of the Database Instance.
408408
:param version: Version of the MongoDB™ engine.
409409
:param node_number: Number of node to use for the Database Instance.
410410
:param node_type: Type of node to use for the Database Instance.
411411
:param user_name: Username created when the Database Instance is created.
412412
:param password: Password of the initial user.
413413
:param region: Region to target. If none is passed will use default region from the config.
414414
:param project_id: The Project ID on which the Database Instance will be created.
415+
:param name: Name of the Database Instance.
415416
:param tags: Tags to apply to the Database Instance.
416417
:param volume: Instance volume information.
417418
:param endpoints: One or multiple EndpointSpec used to expose your Database Instance.
@@ -421,7 +422,6 @@ def create_instance(
421422
::
422423
423424
result = api.create_instance(
424-
name="example",
425425
version="example",
426426
node_number=1,
427427
node_type="example",
@@ -439,14 +439,14 @@ def create_instance(
439439
f"/mongodb/v1alpha1/regions/{param_region}/instances",
440440
body=marshal_CreateInstanceRequest(
441441
CreateInstanceRequest(
442-
name=name,
443442
version=version,
444443
node_number=node_number,
445444
node_type=node_type,
446445
user_name=user_name,
447446
password=password,
448447
region=region,
449448
project_id=project_id,
449+
name=name or random_name(prefix="mgdb"),
450450
tags=tags,
451451
volume=volume,
452452
endpoints=endpoints,

scaleway/scaleway/mongodb/v1alpha1/marshalling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,6 @@ def marshal_CreateInstanceRequest(
656656
) -> Dict[str, Any]:
657657
output: Dict[str, Any] = {}
658658

659-
if request.name is not None:
660-
output["name"] = request.name
661-
662659
if request.version is not None:
663660
output["version"] = request.version
664661

@@ -677,6 +674,9 @@ def marshal_CreateInstanceRequest(
677674
if request.project_id is not None:
678675
output["project_id"] = request.project_id or defaults.default_project_id
679676

677+
if request.name is not None:
678+
output["name"] = request.name
679+
680680
if request.tags is not None:
681681
output["tags"] = request.tags
682682

scaleway/scaleway/mongodb/v1alpha1/types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,6 @@ class RestoreSnapshotRequestVolumeDetails:
513513

514514
@dataclass
515515
class CreateInstanceRequest:
516-
name: str
517-
"""
518-
Name of the Database Instance.
519-
"""
520-
521516
version: str
522517
"""
523518
Version of the MongoDB™ engine.
@@ -553,6 +548,11 @@ class CreateInstanceRequest:
553548
The Project ID on which the Database Instance will be created.
554549
"""
555550

551+
name: Optional[str]
552+
"""
553+
Name of the Database Instance.
554+
"""
555+
556556
tags: Optional[List[str]]
557557
"""
558558
Tags to apply to the Database Instance.

0 commit comments

Comments
 (0)