Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/rdb/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -154,6 +155,7 @@
"DATABASE_BACKUP_TRANSIENT_STATUSES",
"EndpointPrivateNetworkDetailsProvisioningMode",
"EngineSettingPropertyType",
"HighAvailabilityMode",
"InstanceLogStatus",
"INSTANCE_LOG_TRANSIENT_STATUSES",
"InstanceStatus",
Expand Down
27 changes: 19 additions & 8 deletions scaleway-async/scaleway_async/rdb/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
wait_for_resource_async,
)
from .types import (
HighAvailabilityMode,
ListDatabaseBackupsRequestOrderBy,
ListDatabasesRequestOrderBy,
ListInstanceLogsRequestOrderBy,
Expand Down Expand Up @@ -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,
Expand All @@ -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 <Instance>`

Usage:
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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, ...).
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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 <Instance>`

Expand All @@ -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,
Expand Down
66 changes: 43 additions & 23 deletions scaleway-async/scaleway_async/rdb/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DatabaseBackupStatus,
EndpointPrivateNetworkDetailsProvisioningMode,
EngineSettingPropertyType,
HighAvailabilityMode,
InstanceLogStatus,
InstanceStatus,
MaintenanceStatus,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"] = (
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
),
Expand Down
33 changes: 33 additions & 0 deletions scaleway-async/scaleway_async/rdb/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/rdb/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -154,6 +155,7 @@
"DATABASE_BACKUP_TRANSIENT_STATUSES",
"EndpointPrivateNetworkDetailsProvisioningMode",
"EngineSettingPropertyType",
"HighAvailabilityMode",
"InstanceLogStatus",
"INSTANCE_LOG_TRANSIENT_STATUSES",
"InstanceStatus",
Expand Down
Loading
Loading