Skip to content

Commit e53d760

Browse files
authored
feat(iam): add UpdateUserPassword method (scaleway#2267)
1 parent 037d5d2 commit e53d760

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

api/iam/v1alpha1/iam_sdk.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,15 @@ type UpdateSSHKeyRequest struct {
21912191
Disabled *bool `json:"disabled,omitempty"`
21922192
}
21932193

2194+
// UpdateUserPasswordRequest: update user password request.
2195+
type UpdateUserPasswordRequest struct {
2196+
UserID string `json:"-"`
2197+
2198+
Password string `json:"password"`
2199+
2200+
SendEmail bool `json:"send_email"`
2201+
}
2202+
21942203
// UpdateUserRequest: update user request.
21952204
type UpdateUserRequest struct {
21962205
// UserID: ID of the user to update.
@@ -2476,6 +2485,33 @@ func (s *API) CreateUser(req *CreateUserRequest, opts ...scw.RequestOption) (*Us
24762485
return &resp, nil
24772486
}
24782487

2488+
// UpdateUserPassword:
2489+
func (s *API) UpdateUserPassword(req *UpdateUserPasswordRequest, opts ...scw.RequestOption) (*User, error) {
2490+
var err error
2491+
2492+
if fmt.Sprint(req.UserID) == "" {
2493+
return nil, errors.New("field UserID cannot be empty in request")
2494+
}
2495+
2496+
scwReq := &scw.ScalewayRequest{
2497+
Method: "POST",
2498+
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/update-password",
2499+
}
2500+
2501+
err = scwReq.SetBody(req)
2502+
if err != nil {
2503+
return nil, err
2504+
}
2505+
2506+
var resp User
2507+
2508+
err = s.client.Do(scwReq, &resp, opts...)
2509+
if err != nil {
2510+
return nil, err
2511+
}
2512+
return &resp, nil
2513+
}
2514+
24792515
// ListApplications: List the applications of an Organization. By default, the applications listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `organization_id` in the query path of your request. You can also define additional parameters for your query such as `application_ids`.
24802516
func (s *API) ListApplications(req *ListApplicationsRequest, opts ...scw.RequestOption) (*ListApplicationsResponse, error) {
24812517
var err error

0 commit comments

Comments
 (0)