Skip to content

Commit 5dfd81d

Browse files
authored
feat(rdb): allow for multi-zones read replicas (#191)
1 parent 7bb5847 commit 5dfd81d

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

scaleway-async/scaleway_async/rdb/v1/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,13 +1319,15 @@ async def create_read_replica(
13191319
instance_id: str,
13201320
region: Optional[Region] = None,
13211321
endpoint_spec: Optional[List[ReadReplicaEndpointSpec]] = None,
1322+
same_zone: Optional[bool] = None,
13221323
) -> ReadReplica:
13231324
"""
13241325
Create a Read Replica.
13251326
Create a new Read Replica of a Database Instance. You must specify the `region` and the `instance_id`. You can only create a maximum of 3 Read Replicas per Database Instance.
13261327
:param region: Region to target. If none is passed will use default region from the config.
13271328
:param instance_id: UUID of the Database Instance you want to create a Read Replica from.
13281329
:param endpoint_spec: Specification of the endpoint you want to create.
1330+
:param same_zone: Defines whether to create the replica in the same availability zone as the main instance nodes or not.
13291331
:return: :class:`ReadReplica <ReadReplica>`
13301332
13311333
Usage:
@@ -1346,6 +1348,7 @@ async def create_read_replica(
13461348
instance_id=instance_id,
13471349
region=region,
13481350
endpoint_spec=endpoint_spec,
1351+
same_zone=same_zone,
13491352
),
13501353
self.client,
13511354
),

scaleway-async/scaleway_async/rdb/v1/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ def unmarshal_ReadReplica(data: Any) -> ReadReplica:
401401
field = data.get("region")
402402
args["region"] = field
403403

404+
field = data.get("same_zone")
405+
args["same_zone"] = field
406+
404407
field = data.get("status")
405408
args["status"] = field
406409

@@ -1452,6 +1455,7 @@ def marshal_CreateReadReplicaRequest(
14521455
if request.endpoint_spec is not None
14531456
else None,
14541457
"instance_id": request.instance_id,
1458+
"same_zone": request.same_zone,
14551459
}
14561460

14571461

scaleway-async/scaleway_async/rdb/v1/types.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,11 @@ class ReadReplica:
13041304
Region the Read Replica is in.
13051305
"""
13061306

1307+
same_zone: bool
1308+
"""
1309+
Whether the replica is in the same availability zone as the main instance nodes or not.
1310+
"""
1311+
13071312

13081313
@dataclass
13091314
class ReadReplicaEndpointSpec:
@@ -2027,6 +2032,11 @@ class CreateReadReplicaRequest:
20272032
Specification of the endpoint you want to create.
20282033
"""
20292034

2035+
same_zone: Optional[bool]
2036+
"""
2037+
Defines whether to create the replica in the same availability zone as the main instance nodes or not.
2038+
"""
2039+
20302040

20312041
@dataclass
20322042
class GetReadReplicaRequest:

scaleway/scaleway/rdb/v1/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,13 +1315,15 @@ def create_read_replica(
13151315
instance_id: str,
13161316
region: Optional[Region] = None,
13171317
endpoint_spec: Optional[List[ReadReplicaEndpointSpec]] = None,
1318+
same_zone: Optional[bool] = None,
13181319
) -> ReadReplica:
13191320
"""
13201321
Create a Read Replica.
13211322
Create a new Read Replica of a Database Instance. You must specify the `region` and the `instance_id`. You can only create a maximum of 3 Read Replicas per Database Instance.
13221323
:param region: Region to target. If none is passed will use default region from the config.
13231324
:param instance_id: UUID of the Database Instance you want to create a Read Replica from.
13241325
:param endpoint_spec: Specification of the endpoint you want to create.
1326+
:param same_zone: Defines whether to create the replica in the same availability zone as the main instance nodes or not.
13251327
:return: :class:`ReadReplica <ReadReplica>`
13261328
13271329
Usage:
@@ -1342,6 +1344,7 @@ def create_read_replica(
13421344
instance_id=instance_id,
13431345
region=region,
13441346
endpoint_spec=endpoint_spec,
1347+
same_zone=same_zone,
13451348
),
13461349
self.client,
13471350
),

scaleway/scaleway/rdb/v1/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ def unmarshal_ReadReplica(data: Any) -> ReadReplica:
401401
field = data.get("region")
402402
args["region"] = field
403403

404+
field = data.get("same_zone")
405+
args["same_zone"] = field
406+
404407
field = data.get("status")
405408
args["status"] = field
406409

@@ -1452,6 +1455,7 @@ def marshal_CreateReadReplicaRequest(
14521455
if request.endpoint_spec is not None
14531456
else None,
14541457
"instance_id": request.instance_id,
1458+
"same_zone": request.same_zone,
14551459
}
14561460

14571461

scaleway/scaleway/rdb/v1/types.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,11 @@ class ReadReplica:
13041304
Region the Read Replica is in.
13051305
"""
13061306

1307+
same_zone: bool
1308+
"""
1309+
Whether the replica is in the same availability zone as the main instance nodes or not.
1310+
"""
1311+
13071312

13081313
@dataclass
13091314
class ReadReplicaEndpointSpec:
@@ -2027,6 +2032,11 @@ class CreateReadReplicaRequest:
20272032
Specification of the endpoint you want to create.
20282033
"""
20292034

2035+
same_zone: Optional[bool]
2036+
"""
2037+
Defines whether to create the replica in the same availability zone as the main instance nodes or not.
2038+
"""
2039+
20302040

20312041
@dataclass
20322042
class GetReadReplicaRequest:

0 commit comments

Comments
 (0)