Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STORY-642] new api endpoint to handle password reset #388

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## To Be Released

* feat(apps): add the `private_network_ids` field to the model
* feat(database/users): add the `DatabaseUserResetPassword` method

## 7.0.0

Expand Down
16 changes: 16 additions & 0 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,19 @@ func (c *Client) DatabaseListUsers(ctx context.Context, app, addonID string) ([]
func (c *Client) DatabaseDeleteUser(ctx context.Context, app, addonID, userName string) error {
return c.DBAPI(app, addonID).SubresourceDelete(ctx, "databases", addonID, "users", userName)
}

// DatabaseUserResetPassword resets the password for a user for given database addon
func (c *Client) DatabaseUserResetPassword(ctx context.Context, app, addonID, username string) (DatabaseUser, error) {
res := DatabaseUserResponse{}
req := &httpclient.APIRequest{
Method: "POST",
Endpoint: "/databases/" + addonID + "/users/" + username + "/reset_password",
Expected: httpclient.Statuses{http.StatusOK},
}
err := c.DBAPI(app, addonID).DoRequest(ctx, req, &res)
if err != nil {
return DatabaseUser{}, err
}

return res.DatabaseUser, nil
}