From 3b0ef23305d682bc1b90540af8d12c004cc848d0 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 4 Nov 2024 08:39:35 +0100 Subject: [PATCH] feat(iam): add LockUser and UnlockUser method (#1552) Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com> --- .../clients/src/api/iam/v1alpha1/api.gen.ts | 37 +++++++++++++++++++ .../clients/src/api/iam/v1alpha1/index.gen.ts | 2 + .../clients/src/api/iam/v1alpha1/types.gen.ts | 8 ++++ 3 files changed, 47 insertions(+) diff --git a/packages/clients/src/api/iam/v1alpha1/api.gen.ts b/packages/clients/src/api/iam/v1alpha1/api.gen.ts index 0b7018b31..0532fddcb 100644 --- a/packages/clients/src/api/iam/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/api.gen.ts @@ -104,6 +104,7 @@ import type { ListSSHKeysResponse, ListUsersRequest, ListUsersResponse, + LockUserRequest, Log, Policy, Quotum, @@ -112,6 +113,7 @@ import type { SetGroupMembersRequest, SetRulesRequest, SetRulesResponse, + UnlockUserRequest, UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, @@ -358,6 +360,41 @@ export class API extends ParentAPI { unmarshalUser, ) + /** + * Lock a user. Lock a user. Note that a locked user cannot log in or use API + * keys until the locked status is removed. + * + * @param request - The request {@link LockUserRequest} + * @returns A Promise of User + */ + lockUser = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/iam/v1alpha1/users/${validatePathParam('userId', request.userId)}/lock`, + }, + unmarshalUser, + ) + + /** + * Unlock a user. + * + * @param request - The request {@link UnlockUserRequest} + * @returns A Promise of User + */ + unlockUser = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/iam/v1alpha1/users/${validatePathParam('userId', request.userId)}/unlock`, + }, + unmarshalUser, + ) + protected pageOfListApplications = ( request: Readonly = {}, ) => diff --git a/packages/clients/src/api/iam/v1alpha1/index.gen.ts b/packages/clients/src/api/iam/v1alpha1/index.gen.ts index f7145a67b..98597f4e7 100644 --- a/packages/clients/src/api/iam/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/index.gen.ts @@ -67,6 +67,7 @@ export type { ListUsersRequest, ListUsersRequestOrderBy, ListUsersResponse, + LockUserRequest, Log, LogAction, LogResourceType, @@ -81,6 +82,7 @@ export type { SetGroupMembersRequest, SetRulesRequest, SetRulesResponse, + UnlockUserRequest, UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, diff --git a/packages/clients/src/api/iam/v1alpha1/types.gen.ts b/packages/clients/src/api/iam/v1alpha1/types.gen.ts index 90be242bd..d54393f37 100644 --- a/packages/clients/src/api/iam/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/types.gen.ts @@ -954,6 +954,10 @@ export interface ListUsersResponse { totalCount: number } +export type LockUserRequest = { + userId: string +} + export type RemoveGroupMemberRequest = { /** ID of the group. */ groupId: string @@ -989,6 +993,10 @@ export interface SetRulesResponse { rules: Rule[] } +export type UnlockUserRequest = { + userId: string +} + export type UpdateAPIKeyRequest = { /** Access key to update. */ accessKey: string