Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mongodb): add deleteUser route #811

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/mongodb/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .types import DeleteEndpointRequest
from .types import DeleteInstanceRequest
from .types import DeleteSnapshotRequest
from .types import DeleteUserRequest
from .types import GetInstanceCertificateRequest
from .types import GetInstanceRequest
from .types import GetSnapshotRequest
Expand Down Expand Up @@ -91,6 +92,7 @@
"DeleteEndpointRequest",
"DeleteInstanceRequest",
"DeleteSnapshotRequest",
"DeleteUserRequest",
"GetInstanceCertificateRequest",
"GetInstanceRequest",
"GetSnapshotRequest",
Expand Down
37 changes: 37 additions & 0 deletions scaleway-async/scaleway_async/mongodb/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,43 @@ async def update_user(
self._throw_on_error(res)
return unmarshal_User(res.json())

async def delete_user(
self,
*,
instance_id: str,
name: str,
region: Optional[Region] = None,
) -> None:
"""
Delete a user on a Database Instance.
Delete an existing user on a Database Instance.
:param instance_id: UUID of the Database Instance the user belongs to.
:param name: Name of the database user.
:param region: Region to target. If none is passed will use default region from the config.

Usage:
::

result = await api.delete_user(
instance_id="example",
name="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_instance_id = validate_path_param("instance_id", instance_id)
param_name = validate_path_param("name", name)

res = self._request(
"DELETE",
f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}",
body={},
)

self._throw_on_error(res)

async def delete_endpoint(
self,
*,
Expand Down
18 changes: 18 additions & 0 deletions scaleway-async/scaleway_async/mongodb/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,24 @@ class DeleteSnapshotRequest:
"""


@dataclass
class DeleteUserRequest:
instance_id: str
"""
UUID of the Database Instance the user belongs to.
"""

name: str
"""
Name of the database user.
"""

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class GetInstanceCertificateRequest:
instance_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/mongodb/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .types import DeleteEndpointRequest
from .types import DeleteInstanceRequest
from .types import DeleteSnapshotRequest
from .types import DeleteUserRequest
from .types import GetInstanceCertificateRequest
from .types import GetInstanceRequest
from .types import GetSnapshotRequest
Expand Down Expand Up @@ -91,6 +92,7 @@
"DeleteEndpointRequest",
"DeleteInstanceRequest",
"DeleteSnapshotRequest",
"DeleteUserRequest",
"GetInstanceCertificateRequest",
"GetInstanceRequest",
"GetSnapshotRequest",
Expand Down
37 changes: 37 additions & 0 deletions scaleway/scaleway/mongodb/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,43 @@ def update_user(
self._throw_on_error(res)
return unmarshal_User(res.json())

def delete_user(
self,
*,
instance_id: str,
name: str,
region: Optional[Region] = None,
) -> None:
"""
Delete a user on a Database Instance.
Delete an existing user on a Database Instance.
:param instance_id: UUID of the Database Instance the user belongs to.
:param name: Name of the database user.
:param region: Region to target. If none is passed will use default region from the config.

Usage:
::

result = api.delete_user(
instance_id="example",
name="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_instance_id = validate_path_param("instance_id", instance_id)
param_name = validate_path_param("name", name)

res = self._request(
"DELETE",
f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}",
body={},
)

self._throw_on_error(res)

def delete_endpoint(
self,
*,
Expand Down
18 changes: 18 additions & 0 deletions scaleway/scaleway/mongodb/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,24 @@ class DeleteSnapshotRequest:
"""


@dataclass
class DeleteUserRequest:
instance_id: str
"""
UUID of the Database Instance the user belongs to.
"""

name: str
"""
Name of the database user.
"""

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class GetInstanceCertificateRequest:
instance_id: str
Expand Down
Loading