From fae76997a080c9ebadf0a705ea9543b355d1247a Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 11 Aug 2026 14:19:59 +0000 Subject: [PATCH] feat(rdb): add high_availability_mode enum --- scaleway-async/scaleway_async/lb/v1/types.py | 2 +- .../scaleway_async/rdb/v1/__init__.py | 2 + scaleway-async/scaleway_async/rdb/v1/api.py | 27 +++++--- .../scaleway_async/rdb/v1/marshalling.py | 66 ++++++++++++------- scaleway-async/scaleway_async/rdb/v1/types.py | 33 ++++++++++ scaleway/scaleway/lb/v1/types.py | 2 +- scaleway/scaleway/rdb/v1/__init__.py | 2 + scaleway/scaleway/rdb/v1/api.py | 27 +++++--- scaleway/scaleway/rdb/v1/marshalling.py | 66 ++++++++++++------- scaleway/scaleway/rdb/v1/types.py | 33 ++++++++++ 10 files changed, 196 insertions(+), 64 deletions(-) diff --git a/scaleway-async/scaleway_async/lb/v1/types.py b/scaleway-async/scaleway_async/lb/v1/types.py index 1857c9ed1..08a0ed3fc 100644 --- a/scaleway-async/scaleway_async/lb/v1/types.py +++ b/scaleway-async/scaleway_async/lb/v1/types.py @@ -874,7 +874,7 @@ class AclMatch: ips_edge_services: bool """ - Defines whether Edge Services IPs should be matched. + Defines whether Edge Services IPs should be matched. If set to `true`, restricts all connections except for Edge Services. """ http_filter: AclHttpFilter diff --git a/scaleway-async/scaleway_async/rdb/v1/__init__.py b/scaleway-async/scaleway_async/rdb/v1/__init__.py index 1ba2fa889..602c1da68 100644 --- a/scaleway-async/scaleway_async/rdb/v1/__init__.py +++ b/scaleway-async/scaleway_async/rdb/v1/__init__.py @@ -7,6 +7,7 @@ from .content import DATABASE_BACKUP_TRANSIENT_STATUSES from .types import EndpointPrivateNetworkDetailsProvisioningMode from .types import EngineSettingPropertyType +from .types import HighAvailabilityMode from .types import InstanceLogStatus from .content import INSTANCE_LOG_TRANSIENT_STATUSES from .types import InstanceStatus @@ -154,6 +155,7 @@ "DATABASE_BACKUP_TRANSIENT_STATUSES", "EndpointPrivateNetworkDetailsProvisioningMode", "EngineSettingPropertyType", + "HighAvailabilityMode", "InstanceLogStatus", "INSTANCE_LOG_TRANSIENT_STATUSES", "InstanceStatus", diff --git a/scaleway-async/scaleway_async/rdb/v1/api.py b/scaleway-async/scaleway_async/rdb/v1/api.py index f9483f740..14b5fac96 100644 --- a/scaleway-async/scaleway_async/rdb/v1/api.py +++ b/scaleway-async/scaleway_async/rdb/v1/api.py @@ -18,6 +18,7 @@ wait_for_resource_async, ) from .types import ( + HighAvailabilityMode, ListDatabaseBackupsRequestOrderBy, ListDatabasesRequestOrderBy, ListInstanceLogsRequestOrderBy, @@ -730,6 +731,7 @@ async def upgrade_instance( region: Optional[ScwRegion] = None, node_type: Optional[str] = None, enable_ha: Optional[bool] = None, + high_availability_mode: Optional[HighAvailabilityMode] = None, volume_size: Optional[int] = None, volume_type: Optional[VolumeType] = None, upgradable_version_id: Optional[str] = None, @@ -744,19 +746,21 @@ async def upgrade_instance( :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 node_type: Node type of the Database Instance you want to upgrade to. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param enable_ha: Defines whether or not high availability should be enabled on the Database Instance. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + :param high_availability_mode: Defines the High-Availability mode of the instance. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param volume_size: Increase your block storage volume size. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param volume_type: Change your Database Instance storage type. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param upgradable_version_id: This will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param major_upgrade_workflow: Upgrade your database engine to a new major version including instance endpoints. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param enable_encryption: Defines whether or not encryption should be enabled on the Database Instance. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :return: :class:`Instance ` Usage: @@ -781,6 +785,7 @@ async def upgrade_instance( region=region, node_type=node_type, enable_ha=enable_ha, + high_availability_mode=high_availability_mode, volume_size=volume_size, volume_type=volume_type, upgradable_version_id=upgradable_version_id, @@ -988,6 +993,7 @@ async def create_instance( disable_backup: bool, volume_size: int, backup_same_region: bool, + high_availability_mode: Optional[HighAvailabilityMode] = None, tags: Optional[list[str]] = None, init_settings: Optional[list[InstanceSetting]] = None, volume_type: Optional[VolumeType] = None, @@ -1011,6 +1017,7 @@ async def create_instance( :param disable_backup: Defines whether or not backups are disabled. :param volume_size: Volume size when volume_type is not lssd. :param backup_same_region: Defines whether to or not to store logical backups in the same region as the Database Instance. + :param high_availability_mode: Defines the High-Availability mode of the instance. :param tags: Tags to apply to the Database Instance. :param init_settings: List of engine settings to be set upon Database Instance initialization. :param volume_type: Type of volume where data is stored (lssd, bssd, ...). @@ -1046,9 +1053,10 @@ async def create_instance( user_name=user_name, password=password, node_type=node_type, + is_ha_cluster=is_ha_cluster, region=region, name=name or random_name(prefix="ins"), - is_ha_cluster=is_ha_cluster, + high_availability_mode=high_availability_mode, disable_backup=disable_backup, volume_size=volume_size, backup_same_region=backup_same_region, @@ -3094,6 +3102,7 @@ async def create_instance_from_snapshot( instance_name: str, region: Optional[ScwRegion] = None, is_ha_cluster: Optional[bool] = None, + high_availability_mode: Optional[HighAvailabilityMode] = None, node_type: Optional[str] = None, ) -> Instance: """ @@ -3103,6 +3112,7 @@ async def create_instance_from_snapshot( :param instance_name: Name of the Database Instance created with the snapshot. :param region: Region to target. If none is passed will use default region from the config. :param is_ha_cluster: Defines whether or not High-Availability is enabled on the new Database Instance. + :param high_availability_mode: Defines the High-Availability mode of the instance. :param node_type: The node type used to restore the snapshot. :return: :class:`Instance ` @@ -3129,6 +3139,7 @@ async def create_instance_from_snapshot( instance_name=instance_name, region=region, is_ha_cluster=is_ha_cluster, + high_availability_mode=high_availability_mode, node_type=node_type, ), self.client, diff --git a/scaleway-async/scaleway_async/rdb/v1/marshalling.py b/scaleway-async/scaleway_async/rdb/v1/marshalling.py index d3309feed..9d7e8638c 100644 --- a/scaleway-async/scaleway_async/rdb/v1/marshalling.py +++ b/scaleway-async/scaleway_async/rdb/v1/marshalling.py @@ -19,6 +19,7 @@ DatabaseBackupStatus, EndpointPrivateNetworkDetailsProvisioningMode, EngineSettingPropertyType, + HighAvailabilityMode, InstanceLogStatus, InstanceStatus, MaintenanceStatus, @@ -714,18 +715,6 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["organization_id"] = 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("volume", None) - if field is not None: - args["volume"] = unmarshal_Volume(field) - else: - args["volume"] = None - field = data.get("project_id", None) if field is not None: args["project_id"] = field @@ -760,6 +749,24 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["tags"] = [] + 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("volume", None) + if field is not None: + args["volume"] = unmarshal_Volume(field) + else: + args["volume"] = None + + field = data.get("endpoint", None) + if field is not None: + args["endpoint"] = unmarshal_Endpoint(field) + else: + args["endpoint"] = None + field = data.get("settings", None) if field is not None: args["settings"] = ( @@ -774,17 +781,13 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["is_ha_cluster"] = False - field = data.get("endpoint", None) - if field is not None: - args["endpoint"] = unmarshal_Endpoint(field) - else: - args["endpoint"] = None - - field = data.get("backup_schedule", None) + field = data.get("high_availability_mode", None) if field is not None: - args["backup_schedule"] = unmarshal_BackupSchedule(field) + args["high_availability_mode"] = field else: - args["backup_schedule"] = None + args["high_availability_mode"] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) field = data.get("read_replicas", None) if field is not None: @@ -830,6 +833,12 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["maintenances"] = [] + field = data.get("backup_schedule", None) + if field is not None: + args["backup_schedule"] = unmarshal_BackupSchedule(field) + else: + args["backup_schedule"] = None + field = data.get("logs_policy", None) if field is not None: args["logs_policy"] = unmarshal_LogsPolicy(field) @@ -2050,6 +2059,9 @@ def marshal_CreateInstanceFromSnapshotRequest( if request.is_ha_cluster is not None: output["is_ha_cluster"] = request.is_ha_cluster + if request.high_availability_mode is not None: + output["high_availability_mode"] = request.high_availability_mode + if request.node_type is not None: output["node_type"] = request.node_type @@ -2104,11 +2116,14 @@ def marshal_CreateInstanceRequest( if request.node_type is not None: output["node_type"] = request.node_type + if request.is_ha_cluster is not None: + output["is_ha_cluster"] = request.is_ha_cluster + if request.name is not None: output["name"] = request.name - if request.is_ha_cluster is not None: - output["is_ha_cluster"] = request.is_ha_cluster + if request.high_availability_mode is not None: + output["high_availability_mode"] = request.high_availability_mode if request.disable_backup is not None: output["disable_backup"] = request.disable_backup @@ -2525,6 +2540,11 @@ def marshal_UpgradeInstanceRequest( OneOfPossibility( param="enable_ha", value=request.enable_ha, marshal_func=None ), + OneOfPossibility( + param="high_availability_mode", + value=request.high_availability_mode, + marshal_func=None, + ), OneOfPossibility( param="volume_size", value=request.volume_size, marshal_func=None ), diff --git a/scaleway-async/scaleway_async/rdb/v1/types.py b/scaleway-async/scaleway_async/rdb/v1/types.py index 40ea1ca92..38df01c54 100644 --- a/scaleway-async/scaleway_async/rdb/v1/types.py +++ b/scaleway-async/scaleway_async/rdb/v1/types.py @@ -74,6 +74,16 @@ def __str__(self) -> str: return str(self.value) +class HighAvailabilityMode(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HIGH_AVAILABILITY_MODE = "unknown_high_availability_mode" + DISABLED = "disabled" + SINGLE_ZONE = "single_zone" + MULTIPLE_ZONE = "multiple_zone" + + def __str__(self) -> str: + return str(self.value) + + class InstanceLogStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN = "unknown" READY = "ready" @@ -909,6 +919,11 @@ class Instance: Defines whether or not High-Availability is enabled. """ + high_availability_mode: HighAvailabilityMode + """ + Defines the High-Availability mode of the instance. + """ + read_replicas: list[ReadReplica] """ Read Replicas of the Database Instance. @@ -1324,6 +1339,13 @@ class CreateInstanceFromSnapshotRequest: Defines whether or not High-Availability is enabled on the new Database Instance. """ + high_availability_mode: Optional[HighAvailabilityMode] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) + """ + Defines the High-Availability mode of the instance. + """ + node_type: Optional[str] = None """ The node type used to restore the snapshot. @@ -1382,6 +1404,13 @@ class CreateInstanceRequest: Name of the Database Instance. """ + high_availability_mode: Optional[HighAvailabilityMode] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) + """ + Defines the High-Availability mode of the instance. + """ + tags: Optional[list[str]] = field(default_factory=list) """ Tags to apply to the Database Instance. @@ -2601,6 +2630,10 @@ class UpgradeInstanceRequest: enable_ha: Optional[bool] = False + high_availability_mode: Optional[HighAvailabilityMode] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) + volume_size: Optional[int] = 0 volume_type: Optional[VolumeType] = VolumeType.LSSD diff --git a/scaleway/scaleway/lb/v1/types.py b/scaleway/scaleway/lb/v1/types.py index 1857c9ed1..08a0ed3fc 100644 --- a/scaleway/scaleway/lb/v1/types.py +++ b/scaleway/scaleway/lb/v1/types.py @@ -874,7 +874,7 @@ class AclMatch: ips_edge_services: bool """ - Defines whether Edge Services IPs should be matched. + Defines whether Edge Services IPs should be matched. If set to `true`, restricts all connections except for Edge Services. """ http_filter: AclHttpFilter diff --git a/scaleway/scaleway/rdb/v1/__init__.py b/scaleway/scaleway/rdb/v1/__init__.py index 1ba2fa889..602c1da68 100644 --- a/scaleway/scaleway/rdb/v1/__init__.py +++ b/scaleway/scaleway/rdb/v1/__init__.py @@ -7,6 +7,7 @@ from .content import DATABASE_BACKUP_TRANSIENT_STATUSES from .types import EndpointPrivateNetworkDetailsProvisioningMode from .types import EngineSettingPropertyType +from .types import HighAvailabilityMode from .types import InstanceLogStatus from .content import INSTANCE_LOG_TRANSIENT_STATUSES from .types import InstanceStatus @@ -154,6 +155,7 @@ "DATABASE_BACKUP_TRANSIENT_STATUSES", "EndpointPrivateNetworkDetailsProvisioningMode", "EngineSettingPropertyType", + "HighAvailabilityMode", "InstanceLogStatus", "INSTANCE_LOG_TRANSIENT_STATUSES", "InstanceStatus", diff --git a/scaleway/scaleway/rdb/v1/api.py b/scaleway/scaleway/rdb/v1/api.py index c23ef4823..fe4c4c712 100644 --- a/scaleway/scaleway/rdb/v1/api.py +++ b/scaleway/scaleway/rdb/v1/api.py @@ -18,6 +18,7 @@ wait_for_resource, ) from .types import ( + HighAvailabilityMode, ListDatabaseBackupsRequestOrderBy, ListDatabasesRequestOrderBy, ListInstanceLogsRequestOrderBy, @@ -728,6 +729,7 @@ def upgrade_instance( region: Optional[ScwRegion] = None, node_type: Optional[str] = None, enable_ha: Optional[bool] = None, + high_availability_mode: Optional[HighAvailabilityMode] = None, volume_size: Optional[int] = None, volume_type: Optional[VolumeType] = None, upgradable_version_id: Optional[str] = None, @@ -742,19 +744,21 @@ def upgrade_instance( :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 node_type: Node type of the Database Instance you want to upgrade to. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param enable_ha: Defines whether or not high availability should be enabled on the Database Instance. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + :param high_availability_mode: Defines the High-Availability mode of the instance. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param volume_size: Increase your block storage volume size. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param volume_type: Change your Database Instance storage type. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param upgradable_version_id: This will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param major_upgrade_workflow: Upgrade your database engine to a new major version including instance endpoints. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :param enable_encryption: Defines whether or not encryption should be enabled on the Database Instance. - One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. + One-Of ('upgrade_target'): at most one of 'node_type', 'enable_ha', 'high_availability_mode', 'volume_size', 'volume_type', 'upgradable_version_id', 'major_upgrade_workflow', 'enable_encryption' could be set. :return: :class:`Instance ` Usage: @@ -779,6 +783,7 @@ def upgrade_instance( region=region, node_type=node_type, enable_ha=enable_ha, + high_availability_mode=high_availability_mode, volume_size=volume_size, volume_type=volume_type, upgradable_version_id=upgradable_version_id, @@ -984,6 +989,7 @@ def create_instance( disable_backup: bool, volume_size: int, backup_same_region: bool, + high_availability_mode: Optional[HighAvailabilityMode] = None, tags: Optional[list[str]] = None, init_settings: Optional[list[InstanceSetting]] = None, volume_type: Optional[VolumeType] = None, @@ -1007,6 +1013,7 @@ def create_instance( :param disable_backup: Defines whether or not backups are disabled. :param volume_size: Volume size when volume_type is not lssd. :param backup_same_region: Defines whether to or not to store logical backups in the same region as the Database Instance. + :param high_availability_mode: Defines the High-Availability mode of the instance. :param tags: Tags to apply to the Database Instance. :param init_settings: List of engine settings to be set upon Database Instance initialization. :param volume_type: Type of volume where data is stored (lssd, bssd, ...). @@ -1042,9 +1049,10 @@ def create_instance( user_name=user_name, password=password, node_type=node_type, + is_ha_cluster=is_ha_cluster, region=region, name=name or random_name(prefix="ins"), - is_ha_cluster=is_ha_cluster, + high_availability_mode=high_availability_mode, disable_backup=disable_backup, volume_size=volume_size, backup_same_region=backup_same_region, @@ -3084,6 +3092,7 @@ def create_instance_from_snapshot( instance_name: str, region: Optional[ScwRegion] = None, is_ha_cluster: Optional[bool] = None, + high_availability_mode: Optional[HighAvailabilityMode] = None, node_type: Optional[str] = None, ) -> Instance: """ @@ -3093,6 +3102,7 @@ def create_instance_from_snapshot( :param instance_name: Name of the Database Instance created with the snapshot. :param region: Region to target. If none is passed will use default region from the config. :param is_ha_cluster: Defines whether or not High-Availability is enabled on the new Database Instance. + :param high_availability_mode: Defines the High-Availability mode of the instance. :param node_type: The node type used to restore the snapshot. :return: :class:`Instance ` @@ -3119,6 +3129,7 @@ def create_instance_from_snapshot( instance_name=instance_name, region=region, is_ha_cluster=is_ha_cluster, + high_availability_mode=high_availability_mode, node_type=node_type, ), self.client, diff --git a/scaleway/scaleway/rdb/v1/marshalling.py b/scaleway/scaleway/rdb/v1/marshalling.py index d3309feed..9d7e8638c 100644 --- a/scaleway/scaleway/rdb/v1/marshalling.py +++ b/scaleway/scaleway/rdb/v1/marshalling.py @@ -19,6 +19,7 @@ DatabaseBackupStatus, EndpointPrivateNetworkDetailsProvisioningMode, EngineSettingPropertyType, + HighAvailabilityMode, InstanceLogStatus, InstanceStatus, MaintenanceStatus, @@ -714,18 +715,6 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["organization_id"] = 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("volume", None) - if field is not None: - args["volume"] = unmarshal_Volume(field) - else: - args["volume"] = None - field = data.get("project_id", None) if field is not None: args["project_id"] = field @@ -760,6 +749,24 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["tags"] = [] + 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("volume", None) + if field is not None: + args["volume"] = unmarshal_Volume(field) + else: + args["volume"] = None + + field = data.get("endpoint", None) + if field is not None: + args["endpoint"] = unmarshal_Endpoint(field) + else: + args["endpoint"] = None + field = data.get("settings", None) if field is not None: args["settings"] = ( @@ -774,17 +781,13 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["is_ha_cluster"] = False - field = data.get("endpoint", None) - if field is not None: - args["endpoint"] = unmarshal_Endpoint(field) - else: - args["endpoint"] = None - - field = data.get("backup_schedule", None) + field = data.get("high_availability_mode", None) if field is not None: - args["backup_schedule"] = unmarshal_BackupSchedule(field) + args["high_availability_mode"] = field else: - args["backup_schedule"] = None + args["high_availability_mode"] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) field = data.get("read_replicas", None) if field is not None: @@ -830,6 +833,12 @@ def unmarshal_Instance(data: Any) -> Instance: else: args["maintenances"] = [] + field = data.get("backup_schedule", None) + if field is not None: + args["backup_schedule"] = unmarshal_BackupSchedule(field) + else: + args["backup_schedule"] = None + field = data.get("logs_policy", None) if field is not None: args["logs_policy"] = unmarshal_LogsPolicy(field) @@ -2050,6 +2059,9 @@ def marshal_CreateInstanceFromSnapshotRequest( if request.is_ha_cluster is not None: output["is_ha_cluster"] = request.is_ha_cluster + if request.high_availability_mode is not None: + output["high_availability_mode"] = request.high_availability_mode + if request.node_type is not None: output["node_type"] = request.node_type @@ -2104,11 +2116,14 @@ def marshal_CreateInstanceRequest( if request.node_type is not None: output["node_type"] = request.node_type + if request.is_ha_cluster is not None: + output["is_ha_cluster"] = request.is_ha_cluster + if request.name is not None: output["name"] = request.name - if request.is_ha_cluster is not None: - output["is_ha_cluster"] = request.is_ha_cluster + if request.high_availability_mode is not None: + output["high_availability_mode"] = request.high_availability_mode if request.disable_backup is not None: output["disable_backup"] = request.disable_backup @@ -2525,6 +2540,11 @@ def marshal_UpgradeInstanceRequest( OneOfPossibility( param="enable_ha", value=request.enable_ha, marshal_func=None ), + OneOfPossibility( + param="high_availability_mode", + value=request.high_availability_mode, + marshal_func=None, + ), OneOfPossibility( param="volume_size", value=request.volume_size, marshal_func=None ), diff --git a/scaleway/scaleway/rdb/v1/types.py b/scaleway/scaleway/rdb/v1/types.py index 40ea1ca92..38df01c54 100644 --- a/scaleway/scaleway/rdb/v1/types.py +++ b/scaleway/scaleway/rdb/v1/types.py @@ -74,6 +74,16 @@ def __str__(self) -> str: return str(self.value) +class HighAvailabilityMode(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HIGH_AVAILABILITY_MODE = "unknown_high_availability_mode" + DISABLED = "disabled" + SINGLE_ZONE = "single_zone" + MULTIPLE_ZONE = "multiple_zone" + + def __str__(self) -> str: + return str(self.value) + + class InstanceLogStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN = "unknown" READY = "ready" @@ -909,6 +919,11 @@ class Instance: Defines whether or not High-Availability is enabled. """ + high_availability_mode: HighAvailabilityMode + """ + Defines the High-Availability mode of the instance. + """ + read_replicas: list[ReadReplica] """ Read Replicas of the Database Instance. @@ -1324,6 +1339,13 @@ class CreateInstanceFromSnapshotRequest: Defines whether or not High-Availability is enabled on the new Database Instance. """ + high_availability_mode: Optional[HighAvailabilityMode] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) + """ + Defines the High-Availability mode of the instance. + """ + node_type: Optional[str] = None """ The node type used to restore the snapshot. @@ -1382,6 +1404,13 @@ class CreateInstanceRequest: Name of the Database Instance. """ + high_availability_mode: Optional[HighAvailabilityMode] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) + """ + Defines the High-Availability mode of the instance. + """ + tags: Optional[list[str]] = field(default_factory=list) """ Tags to apply to the Database Instance. @@ -2601,6 +2630,10 @@ class UpgradeInstanceRequest: enable_ha: Optional[bool] = False + high_availability_mode: Optional[HighAvailabilityMode] = ( + HighAvailabilityMode.UNKNOWN_HIGH_AVAILABILITY_MODE + ) + volume_size: Optional[int] = 0 volume_type: Optional[VolumeType] = VolumeType.LSSD