Skip to content

Commit 1c1d832

Browse files
authored
feat(rdb): promote read replica (#774)
1 parent 9ca198d commit 1c1d832

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

packages/clients/src/api/rdb/v1/api.gen.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ import type {
138138
PrepareInstanceLogsRequest,
139139
PrepareInstanceLogsResponse,
140140
Privilege,
141+
PromoteReadReplicaRequest,
141142
PurgeInstanceLogsRequest,
142143
ReadReplica,
143144
RenewInstanceCertificateRequest,
@@ -869,6 +870,30 @@ export class API extends ParentAPI {
869870
unmarshalReadReplica,
870871
)
871872

873+
/**
874+
* Promote a Read Replica. Promote a Read Replica to Database Instance
875+
* automatically.
876+
*
877+
* @param request - The request {@link PromoteReadReplicaRequest}
878+
* @returns A Promise of Instance
879+
*/
880+
promoteReadReplica = (request: Readonly<PromoteReadReplicaRequest>) =>
881+
this.client.fetch<Instance>(
882+
{
883+
body: '{}',
884+
headers: jsonContentHeaders,
885+
method: 'POST',
886+
path: `/rdb/v1/regions/${validatePathParam(
887+
'region',
888+
request.region ?? this.client.settings.defaultRegion,
889+
)}/read-replicas/${validatePathParam(
890+
'readReplicaId',
891+
request.readReplicaId,
892+
)}/promote`,
893+
},
894+
unmarshalInstance,
895+
)
896+
872897
/**
873898
* Create an endpoint for a Read Replica. Create a new endpoint for a Read
874899
* Replica. Read Replicas can have at most one direct access and one Private

packages/clients/src/api/rdb/v1/content.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const READ_REPLICA_TRANSIENT_STATUSES: ReadReplicaStatus[] = [
4141
'initializing',
4242
'deleting',
4343
'configuring',
44+
'promoting',
4445
]
4546

4647
/** Lists transient statutes of the enum {@link SnapshotStatus}. */

packages/clients/src/api/rdb/v1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export type {
107107
PrepareInstanceLogsRequest,
108108
PrepareInstanceLogsResponse,
109109
Privilege,
110+
PromoteReadReplicaRequest,
110111
PurgeInstanceLogsRequest,
111112
ReadReplica,
112113
ReadReplicaEndpointSpec,

packages/clients/src/api/rdb/v1/types.gen.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export type ReadReplicaStatus =
109109
| 'error'
110110
| 'locked'
111111
| 'configuring'
112+
| 'promoting'
112113

113114
export type SnapshotStatus =
114115
| 'unknown'
@@ -1166,6 +1167,16 @@ export type ResetReadReplicaRequest = {
11661167
readReplicaId: string
11671168
}
11681169

1170+
export type PromoteReadReplicaRequest = {
1171+
/**
1172+
* Region to target. If none is passed will use default region from the
1173+
* config.
1174+
*/
1175+
region?: Region
1176+
/** UUID of the Read Replica. */
1177+
readReplicaId: string
1178+
}
1179+
11691180
export type CreateReadReplicaEndpointRequest = {
11701181
/**
11711182
* Region to target. If none is passed will use default region from the

0 commit comments

Comments
 (0)