From ffe5f08aad6c22cbb8a93ea0c503d0d5fc280e00 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 16 Oct 2024 13:20:55 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/mongodb/__init__.py | 2 + .../mongodb/v1alpha1/__init__.py | 105 ++ .../scaleway_async/mongodb/v1alpha1/api.py | 1044 +++++++++++++++++ .../mongodb/v1alpha1/content.py | 27 + .../mongodb/v1alpha1/marshalling.py | 801 +++++++++++++ .../scaleway_async/mongodb/v1alpha1/types.py | 958 +++++++++++++++ scaleway/scaleway/mongodb/__init__.py | 2 + .../scaleway/mongodb/v1alpha1/__init__.py | 105 ++ scaleway/scaleway/mongodb/v1alpha1/api.py | 1042 ++++++++++++++++ scaleway/scaleway/mongodb/v1alpha1/content.py | 27 + .../scaleway/mongodb/v1alpha1/marshalling.py | 801 +++++++++++++ scaleway/scaleway/mongodb/v1alpha1/types.py | 958 +++++++++++++++ 12 files changed, 5872 insertions(+) create mode 100644 scaleway-async/scaleway_async/mongodb/__init__.py create mode 100644 scaleway-async/scaleway_async/mongodb/v1alpha1/__init__.py create mode 100644 scaleway-async/scaleway_async/mongodb/v1alpha1/api.py create mode 100644 scaleway-async/scaleway_async/mongodb/v1alpha1/content.py create mode 100644 scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py create mode 100644 scaleway-async/scaleway_async/mongodb/v1alpha1/types.py create mode 100644 scaleway/scaleway/mongodb/__init__.py create mode 100644 scaleway/scaleway/mongodb/v1alpha1/__init__.py create mode 100644 scaleway/scaleway/mongodb/v1alpha1/api.py create mode 100644 scaleway/scaleway/mongodb/v1alpha1/content.py create mode 100644 scaleway/scaleway/mongodb/v1alpha1/marshalling.py create mode 100644 scaleway/scaleway/mongodb/v1alpha1/types.py diff --git a/scaleway-async/scaleway_async/mongodb/__init__.py b/scaleway-async/scaleway_async/mongodb/__init__.py new file mode 100644 index 000000000..8b74a5ed7 --- /dev/null +++ b/scaleway-async/scaleway_async/mongodb/__init__.py @@ -0,0 +1,2 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/__init__.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/__init__.py new file mode 100644 index 000000000..849bdf68c --- /dev/null +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/__init__.py @@ -0,0 +1,105 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import InstanceStatus +from .content import INSTANCE_TRANSIENT_STATUSES +from .types import ListInstancesRequestOrderBy +from .types import ListSnapshotsRequestOrderBy +from .types import ListUsersRequestOrderBy +from .types import NodeTypeStock +from .types import SettingPropertyType +from .types import SnapshotStatus +from .content import SNAPSHOT_TRANSIENT_STATUSES +from .types import VolumeType +from .types import EndpointPrivateNetworkDetails +from .types import EndpointPublicDetails +from .types import EndpointSpecPrivateNetworkDetails +from .types import EndpointSpecPublicDetails +from .types import Endpoint +from .types import InstanceSetting +from .types import Volume +from .types import NodeTypeVolumeType +from .types import SnapshotVolumeType +from .types import Setting +from .types import CreateInstanceRequestVolumeDetails +from .types import EndpointSpec +from .types import Instance +from .types import NodeType +from .types import Snapshot +from .types import User +from .types import Version +from .types import RestoreSnapshotRequestVolumeDetails +from .types import CreateInstanceRequest +from .types import CreateSnapshotRequest +from .types import DeleteInstanceRequest +from .types import DeleteSnapshotRequest +from .types import GetInstanceCertificateRequest +from .types import GetInstanceRequest +from .types import ListInstancesRequest +from .types import ListInstancesResponse +from .types import ListNodeTypesRequest +from .types import ListNodeTypesResponse +from .types import ListSnapshotsRequest +from .types import ListSnapshotsResponse +from .types import ListUsersRequest +from .types import ListUsersResponse +from .types import ListVersionsRequest +from .types import ListVersionsResponse +from .types import RestoreSnapshotRequest +from .types import UpdateInstanceRequest +from .types import UpdateSnapshotRequest +from .types import UpdateUserRequest +from .types import UpgradeInstanceRequest +from .api import MongodbV1Alpha1API + +__all__ = [ + "InstanceStatus", + "INSTANCE_TRANSIENT_STATUSES", + "ListInstancesRequestOrderBy", + "ListSnapshotsRequestOrderBy", + "ListUsersRequestOrderBy", + "NodeTypeStock", + "SettingPropertyType", + "SnapshotStatus", + "SNAPSHOT_TRANSIENT_STATUSES", + "VolumeType", + "EndpointPrivateNetworkDetails", + "EndpointPublicDetails", + "EndpointSpecPrivateNetworkDetails", + "EndpointSpecPublicDetails", + "Endpoint", + "InstanceSetting", + "Volume", + "NodeTypeVolumeType", + "SnapshotVolumeType", + "Setting", + "CreateInstanceRequestVolumeDetails", + "EndpointSpec", + "Instance", + "NodeType", + "Snapshot", + "User", + "Version", + "RestoreSnapshotRequestVolumeDetails", + "CreateInstanceRequest", + "CreateSnapshotRequest", + "DeleteInstanceRequest", + "DeleteSnapshotRequest", + "GetInstanceCertificateRequest", + "GetInstanceRequest", + "ListInstancesRequest", + "ListInstancesResponse", + "ListNodeTypesRequest", + "ListNodeTypesResponse", + "ListSnapshotsRequest", + "ListSnapshotsResponse", + "ListUsersRequest", + "ListUsersResponse", + "ListVersionsRequest", + "ListVersionsResponse", + "RestoreSnapshotRequest", + "UpdateInstanceRequest", + "UpdateSnapshotRequest", + "UpdateUserRequest", + "UpgradeInstanceRequest", + "MongodbV1Alpha1API", +] diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py new file mode 100644 index 000000000..0dfbb8231 --- /dev/null +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py @@ -0,0 +1,1044 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from datetime import datetime +from typing import Awaitable, List, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region, + ScwFile, + unmarshal_ScwFile, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + ListInstancesRequestOrderBy, + ListSnapshotsRequestOrderBy, + ListUsersRequestOrderBy, + CreateInstanceRequest, + CreateInstanceRequestVolumeDetails, + CreateSnapshotRequest, + EndpointSpec, + Instance, + ListInstancesResponse, + ListNodeTypesResponse, + ListSnapshotsResponse, + ListUsersResponse, + ListVersionsResponse, + NodeType, + RestoreSnapshotRequest, + RestoreSnapshotRequestVolumeDetails, + Snapshot, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradeInstanceRequest, + User, + Version, +) +from .content import ( + INSTANCE_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Instance, + unmarshal_Snapshot, + unmarshal_User, + unmarshal_ListInstancesResponse, + unmarshal_ListNodeTypesResponse, + unmarshal_ListSnapshotsResponse, + unmarshal_ListUsersResponse, + unmarshal_ListVersionsResponse, + marshal_CreateInstanceRequest, + marshal_CreateSnapshotRequest, + marshal_RestoreSnapshotRequest, + marshal_UpdateInstanceRequest, + marshal_UpdateSnapshotRequest, + marshal_UpdateUserRequest, + marshal_UpgradeInstanceRequest, +) + + +class MongodbV1Alpha1API(API): + """ + This API allows you to manage your Managed Databases for MongoDB. + """ + + async def list_node_types( + self, + *, + region: Optional[Region] = None, + include_disabled_types: Optional[bool] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListNodeTypesResponse: + """ + List available node types. + :param region: Region to target. If none is passed will use default region from the config. + :param include_disabled_types: Defines whether or not to include disabled types. + :param page: + :param page_size: + :return: :class:`ListNodeTypesResponse ` + + Usage: + :: + + result = await api.list_node_types() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/node-types", + params={ + "include_disabled_types": include_disabled_types, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListNodeTypesResponse(res.json()) + + async def list_node_types_all( + self, + *, + region: Optional[Region] = None, + include_disabled_types: Optional[bool] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[NodeType]: + """ + List available node types. + :param region: Region to target. If none is passed will use default region from the config. + :param include_disabled_types: Defines whether or not to include disabled types. + :param page: + :param page_size: + :return: :class:`List[NodeType] ` + + Usage: + :: + + result = await api.list_node_types_all() + """ + + return await fetch_all_pages_async( + type=ListNodeTypesResponse, + key="node_types", + fetcher=self.list_node_types, + args={ + "region": region, + "include_disabled_types": include_disabled_types, + "page": page, + "page_size": page_size, + }, + ) + + async def list_versions( + self, + *, + region: Optional[Region] = None, + version: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListVersionsResponse: + """ + List available MongoDB™ versions. + :param region: Region to target. If none is passed will use default region from the config. + :param version: + :param page: + :param page_size: + :return: :class:`ListVersionsResponse ` + + Usage: + :: + + result = await api.list_versions() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/versions", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + "version": version, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVersionsResponse(res.json()) + + async def list_versions_all( + self, + *, + region: Optional[Region] = None, + version: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[Version]: + """ + List available MongoDB™ versions. + :param region: Region to target. If none is passed will use default region from the config. + :param version: + :param page: + :param page_size: + :return: :class:`List[Version] ` + + Usage: + :: + + result = await api.list_versions_all() + """ + + return await fetch_all_pages_async( + type=ListVersionsResponse, + key="versions", + fetcher=self.list_versions, + args={ + "region": region, + "version": version, + "page": page, + "page_size": page_size, + }, + ) + + async def list_instances( + self, + *, + region: Optional[Region] = None, + tags: Optional[List[str]] = None, + name: Optional[str] = None, + order_by: Optional[ListInstancesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListInstancesResponse: + """ + List MongoDB™ Database Instances. + List all MongoDB™ Database Instances in the specified region, for a given Scaleway Project. By default, the MongoDB™ Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: List Database Instances that have a given tag. + :param name: Lists Database Instances that match a name pattern. + :param order_by: Criteria to use when ordering Database Instance listings. + :param organization_id: Organization ID the Database Instance belongs to. + :param project_id: Project ID to list the Database Instance of. + :param page: + :param page_size: + :return: :class:`ListInstancesResponse ` + + Usage: + :: + + result = await api.list_instances() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances", + params={ + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListInstancesResponse(res.json()) + + async def list_instances_all( + self, + *, + region: Optional[Region] = None, + tags: Optional[List[str]] = None, + name: Optional[str] = None, + order_by: Optional[ListInstancesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[Instance]: + """ + List MongoDB™ Database Instances. + List all MongoDB™ Database Instances in the specified region, for a given Scaleway Project. By default, the MongoDB™ Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: List Database Instances that have a given tag. + :param name: Lists Database Instances that match a name pattern. + :param order_by: Criteria to use when ordering Database Instance listings. + :param organization_id: Organization ID the Database Instance belongs to. + :param project_id: Project ID to list the Database Instance of. + :param page: + :param page_size: + :return: :class:`List[Instance] ` + + Usage: + :: + + result = await api.list_instances_all() + """ + + return await fetch_all_pages_async( + type=ListInstancesResponse, + key="instances", + fetcher=self.list_instances, + args={ + "region": region, + "tags": tags, + "name": name, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "page": page, + "page_size": page_size, + }, + ) + + async def get_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + ) -> Instance: + """ + Get a MongoDB™ Database Instance. + Retrieve information about a given MongoDB™ Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.get_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}", + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + async def wait_for_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + options: Optional[ + WaitForOptions[Instance, Union[bool, Awaitable[bool]]] + ] = None, + ) -> Instance: + """ + Get a MongoDB™ Database Instance. + Retrieve information about a given MongoDB™ Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.get_instance( + instance_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in INSTANCE_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_instance, + options=options, + args={ + "instance_id": instance_id, + "region": region, + }, + ) + + async def create_instance( + self, + *, + name: str, + version: str, + node_number: int, + node_type: str, + user_name: str, + password: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + volume: Optional[CreateInstanceRequestVolumeDetails] = None, + endpoints: Optional[List[EndpointSpec]] = None, + ) -> Instance: + """ + Create a MongoDB™ Database Instance. + Create a new MongoDB™ Database Instance. + :param name: Name of the Database Instance. + :param version: Version of the MongoDB™ engine. + :param node_number: Number of node to use for the Database Instance. + :param node_type: Type of node to use for the Database Instance. + :param user_name: Username created when the Database Instance is created. + :param password: Password of the initial user. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: The Project ID on which the Database Instance will be created. + :param tags: Tags to apply to the Database Instance. + :param volume: Instance volume information. + :param endpoints: One or multiple EndpointSpec used to expose your Database Instance. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.create_instance( + name="example", + version="example", + node_number=1, + node_type="example", + user_name="example", + password="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/instances", + body=marshal_CreateInstanceRequest( + CreateInstanceRequest( + name=name, + version=version, + node_number=node_number, + node_type=node_type, + user_name=user_name, + password=password, + region=region, + project_id=project_id, + tags=tags, + volume=volume, + endpoints=endpoints, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + async def update_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Instance: + """ + Update a MongoDB™ Database Instance. + Update the parameters of a MongoDB™ Database Instance. + :param instance_id: UUID of the Database Instance to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the Database Instance. + :param tags: Tags of a Database Instance. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.update_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "PATCH", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}", + body=marshal_UpdateInstanceRequest( + UpdateInstanceRequest( + instance_id=instance_id, + region=region, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + async def delete_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + ) -> Instance: + """ + Delete a MongoDB™ Database Instance. + Delete a given MongoDB™ Database Instance, specified by the `region` and `instance_id` parameters. Deleting a MongoDB™ Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost. + :param instance_id: UUID of the Database Instance to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.delete_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "DELETE", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}", + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + async def upgrade_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + volume_size: Optional[int] = None, + ) -> Instance: + """ + Upgrade a Database Instance. + Upgrade your current Database Instance specifications like volume size. + :param instance_id: UUID of the Database Instance you want to upgrade. + :param region: Region to target. If none is passed will use default region from the config. + :param volume_size: Increase your block storage volume size. + One-Of ('upgrade_target'): at most one of 'volume_size' could be set. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.upgrade_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/upgrade", + body=marshal_UpgradeInstanceRequest( + UpgradeInstanceRequest( + instance_id=instance_id, + region=region, + volume_size=volume_size, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + async def get_instance_certificate( + self, + *, + instance_id: str, + region: Optional[Region] = None, + ) -> ScwFile: + """ + Get the certificate of a Database Instance. + Retrieve the certificate of a given Database Instance, specified by the `instance_id` parameter. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ScwFile ` + + Usage: + :: + + result = await api.get_instance_certificate( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/certificate", + ) + + self._throw_on_error(res) + return unmarshal_ScwFile(res.json()) + + async def create_snapshot( + self, + *, + instance_id: str, + name: str, + region: Optional[Region] = None, + expires_at: Optional[datetime] = None, + ) -> Snapshot: + """ + Create a Database Instance snapshot. + Create a new snapshot of a Database Instance. You must define the `name` and `instance_id` parameters in the request. + :param instance_id: UUID of the Database Instance to snapshot. + :param name: Name of the snapshot. + :param region: Region to target. If none is passed will use default region from the config. + :param expires_at: Expiration date of the snapshot (must follow the ISO 8601 format). + :return: :class:`Snapshot ` + + Usage: + :: + + result = await api.create_snapshot( + 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) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/snapshots", + body=marshal_CreateSnapshotRequest( + CreateSnapshotRequest( + instance_id=instance_id, + name=name, + region=region, + expires_at=expires_at, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + async def update_snapshot( + self, + *, + snapshot_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + expires_at: Optional[datetime] = None, + ) -> Snapshot: + """ + :param snapshot_id: UUID of the Snapshot. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the snapshot. + :param expires_at: Expiration date of the snapshot (must follow the ISO 8601 format). + :return: :class:`Snapshot ` + + Usage: + :: + + result = await api.update_snapshot( + snapshot_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots/{param_snapshot_id}", + body=marshal_UpdateSnapshotRequest( + UpdateSnapshotRequest( + snapshot_id=snapshot_id, + region=region, + name=name, + expires_at=expires_at, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + async def restore_snapshot( + self, + *, + snapshot_id: str, + instance_name: str, + node_type: str, + node_number: int, + volume: RestoreSnapshotRequestVolumeDetails, + region: Optional[Region] = None, + ) -> Instance: + """ + Restore a Database Instance snapshot. + Restore a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to restore, the `instance_name` of the new Database Instance, `node_type` of the new Database Instance and `node_number` of the new Database Instance. + :param snapshot_id: UUID of the snapshot. + :param instance_name: Name of the new Database Instance. + :param node_type: Node type to use for the new Database Instance. + :param node_number: Number of nodes to use for the new Database Instance. + :param volume: Instance volume information. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = await api.restore_snapshot( + snapshot_id="example", + instance_name="example", + node_type="example", + node_number=1, + volume=RestoreSnapshotRequestVolumeDetails(), + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots/{param_snapshot_id}/restore", + body=marshal_RestoreSnapshotRequest( + RestoreSnapshotRequest( + snapshot_id=snapshot_id, + instance_name=instance_name, + node_type=node_type, + node_number=node_number, + volume=volume, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + async def list_snapshots( + self, + *, + region: Optional[Region] = None, + instance_id: Optional[str] = None, + name: Optional[str] = None, + order_by: Optional[ListSnapshotsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListSnapshotsResponse: + """ + List snapshots. + List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param instance_id: Instance ID the snapshots belongs to. + :param name: Lists Database snapshots that match a name pattern. + :param order_by: Criteria to use when ordering snapshot listings. + :param organization_id: Organization ID the snapshots belongs to. + :param project_id: Project ID to list the snapshots of. + :param page: + :param page_size: + :return: :class:`ListSnapshotsResponse ` + + Usage: + :: + + result = await api.list_snapshots() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots", + params={ + "instance_id": instance_id, + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListSnapshotsResponse(res.json()) + + async def list_snapshots_all( + self, + *, + region: Optional[Region] = None, + instance_id: Optional[str] = None, + name: Optional[str] = None, + order_by: Optional[ListSnapshotsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[Snapshot]: + """ + List snapshots. + List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param instance_id: Instance ID the snapshots belongs to. + :param name: Lists Database snapshots that match a name pattern. + :param order_by: Criteria to use when ordering snapshot listings. + :param organization_id: Organization ID the snapshots belongs to. + :param project_id: Project ID to list the snapshots of. + :param page: + :param page_size: + :return: :class:`List[Snapshot] ` + + Usage: + :: + + result = await api.list_snapshots_all() + """ + + return await fetch_all_pages_async( + type=ListSnapshotsResponse, + key="snapshots", + fetcher=self.list_snapshots, + args={ + "region": region, + "instance_id": instance_id, + "name": name, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "page": page, + "page_size": page_size, + }, + ) + + async def delete_snapshot( + self, + *, + snapshot_id: str, + region: Optional[Region] = None, + ) -> Snapshot: + """ + Delete a Database Instance snapshot. + Delete a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to delete. + :param snapshot_id: UUID of the snapshot. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Snapshot ` + + Usage: + :: + + result = await api.delete_snapshot( + snapshot_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "DELETE", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots/{param_snapshot_id}", + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + async def list_users( + self, + *, + instance_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + order_by: Optional[ListUsersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListUsersResponse: + """ + List users of a Database Instance. + List all users of a given Database Instance. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the user. + :param order_by: Criteria to use when requesting user listing. + :param page: + :param page_size: + :return: :class:`ListUsersResponse ` + + Usage: + :: + + result = await api.list_users( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListUsersResponse(res.json()) + + async def list_users_all( + self, + *, + instance_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + order_by: Optional[ListUsersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[User]: + """ + List users of a Database Instance. + List all users of a given Database Instance. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the user. + :param order_by: Criteria to use when requesting user listing. + :param page: + :param page_size: + :return: :class:`List[User] ` + + Usage: + :: + + result = await api.list_users_all( + instance_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListUsersResponse, + key="users", + fetcher=self.list_users, + args={ + "instance_id": instance_id, + "region": region, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size, + }, + ) + + async def update_user( + self, + *, + instance_id: str, + name: str, + region: Optional[Region] = None, + password: Optional[str] = None, + ) -> User: + """ + Update a user on a Database Instance. + Update the parameters of a user on a Database Instance. You can update the `password` parameter, but you cannot change the name of the user. + :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. + :param password: Password of the database user. + :return: :class:`User ` + + Usage: + :: + + result = await api.update_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( + "PATCH", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}", + body=marshal_UpdateUserRequest( + UpdateUserRequest( + instance_id=instance_id, + name=name, + region=region, + password=password, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/content.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/content.py new file mode 100644 index 000000000..8e0092203 --- /dev/null +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/content.py @@ -0,0 +1,27 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + InstanceStatus, + SnapshotStatus, +) + +INSTANCE_TRANSIENT_STATUSES: List[InstanceStatus] = [ + InstanceStatus.PROVISIONING, + InstanceStatus.CONFIGURING, + InstanceStatus.DELETING, + InstanceStatus.INITIALIZING, + InstanceStatus.SNAPSHOTTING, +] +""" +Lists transient statutes of the enum :class:`InstanceStatus `. +""" +SNAPSHOT_TRANSIENT_STATUSES: List[SnapshotStatus] = [ + SnapshotStatus.CREATING, + SnapshotStatus.RESTORING, + SnapshotStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`SnapshotStatus `. +""" diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py new file mode 100644 index 000000000..e3012a10b --- /dev/null +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py @@ -0,0 +1,801 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + EndpointPrivateNetworkDetails, + EndpointPublicDetails, + Endpoint, + InstanceSetting, + Volume, + Instance, + SnapshotVolumeType, + Snapshot, + User, + ListInstancesResponse, + NodeTypeVolumeType, + NodeType, + ListNodeTypesResponse, + ListSnapshotsResponse, + ListUsersResponse, + Setting, + Version, + ListVersionsResponse, + EndpointSpecPrivateNetworkDetails, + EndpointSpecPublicDetails, + CreateInstanceRequestVolumeDetails, + EndpointSpec, + CreateInstanceRequest, + CreateSnapshotRequest, + RestoreSnapshotRequestVolumeDetails, + RestoreSnapshotRequest, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradeInstanceRequest, +) + + +def unmarshal_EndpointPrivateNetworkDetails(data: Any) -> EndpointPrivateNetworkDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + + return EndpointPrivateNetworkDetails(**args) + + +def unmarshal_EndpointPublicDetails(data: Any) -> EndpointPublicDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + return EndpointPublicDetails(**args) + + +def unmarshal_Endpoint(data: Any) -> Endpoint: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Endpoint' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("ips", None) + if field is not None: + args["ips"] = field + + field = data.get("dns_records", None) + if field is not None: + args["dns_records"] = field + + field = data.get("port", None) + if field is not None: + args["port"] = field + + field = data.get("private_network", None) + if field is not None: + args["private_network"] = unmarshal_EndpointPrivateNetworkDetails(field) + else: + args["private_network"] = None + + field = data.get("public", None) + if field is not None: + args["public"] = unmarshal_EndpointPublicDetails(field) + else: + args["public"] = None + + return Endpoint(**args) + + +def unmarshal_InstanceSetting(data: Any) -> InstanceSetting: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("value", None) + if field is not None: + args["value"] = field + + return InstanceSetting(**args) + + +def unmarshal_Volume(data: Any) -> Volume: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Volume' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("size", None) + if field is not None: + args["size"] = field + + return Volume(**args) + + +def unmarshal_Instance(data: Any) -> Instance: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Instance' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("version", None) + if field is not None: + args["version"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("settings", None) + if field is not None: + args["settings"] = ( + [unmarshal_InstanceSetting(v) for v in field] if field is not None else None + ) + + field = data.get("node_number", None) + if field is not None: + args["node_number"] = field + + field = data.get("node_type", None) + if field is not None: + args["node_type"] = field + + field = data.get("endpoints", None) + if field is not None: + args["endpoints"] = ( + [unmarshal_Endpoint(v) for v in field] if field is not None else None + ) + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("volume", None) + if field is not None: + args["volume"] = unmarshal_Volume(field) + else: + args["volume"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + return Instance(**args) + + +def unmarshal_SnapshotVolumeType(data: Any) -> SnapshotVolumeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + return SnapshotVolumeType(**args) + + +def unmarshal_Snapshot(data: Any) -> Snapshot: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Snapshot' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("instance_id", None) + if field is not None: + args["instance_id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("size", None) + if field is not None: + args["size"] = field + + field = data.get("instance_name", None) + if field is not None: + args["instance_name"] = field + + field = data.get("node_type", None) + if field is not None: + args["node_type"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("expires_at", None) + if field is not None: + args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["expires_at"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("volume_type", None) + if field is not None: + args["volume_type"] = unmarshal_SnapshotVolumeType(field) + else: + args["volume_type"] = None + + return Snapshot(**args) + + +def unmarshal_User(data: Any) -> User: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'User' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + return User(**args) + + +def unmarshal_ListInstancesResponse(data: Any) -> ListInstancesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("instances", None) + if field is not None: + args["instances"] = ( + [unmarshal_Instance(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListInstancesResponse(**args) + + +def unmarshal_NodeTypeVolumeType(data: Any) -> NodeTypeVolumeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("min_size", None) + if field is not None: + args["min_size"] = field + + field = data.get("max_size", None) + if field is not None: + args["max_size"] = field + + field = data.get("chunk_size", None) + if field is not None: + args["chunk_size"] = field + + return NodeTypeVolumeType(**args) + + +def unmarshal_NodeType(data: Any) -> NodeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'NodeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("stock_status", None) + if field is not None: + args["stock_status"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("vcpus", None) + if field is not None: + args["vcpus"] = field + + field = data.get("memory", None) + if field is not None: + args["memory"] = field + + field = data.get("available_volume_types", None) + if field is not None: + args["available_volume_types"] = ( + [unmarshal_NodeTypeVolumeType(v) for v in field] + if field is not None + else None + ) + + field = data.get("disabled", None) + if field is not None: + args["disabled"] = field + + field = data.get("beta", None) + if field is not None: + args["beta"] = field + + field = data.get("instance_range", None) + if field is not None: + args["instance_range"] = field + + return NodeType(**args) + + +def unmarshal_ListNodeTypesResponse(data: Any) -> ListNodeTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("node_types", None) + if field is not None: + args["node_types"] = ( + [unmarshal_NodeType(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListNodeTypesResponse(**args) + + +def unmarshal_ListSnapshotsResponse(data: Any) -> ListSnapshotsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("snapshots", None) + if field is not None: + args["snapshots"] = ( + [unmarshal_Snapshot(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListSnapshotsResponse(**args) + + +def unmarshal_ListUsersResponse(data: Any) -> ListUsersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("users", None) + if field is not None: + args["users"] = ( + [unmarshal_User(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListUsersResponse(**args) + + +def unmarshal_Setting(data: Any) -> Setting: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Setting' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("default_value", None) + if field is not None: + args["default_value"] = field + + field = data.get("hot_configurable", None) + if field is not None: + args["hot_configurable"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("property_type", None) + if field is not None: + args["property_type"] = field + + field = data.get("unit", None) + if field is not None: + args["unit"] = field + else: + args["unit"] = None + + field = data.get("string_constraint", None) + if field is not None: + args["string_constraint"] = field + else: + args["string_constraint"] = None + + field = data.get("int_min", None) + if field is not None: + args["int_min"] = field + else: + args["int_min"] = None + + field = data.get("int_max", None) + if field is not None: + args["int_max"] = field + else: + args["int_max"] = None + + field = data.get("float_min", None) + if field is not None: + args["float_min"] = field + else: + args["float_min"] = None + + field = data.get("float_max", None) + if field is not None: + args["float_max"] = field + else: + args["float_max"] = None + + return Setting(**args) + + +def unmarshal_Version(data: Any) -> Version: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Version' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("version", None) + if field is not None: + args["version"] = field + + field = data.get("available_settings", None) + if field is not None: + args["available_settings"] = ( + [unmarshal_Setting(v) for v in field] if field is not None else None + ) + + field = data.get("end_of_life_at", None) + if field is not None: + args["end_of_life_at"] = ( + parser.isoparse(field) if isinstance(field, str) else field + ) + else: + args["end_of_life_at"] = None + + return Version(**args) + + +def unmarshal_ListVersionsResponse(data: Any) -> ListVersionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("versions", None) + if field is not None: + args["versions"] = ( + [unmarshal_Version(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListVersionsResponse(**args) + + +def marshal_EndpointSpecPrivateNetworkDetails( + request: EndpointSpecPrivateNetworkDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + return output + + +def marshal_EndpointSpecPublicDetails( + request: EndpointSpecPublicDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + return output + + +def marshal_CreateInstanceRequestVolumeDetails( + request: CreateInstanceRequestVolumeDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.volume_size is not None: + output["volume_size"] = request.volume_size + + if request.volume_type is not None: + output["volume_type"] = str(request.volume_type) + + return output + + +def marshal_EndpointSpec( + request: EndpointSpec, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("public", request.public), + OneOfPossibility("private_network", request.private_network), + ] + ), + ) + + return output + + +def marshal_CreateInstanceRequest( + request: CreateInstanceRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.version is not None: + output["version"] = request.version + + if request.node_number is not None: + output["node_number"] = request.node_number + + if request.node_type is not None: + output["node_type"] = request.node_type + + if request.user_name is not None: + output["user_name"] = request.user_name + + if request.password is not None: + output["password"] = request.password + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.volume is not None: + output["volume"] = marshal_CreateInstanceRequestVolumeDetails( + request.volume, defaults + ) + + if request.endpoints is not None: + output["endpoints"] = [ + marshal_EndpointSpec(item, defaults) for item in request.endpoints + ] + + return output + + +def marshal_CreateSnapshotRequest( + request: CreateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.expires_at is not None: + output["expires_at"] = request.expires_at.isoformat() + + return output + + +def marshal_RestoreSnapshotRequestVolumeDetails( + request: RestoreSnapshotRequestVolumeDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.volume_type is not None: + output["volume_type"] = str(request.volume_type) + + return output + + +def marshal_RestoreSnapshotRequest( + request: RestoreSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.instance_name is not None: + output["instance_name"] = request.instance_name + + if request.node_type is not None: + output["node_type"] = request.node_type + + if request.node_number is not None: + output["node_number"] = request.node_number + + if request.volume is not None: + output["volume"] = marshal_RestoreSnapshotRequestVolumeDetails( + request.volume, defaults + ) + + return output + + +def marshal_UpdateInstanceRequest( + request: UpdateInstanceRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateSnapshotRequest( + request: UpdateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.expires_at is not None: + output["expires_at"] = request.expires_at.isoformat() + + return output + + +def marshal_UpdateUserRequest( + request: UpdateUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_UpgradeInstanceRequest( + request: UpgradeInstanceRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("volume_size", request.volume_size), + ] + ), + ) + + return output diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py new file mode 100644 index 000000000..825aa81f0 --- /dev/null +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py @@ -0,0 +1,958 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class InstanceStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + READY = "ready" + PROVISIONING = "provisioning" + CONFIGURING = "configuring" + DELETING = "deleting" + ERROR = "error" + INITIALIZING = "initializing" + LOCKED = "locked" + SNAPSHOTTING = "snapshotting" + + def __str__(self) -> str: + return str(self.value) + + +class ListInstancesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListSnapshotsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + EXPIRES_AT_ASC = "expires_at_asc" + EXPIRES_AT_DESC = "expires_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListUsersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class NodeTypeStock(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STOCK = "unknown_stock" + LOW_STOCK = "low_stock" + OUT_OF_STOCK = "out_of_stock" + AVAILABLE = "available" + + def __str__(self) -> str: + return str(self.value) + + +class SettingPropertyType(str, Enum, metaclass=StrEnumMeta): + BOOLEAN = "boolean" + INT = "int" + STRING = "string" + FLOAT = "float" + + def __str__(self) -> str: + return str(self.value) + + +class SnapshotStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + READY = "ready" + RESTORING = "restoring" + DELETING = "deleting" + ERROR = "error" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class VolumeType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + SBS_5K = "sbs_5k" + SBS_15K = "sbs_15k" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class EndpointPrivateNetworkDetails: + """ + Private Network details. + """ + + private_network_id: str + """ + UUID of the private network. + """ + + +@dataclass +class EndpointPublicDetails: + pass + + +@dataclass +class EndpointSpecPrivateNetworkDetails: + private_network_id: str + """ + UUID of the private network. + """ + + +@dataclass +class EndpointSpecPublicDetails: + pass + + +@dataclass +class Endpoint: + id: str + """ + UUID of the endpoint. + """ + + ips: List[str] + """ + List of IPv4 addresses of the endpoint. + """ + + dns_records: List[str] + """ + List of DNS records of the endpoint. + """ + + port: int + """ + TCP port of the endpoint. + """ + + private_network: Optional[EndpointPrivateNetworkDetails] + + public: Optional[EndpointPublicDetails] + + +@dataclass +class InstanceSetting: + name: str + """ + Name of the settings. + """ + + value: str + """ + Value of the settings. + """ + + +@dataclass +class Volume: + type_: VolumeType + """ + Type of volume where data is stored. + """ + + size: int + """ + Volume size. + """ + + +@dataclass +class NodeTypeVolumeType: + type_: VolumeType + """ + Volume Type. + """ + + description: str + """ + The description of the Volume. + """ + + min_size: int + """ + Mimimum size required for the Volume. + """ + + max_size: int + """ + Maximum size required for the Volume. + """ + + chunk_size: int + """ + Minimum increment level for a Block Storage volume size. + """ + + +@dataclass +class SnapshotVolumeType: + type_: VolumeType + + +@dataclass +class Setting: + name: str + """ + Setting name from the database engine. + """ + + default_value: str + """ + Value set when not specified. + """ + + hot_configurable: bool + """ + Setting can be applied without restarting. + """ + + description: str + """ + Setting description. + """ + + property_type: SettingPropertyType + """ + Setting type. + """ + + unit: Optional[str] + """ + Setting base unit. + """ + + string_constraint: Optional[str] + """ + Validation regex for string type settings. + """ + + int_min: Optional[int] + """ + Minimum value for int types. + """ + + int_max: Optional[int] + """ + Maximum value for int types. + """ + + float_min: Optional[float] + """ + Minimum value for float types. + """ + + float_max: Optional[float] + """ + Maximum value for float types. + """ + + +@dataclass +class CreateInstanceRequestVolumeDetails: + volume_size: int + """ + Volume size. + """ + + volume_type: VolumeType + """ + Type of volume where data is stored. + """ + + +@dataclass +class EndpointSpec: + public: Optional[EndpointSpecPublicDetails] + + private_network: Optional[EndpointSpecPrivateNetworkDetails] + + +@dataclass +class Instance: + id: str + """ + UUID of the Database Instance. + """ + + name: str + """ + Name of the Database Instance. + """ + + project_id: str + """ + Project ID the Database Instance belongs to. + """ + + status: InstanceStatus + """ + Status of the Database Instance. + """ + + version: str + """ + MongoDB™ engine version of the Database Instance. + """ + + tags: List[str] + """ + List of tags applied to the Database Instance. + """ + + settings: List[InstanceSetting] + """ + Advanced settings of the Database Instance. + """ + + node_number: int + """ + Number of node in the Database Instance. + """ + + node_type: str + """ + Node type of the Database Instance. + """ + + endpoints: List[Endpoint] + """ + List of Database Instance endpoints. + """ + + region: Region + """ + Region the Database Instance is in. + """ + + volume: Optional[Volume] + """ + Volumes of the Database Instance. + """ + + created_at: Optional[datetime] + """ + Creation date (must follow the ISO 8601 format). + """ + + +@dataclass +class NodeType: + name: str + """ + Node Type name identifier. + """ + + stock_status: NodeTypeStock + """ + Current stock status for the Node Type. + """ + + description: str + """ + Current specs of the offer. + """ + + vcpus: int + """ + Number of virtual CPUs. + """ + + memory: int + """ + Quantity of RAM. + """ + + available_volume_types: List[NodeTypeVolumeType] + """ + Available storage options for the Node Type. + """ + + disabled: bool + """ + The Node Type is currently disabled. + """ + + beta: bool + """ + The Node Type is currently in beta. + """ + + instance_range: str + """ + Instance range associated with the NodeType offer. + """ + + +@dataclass +class Snapshot: + id: str + """ + UUID of the snapshot. + """ + + instance_id: str + """ + UUID of the Database Instance. + """ + + name: str + """ + Name of the snapshot. + """ + + status: SnapshotStatus + """ + Status of the snapshot. + """ + + size: int + """ + Size of the snapshot. + """ + + instance_name: str + """ + Name of the Database Instance of the snapshot. + """ + + node_type: str + """ + Source node type. + """ + + region: Region + """ + Region of this snapshot. + """ + + expires_at: Optional[datetime] + """ + Expiration date (must follow the ISO 8601 format). + """ + + created_at: Optional[datetime] + """ + Creation date (must follow the ISO 8601 format). + """ + + updated_at: Optional[datetime] + """ + Updated date (must follow the ISO 8601 format). + """ + + volume_type: Optional[SnapshotVolumeType] + """ + Type of volume where data is stored sbs_5k or sbs_15k. + """ + + +@dataclass +class User: + name: str + """ + Name of the user (Length must be between 1 and 63 characters. First character must be an alphabet character (a-zA-Z). Only a-zA-Z0-9_$- characters are accepted). + """ + + +@dataclass +class Version: + version: str + """ + MongoDB™ engine version. + """ + + available_settings: List[Setting] + """ + Instance settings available to be updated. + """ + + end_of_life_at: Optional[datetime] + """ + Date of End of Life. + """ + + +@dataclass +class RestoreSnapshotRequestVolumeDetails: + volume_type: VolumeType + """ + Type of volume where data is stored. + """ + + +@dataclass +class CreateInstanceRequest: + name: str + """ + Name of the Database Instance. + """ + + version: str + """ + Version of the MongoDB™ engine. + """ + + node_number: int + """ + Number of node to use for the Database Instance. + """ + + node_type: str + """ + Type of node to use for the Database Instance. + """ + + user_name: str + """ + Username created when the Database Instance is created. + """ + + password: str + """ + Password of the initial user. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + The Project ID on which the Database Instance will be created. + """ + + tags: Optional[List[str]] + """ + Tags to apply to the Database Instance. + """ + + volume: Optional[CreateInstanceRequestVolumeDetails] + """ + Instance volume information. + """ + + endpoints: Optional[List[EndpointSpec]] + """ + One or multiple EndpointSpec used to expose your Database Instance. + """ + + +@dataclass +class CreateSnapshotRequest: + instance_id: str + """ + UUID of the Database Instance to snapshot. + """ + + name: str + """ + Name of the snapshot. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + expires_at: Optional[datetime] + """ + Expiration date of the snapshot (must follow the ISO 8601 format). + """ + + +@dataclass +class DeleteInstanceRequest: + instance_id: str + """ + UUID of the Database Instance to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteSnapshotRequest: + snapshot_id: str + """ + UUID of the snapshot. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetInstanceCertificateRequest: + instance_id: str + """ + UUID of the Database Instance. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetInstanceRequest: + instance_id: str + """ + UUID of the Database Instance. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListInstancesRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + tags: Optional[List[str]] + """ + List Database Instances that have a given tag. + """ + + name: Optional[str] + """ + Lists Database Instances that match a name pattern. + """ + + order_by: Optional[ListInstancesRequestOrderBy] + """ + Criteria to use when ordering Database Instance listings. + """ + + organization_id: Optional[str] + """ + Organization ID the Database Instance belongs to. + """ + + project_id: Optional[str] + """ + Project ID to list the Database Instance of. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListInstancesResponse: + instances: List[Instance] + """ + List of all Database Instances available in an Organization or Project. + """ + + total_count: int + """ + Total count of Database Instances available in a Organization or Project. + """ + + +@dataclass +class ListNodeTypesRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + include_disabled_types: Optional[bool] + """ + Defines whether or not to include disabled types. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListNodeTypesResponse: + node_types: List[NodeType] + """ + Types of the node. + """ + + total_count: int + """ + Total count of node-types available. + """ + + +@dataclass +class ListSnapshotsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + instance_id: Optional[str] + """ + Instance ID the snapshots belongs to. + """ + + name: Optional[str] + """ + Lists Database snapshots that match a name pattern. + """ + + order_by: Optional[ListSnapshotsRequestOrderBy] + """ + Criteria to use when ordering snapshot listings. + """ + + organization_id: Optional[str] + """ + Organization ID the snapshots belongs to. + """ + + project_id: Optional[str] + """ + Project ID to list the snapshots of. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListSnapshotsResponse: + snapshots: List[Snapshot] + """ + List of all Database Snapshots available in an Organization or Project. + """ + + total_count: int + """ + Total count of Database Snapshots available in a Organization or Project. + """ + + +@dataclass +class ListUsersRequest: + instance_id: str + """ + UUID of the Database Instance. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the user. + """ + + order_by: Optional[ListUsersRequestOrderBy] + """ + Criteria to use when requesting user listing. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListUsersResponse: + users: List[User] + """ + List of users in a Database Instance. + """ + + total_count: int + """ + Total count of users present on a Database Instance. + """ + + +@dataclass +class ListVersionsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + version: Optional[str] + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListVersionsResponse: + versions: List[Version] + """ + Available MongoDB™ engine version. + """ + + total_count: int + """ + Total count of MongoDB™ engine version available. + """ + + +@dataclass +class RestoreSnapshotRequest: + snapshot_id: str + """ + UUID of the snapshot. + """ + + instance_name: str + """ + Name of the new Database Instance. + """ + + node_type: str + """ + Node type to use for the new Database Instance. + """ + + node_number: int + """ + Number of nodes to use for the new Database Instance. + """ + + volume: RestoreSnapshotRequestVolumeDetails + """ + Instance volume information. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class UpdateInstanceRequest: + instance_id: str + """ + UUID of the Database Instance to update. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the Database Instance. + """ + + tags: Optional[List[str]] + """ + Tags of a Database Instance. + """ + + +@dataclass +class UpdateSnapshotRequest: + snapshot_id: str + """ + UUID of the Snapshot. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the snapshot. + """ + + expires_at: Optional[datetime] + """ + Expiration date of the snapshot (must follow the ISO 8601 format). + """ + + +@dataclass +class UpdateUserRequest: + 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. + """ + + password: Optional[str] + """ + Password of the database user. + """ + + +@dataclass +class UpgradeInstanceRequest: + instance_id: str + """ + UUID of the Database Instance you want to upgrade. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + volume_size: Optional[int] diff --git a/scaleway/scaleway/mongodb/__init__.py b/scaleway/scaleway/mongodb/__init__.py new file mode 100644 index 000000000..8b74a5ed7 --- /dev/null +++ b/scaleway/scaleway/mongodb/__init__.py @@ -0,0 +1,2 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. diff --git a/scaleway/scaleway/mongodb/v1alpha1/__init__.py b/scaleway/scaleway/mongodb/v1alpha1/__init__.py new file mode 100644 index 000000000..849bdf68c --- /dev/null +++ b/scaleway/scaleway/mongodb/v1alpha1/__init__.py @@ -0,0 +1,105 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import InstanceStatus +from .content import INSTANCE_TRANSIENT_STATUSES +from .types import ListInstancesRequestOrderBy +from .types import ListSnapshotsRequestOrderBy +from .types import ListUsersRequestOrderBy +from .types import NodeTypeStock +from .types import SettingPropertyType +from .types import SnapshotStatus +from .content import SNAPSHOT_TRANSIENT_STATUSES +from .types import VolumeType +from .types import EndpointPrivateNetworkDetails +from .types import EndpointPublicDetails +from .types import EndpointSpecPrivateNetworkDetails +from .types import EndpointSpecPublicDetails +from .types import Endpoint +from .types import InstanceSetting +from .types import Volume +from .types import NodeTypeVolumeType +from .types import SnapshotVolumeType +from .types import Setting +from .types import CreateInstanceRequestVolumeDetails +from .types import EndpointSpec +from .types import Instance +from .types import NodeType +from .types import Snapshot +from .types import User +from .types import Version +from .types import RestoreSnapshotRequestVolumeDetails +from .types import CreateInstanceRequest +from .types import CreateSnapshotRequest +from .types import DeleteInstanceRequest +from .types import DeleteSnapshotRequest +from .types import GetInstanceCertificateRequest +from .types import GetInstanceRequest +from .types import ListInstancesRequest +from .types import ListInstancesResponse +from .types import ListNodeTypesRequest +from .types import ListNodeTypesResponse +from .types import ListSnapshotsRequest +from .types import ListSnapshotsResponse +from .types import ListUsersRequest +from .types import ListUsersResponse +from .types import ListVersionsRequest +from .types import ListVersionsResponse +from .types import RestoreSnapshotRequest +from .types import UpdateInstanceRequest +from .types import UpdateSnapshotRequest +from .types import UpdateUserRequest +from .types import UpgradeInstanceRequest +from .api import MongodbV1Alpha1API + +__all__ = [ + "InstanceStatus", + "INSTANCE_TRANSIENT_STATUSES", + "ListInstancesRequestOrderBy", + "ListSnapshotsRequestOrderBy", + "ListUsersRequestOrderBy", + "NodeTypeStock", + "SettingPropertyType", + "SnapshotStatus", + "SNAPSHOT_TRANSIENT_STATUSES", + "VolumeType", + "EndpointPrivateNetworkDetails", + "EndpointPublicDetails", + "EndpointSpecPrivateNetworkDetails", + "EndpointSpecPublicDetails", + "Endpoint", + "InstanceSetting", + "Volume", + "NodeTypeVolumeType", + "SnapshotVolumeType", + "Setting", + "CreateInstanceRequestVolumeDetails", + "EndpointSpec", + "Instance", + "NodeType", + "Snapshot", + "User", + "Version", + "RestoreSnapshotRequestVolumeDetails", + "CreateInstanceRequest", + "CreateSnapshotRequest", + "DeleteInstanceRequest", + "DeleteSnapshotRequest", + "GetInstanceCertificateRequest", + "GetInstanceRequest", + "ListInstancesRequest", + "ListInstancesResponse", + "ListNodeTypesRequest", + "ListNodeTypesResponse", + "ListSnapshotsRequest", + "ListSnapshotsResponse", + "ListUsersRequest", + "ListUsersResponse", + "ListVersionsRequest", + "ListVersionsResponse", + "RestoreSnapshotRequest", + "UpdateInstanceRequest", + "UpdateSnapshotRequest", + "UpdateUserRequest", + "UpgradeInstanceRequest", + "MongodbV1Alpha1API", +] diff --git a/scaleway/scaleway/mongodb/v1alpha1/api.py b/scaleway/scaleway/mongodb/v1alpha1/api.py new file mode 100644 index 000000000..efd6b88c0 --- /dev/null +++ b/scaleway/scaleway/mongodb/v1alpha1/api.py @@ -0,0 +1,1042 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from datetime import datetime +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region, + ScwFile, + unmarshal_ScwFile, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + ListInstancesRequestOrderBy, + ListSnapshotsRequestOrderBy, + ListUsersRequestOrderBy, + CreateInstanceRequest, + CreateInstanceRequestVolumeDetails, + CreateSnapshotRequest, + EndpointSpec, + Instance, + ListInstancesResponse, + ListNodeTypesResponse, + ListSnapshotsResponse, + ListUsersResponse, + ListVersionsResponse, + NodeType, + RestoreSnapshotRequest, + RestoreSnapshotRequestVolumeDetails, + Snapshot, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradeInstanceRequest, + User, + Version, +) +from .content import ( + INSTANCE_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Instance, + unmarshal_Snapshot, + unmarshal_User, + unmarshal_ListInstancesResponse, + unmarshal_ListNodeTypesResponse, + unmarshal_ListSnapshotsResponse, + unmarshal_ListUsersResponse, + unmarshal_ListVersionsResponse, + marshal_CreateInstanceRequest, + marshal_CreateSnapshotRequest, + marshal_RestoreSnapshotRequest, + marshal_UpdateInstanceRequest, + marshal_UpdateSnapshotRequest, + marshal_UpdateUserRequest, + marshal_UpgradeInstanceRequest, +) + + +class MongodbV1Alpha1API(API): + """ + This API allows you to manage your Managed Databases for MongoDB. + """ + + def list_node_types( + self, + *, + region: Optional[Region] = None, + include_disabled_types: Optional[bool] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListNodeTypesResponse: + """ + List available node types. + :param region: Region to target. If none is passed will use default region from the config. + :param include_disabled_types: Defines whether or not to include disabled types. + :param page: + :param page_size: + :return: :class:`ListNodeTypesResponse ` + + Usage: + :: + + result = api.list_node_types() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/node-types", + params={ + "include_disabled_types": include_disabled_types, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListNodeTypesResponse(res.json()) + + def list_node_types_all( + self, + *, + region: Optional[Region] = None, + include_disabled_types: Optional[bool] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[NodeType]: + """ + List available node types. + :param region: Region to target. If none is passed will use default region from the config. + :param include_disabled_types: Defines whether or not to include disabled types. + :param page: + :param page_size: + :return: :class:`List[NodeType] ` + + Usage: + :: + + result = api.list_node_types_all() + """ + + return fetch_all_pages( + type=ListNodeTypesResponse, + key="node_types", + fetcher=self.list_node_types, + args={ + "region": region, + "include_disabled_types": include_disabled_types, + "page": page, + "page_size": page_size, + }, + ) + + def list_versions( + self, + *, + region: Optional[Region] = None, + version: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListVersionsResponse: + """ + List available MongoDB™ versions. + :param region: Region to target. If none is passed will use default region from the config. + :param version: + :param page: + :param page_size: + :return: :class:`ListVersionsResponse ` + + Usage: + :: + + result = api.list_versions() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/versions", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + "version": version, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVersionsResponse(res.json()) + + def list_versions_all( + self, + *, + region: Optional[Region] = None, + version: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[Version]: + """ + List available MongoDB™ versions. + :param region: Region to target. If none is passed will use default region from the config. + :param version: + :param page: + :param page_size: + :return: :class:`List[Version] ` + + Usage: + :: + + result = api.list_versions_all() + """ + + return fetch_all_pages( + type=ListVersionsResponse, + key="versions", + fetcher=self.list_versions, + args={ + "region": region, + "version": version, + "page": page, + "page_size": page_size, + }, + ) + + def list_instances( + self, + *, + region: Optional[Region] = None, + tags: Optional[List[str]] = None, + name: Optional[str] = None, + order_by: Optional[ListInstancesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListInstancesResponse: + """ + List MongoDB™ Database Instances. + List all MongoDB™ Database Instances in the specified region, for a given Scaleway Project. By default, the MongoDB™ Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: List Database Instances that have a given tag. + :param name: Lists Database Instances that match a name pattern. + :param order_by: Criteria to use when ordering Database Instance listings. + :param organization_id: Organization ID the Database Instance belongs to. + :param project_id: Project ID to list the Database Instance of. + :param page: + :param page_size: + :return: :class:`ListInstancesResponse ` + + Usage: + :: + + result = api.list_instances() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances", + params={ + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListInstancesResponse(res.json()) + + def list_instances_all( + self, + *, + region: Optional[Region] = None, + tags: Optional[List[str]] = None, + name: Optional[str] = None, + order_by: Optional[ListInstancesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[Instance]: + """ + List MongoDB™ Database Instances. + List all MongoDB™ Database Instances in the specified region, for a given Scaleway Project. By default, the MongoDB™ Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: List Database Instances that have a given tag. + :param name: Lists Database Instances that match a name pattern. + :param order_by: Criteria to use when ordering Database Instance listings. + :param organization_id: Organization ID the Database Instance belongs to. + :param project_id: Project ID to list the Database Instance of. + :param page: + :param page_size: + :return: :class:`List[Instance] ` + + Usage: + :: + + result = api.list_instances_all() + """ + + return fetch_all_pages( + type=ListInstancesResponse, + key="instances", + fetcher=self.list_instances, + args={ + "region": region, + "tags": tags, + "name": name, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "page": page, + "page_size": page_size, + }, + ) + + def get_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + ) -> Instance: + """ + Get a MongoDB™ Database Instance. + Retrieve information about a given MongoDB™ Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = api.get_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}", + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + def wait_for_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Instance, bool]] = None, + ) -> Instance: + """ + Get a MongoDB™ Database Instance. + Retrieve information about a given MongoDB™ Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = api.get_instance( + instance_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in INSTANCE_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_instance, + options=options, + args={ + "instance_id": instance_id, + "region": region, + }, + ) + + def create_instance( + self, + *, + name: str, + version: str, + node_number: int, + node_type: str, + user_name: str, + password: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + volume: Optional[CreateInstanceRequestVolumeDetails] = None, + endpoints: Optional[List[EndpointSpec]] = None, + ) -> Instance: + """ + Create a MongoDB™ Database Instance. + Create a new MongoDB™ Database Instance. + :param name: Name of the Database Instance. + :param version: Version of the MongoDB™ engine. + :param node_number: Number of node to use for the Database Instance. + :param node_type: Type of node to use for the Database Instance. + :param user_name: Username created when the Database Instance is created. + :param password: Password of the initial user. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: The Project ID on which the Database Instance will be created. + :param tags: Tags to apply to the Database Instance. + :param volume: Instance volume information. + :param endpoints: One or multiple EndpointSpec used to expose your Database Instance. + :return: :class:`Instance ` + + Usage: + :: + + result = api.create_instance( + name="example", + version="example", + node_number=1, + node_type="example", + user_name="example", + password="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/instances", + body=marshal_CreateInstanceRequest( + CreateInstanceRequest( + name=name, + version=version, + node_number=node_number, + node_type=node_type, + user_name=user_name, + password=password, + region=region, + project_id=project_id, + tags=tags, + volume=volume, + endpoints=endpoints, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + def update_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Instance: + """ + Update a MongoDB™ Database Instance. + Update the parameters of a MongoDB™ Database Instance. + :param instance_id: UUID of the Database Instance to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the Database Instance. + :param tags: Tags of a Database Instance. + :return: :class:`Instance ` + + Usage: + :: + + result = api.update_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "PATCH", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}", + body=marshal_UpdateInstanceRequest( + UpdateInstanceRequest( + instance_id=instance_id, + region=region, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + def delete_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + ) -> Instance: + """ + Delete a MongoDB™ Database Instance. + Delete a given MongoDB™ Database Instance, specified by the `region` and `instance_id` parameters. Deleting a MongoDB™ Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost. + :param instance_id: UUID of the Database Instance to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = api.delete_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "DELETE", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}", + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + def upgrade_instance( + self, + *, + instance_id: str, + region: Optional[Region] = None, + volume_size: Optional[int] = None, + ) -> Instance: + """ + Upgrade a Database Instance. + Upgrade your current Database Instance specifications like volume size. + :param instance_id: UUID of the Database Instance you want to upgrade. + :param region: Region to target. If none is passed will use default region from the config. + :param volume_size: Increase your block storage volume size. + One-Of ('upgrade_target'): at most one of 'volume_size' could be set. + :return: :class:`Instance ` + + Usage: + :: + + result = api.upgrade_instance( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/upgrade", + body=marshal_UpgradeInstanceRequest( + UpgradeInstanceRequest( + instance_id=instance_id, + region=region, + volume_size=volume_size, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + def get_instance_certificate( + self, + *, + instance_id: str, + region: Optional[Region] = None, + ) -> ScwFile: + """ + Get the certificate of a Database Instance. + Retrieve the certificate of a given Database Instance, specified by the `instance_id` parameter. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ScwFile ` + + Usage: + :: + + result = api.get_instance_certificate( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/certificate", + ) + + self._throw_on_error(res) + return unmarshal_ScwFile(res.json()) + + def create_snapshot( + self, + *, + instance_id: str, + name: str, + region: Optional[Region] = None, + expires_at: Optional[datetime] = None, + ) -> Snapshot: + """ + Create a Database Instance snapshot. + Create a new snapshot of a Database Instance. You must define the `name` and `instance_id` parameters in the request. + :param instance_id: UUID of the Database Instance to snapshot. + :param name: Name of the snapshot. + :param region: Region to target. If none is passed will use default region from the config. + :param expires_at: Expiration date of the snapshot (must follow the ISO 8601 format). + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.create_snapshot( + 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) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/snapshots", + body=marshal_CreateSnapshotRequest( + CreateSnapshotRequest( + instance_id=instance_id, + name=name, + region=region, + expires_at=expires_at, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + def update_snapshot( + self, + *, + snapshot_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + expires_at: Optional[datetime] = None, + ) -> Snapshot: + """ + :param snapshot_id: UUID of the Snapshot. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the snapshot. + :param expires_at: Expiration date of the snapshot (must follow the ISO 8601 format). + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.update_snapshot( + snapshot_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots/{param_snapshot_id}", + body=marshal_UpdateSnapshotRequest( + UpdateSnapshotRequest( + snapshot_id=snapshot_id, + region=region, + name=name, + expires_at=expires_at, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + def restore_snapshot( + self, + *, + snapshot_id: str, + instance_name: str, + node_type: str, + node_number: int, + volume: RestoreSnapshotRequestVolumeDetails, + region: Optional[Region] = None, + ) -> Instance: + """ + Restore a Database Instance snapshot. + Restore a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to restore, the `instance_name` of the new Database Instance, `node_type` of the new Database Instance and `node_number` of the new Database Instance. + :param snapshot_id: UUID of the snapshot. + :param instance_name: Name of the new Database Instance. + :param node_type: Node type to use for the new Database Instance. + :param node_number: Number of nodes to use for the new Database Instance. + :param volume: Instance volume information. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Instance ` + + Usage: + :: + + result = api.restore_snapshot( + snapshot_id="example", + instance_name="example", + node_type="example", + node_number=1, + volume=RestoreSnapshotRequestVolumeDetails(), + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "POST", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots/{param_snapshot_id}/restore", + body=marshal_RestoreSnapshotRequest( + RestoreSnapshotRequest( + snapshot_id=snapshot_id, + instance_name=instance_name, + node_type=node_type, + node_number=node_number, + volume=volume, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Instance(res.json()) + + def list_snapshots( + self, + *, + region: Optional[Region] = None, + instance_id: Optional[str] = None, + name: Optional[str] = None, + order_by: Optional[ListSnapshotsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListSnapshotsResponse: + """ + List snapshots. + List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param instance_id: Instance ID the snapshots belongs to. + :param name: Lists Database snapshots that match a name pattern. + :param order_by: Criteria to use when ordering snapshot listings. + :param organization_id: Organization ID the snapshots belongs to. + :param project_id: Project ID to list the snapshots of. + :param page: + :param page_size: + :return: :class:`ListSnapshotsResponse ` + + Usage: + :: + + result = api.list_snapshots() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots", + params={ + "instance_id": instance_id, + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListSnapshotsResponse(res.json()) + + def list_snapshots_all( + self, + *, + region: Optional[Region] = None, + instance_id: Optional[str] = None, + name: Optional[str] = None, + order_by: Optional[ListSnapshotsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[Snapshot]: + """ + List snapshots. + List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param instance_id: Instance ID the snapshots belongs to. + :param name: Lists Database snapshots that match a name pattern. + :param order_by: Criteria to use when ordering snapshot listings. + :param organization_id: Organization ID the snapshots belongs to. + :param project_id: Project ID to list the snapshots of. + :param page: + :param page_size: + :return: :class:`List[Snapshot] ` + + Usage: + :: + + result = api.list_snapshots_all() + """ + + return fetch_all_pages( + type=ListSnapshotsResponse, + key="snapshots", + fetcher=self.list_snapshots, + args={ + "region": region, + "instance_id": instance_id, + "name": name, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "page": page, + "page_size": page_size, + }, + ) + + def delete_snapshot( + self, + *, + snapshot_id: str, + region: Optional[Region] = None, + ) -> Snapshot: + """ + Delete a Database Instance snapshot. + Delete a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to delete. + :param snapshot_id: UUID of the snapshot. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Snapshot ` + + Usage: + :: + + result = api.delete_snapshot( + snapshot_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_snapshot_id = validate_path_param("snapshot_id", snapshot_id) + + res = self._request( + "DELETE", + f"/mongodb/v1alpha1/regions/{param_region}/snapshots/{param_snapshot_id}", + ) + + self._throw_on_error(res) + return unmarshal_Snapshot(res.json()) + + def list_users( + self, + *, + instance_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + order_by: Optional[ListUsersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListUsersResponse: + """ + List users of a Database Instance. + List all users of a given Database Instance. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the user. + :param order_by: Criteria to use when requesting user listing. + :param page: + :param page_size: + :return: :class:`ListUsersResponse ` + + Usage: + :: + + result = api.list_users( + instance_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_instance_id = validate_path_param("instance_id", instance_id) + + res = self._request( + "GET", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListUsersResponse(res.json()) + + def list_users_all( + self, + *, + instance_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + order_by: Optional[ListUsersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[User]: + """ + List users of a Database Instance. + List all users of a given Database Instance. + :param instance_id: UUID of the Database Instance. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the user. + :param order_by: Criteria to use when requesting user listing. + :param page: + :param page_size: + :return: :class:`List[User] ` + + Usage: + :: + + result = api.list_users_all( + instance_id="example", + ) + """ + + return fetch_all_pages( + type=ListUsersResponse, + key="users", + fetcher=self.list_users, + args={ + "instance_id": instance_id, + "region": region, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size, + }, + ) + + def update_user( + self, + *, + instance_id: str, + name: str, + region: Optional[Region] = None, + password: Optional[str] = None, + ) -> User: + """ + Update a user on a Database Instance. + Update the parameters of a user on a Database Instance. You can update the `password` parameter, but you cannot change the name of the user. + :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. + :param password: Password of the database user. + :return: :class:`User ` + + Usage: + :: + + result = api.update_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( + "PATCH", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}", + body=marshal_UpdateUserRequest( + UpdateUserRequest( + instance_id=instance_id, + name=name, + region=region, + password=password, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) diff --git a/scaleway/scaleway/mongodb/v1alpha1/content.py b/scaleway/scaleway/mongodb/v1alpha1/content.py new file mode 100644 index 000000000..8e0092203 --- /dev/null +++ b/scaleway/scaleway/mongodb/v1alpha1/content.py @@ -0,0 +1,27 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + InstanceStatus, + SnapshotStatus, +) + +INSTANCE_TRANSIENT_STATUSES: List[InstanceStatus] = [ + InstanceStatus.PROVISIONING, + InstanceStatus.CONFIGURING, + InstanceStatus.DELETING, + InstanceStatus.INITIALIZING, + InstanceStatus.SNAPSHOTTING, +] +""" +Lists transient statutes of the enum :class:`InstanceStatus `. +""" +SNAPSHOT_TRANSIENT_STATUSES: List[SnapshotStatus] = [ + SnapshotStatus.CREATING, + SnapshotStatus.RESTORING, + SnapshotStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`SnapshotStatus `. +""" diff --git a/scaleway/scaleway/mongodb/v1alpha1/marshalling.py b/scaleway/scaleway/mongodb/v1alpha1/marshalling.py new file mode 100644 index 000000000..e3012a10b --- /dev/null +++ b/scaleway/scaleway/mongodb/v1alpha1/marshalling.py @@ -0,0 +1,801 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + EndpointPrivateNetworkDetails, + EndpointPublicDetails, + Endpoint, + InstanceSetting, + Volume, + Instance, + SnapshotVolumeType, + Snapshot, + User, + ListInstancesResponse, + NodeTypeVolumeType, + NodeType, + ListNodeTypesResponse, + ListSnapshotsResponse, + ListUsersResponse, + Setting, + Version, + ListVersionsResponse, + EndpointSpecPrivateNetworkDetails, + EndpointSpecPublicDetails, + CreateInstanceRequestVolumeDetails, + EndpointSpec, + CreateInstanceRequest, + CreateSnapshotRequest, + RestoreSnapshotRequestVolumeDetails, + RestoreSnapshotRequest, + UpdateInstanceRequest, + UpdateSnapshotRequest, + UpdateUserRequest, + UpgradeInstanceRequest, +) + + +def unmarshal_EndpointPrivateNetworkDetails(data: Any) -> EndpointPrivateNetworkDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + + return EndpointPrivateNetworkDetails(**args) + + +def unmarshal_EndpointPublicDetails(data: Any) -> EndpointPublicDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + return EndpointPublicDetails(**args) + + +def unmarshal_Endpoint(data: Any) -> Endpoint: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Endpoint' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("ips", None) + if field is not None: + args["ips"] = field + + field = data.get("dns_records", None) + if field is not None: + args["dns_records"] = field + + field = data.get("port", None) + if field is not None: + args["port"] = field + + field = data.get("private_network", None) + if field is not None: + args["private_network"] = unmarshal_EndpointPrivateNetworkDetails(field) + else: + args["private_network"] = None + + field = data.get("public", None) + if field is not None: + args["public"] = unmarshal_EndpointPublicDetails(field) + else: + args["public"] = None + + return Endpoint(**args) + + +def unmarshal_InstanceSetting(data: Any) -> InstanceSetting: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("value", None) + if field is not None: + args["value"] = field + + return InstanceSetting(**args) + + +def unmarshal_Volume(data: Any) -> Volume: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Volume' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("size", None) + if field is not None: + args["size"] = field + + return Volume(**args) + + +def unmarshal_Instance(data: Any) -> Instance: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Instance' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("version", None) + if field is not None: + args["version"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("settings", None) + if field is not None: + args["settings"] = ( + [unmarshal_InstanceSetting(v) for v in field] if field is not None else None + ) + + field = data.get("node_number", None) + if field is not None: + args["node_number"] = field + + field = data.get("node_type", None) + if field is not None: + args["node_type"] = field + + field = data.get("endpoints", None) + if field is not None: + args["endpoints"] = ( + [unmarshal_Endpoint(v) for v in field] if field is not None else None + ) + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("volume", None) + if field is not None: + args["volume"] = unmarshal_Volume(field) + else: + args["volume"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + return Instance(**args) + + +def unmarshal_SnapshotVolumeType(data: Any) -> SnapshotVolumeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + return SnapshotVolumeType(**args) + + +def unmarshal_Snapshot(data: Any) -> Snapshot: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Snapshot' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("instance_id", None) + if field is not None: + args["instance_id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("size", None) + if field is not None: + args["size"] = field + + field = data.get("instance_name", None) + if field is not None: + args["instance_name"] = field + + field = data.get("node_type", None) + if field is not None: + args["node_type"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("expires_at", None) + if field is not None: + args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["expires_at"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("volume_type", None) + if field is not None: + args["volume_type"] = unmarshal_SnapshotVolumeType(field) + else: + args["volume_type"] = None + + return Snapshot(**args) + + +def unmarshal_User(data: Any) -> User: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'User' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + return User(**args) + + +def unmarshal_ListInstancesResponse(data: Any) -> ListInstancesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("instances", None) + if field is not None: + args["instances"] = ( + [unmarshal_Instance(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListInstancesResponse(**args) + + +def unmarshal_NodeTypeVolumeType(data: Any) -> NodeTypeVolumeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("min_size", None) + if field is not None: + args["min_size"] = field + + field = data.get("max_size", None) + if field is not None: + args["max_size"] = field + + field = data.get("chunk_size", None) + if field is not None: + args["chunk_size"] = field + + return NodeTypeVolumeType(**args) + + +def unmarshal_NodeType(data: Any) -> NodeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'NodeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("stock_status", None) + if field is not None: + args["stock_status"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("vcpus", None) + if field is not None: + args["vcpus"] = field + + field = data.get("memory", None) + if field is not None: + args["memory"] = field + + field = data.get("available_volume_types", None) + if field is not None: + args["available_volume_types"] = ( + [unmarshal_NodeTypeVolumeType(v) for v in field] + if field is not None + else None + ) + + field = data.get("disabled", None) + if field is not None: + args["disabled"] = field + + field = data.get("beta", None) + if field is not None: + args["beta"] = field + + field = data.get("instance_range", None) + if field is not None: + args["instance_range"] = field + + return NodeType(**args) + + +def unmarshal_ListNodeTypesResponse(data: Any) -> ListNodeTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("node_types", None) + if field is not None: + args["node_types"] = ( + [unmarshal_NodeType(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListNodeTypesResponse(**args) + + +def unmarshal_ListSnapshotsResponse(data: Any) -> ListSnapshotsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("snapshots", None) + if field is not None: + args["snapshots"] = ( + [unmarshal_Snapshot(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListSnapshotsResponse(**args) + + +def unmarshal_ListUsersResponse(data: Any) -> ListUsersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("users", None) + if field is not None: + args["users"] = ( + [unmarshal_User(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListUsersResponse(**args) + + +def unmarshal_Setting(data: Any) -> Setting: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Setting' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("default_value", None) + if field is not None: + args["default_value"] = field + + field = data.get("hot_configurable", None) + if field is not None: + args["hot_configurable"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("property_type", None) + if field is not None: + args["property_type"] = field + + field = data.get("unit", None) + if field is not None: + args["unit"] = field + else: + args["unit"] = None + + field = data.get("string_constraint", None) + if field is not None: + args["string_constraint"] = field + else: + args["string_constraint"] = None + + field = data.get("int_min", None) + if field is not None: + args["int_min"] = field + else: + args["int_min"] = None + + field = data.get("int_max", None) + if field is not None: + args["int_max"] = field + else: + args["int_max"] = None + + field = data.get("float_min", None) + if field is not None: + args["float_min"] = field + else: + args["float_min"] = None + + field = data.get("float_max", None) + if field is not None: + args["float_max"] = field + else: + args["float_max"] = None + + return Setting(**args) + + +def unmarshal_Version(data: Any) -> Version: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Version' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("version", None) + if field is not None: + args["version"] = field + + field = data.get("available_settings", None) + if field is not None: + args["available_settings"] = ( + [unmarshal_Setting(v) for v in field] if field is not None else None + ) + + field = data.get("end_of_life_at", None) + if field is not None: + args["end_of_life_at"] = ( + parser.isoparse(field) if isinstance(field, str) else field + ) + else: + args["end_of_life_at"] = None + + return Version(**args) + + +def unmarshal_ListVersionsResponse(data: Any) -> ListVersionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("versions", None) + if field is not None: + args["versions"] = ( + [unmarshal_Version(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListVersionsResponse(**args) + + +def marshal_EndpointSpecPrivateNetworkDetails( + request: EndpointSpecPrivateNetworkDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + return output + + +def marshal_EndpointSpecPublicDetails( + request: EndpointSpecPublicDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + return output + + +def marshal_CreateInstanceRequestVolumeDetails( + request: CreateInstanceRequestVolumeDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.volume_size is not None: + output["volume_size"] = request.volume_size + + if request.volume_type is not None: + output["volume_type"] = str(request.volume_type) + + return output + + +def marshal_EndpointSpec( + request: EndpointSpec, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("public", request.public), + OneOfPossibility("private_network", request.private_network), + ] + ), + ) + + return output + + +def marshal_CreateInstanceRequest( + request: CreateInstanceRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.version is not None: + output["version"] = request.version + + if request.node_number is not None: + output["node_number"] = request.node_number + + if request.node_type is not None: + output["node_type"] = request.node_type + + if request.user_name is not None: + output["user_name"] = request.user_name + + if request.password is not None: + output["password"] = request.password + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.volume is not None: + output["volume"] = marshal_CreateInstanceRequestVolumeDetails( + request.volume, defaults + ) + + if request.endpoints is not None: + output["endpoints"] = [ + marshal_EndpointSpec(item, defaults) for item in request.endpoints + ] + + return output + + +def marshal_CreateSnapshotRequest( + request: CreateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.expires_at is not None: + output["expires_at"] = request.expires_at.isoformat() + + return output + + +def marshal_RestoreSnapshotRequestVolumeDetails( + request: RestoreSnapshotRequestVolumeDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.volume_type is not None: + output["volume_type"] = str(request.volume_type) + + return output + + +def marshal_RestoreSnapshotRequest( + request: RestoreSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.instance_name is not None: + output["instance_name"] = request.instance_name + + if request.node_type is not None: + output["node_type"] = request.node_type + + if request.node_number is not None: + output["node_number"] = request.node_number + + if request.volume is not None: + output["volume"] = marshal_RestoreSnapshotRequestVolumeDetails( + request.volume, defaults + ) + + return output + + +def marshal_UpdateInstanceRequest( + request: UpdateInstanceRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateSnapshotRequest( + request: UpdateSnapshotRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.expires_at is not None: + output["expires_at"] = request.expires_at.isoformat() + + return output + + +def marshal_UpdateUserRequest( + request: UpdateUserRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.password is not None: + output["password"] = request.password + + return output + + +def marshal_UpgradeInstanceRequest( + request: UpgradeInstanceRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("volume_size", request.volume_size), + ] + ), + ) + + return output diff --git a/scaleway/scaleway/mongodb/v1alpha1/types.py b/scaleway/scaleway/mongodb/v1alpha1/types.py new file mode 100644 index 000000000..825aa81f0 --- /dev/null +++ b/scaleway/scaleway/mongodb/v1alpha1/types.py @@ -0,0 +1,958 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class InstanceStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + READY = "ready" + PROVISIONING = "provisioning" + CONFIGURING = "configuring" + DELETING = "deleting" + ERROR = "error" + INITIALIZING = "initializing" + LOCKED = "locked" + SNAPSHOTTING = "snapshotting" + + def __str__(self) -> str: + return str(self.value) + + +class ListInstancesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListSnapshotsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + EXPIRES_AT_ASC = "expires_at_asc" + EXPIRES_AT_DESC = "expires_at_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListUsersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class NodeTypeStock(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STOCK = "unknown_stock" + LOW_STOCK = "low_stock" + OUT_OF_STOCK = "out_of_stock" + AVAILABLE = "available" + + def __str__(self) -> str: + return str(self.value) + + +class SettingPropertyType(str, Enum, metaclass=StrEnumMeta): + BOOLEAN = "boolean" + INT = "int" + STRING = "string" + FLOAT = "float" + + def __str__(self) -> str: + return str(self.value) + + +class SnapshotStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + READY = "ready" + RESTORING = "restoring" + DELETING = "deleting" + ERROR = "error" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class VolumeType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TYPE = "unknown_type" + SBS_5K = "sbs_5k" + SBS_15K = "sbs_15k" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class EndpointPrivateNetworkDetails: + """ + Private Network details. + """ + + private_network_id: str + """ + UUID of the private network. + """ + + +@dataclass +class EndpointPublicDetails: + pass + + +@dataclass +class EndpointSpecPrivateNetworkDetails: + private_network_id: str + """ + UUID of the private network. + """ + + +@dataclass +class EndpointSpecPublicDetails: + pass + + +@dataclass +class Endpoint: + id: str + """ + UUID of the endpoint. + """ + + ips: List[str] + """ + List of IPv4 addresses of the endpoint. + """ + + dns_records: List[str] + """ + List of DNS records of the endpoint. + """ + + port: int + """ + TCP port of the endpoint. + """ + + private_network: Optional[EndpointPrivateNetworkDetails] + + public: Optional[EndpointPublicDetails] + + +@dataclass +class InstanceSetting: + name: str + """ + Name of the settings. + """ + + value: str + """ + Value of the settings. + """ + + +@dataclass +class Volume: + type_: VolumeType + """ + Type of volume where data is stored. + """ + + size: int + """ + Volume size. + """ + + +@dataclass +class NodeTypeVolumeType: + type_: VolumeType + """ + Volume Type. + """ + + description: str + """ + The description of the Volume. + """ + + min_size: int + """ + Mimimum size required for the Volume. + """ + + max_size: int + """ + Maximum size required for the Volume. + """ + + chunk_size: int + """ + Minimum increment level for a Block Storage volume size. + """ + + +@dataclass +class SnapshotVolumeType: + type_: VolumeType + + +@dataclass +class Setting: + name: str + """ + Setting name from the database engine. + """ + + default_value: str + """ + Value set when not specified. + """ + + hot_configurable: bool + """ + Setting can be applied without restarting. + """ + + description: str + """ + Setting description. + """ + + property_type: SettingPropertyType + """ + Setting type. + """ + + unit: Optional[str] + """ + Setting base unit. + """ + + string_constraint: Optional[str] + """ + Validation regex for string type settings. + """ + + int_min: Optional[int] + """ + Minimum value for int types. + """ + + int_max: Optional[int] + """ + Maximum value for int types. + """ + + float_min: Optional[float] + """ + Minimum value for float types. + """ + + float_max: Optional[float] + """ + Maximum value for float types. + """ + + +@dataclass +class CreateInstanceRequestVolumeDetails: + volume_size: int + """ + Volume size. + """ + + volume_type: VolumeType + """ + Type of volume where data is stored. + """ + + +@dataclass +class EndpointSpec: + public: Optional[EndpointSpecPublicDetails] + + private_network: Optional[EndpointSpecPrivateNetworkDetails] + + +@dataclass +class Instance: + id: str + """ + UUID of the Database Instance. + """ + + name: str + """ + Name of the Database Instance. + """ + + project_id: str + """ + Project ID the Database Instance belongs to. + """ + + status: InstanceStatus + """ + Status of the Database Instance. + """ + + version: str + """ + MongoDB™ engine version of the Database Instance. + """ + + tags: List[str] + """ + List of tags applied to the Database Instance. + """ + + settings: List[InstanceSetting] + """ + Advanced settings of the Database Instance. + """ + + node_number: int + """ + Number of node in the Database Instance. + """ + + node_type: str + """ + Node type of the Database Instance. + """ + + endpoints: List[Endpoint] + """ + List of Database Instance endpoints. + """ + + region: Region + """ + Region the Database Instance is in. + """ + + volume: Optional[Volume] + """ + Volumes of the Database Instance. + """ + + created_at: Optional[datetime] + """ + Creation date (must follow the ISO 8601 format). + """ + + +@dataclass +class NodeType: + name: str + """ + Node Type name identifier. + """ + + stock_status: NodeTypeStock + """ + Current stock status for the Node Type. + """ + + description: str + """ + Current specs of the offer. + """ + + vcpus: int + """ + Number of virtual CPUs. + """ + + memory: int + """ + Quantity of RAM. + """ + + available_volume_types: List[NodeTypeVolumeType] + """ + Available storage options for the Node Type. + """ + + disabled: bool + """ + The Node Type is currently disabled. + """ + + beta: bool + """ + The Node Type is currently in beta. + """ + + instance_range: str + """ + Instance range associated with the NodeType offer. + """ + + +@dataclass +class Snapshot: + id: str + """ + UUID of the snapshot. + """ + + instance_id: str + """ + UUID of the Database Instance. + """ + + name: str + """ + Name of the snapshot. + """ + + status: SnapshotStatus + """ + Status of the snapshot. + """ + + size: int + """ + Size of the snapshot. + """ + + instance_name: str + """ + Name of the Database Instance of the snapshot. + """ + + node_type: str + """ + Source node type. + """ + + region: Region + """ + Region of this snapshot. + """ + + expires_at: Optional[datetime] + """ + Expiration date (must follow the ISO 8601 format). + """ + + created_at: Optional[datetime] + """ + Creation date (must follow the ISO 8601 format). + """ + + updated_at: Optional[datetime] + """ + Updated date (must follow the ISO 8601 format). + """ + + volume_type: Optional[SnapshotVolumeType] + """ + Type of volume where data is stored sbs_5k or sbs_15k. + """ + + +@dataclass +class User: + name: str + """ + Name of the user (Length must be between 1 and 63 characters. First character must be an alphabet character (a-zA-Z). Only a-zA-Z0-9_$- characters are accepted). + """ + + +@dataclass +class Version: + version: str + """ + MongoDB™ engine version. + """ + + available_settings: List[Setting] + """ + Instance settings available to be updated. + """ + + end_of_life_at: Optional[datetime] + """ + Date of End of Life. + """ + + +@dataclass +class RestoreSnapshotRequestVolumeDetails: + volume_type: VolumeType + """ + Type of volume where data is stored. + """ + + +@dataclass +class CreateInstanceRequest: + name: str + """ + Name of the Database Instance. + """ + + version: str + """ + Version of the MongoDB™ engine. + """ + + node_number: int + """ + Number of node to use for the Database Instance. + """ + + node_type: str + """ + Type of node to use for the Database Instance. + """ + + user_name: str + """ + Username created when the Database Instance is created. + """ + + password: str + """ + Password of the initial user. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + The Project ID on which the Database Instance will be created. + """ + + tags: Optional[List[str]] + """ + Tags to apply to the Database Instance. + """ + + volume: Optional[CreateInstanceRequestVolumeDetails] + """ + Instance volume information. + """ + + endpoints: Optional[List[EndpointSpec]] + """ + One or multiple EndpointSpec used to expose your Database Instance. + """ + + +@dataclass +class CreateSnapshotRequest: + instance_id: str + """ + UUID of the Database Instance to snapshot. + """ + + name: str + """ + Name of the snapshot. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + expires_at: Optional[datetime] + """ + Expiration date of the snapshot (must follow the ISO 8601 format). + """ + + +@dataclass +class DeleteInstanceRequest: + instance_id: str + """ + UUID of the Database Instance to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteSnapshotRequest: + snapshot_id: str + """ + UUID of the snapshot. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetInstanceCertificateRequest: + instance_id: str + """ + UUID of the Database Instance. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetInstanceRequest: + instance_id: str + """ + UUID of the Database Instance. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListInstancesRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + tags: Optional[List[str]] + """ + List Database Instances that have a given tag. + """ + + name: Optional[str] + """ + Lists Database Instances that match a name pattern. + """ + + order_by: Optional[ListInstancesRequestOrderBy] + """ + Criteria to use when ordering Database Instance listings. + """ + + organization_id: Optional[str] + """ + Organization ID the Database Instance belongs to. + """ + + project_id: Optional[str] + """ + Project ID to list the Database Instance of. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListInstancesResponse: + instances: List[Instance] + """ + List of all Database Instances available in an Organization or Project. + """ + + total_count: int + """ + Total count of Database Instances available in a Organization or Project. + """ + + +@dataclass +class ListNodeTypesRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + include_disabled_types: Optional[bool] + """ + Defines whether or not to include disabled types. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListNodeTypesResponse: + node_types: List[NodeType] + """ + Types of the node. + """ + + total_count: int + """ + Total count of node-types available. + """ + + +@dataclass +class ListSnapshotsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + instance_id: Optional[str] + """ + Instance ID the snapshots belongs to. + """ + + name: Optional[str] + """ + Lists Database snapshots that match a name pattern. + """ + + order_by: Optional[ListSnapshotsRequestOrderBy] + """ + Criteria to use when ordering snapshot listings. + """ + + organization_id: Optional[str] + """ + Organization ID the snapshots belongs to. + """ + + project_id: Optional[str] + """ + Project ID to list the snapshots of. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListSnapshotsResponse: + snapshots: List[Snapshot] + """ + List of all Database Snapshots available in an Organization or Project. + """ + + total_count: int + """ + Total count of Database Snapshots available in a Organization or Project. + """ + + +@dataclass +class ListUsersRequest: + instance_id: str + """ + UUID of the Database Instance. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the user. + """ + + order_by: Optional[ListUsersRequestOrderBy] + """ + Criteria to use when requesting user listing. + """ + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListUsersResponse: + users: List[User] + """ + List of users in a Database Instance. + """ + + total_count: int + """ + Total count of users present on a Database Instance. + """ + + +@dataclass +class ListVersionsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + version: Optional[str] + + page: Optional[int] + + page_size: Optional[int] + + +@dataclass +class ListVersionsResponse: + versions: List[Version] + """ + Available MongoDB™ engine version. + """ + + total_count: int + """ + Total count of MongoDB™ engine version available. + """ + + +@dataclass +class RestoreSnapshotRequest: + snapshot_id: str + """ + UUID of the snapshot. + """ + + instance_name: str + """ + Name of the new Database Instance. + """ + + node_type: str + """ + Node type to use for the new Database Instance. + """ + + node_number: int + """ + Number of nodes to use for the new Database Instance. + """ + + volume: RestoreSnapshotRequestVolumeDetails + """ + Instance volume information. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class UpdateInstanceRequest: + instance_id: str + """ + UUID of the Database Instance to update. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the Database Instance. + """ + + tags: Optional[List[str]] + """ + Tags of a Database Instance. + """ + + +@dataclass +class UpdateSnapshotRequest: + snapshot_id: str + """ + UUID of the Snapshot. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the snapshot. + """ + + expires_at: Optional[datetime] + """ + Expiration date of the snapshot (must follow the ISO 8601 format). + """ + + +@dataclass +class UpdateUserRequest: + 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. + """ + + password: Optional[str] + """ + Password of the database user. + """ + + +@dataclass +class UpgradeInstanceRequest: + instance_id: str + """ + UUID of the Database Instance you want to upgrade. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + volume_size: Optional[int]