Skip to content

Commit

Permalink
feat(database): add database user password update route
Browse files Browse the repository at this point in the history
  • Loading branch information
curzolapierre committed Feb 21, 2024
1 parent 07661a2 commit c2015d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

## To Be Released

* feat(databases): add databases user update

## 6.7.6

fix(errors): `IsOTPRequired` detects 'OTP Required' API errors
* fix(errors): `IsOTPRequired` detects 'OTP Required' API errors

## 6.7.5

fix(events): `link_scm` data types
* fix(events): `link_scm` data types

## 6.7.4

Expand Down
23 changes: 23 additions & 0 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,29 @@ func (c *Client) DatabaseCreateUser(ctx context.Context, app, addonID string, us
return res.DatabaseUser, nil
}

type DatabaseUpdateUserParam struct {
DatabaseID string `json:"database_id"`
Password string `json:"password,omitempty"`
PasswordConfirmation string `json:"password_confirmation,omitempty"`
}

type databaseUpdateUserPayload struct {
DatabaseUser DatabaseUpdateUserParam `json:"database_user"`
}

// DatabaseUpdateUser updates a user to the given database addon
func (c *Client) DatabaseUpdateUser(ctx context.Context, app, addonID, username string, databaseUserParams DatabaseUpdateUserParam) (DatabaseUser, error) {
res := DatabaseUserResponse{}
payload := databaseUpdateUserPayload{
DatabaseUser: databaseUserParams,
}
err := c.DBAPI(app, addonID).SubresourceUpdate(ctx, "databases", addonID, "users", username, payload, &res)
if err != nil {
return res.DatabaseUser, errors.Wrapf(ctx, err, "update a user on database %s", addonID)
}
return res.DatabaseUser, nil
}

// DatabaseUsersResponse is the response body of database list users
type DatabaseUsersResponse struct {
DatabaseUsers []DatabaseUser `json:"database-users"`
Expand Down

0 comments on commit c2015d2

Please sign in to comment.