Skip to content

Commit 0d220e0

Browse files
authored
feat(iam): add UpdateUserUsername (scaleway#2356)
1 parent 87ddc26 commit 0d220e0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

api/iam/v1alpha1/iam_sdk.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,13 @@ type UpdateUserRequest struct {
23362336
Email *string `json:"email,omitempty"`
23372337
}
23382338

2339+
// UpdateUserUsernameRequest: update user username request.
2340+
type UpdateUserUsernameRequest struct {
2341+
UserID string `json:"-"`
2342+
2343+
Username string `json:"username"`
2344+
}
2345+
23392346
// This API allows you to manage Identity and Access Management (IAM) across your Scaleway Organizations, Projects and resources.
23402347
type API struct {
23412348
client *scw.Client
@@ -2612,6 +2619,33 @@ func (s *API) CreateUser(req *CreateUserRequest, opts ...scw.RequestOption) (*Us
26122619
return &resp, nil
26132620
}
26142621

2622+
// UpdateUserUsername:
2623+
func (s *API) UpdateUserUsername(req *UpdateUserUsernameRequest, opts ...scw.RequestOption) (*User, error) {
2624+
var err error
2625+
2626+
if fmt.Sprint(req.UserID) == "" {
2627+
return nil, errors.New("field UserID cannot be empty in request")
2628+
}
2629+
2630+
scwReq := &scw.ScalewayRequest{
2631+
Method: "POST",
2632+
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/update-username",
2633+
}
2634+
2635+
err = scwReq.SetBody(req)
2636+
if err != nil {
2637+
return nil, err
2638+
}
2639+
2640+
var resp User
2641+
2642+
err = s.client.Do(scwReq, &resp, opts...)
2643+
if err != nil {
2644+
return nil, err
2645+
}
2646+
return &resp, nil
2647+
}
2648+
26152649
// UpdateUserPassword: Update an user's password. Private Beta feature.
26162650
func (s *API) UpdateUserPassword(req *UpdateUserPasswordRequest, opts ...scw.RequestOption) (*User, error) {
26172651
var err error

0 commit comments

Comments
 (0)