Skip to content

Commit fd0f14f

Browse files
authored
feat(iam): add UpdateUser (#1966)
1 parent 8d1cd05 commit fd0f14f

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
@@ -1938,6 +1938,15 @@ type UpdateSSHKeyRequest struct {
19381938
Disabled *bool `json:"disabled,omitempty"`
19391939
}
19401940

1941+
// UpdateUserRequest: update user request.
1942+
type UpdateUserRequest struct {
1943+
// UserID: ID of the user to update.
1944+
UserID string `json:"-"`
1945+
1946+
// Tags: new tags for the user (maximum of 10 tags).
1947+
Tags *[]string `json:"tags,omitempty"`
1948+
}
1949+
19411950
// IAM API.
19421951
type API struct {
19431952
client *scw.Client
@@ -2139,6 +2148,33 @@ func (s *API) GetUser(req *GetUserRequest, opts ...scw.RequestOption) (*User, er
21392148
return &resp, nil
21402149
}
21412150

2151+
// UpdateUser: Update the parameters of a user, including `tags`.
2152+
func (s *API) UpdateUser(req *UpdateUserRequest, opts ...scw.RequestOption) (*User, error) {
2153+
var err error
2154+
2155+
if fmt.Sprint(req.UserID) == "" {
2156+
return nil, errors.New("field UserID cannot be empty in request")
2157+
}
2158+
2159+
scwReq := &scw.ScalewayRequest{
2160+
Method: "PATCH",
2161+
Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "",
2162+
}
2163+
2164+
err = scwReq.SetBody(req)
2165+
if err != nil {
2166+
return nil, err
2167+
}
2168+
2169+
var resp User
2170+
2171+
err = s.client.Do(scwReq, &resp, opts...)
2172+
if err != nil {
2173+
return nil, err
2174+
}
2175+
return &resp, nil
2176+
}
2177+
21422178
// DeleteUser: Remove a user from an Organization in which they are a guest. You must define the `user_id` in your request. Note that removing a user from an Organization automatically deletes their API keys, and any policies directly attached to them become orphaned.
21432179
func (s *API) DeleteUser(req *DeleteUserRequest, opts ...scw.RequestOption) error {
21442180
var err error

0 commit comments

Comments
 (0)