Skip to content

Commit c63b0a0

Browse files
scaleway-botyfodil
andauthored
feat(iam): generate cli for UpdateUser (#3579)
Co-authored-by: Yacine FODIL <[email protected]>
1 parent 4da8779 commit c63b0a0

File tree

6 files changed

+81
-3
lines changed

6 files changed

+81
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Update the parameters of a user, including `tags`.
4+
5+
USAGE:
6+
scw iam user update <user-id ...> [arg=value ...]
7+
8+
ARGS:
9+
user-id ID of the user to update
10+
[tags.{index}] New tags for the user (maximum of 10 tags)
11+
12+
FLAGS:
13+
-h, --help help for update
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ 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+
update Update a user
1314

1415
FLAGS:
1516
-h, --help help for user

docs/commands/iam.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ IAM API.
5555
- [Delete a guest user from an Organization](#delete-a-guest-user-from-an-organization)
5656
- [Get a given user](#get-a-given-user)
5757
- [List users of an Organization](#list-users-of-an-organization)
58+
- [Update a user](#update-a-user)
5859

5960

6061
## API keys management commands
@@ -1074,3 +1075,23 @@ scw iam user list [arg=value ...]
10741075

10751076

10761077

1078+
### Update a user
1079+
1080+
Update the parameters of a user, including `tags`.
1081+
1082+
**Usage:**
1083+
1084+
```
1085+
scw iam user update <user-id ...> [arg=value ...]
1086+
```
1087+
1088+
1089+
**Args:**
1090+
1091+
| Name | | Description |
1092+
|------|---|-------------|
1093+
| user-id | Required | ID of the user to update |
1094+
| tags.{index} | | New tags for the user (maximum of 10 tags) |
1095+
1096+
1097+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/moby/buildkit v0.11.6
2525
github.com/opencontainers/go-digest v1.0.0
2626
github.com/pkg/errors v0.9.1
27-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20231229162831-8d1cd051858d
27+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240103152155-b6170c7b5894
2828
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2929
github.com/spf13/cobra v1.8.0
3030
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
386386
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
387387
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
388388
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
389-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20231229162831-8d1cd051858d h1:cbzT1T/CEsxu2SHFlewnIIUsJfV/vP65WNEPz0CAd1g=
390-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20231229162831-8d1cd051858d/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
389+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240103152155-b6170c7b5894 h1:k0sP67Yer2X9O+F1tK2THU4PVPNsbU3SHzhR80eaJvU=
390+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240103152155-b6170c7b5894/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
391391
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
392392
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
393393
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=

internal/namespaces/iam/v1alpha1/iam_cli.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func GetGeneratedCommands() *core.Commands {
3737
iamSSHKeyDelete(),
3838
iamUserList(),
3939
iamUserGet(),
40+
iamUserUpdate(),
4041
iamUserDelete(),
4142
iamUserCreate(),
4243
iamApplicationList(),
@@ -524,6 +525,42 @@ func iamUserGet() *core.Command {
524525
}
525526
}
526527

528+
func iamUserUpdate() *core.Command {
529+
return &core.Command{
530+
Short: `Update a user`,
531+
Long: `Update the parameters of a user, including ` + "`" + `tags` + "`" + `.`,
532+
Namespace: "iam",
533+
Resource: "user",
534+
Verb: "update",
535+
// Deprecated: false,
536+
ArgsType: reflect.TypeOf(iam.UpdateUserRequest{}),
537+
ArgSpecs: core.ArgSpecs{
538+
{
539+
Name: "user-id",
540+
Short: `ID of the user to update`,
541+
Required: true,
542+
Deprecated: false,
543+
Positional: true,
544+
},
545+
{
546+
Name: "tags.{index}",
547+
Short: `New tags for the user (maximum of 10 tags)`,
548+
Required: false,
549+
Deprecated: false,
550+
Positional: false,
551+
},
552+
},
553+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
554+
request := args.(*iam.UpdateUserRequest)
555+
556+
client := core.ExtractClient(ctx)
557+
api := iam.NewAPI(client)
558+
return api.UpdateUser(request)
559+
560+
},
561+
}
562+
}
563+
527564
func iamUserDelete() *core.Command {
528565
return &core.Command{
529566
Short: `Delete a guest user from an Organization`,

0 commit comments

Comments
 (0)