Skip to content

Commit

Permalink
Support read replica promotion for Managed Databases
Browse files Browse the repository at this point in the history
  • Loading branch information
christhemorse committed Nov 3, 2023
1 parent b693a3a commit f3fce57
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f3fce57

Please sign in to comment.