diff --git a/api/iam/v1alpha1/iam_sdk.go b/api/iam/v1alpha1/iam_sdk.go index 8d0eadb62..2abb934de 100644 --- a/api/iam/v1alpha1/iam_sdk.go +++ b/api/iam/v1alpha1/iam_sdk.go @@ -2069,6 +2069,11 @@ func (r *ListUsersResponse) UnsafeAppend(res interface{}) (uint32, error) { return uint32(len(results.Users)), nil } +// LockUserRequest: lock user request. +type LockUserRequest struct { + UserID string `json:"-"` +} + // RemoveGroupMemberRequest: remove group member request. type RemoveGroupMemberRequest struct { // GroupID: ID of the group. @@ -2107,6 +2112,11 @@ type SetRulesResponse struct { Rules []*Rule `json:"rules"` } +// UnlockUserRequest: unlock user request. +type UnlockUserRequest struct { + UserID string `json:"-"` +} + // UpdateAPIKeyRequest: update api key request. type UpdateAPIKeyRequest struct { // AccessKey: access key to update. @@ -2512,6 +2522,60 @@ func (s *API) UpdateUserPassword(req *UpdateUserPasswordRequest, opts ...scw.Req return &resp, nil } +// LockUser: Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed. +func (s *API) LockUser(req *LockUserRequest, opts ...scw.RequestOption) (*User, error) { + var err error + + if fmt.Sprint(req.UserID) == "" { + return nil, errors.New("field UserID cannot be empty in request") + } + + scwReq := &scw.ScalewayRequest{ + Method: "POST", + Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/lock", + } + + err = scwReq.SetBody(req) + if err != nil { + return nil, err + } + + var resp User + + err = s.client.Do(scwReq, &resp, opts...) + if err != nil { + return nil, err + } + return &resp, nil +} + +// UnlockUser: Unlock a user. +func (s *API) UnlockUser(req *UnlockUserRequest, opts ...scw.RequestOption) (*User, error) { + var err error + + if fmt.Sprint(req.UserID) == "" { + return nil, errors.New("field UserID cannot be empty in request") + } + + scwReq := &scw.ScalewayRequest{ + Method: "POST", + Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "/unlock", + } + + err = scwReq.SetBody(req) + if err != nil { + return nil, err + } + + var resp User + + err = s.client.Do(scwReq, &resp, opts...) + if err != nil { + return nil, err + } + return &resp, nil +} + // 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`. func (s *API) ListApplications(req *ListApplicationsRequest, opts ...scw.RequestOption) (*ListApplicationsResponse, error) { var err error