Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iam): generate cli for UpdateUser #3579

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-iam-user-update-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Update the parameters of a user, including `tags`.

USAGE:
scw iam user update <user-id ...> [arg=value ...]

ARGS:
user-id ID of the user to update
[tags.{index}] New tags for the user (maximum of 10 tags)

FLAGS:
-h, --help help for update

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
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-iam-user-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AVAILABLE COMMANDS:
delete Delete a guest user from an Organization
get Get a given user
list List users of an Organization
update Update a user

FLAGS:
-h, --help help for user
Expand Down
21 changes: 21 additions & 0 deletions docs/commands/iam.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ IAM API.
- [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)
- [Update a user](#update-a-user)


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



### Update a user

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

**Usage:**

```
scw iam user update <user-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| user-id | Required | ID of the user to update |
| tags.{index} | | New tags for the user (maximum of 10 tags) |



2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/moby/buildkit v0.11.6
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20231229162831-8d1cd051858d
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240103152155-b6170c7b5894
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
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.22.0.20231229162831-8d1cd051858d h1:cbzT1T/CEsxu2SHFlewnIIUsJfV/vP65WNEPz0CAd1g=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20231229162831-8d1cd051858d/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240103152155-b6170c7b5894 h1:k0sP67Yer2X9O+F1tK2THU4PVPNsbU3SHzhR80eaJvU=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22.0.20240103152155-b6170c7b5894/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
37 changes: 37 additions & 0 deletions internal/namespaces/iam/v1alpha1/iam_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func GetGeneratedCommands() *core.Commands {
iamSSHKeyDelete(),
iamUserList(),
iamUserGet(),
iamUserUpdate(),
iamUserDelete(),
iamUserCreate(),
iamApplicationList(),
Expand Down Expand Up @@ -524,6 +525,42 @@ func iamUserGet() *core.Command {
}
}

func iamUserUpdate() *core.Command {
return &core.Command{
Short: `Update a user`,
Long: `Update the parameters of a user, including ` + "`" + `tags` + "`" + `.`,
Namespace: "iam",
Resource: "user",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(iam.UpdateUserRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "user-id",
Short: `ID of the user to update`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "tags.{index}",
Short: `New tags for the user (maximum of 10 tags)`,
Required: false,
Deprecated: false,
Positional: false,
},
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iam.UpdateUserRequest)

client := core.ExtractClient(ctx)
api := iam.NewAPI(client)
return api.UpdateUser(request)

},
}
}

func iamUserDelete() *core.Command {
return &core.Command{
Short: `Delete a guest user from an Organization`,
Expand Down
Loading