Skip to content

Commit

Permalink
[DBAAS] | Add API endpoint for applying cluster patches (#721)
Browse files Browse the repository at this point in the history
* [DBAAS-35] | Add API endpoint for applying cluster patches

* renamed `databaseUpdateInstalltionPath` to `databaseUpdateInstallationPath`

* Update databases_test.go

Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com>

---------

Co-authored-by: v.sharma <v.sharma@digitalocean.com>
Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent 3ce4966 commit 908e778
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
databaseResizePath = databaseBasePath + "/%s/resize"
databaseMigratePath = databaseBasePath + "/%s/migrate"
databaseMaintenancePath = databaseBasePath + "/%s/maintenance"
databaseUpdateInstallationPath = databaseBasePath + "/%s/install_update"
databaseBackupsPath = databaseBasePath + "/%s/backups"
databaseUsersPath = databaseBasePath + "/%s/users"
databaseUserPath = databaseBasePath + "/%s/users/%s"
Expand Down Expand Up @@ -120,6 +121,7 @@ type DatabasesService interface {
Resize(context.Context, string, *DatabaseResizeRequest) (*Response, error)
Migrate(context.Context, string, *DatabaseMigrateRequest) (*Response, error)
UpdateMaintenance(context.Context, string, *DatabaseUpdateMaintenanceRequest) (*Response, error)
InstallUpdate(context.Context, string) (*Response, error)
ListBackups(context.Context, string, *ListOptions) ([]DatabaseBackup, *Response, error)
GetUser(context.Context, string, string) (*DatabaseUser, *Response, error)
ListUsers(context.Context, string, *ListOptions) ([]DatabaseUser, *Response, error)
Expand Down Expand Up @@ -940,6 +942,20 @@ func (svc *DatabasesServiceOp) UpdateMaintenance(ctx context.Context, databaseID
return resp, nil
}

// InstallUpdate starts installation of updates
func (svc *DatabasesServiceOp) InstallUpdate(ctx context.Context, databaseID string) (*Response, error) {
path := fmt.Sprintf(databaseUpdateInstallationPath, databaseID)
req, err := svc.client.NewRequest(ctx, http.MethodPut, path, nil)
if err != nil {
return nil, err
}
resp, err := svc.client.Do(ctx, req, nil)
if err != nil {
return resp, err
}
return resp, nil
}

// ListBackups returns a list of the current backups of a database
func (svc *DatabasesServiceOp) ListBackups(ctx context.Context, databaseID string, opts *ListOptions) ([]DatabaseBackup, *Response, error) {
path := fmt.Sprintf(databaseBackupsPath, databaseID)
Expand Down
16 changes: 16 additions & 0 deletions databases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,22 @@ func TestDatabases_UpdateMaintenance(t *testing.T) {
require.NoError(t, err)
}

func TestDatabases_InstallUpdate(t *testing.T) {
setup()
defer teardown()

dbID := "deadbeef-dead-4aa5-beef-deadbeef347d"

path := fmt.Sprintf("/v2/databases/%s/install_update", dbID)

mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPut)
})

_, err := client.Databases.InstallUpdate(ctx, "deadbeef-dead-4aa5-beef-deadbeef347d")
require.NoError(t, err)
}

func TestDatabases_ListBackups(t *testing.T) {
setup()
defer teardown()
Expand Down

0 comments on commit 908e778

Please sign in to comment.