From 908e7782901596eb4c2b4e55e2faa155ce517f60 Mon Sep 17 00:00:00 2001 From: vsharma6855 Date: Mon, 9 Sep 2024 22:33:06 +0530 Subject: [PATCH] [DBAAS] | Add API endpoint for applying cluster patches (#721) * [DBAAS-35] | Add API endpoint for applying cluster patches * renamed `databaseUpdateInstalltionPath` to `databaseUpdateInstallationPath` * Update databases_test.go Co-authored-by: Andrew Starr-Bochicchio --------- Co-authored-by: v.sharma Co-authored-by: Andrew Starr-Bochicchio --- databases.go | 16 ++++++++++++++++ databases_test.go | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/databases.go b/databases.go index 3b6869c..8305770 100644 --- a/databases.go +++ b/databases.go @@ -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" @@ -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) @@ -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) diff --git a/databases_test.go b/databases_test.go index c742d0e..601a6b4 100644 --- a/databases_test.go +++ b/databases_test.go @@ -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()