Skip to content

Commit 908e778

Browse files
vsharma6855v.sharmaandrewsomething
authored
[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 <[email protected]> --------- Co-authored-by: v.sharma <[email protected]> Co-authored-by: Andrew Starr-Bochicchio <[email protected]>
1 parent 3ce4966 commit 908e778

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

databases.go

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
databaseResizePath = databaseBasePath + "/%s/resize"
1717
databaseMigratePath = databaseBasePath + "/%s/migrate"
1818
databaseMaintenancePath = databaseBasePath + "/%s/maintenance"
19+
databaseUpdateInstallationPath = databaseBasePath + "/%s/install_update"
1920
databaseBackupsPath = databaseBasePath + "/%s/backups"
2021
databaseUsersPath = databaseBasePath + "/%s/users"
2122
databaseUserPath = databaseBasePath + "/%s/users/%s"
@@ -120,6 +121,7 @@ type DatabasesService interface {
120121
Resize(context.Context, string, *DatabaseResizeRequest) (*Response, error)
121122
Migrate(context.Context, string, *DatabaseMigrateRequest) (*Response, error)
122123
UpdateMaintenance(context.Context, string, *DatabaseUpdateMaintenanceRequest) (*Response, error)
124+
InstallUpdate(context.Context, string) (*Response, error)
123125
ListBackups(context.Context, string, *ListOptions) ([]DatabaseBackup, *Response, error)
124126
GetUser(context.Context, string, string) (*DatabaseUser, *Response, error)
125127
ListUsers(context.Context, string, *ListOptions) ([]DatabaseUser, *Response, error)
@@ -940,6 +942,20 @@ func (svc *DatabasesServiceOp) UpdateMaintenance(ctx context.Context, databaseID
940942
return resp, nil
941943
}
942944

945+
// InstallUpdate starts installation of updates
946+
func (svc *DatabasesServiceOp) InstallUpdate(ctx context.Context, databaseID string) (*Response, error) {
947+
path := fmt.Sprintf(databaseUpdateInstallationPath, databaseID)
948+
req, err := svc.client.NewRequest(ctx, http.MethodPut, path, nil)
949+
if err != nil {
950+
return nil, err
951+
}
952+
resp, err := svc.client.Do(ctx, req, nil)
953+
if err != nil {
954+
return resp, err
955+
}
956+
return resp, nil
957+
}
958+
943959
// ListBackups returns a list of the current backups of a database
944960
func (svc *DatabasesServiceOp) ListBackups(ctx context.Context, databaseID string, opts *ListOptions) ([]DatabaseBackup, *Response, error) {
945961
path := fmt.Sprintf(databaseBackupsPath, databaseID)

databases_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,22 @@ func TestDatabases_UpdateMaintenance(t *testing.T) {
747747
require.NoError(t, err)
748748
}
749749

750+
func TestDatabases_InstallUpdate(t *testing.T) {
751+
setup()
752+
defer teardown()
753+
754+
dbID := "deadbeef-dead-4aa5-beef-deadbeef347d"
755+
756+
path := fmt.Sprintf("/v2/databases/%s/install_update", dbID)
757+
758+
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
759+
testMethod(t, r, http.MethodPut)
760+
})
761+
762+
_, err := client.Databases.InstallUpdate(ctx, "deadbeef-dead-4aa5-beef-deadbeef347d")
763+
require.NoError(t, err)
764+
}
765+
750766
func TestDatabases_ListBackups(t *testing.T) {
751767
setup()
752768
defer teardown()

0 commit comments

Comments
 (0)