diff --git a/packages/clients/src/api/rdb/v1/api.gen.ts b/packages/clients/src/api/rdb/v1/api.gen.ts index 7b831aba9..60d14c2b2 100644 --- a/packages/clients/src/api/rdb/v1/api.gen.ts +++ b/packages/clients/src/api/rdb/v1/api.gen.ts @@ -13,6 +13,8 @@ import { DATABASE_BACKUP_TRANSIENT_STATUSES, INSTANCE_LOG_TRANSIENT_STATUSES, INSTANCE_TRANSIENT_STATUSES, + READ_REPLICA_TRANSIENT_STATUSES, + SNAPSHOT_TRANSIENT_STATUSES, } from './content.gen' import { marshalAddInstanceACLRulesRequest, @@ -757,6 +759,28 @@ export class RdbV1GenAPI extends API { unmarshalReadReplica, ) + /** + * Waits for {@link ReadReplica} to be in a final state. + * + * @param request - The request {@link GetReadReplicaRequest} + * @param options - The waiting options + * @returns A Promise of ReadReplica + */ + waitForReadReplica = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve( + !READ_REPLICA_TRANSIENT_STATUSES.includes(res.status), + )), + this.getReadReplica, + request, + options, + ) + /** * Delete a read replica * @@ -1446,6 +1470,26 @@ export class RdbV1GenAPI extends API { unmarshalSnapshot, ) + /** + * Waits for {@link Snapshot} to be in a final state. + * + * @param request - The request {@link GetSnapshotRequest} + * @param options - The waiting options + * @returns A Promise of Snapshot + */ + waitForSnapshot = ( + request: Readonly, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))), + this.getSnapshot, + request, + options, + ) + /** * Create an instance snapshot * diff --git a/packages/clients/src/api/rdb/v1/content.gen.ts b/packages/clients/src/api/rdb/v1/content.gen.ts index ddad07096..1c7474556 100644 --- a/packages/clients/src/api/rdb/v1/content.gen.ts +++ b/packages/clients/src/api/rdb/v1/content.gen.ts @@ -5,6 +5,8 @@ import type { InstanceLogStatus, InstanceStatus, MaintenanceStatus, + ReadReplicaStatus, + SnapshotStatus, } from './types.gen' /** Lists transient statutes of the enum {@link DatabaseBackupStatus}. */ @@ -32,3 +34,18 @@ export const INSTANCE_TRANSIENT_STATUSES: InstanceStatus[] = [ /** Lists transient statutes of the enum {@link MaintenanceStatus}. */ export const MAINTENANCE_TRANSIENT_STATUSES: MaintenanceStatus[] = ['pending'] + +/** Lists transient statutes of the enum {@link ReadReplicaStatus}. */ +export const READ_REPLICA_TRANSIENT_STATUSES: ReadReplicaStatus[] = [ + 'provisioning', + 'initializing', + 'deleting', + 'configuring', +] + +/** Lists transient statutes of the enum {@link SnapshotStatus}. */ +export const SNAPSHOT_TRANSIENT_STATUSES: SnapshotStatus[] = [ + 'creating', + 'restoring', + 'deleting', +]