From f3fce57f687a24e654782794575424ca1e60515a Mon Sep 17 00:00:00 2001 From: Chris Morse Date: Fri, 3 Nov 2023 13:11:17 -0400 Subject: [PATCH] Support read replica promotion for Managed Databases --- database.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/database.go b/database.go index 069018b..17c3279 100644 --- a/database.go +++ b/database.go @@ -42,6 +42,7 @@ type DatabaseService interface { DetachMigration(ctx context.Context, databaseID string) error AddReadOnlyReplica(ctx context.Context, databaseID string, databaseReplicaReq *DatabaseAddReplicaReq) (*Database, *http.Response, error) + PromoteReadReplica(ctx context.Context, databaseID string) error GetBackupInformation(ctx context.Context, databaseID string) (*DatabaseBackups, *http.Response, error) RestoreFromBackup(ctx context.Context, databaseID string, databaseRestoreReq *DatabaseBackupRestoreReq) (*Database, *http.Response, error) @@ -872,6 +873,19 @@ func (d *DatabaseServiceHandler) AddReadOnlyReplica(ctx context.Context, databas return database.Database, resp, nil } +// PromoteReadReplica will promote a read-only replica to its own standalone Managed Database subscription. +func (d *DatabaseServiceHandler) PromoteReadReplica(ctx context.Context, databaseID string) error { + uri := fmt.Sprintf("%s/%s/promote-read-replica", databasePath, databaseID) + + req, err := d.client.NewRequest(ctx, http.MethodPost, uri, nil) + if err != nil { + return err + } + + _, err = d.client.DoWithContext(ctx, req, nil) + return err +} + // GetBackupInformation retrieves backup information for your Managed Database. func (d *DatabaseServiceHandler) GetBackupInformation(ctx context.Context, databaseID string) (*DatabaseBackups, *http.Response, error) { uri := fmt.Sprintf("%s/%s/backups", databasePath, databaseID)