Skip to content

Commit 0cfe8a9

Browse files
feat(iam): add CreateUser to the Scaleway CLI (#3416)
Co-authored-by: Rémy Léone <[email protected]>
1 parent b48e188 commit 0cfe8a9

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
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+
Create a new user. You must define the `organization_id` and the `email` in your request.
4+
5+
USAGE:
6+
scw iam user create [arg=value ...]
7+
8+
ARGS:
9+
email Email of the user
10+
[organization-id] Organization ID to use. If none is passed the default organization ID will be used
11+
12+
FLAGS:
13+
-h, --help help for create
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
@@ -6,6 +6,7 @@ USAGE:
66
scw iam user <command>
77

88
AVAILABLE COMMANDS:
9+
create Create a new user
910
delete Delete a guest user from an Organization
1011
get Get a given user
1112
list List users of an Organization

docs/commands/iam.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ IAM API.
4848
- [List SSH keys](#list-ssh-keys)
4949
- [Update an SSH key](#update-an-ssh-key)
5050
- [Users management commands](#users-management-commands)
51+
- [Create a new user](#create-a-new-user)
5152
- [Delete a guest user from an Organization](#delete-a-guest-user-from-an-organization)
5253
- [Get a given user](#get-a-given-user)
5354
- [List users of an Organization](#list-users-of-an-organization)
@@ -930,6 +931,26 @@ scw iam ssh-key update <ssh-key-id ...> [arg=value ...]
930931
Users management commands.
931932

932933

934+
### Create a new user
935+
936+
Create a new user. You must define the `organization_id` and the `email` in your request.
937+
938+
**Usage:**
939+
940+
```
941+
scw iam user create [arg=value ...]
942+
```
943+
944+
945+
**Args:**
946+
947+
| Name | | Description |
948+
|------|---|-------------|
949+
| email | Required | Email of the user |
950+
| organization-id | | Organization ID to use. If none is passed the default organization ID will be used |
951+
952+
953+
933954
### Delete a guest user from an Organization
934955

935956
Remove a user from an Organization in which they are a guest. You must define the `user_id` in your request. Note that removing a user from an Organization automatically deletes their API keys, and any policies directly attached to them become orphaned.

internal/namespaces/iam/v1alpha1/iam_cli.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func GetGeneratedCommands() *core.Commands {
3737
iamUserList(),
3838
iamUserGet(),
3939
iamUserDelete(),
40+
iamUserCreate(),
4041
iamApplicationList(),
4142
iamApplicationCreate(),
4243
iamApplicationGet(),
@@ -539,6 +540,36 @@ func iamUserDelete() *core.Command {
539540
}
540541
}
541542

543+
func iamUserCreate() *core.Command {
544+
return &core.Command{
545+
Short: `Create a new user`,
546+
Long: `Create a new user. You must define the ` + "`" + `organization_id` + "`" + ` and the ` + "`" + `email` + "`" + ` in your request.`,
547+
Namespace: "iam",
548+
Resource: "user",
549+
Verb: "create",
550+
// Deprecated: false,
551+
ArgsType: reflect.TypeOf(iam.CreateUserRequest{}),
552+
ArgSpecs: core.ArgSpecs{
553+
{
554+
Name: "email",
555+
Short: `Email of the user`,
556+
Required: true,
557+
Deprecated: false,
558+
Positional: false,
559+
},
560+
core.OrganizationIDArgSpec(),
561+
},
562+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
563+
request := args.(*iam.CreateUserRequest)
564+
565+
client := core.ExtractClient(ctx)
566+
api := iam.NewAPI(client)
567+
return api.CreateUser(request)
568+
569+
},
570+
}
571+
}
572+
542573
func iamApplicationList() *core.Command {
543574
return &core.Command{
544575
Short: `List applications of an Organization`,

0 commit comments

Comments
 (0)