Skip to content

Commit 40fca90

Browse files
feat(iam): enable user lock/unlock in CLI (#5182)
Co-authored-by: esoulard <esoulard@scaleway.com>
1 parent 9854b20 commit 40fca90

File tree

7 files changed

+141
-3
lines changed

7 files changed

+141
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Lock a member. A locked member cannot log in or use API keys until the locked status is removed.
4+
5+
USAGE:
6+
scw iam user lock <user-id ...> [arg=value ...]
7+
8+
ARGS:
9+
user-id ID of the user to lock
10+
11+
FLAGS:
12+
-h, --help help for lock
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Unlock a member.
4+
5+
USAGE:
6+
scw iam user unlock <user-id ...> [arg=value ...]
7+
8+
ARGS:
9+
user-id ID of the user to unlock
10+
11+
FLAGS:
12+
-h, --help help for unlock
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-iam-user-usage.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ AVAILABLE COMMANDS:
1010
delete Delete a guest user from an Organization
1111
get Get a given user
1212
list List users of an Organization
13+
lock Lock a member
14+
unlock Unlock a member
1315
update Update a user
1416
update-password Update an user's password.
1517
update-username Update an user's username.

docs/commands/iam.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ This API allows you to manage Identity and Access Management (IAM) across your S
6767
- [Delete a guest user from an Organization](#delete-a-guest-user-from-an-organization)
6868
- [Get a given user](#get-a-given-user)
6969
- [List users of an Organization](#list-users-of-an-organization)
70+
- [Lock a member](#lock-a-member)
71+
- [Unlock a member](#unlock-a-member)
7072
- [Update a user](#update-a-user)
7173
- [Update an user's password.](#update-an-user's-password.)
7274
- [Update an user's username.](#update-an-user's-username.)
@@ -1299,6 +1301,44 @@ scw iam user list [arg=value ...]
12991301

13001302

13011303

1304+
### Lock a member
1305+
1306+
Lock a member. A locked member cannot log in or use API keys until the locked status is removed.
1307+
1308+
**Usage:**
1309+
1310+
```
1311+
scw iam user lock <user-id ...> [arg=value ...]
1312+
```
1313+
1314+
1315+
**Args:**
1316+
1317+
| Name | | Description |
1318+
|------|---|-------------|
1319+
| user-id | Required | ID of the user to lock |
1320+
1321+
1322+
1323+
### Unlock a member
1324+
1325+
Unlock a member.
1326+
1327+
**Usage:**
1328+
1329+
```
1330+
scw iam user unlock <user-id ...> [arg=value ...]
1331+
```
1332+
1333+
1334+
**Args:**
1335+
1336+
| Name | | Description |
1337+
|------|---|-------------|
1338+
| user-id | Required | ID of the user to unlock |
1339+
1340+
1341+
13021342
### Update a user
13031343

13041344
Update the parameters of a user, including `tags`.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/mattn/go-isatty v0.0.20
2424
github.com/moby/buildkit v0.26.2
2525
github.com/opencontainers/go-digest v1.0.0
26-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126083441-c306e91d6b43
26+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126163841-f8e137ded5a4
2727
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2828
github.com/spf13/cobra v1.10.1
2929
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
462462
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
463463
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
464464
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
465-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126083441-c306e91d6b43 h1:MXwUsRKtGFvYZxVJz2Z8A+9l81Ag4TKoL6LpMLrNc+I=
466-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126083441-c306e91d6b43/go.mod h1:h/elW4JdNo225GP5FZHJ/RPyCNz79lxaeub3PyGzE9o=
465+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126163841-f8e137ded5a4 h1:6/n7fmgdMmeWXcnXdIMWhfvNQWg7EFpzP/roBAPItR4=
466+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.35.0.20251126163841-f8e137ded5a4/go.mod h1:h/elW4JdNo225GP5FZHJ/RPyCNz79lxaeub3PyGzE9o=
467467
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
468468
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
469469
github.com/secure-systems-lab/go-securesystemslib v0.9.1 h1:nZZaNz4DiERIQguNy0cL5qTdn9lR8XKHf4RUyG1Sx3g=

internal/namespaces/iam/v1alpha1/iam_cli.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func GetGeneratedCommands() *core.Commands {
4545
iamUserCreate(),
4646
iamUserUpdateUsername(),
4747
iamUserUpdatePassword(),
48+
iamUserLock(),
49+
iamUserUnlock(),
4850
iamApplicationList(),
4951
iamApplicationCreate(),
5052
iamApplicationGet(),
@@ -875,6 +877,64 @@ func iamUserUpdatePassword() *core.Command {
875877
}
876878
}
877879

880+
func iamUserLock() *core.Command {
881+
return &core.Command{
882+
Short: `Lock a member`,
883+
Long: `Lock a member. A locked member cannot log in or use API keys until the locked status is removed.`,
884+
Namespace: "iam",
885+
Resource: "user",
886+
Verb: "lock",
887+
// Deprecated: false,
888+
ArgsType: reflect.TypeOf(iam.LockUserRequest{}),
889+
ArgSpecs: core.ArgSpecs{
890+
{
891+
Name: "user-id",
892+
Short: `ID of the user to lock`,
893+
Required: true,
894+
Deprecated: false,
895+
Positional: true,
896+
},
897+
},
898+
Run: func(ctx context.Context, args any) (i any, e error) {
899+
request := args.(*iam.LockUserRequest)
900+
901+
client := core.ExtractClient(ctx)
902+
api := iam.NewAPI(client)
903+
904+
return api.LockUser(request)
905+
},
906+
}
907+
}
908+
909+
func iamUserUnlock() *core.Command {
910+
return &core.Command{
911+
Short: `Unlock a member`,
912+
Long: `Unlock a member.`,
913+
Namespace: "iam",
914+
Resource: "user",
915+
Verb: "unlock",
916+
// Deprecated: false,
917+
ArgsType: reflect.TypeOf(iam.UnlockUserRequest{}),
918+
ArgSpecs: core.ArgSpecs{
919+
{
920+
Name: "user-id",
921+
Short: `ID of the user to unlock`,
922+
Required: true,
923+
Deprecated: false,
924+
Positional: true,
925+
},
926+
},
927+
Run: func(ctx context.Context, args any) (i any, e error) {
928+
request := args.(*iam.UnlockUserRequest)
929+
930+
client := core.ExtractClient(ctx)
931+
api := iam.NewAPI(client)
932+
933+
return api.UnlockUser(request)
934+
},
935+
}
936+
}
937+
878938
func iamApplicationList() *core.Command {
879939
return &core.Command{
880940
Short: `List applications of an Organization`,

0 commit comments

Comments
 (0)