diff --git a/cmd/scw/testdata/test-all-usage-iam-user-update-username-usage.golden b/cmd/scw/testdata/test-all-usage-iam-user-update-username-usage.golden new file mode 100644 index 0000000000..9b017853c8 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-iam-user-update-username-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Update an user's username. Private Beta feature. + +USAGE: + scw iam user update-username [arg=value ...] + +ARGS: + user-id ID of the user to update + username The new username + +FLAGS: + -h, --help help for update-username + +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 3519fb5db6..ccd5b251b2 100644 --- a/cmd/scw/testdata/test-all-usage-iam-user-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-user-usage.golden @@ -12,6 +12,7 @@ AVAILABLE COMMANDS: list List users of an Organization update Update a user update-password Update an user's password. Private Beta feature. + update-username Update an user's username. Private Beta feature. FLAGS: -h, --help help for user diff --git a/docs/commands/iam.md b/docs/commands/iam.md index 6bf9110e78..6a5ad4885c 100644 --- a/docs/commands/iam.md +++ b/docs/commands/iam.md @@ -59,6 +59,7 @@ This API allows you to manage Identity and Access Management (IAM) across your S - [List users of an Organization](#list-users-of-an-organization) - [Update a user](#update-a-user) - [Update an user's password. Private Beta feature.](#update-an-user's-password.-private-beta-feature.) + - [Update an user's username. Private Beta feature.](#update-an-user's-username.-private-beta-feature.) ## API keys management commands @@ -1171,3 +1172,23 @@ scw iam user update-password [arg=value ...] +### Update an user's username. Private Beta feature. + +Update an user's username. Private Beta feature. + +**Usage:** + +``` +scw iam user update-username [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| user-id | Required | ID of the user to update | +| username | Required | The new username | + + + diff --git a/go.mod b/go.mod index f8163733c4..670a419791 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/moby/buildkit v0.13.2 github.com/opencontainers/go-digest v1.0.0 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209153125-92afa47368ef + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241212151423-0d220e058bfc github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 7b4af5348e..664ca7e279 100644 --- a/go.sum +++ b/go.sum @@ -466,8 +466,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz 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.30.0.20241209153125-92afa47368ef h1:WlyvzZzG1ipVvmolk69a7VdWCP5J0nCRxsNGpUspGrc= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241209153125-92afa47368ef/go.mod h1:kzh+BSAvpoyHHdHBCDhmSWtBc1NbLMZ2lWHqnBoxFks= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241212151423-0d220e058bfc h1:TxTKg5QuwgdKZ3+i1xPgihahVMGoO4zlqkC6zh9aHp4= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30.0.20241212151423-0d220e058bfc/go.mod h1:kzh+BSAvpoyHHdHBCDhmSWtBc1NbLMZ2lWHqnBoxFks= 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.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA= diff --git a/internal/namespaces/iam/v1alpha1/iam_cli.go b/internal/namespaces/iam/v1alpha1/iam_cli.go index 6471d03a71..ee0b4255c5 100644 --- a/internal/namespaces/iam/v1alpha1/iam_cli.go +++ b/internal/namespaces/iam/v1alpha1/iam_cli.go @@ -40,6 +40,7 @@ func GetGeneratedCommands() *core.Commands { iamUserUpdate(), iamUserDelete(), iamUserCreate(), + iamUserUpdateUsername(), iamUserUpdatePassword(), iamApplicationList(), iamApplicationCreate(), @@ -676,6 +677,42 @@ func iamUserCreate() *core.Command { } } +func iamUserUpdateUsername() *core.Command { + return &core.Command{ + Short: `Update an user's username. Private Beta feature.`, + Long: `Update an user's username. Private Beta feature.`, + Namespace: "iam", + Resource: "user", + Verb: "update-username", + // Deprecated: false, + ArgsType: reflect.TypeOf(iam.UpdateUserUsernameRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "user-id", + Short: `ID of the user to update`, + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "username", + Short: `The new username`, + Required: true, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*iam.UpdateUserUsernameRequest) + + client := core.ExtractClient(ctx) + api := iam.NewAPI(client) + return api.UpdateUserUsername(request) + + }, + } +} + func iamUserUpdatePassword() *core.Command { return &core.Command{ Short: `Update an user's password. Private Beta feature.`,