diff --git a/cmd/scw/testdata/test-all-usage-iam-user-lock-usage.golden b/cmd/scw/testdata/test-all-usage-iam-user-lock-usage.golden new file mode 100644 index 0000000000..f31b9cc100 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-iam-user-lock-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Lock a member. A locked member cannot log in or use API keys until the locked status is removed. + +USAGE: + scw iam user lock [arg=value ...] + +ARGS: + user-id ID of the user to lock + +FLAGS: + -h, --help help for lock + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-iam-user-unlock-usage.golden b/cmd/scw/testdata/test-all-usage-iam-user-unlock-usage.golden new file mode 100644 index 0000000000..64f6d77259 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-iam-user-unlock-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Unlock a member. + +USAGE: + scw iam user unlock [arg=value ...] + +ARGS: + user-id ID of the user to unlock + +FLAGS: + -h, --help help for unlock + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-iam-user-usage.golden b/cmd/scw/testdata/test-all-usage-iam-user-usage.golden index e48a99fe41..d7ffe3a9e8 100644 --- a/cmd/scw/testdata/test-all-usage-iam-user-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-user-usage.golden @@ -10,6 +10,8 @@ AVAILABLE COMMANDS: delete Delete a guest user from an Organization get Get a given user list List users of an Organization + lock Lock a member + unlock Unlock a member update Update a user update-password Update an user's password. update-username Update an user's username. diff --git a/docs/commands/iam.md b/docs/commands/iam.md index fa5069792e..2921fe1b10 100644 --- a/docs/commands/iam.md +++ b/docs/commands/iam.md @@ -67,6 +67,8 @@ This API allows you to manage Identity and Access Management (IAM) across your S - [Delete a guest user from an Organization](#delete-a-guest-user-from-an-organization) - [Get a given user](#get-a-given-user) - [List users of an Organization](#list-users-of-an-organization) + - [Lock a member](#lock-a-member) + - [Unlock a member](#unlock-a-member) - [Update a user](#update-a-user) - [Update an user's password.](#update-an-user's-password.) - [Update an user's username.](#update-an-user's-username.) @@ -1299,6 +1301,44 @@ scw iam user list [arg=value ...] +### Lock a member + +Lock a member. A locked member cannot log in or use API keys until the locked status is removed. + +**Usage:** + +``` +scw iam user lock [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| user-id | Required | ID of the user to lock | + + + +### Unlock a member + +Unlock a member. + +**Usage:** + +``` +scw iam user unlock [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| user-id | Required | ID of the user to unlock | + + + ### Update a user Update the parameters of a user, including `tags`. diff --git a/go.mod b/go.mod index d23adb74fe..b246bdd5a1 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/moby/buildkit v0.26.2 github.com/opencontainers/go-digest v1.0.0 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126083441-c306e91d6b43 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126163841-f8e137ded5a4 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.10.1 github.com/spf13/pflag v1.0.10 diff --git a/go.sum b/go.sum index 9f7b3494e7..1c6978e6e1 100644 --- a/go.sum +++ b/go.sum @@ -462,8 +462,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126083441-c306e91d6b43 h1:MXwUsRKtGFvYZxVJz2Z8A+9l81Ag4TKoL6LpMLrNc+I= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126083441-c306e91d6b43/go.mod h1:h/elW4JdNo225GP5FZHJ/RPyCNz79lxaeub3PyGzE9o= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126163841-f8e137ded5a4 h1:6/n7fmgdMmeWXcnXdIMWhfvNQWg7EFpzP/roBAPItR4= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126163841-f8e137ded5a4/go.mod h1:h/elW4JdNo225GP5FZHJ/RPyCNz79lxaeub3PyGzE9o= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= github.com/secure-systems-lab/go-securesystemslib v0.9.1 h1:nZZaNz4DiERIQguNy0cL5qTdn9lR8XKHf4RUyG1Sx3g= diff --git a/internal/namespaces/iam/v1alpha1/iam_cli.go b/internal/namespaces/iam/v1alpha1/iam_cli.go index 366a0e3321..c32fd0908e 100644 --- a/internal/namespaces/iam/v1alpha1/iam_cli.go +++ b/internal/namespaces/iam/v1alpha1/iam_cli.go @@ -45,6 +45,8 @@ func GetGeneratedCommands() *core.Commands { iamUserCreate(), iamUserUpdateUsername(), iamUserUpdatePassword(), + iamUserLock(), + iamUserUnlock(), iamApplicationList(), iamApplicationCreate(), iamApplicationGet(), @@ -875,6 +877,64 @@ func iamUserUpdatePassword() *core.Command { } } +func iamUserLock() *core.Command { + return &core.Command{ + Short: `Lock a member`, + Long: `Lock a member. A locked member cannot log in or use API keys until the locked status is removed.`, + Namespace: "iam", + Resource: "user", + Verb: "lock", + // Deprecated: false, + ArgsType: reflect.TypeOf(iam.LockUserRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "user-id", + Short: `ID of the user to lock`, + Required: true, + Deprecated: false, + Positional: true, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*iam.LockUserRequest) + + client := core.ExtractClient(ctx) + api := iam.NewAPI(client) + + return api.LockUser(request) + }, + } +} + +func iamUserUnlock() *core.Command { + return &core.Command{ + Short: `Unlock a member`, + Long: `Unlock a member.`, + Namespace: "iam", + Resource: "user", + Verb: "unlock", + // Deprecated: false, + ArgsType: reflect.TypeOf(iam.UnlockUserRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "user-id", + Short: `ID of the user to unlock`, + Required: true, + Deprecated: false, + Positional: true, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*iam.UnlockUserRequest) + + client := core.ExtractClient(ctx) + api := iam.NewAPI(client) + + return api.UnlockUser(request) + }, + } +} + func iamApplicationList() *core.Command { return &core.Command{ Short: `List applications of an Organization`,