From 12be2fad3c3904e8fc69a5456e7ed88f7557c80f Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 7 Sep 2022 14:00:39 +0000 Subject: [PATCH] feat: update generated cli --- ...-usage-container-token-create-usage.golden | 22 +++ ...-usage-container-token-delete-usage.golden | 19 ++ ...all-usage-container-token-get-usage.golden | 19 ++ ...ll-usage-container-token-list-usage.golden | 21 +++ ...est-all-usage-container-token-usage.golden | 23 +++ .../test-all-usage-container-usage.golden | 1 + ...l-usage-function-token-create-usage.golden | 22 +++ ...l-usage-function-token-delete-usage.golden | 19 ++ ...-all-usage-function-token-get-usage.golden | 19 ++ ...all-usage-function-token-list-usage.golden | 21 +++ ...test-all-usage-function-token-usage.golden | 23 +++ .../test-all-usage-function-usage.golden | 1 + ...sage-instance-snapshot-create-usage.golden | 2 +- docs/commands/container.md | 95 ++++++++++ docs/commands/function.md | 95 ++++++++++ docs/commands/instance.md | 2 +- go.mod | 2 +- go.sum | 4 +- .../container/v1beta1/container_cli.go | 165 ++++++++++++++++++ .../function/v1beta1/function_cli.go | 165 ++++++++++++++++++ .../namespaces/instance/v1/instance_cli.go | 2 +- 21 files changed, 736 insertions(+), 6 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-container-token-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-token-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-token-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-token-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-token-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-token-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-token-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-token-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-token-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-token-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-container-token-create-usage.golden b/cmd/scw/testdata/test-all-usage-container-token-create-usage.golden new file mode 100644 index 0000000000..d88b82f9c3 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-token-create-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a new revocable token. + +USAGE: + scw container token create [arg=value ...] + +ARGS: + [container-id] + [namespace-id] + [description] + [expires-at] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for create + +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-container-token-delete-usage.golden b/cmd/scw/testdata/test-all-usage-container-token-delete-usage.golden new file mode 100644 index 0000000000..bd7c09cc56 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-token-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete a token. + +USAGE: + scw container token delete [arg=value ...] + +ARGS: + token-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for delete + +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-container-token-get-usage.golden b/cmd/scw/testdata/test-all-usage-container-token-get-usage.golden new file mode 100644 index 0000000000..ea864ece14 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-token-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get a token. + +USAGE: + scw container token get [arg=value ...] + +ARGS: + token-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get + +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-container-token-list-usage.golden b/cmd/scw/testdata/test-all-usage-container-token-list-usage.golden new file mode 100644 index 0000000000..f27f23c907 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-token-list-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all tokens. + +USAGE: + scw container token list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc) + [container-id] + [namespace-id] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +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-container-token-usage.golden b/cmd/scw/testdata/test-all-usage-container-token-usage.golden new file mode 100644 index 0000000000..160357918f --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-token-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Token management commands. + +USAGE: + scw container token + +AVAILABLE COMMANDS: + create Create a new revocable token + delete Delete a token + get Get a token + list List all tokens + +FLAGS: + -h, --help help for token + +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 + +Use "scw container token [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-container-usage.golden b/cmd/scw/testdata/test-all-usage-container-usage.golden index 272a1be892..d07d470de8 100644 --- a/cmd/scw/testdata/test-all-usage-container-usage.golden +++ b/cmd/scw/testdata/test-all-usage-container-usage.golden @@ -10,6 +10,7 @@ AVAILABLE COMMANDS: cron Cron management commands domain Domain management commands namespace Namespace management commands + token Token management commands FLAGS: -h, --help help for container diff --git a/cmd/scw/testdata/test-all-usage-function-token-create-usage.golden b/cmd/scw/testdata/test-all-usage-function-token-create-usage.golden new file mode 100644 index 0000000000..1f699bf94c --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-token-create-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a new revocable token. + +USAGE: + scw function token create [arg=value ...] + +ARGS: + [function-id] + [namespace-id] + [description] + [expires-at] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for create + +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-function-token-delete-usage.golden b/cmd/scw/testdata/test-all-usage-function-token-delete-usage.golden new file mode 100644 index 0000000000..0ca8f5cb73 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-token-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete a token. + +USAGE: + scw function token delete [arg=value ...] + +ARGS: + token-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for delete + +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-function-token-get-usage.golden b/cmd/scw/testdata/test-all-usage-function-token-get-usage.golden new file mode 100644 index 0000000000..ac43bba526 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-token-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get a token. + +USAGE: + scw function token get [arg=value ...] + +ARGS: + token-id + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for get + +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-function-token-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-token-list-usage.golden new file mode 100644 index 0000000000..c66cd0cee5 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-token-list-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all tokens. + +USAGE: + scw function token list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc) + [function-id] + [namespace-id] + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for list + +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-function-token-usage.golden b/cmd/scw/testdata/test-all-usage-function-token-usage.golden new file mode 100644 index 0000000000..23824f92f4 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-token-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Token management commands. + +USAGE: + scw function token + +AVAILABLE COMMANDS: + create Create a new revocable token + delete Delete a token + get Get a token + list List all tokens + +FLAGS: + -h, --help help for token + +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 + +Use "scw function token [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-function-usage.golden b/cmd/scw/testdata/test-all-usage-function-usage.golden index ebe1a5dc1a..fb90b65175 100644 --- a/cmd/scw/testdata/test-all-usage-function-usage.golden +++ b/cmd/scw/testdata/test-all-usage-function-usage.golden @@ -12,6 +12,7 @@ AVAILABLE COMMANDS: logs Logs management commands namespace Function namespace management commands runtime Runtime management commands + token Token management commands FLAGS: -h, --help help for function diff --git a/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.golden b/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.golden index 5f1da70191..9117faae70 100644 --- a/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.golden @@ -20,7 +20,7 @@ EXAMPLES: ARGS: [name=] Name of the snapshot - volume-id UUID of the volume + [volume-id] UUID of the volume [unified] Whether a snapshot is unified or not. [tags.{index}] The tags of the snapshot [project-id] Project ID to use. If none is passed the default project ID will be used diff --git a/docs/commands/container.md b/docs/commands/container.md index 9dc5a65d77..83442b9074 100644 --- a/docs/commands/container.md +++ b/docs/commands/container.md @@ -24,6 +24,11 @@ Container as a Service API - [Get a namespace](#get-a-namespace) - [List all your namespaces](#list-all-your-namespaces) - [Update an existing namespace](#update-an-existing-namespace) +- [Token management commands](#token-management-commands) + - [Create a new revocable token](#create-a-new-revocable-token) + - [Delete a token](#delete-a-token) + - [Get a token](#get-a-token) + - [List all tokens](#list-all-tokens) ## Container management commands @@ -457,3 +462,93 @@ scw container namespace update [arg=value ...] +## Token management commands + +Token management commands. + + +### Create a new revocable token + +Create a new revocable token. + +**Usage:** + +``` +scw container token create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| container-id | | | +| namespace-id | | | +| description | | | +| expires-at | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Delete a token + +Delete a token. + +**Usage:** + +``` +scw container token delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| token-id | Required | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Get a token + +Get a token. + +**Usage:** + +``` +scw container token get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| token-id | Required | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### List all tokens + +List all tokens. + +**Usage:** + +``` +scw container token list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| order-by | One of: `created_at_asc`, `created_at_desc` | | +| container-id | | | +| namespace-id | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + diff --git a/docs/commands/function.md b/docs/commands/function.md index b973de5c9b..b19ab312a2 100644 --- a/docs/commands/function.md +++ b/docs/commands/function.md @@ -30,6 +30,11 @@ Function as a Service API - [Update an existing namespace](#update-an-existing-namespace) - [Runtime management commands](#runtime-management-commands) - [List function runtimes](#list-function-runtimes) +- [Token management commands](#token-management-commands) + - [Create a new revocable token](#create-a-new-revocable-token) + - [Delete a token](#delete-a-token) + - [Get a token](#get-a-token) + - [List all tokens](#list-all-tokens) ## Cron management commands @@ -550,3 +555,93 @@ scw function runtime list [arg=value ...] +## Token management commands + +Token management commands. + + +### Create a new revocable token + +Create a new revocable token. + +**Usage:** + +``` +scw function token create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| function-id | | | +| namespace-id | | | +| description | | | +| expires-at | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Delete a token + +Delete a token. + +**Usage:** + +``` +scw function token delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| token-id | Required | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Get a token + +Get a token. + +**Usage:** + +``` +scw function token get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| token-id | Required | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### List all tokens + +List all tokens. + +**Usage:** + +``` +scw function token list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| order-by | One of: `created_at_asc`, `created_at_desc` | | +| function-id | | | +| namespace-id | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + diff --git a/docs/commands/instance.md b/docs/commands/instance.md index a426546d57..7394574f44 100644 --- a/docs/commands/instance.md +++ b/docs/commands/instance.md @@ -1928,7 +1928,7 @@ scw instance snapshot create [arg=value ...] | Name | | Description | |------|---|-------------| | name | Default: `` | Name of the snapshot | -| volume-id | Required | UUID of the volume | +| volume-id | | UUID of the volume | | unified | | Whether a snapshot is unified or not. | | tags.{index} | | The tags of the snapshot | | project-id | | Project ID to use. If none is passed the default project ID will be used | diff --git a/go.mod b/go.mod index 629bd1c5fc..48263bacdd 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98 github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-isatty v0.0.16 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220905101028-f685ad03ae6c + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220907082605-794394649db9 github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.0 diff --git a/go.sum b/go.sum index 96f9f6438e..ba73a4f4c2 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220905101028-f685ad03ae6c h1:XPDFZZqhdrTACClt3Kwke5fyOMhX+8fqHSDF+U7YWbk= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220905101028-f685ad03ae6c/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220907082605-794394649db9 h1:cQE7TtLqtXqIAI1vYvhiAeIOfWr0nBEwIb234125Feg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220907082605-794394649db9/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= diff --git a/internal/namespaces/container/v1beta1/container_cli.go b/internal/namespaces/container/v1beta1/container_cli.go index 1d74231d04..d78211c439 100644 --- a/internal/namespaces/container/v1beta1/container_cli.go +++ b/internal/namespaces/container/v1beta1/container_cli.go @@ -24,6 +24,7 @@ func GetGeneratedCommands() *core.Commands { containerContainer(), containerCron(), containerDomain(), + containerToken(), containerNamespaceList(), containerNamespaceGet(), containerNamespaceCreate(), @@ -42,6 +43,10 @@ func GetGeneratedCommands() *core.Commands { containerDomainGet(), containerDomainCreate(), containerDomainDelete(), + containerTokenCreate(), + containerTokenGet(), + containerTokenList(), + containerTokenDelete(), ) } func containerRoot() *core.Command { @@ -88,6 +93,15 @@ func containerDomain() *core.Command { } } +func containerToken() *core.Command { + return &core.Command{ + Short: `Token management commands`, + Long: `Token management commands.`, + Namespace: "container", + Resource: "token", + } +} + func containerNamespaceList() *core.Command { return &core.Command{ Short: `List all your namespaces`, @@ -938,3 +952,154 @@ func containerDomainDelete() *core.Command { }, } } + +func containerTokenCreate() *core.Command { + return &core.Command{ + Short: `Create a new revocable token`, + Long: `Create a new revocable token.`, + Namespace: "container", + Resource: "token", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.CreateTokenRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "container-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "namespace-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "expires-at", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*container.CreateTokenRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + return api.CreateToken(request) + + }, + } +} + +func containerTokenGet() *core.Command { + return &core.Command{ + Short: `Get a token`, + Long: `Get a token.`, + Namespace: "container", + Resource: "token", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.GetTokenRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "token-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*container.GetTokenRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + return api.GetToken(request) + + }, + } +} + +func containerTokenList() *core.Command { + return &core.Command{ + Short: `List all tokens`, + Long: `List all tokens.`, + Namespace: "container", + Resource: "token", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.ListTokensRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "container-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "namespace-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*container.ListTokensRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + resp, err := api.ListTokens(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Tokens, nil + + }, + } +} + +func containerTokenDelete() *core.Command { + return &core.Command{ + Short: `Delete a token`, + Long: `Delete a token.`, + Namespace: "container", + Resource: "token", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.DeleteTokenRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "token-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*container.DeleteTokenRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + return api.DeleteToken(request) + + }, + } +} diff --git a/internal/namespaces/function/v1beta1/function_cli.go b/internal/namespaces/function/v1beta1/function_cli.go index 3592a36ec8..fde7dbe16c 100644 --- a/internal/namespaces/function/v1beta1/function_cli.go +++ b/internal/namespaces/function/v1beta1/function_cli.go @@ -26,6 +26,7 @@ func GetGeneratedCommands() *core.Commands { functionRuntime(), functionLogs(), functionDomain(), + functionToken(), functionNamespaceList(), functionNamespaceGet(), functionNamespaceCreate(), @@ -48,6 +49,10 @@ func GetGeneratedCommands() *core.Commands { functionDomainGet(), functionDomainCreate(), functionDomainDelete(), + functionTokenCreate(), + functionTokenGet(), + functionTokenList(), + functionTokenDelete(), ) } func functionRoot() *core.Command { @@ -112,6 +117,15 @@ func functionDomain() *core.Command { } } +func functionToken() *core.Command { + return &core.Command{ + Short: `Token management commands`, + Long: `Token management commands.`, + Namespace: "function", + Resource: "token", + } +} + func functionNamespaceList() *core.Command { return &core.Command{ Short: `List all your namespaces`, @@ -1100,3 +1114,154 @@ func functionDomainDelete() *core.Command { }, } } + +func functionTokenCreate() *core.Command { + return &core.Command{ + Short: `Create a new revocable token`, + Long: `Create a new revocable token.`, + Namespace: "function", + Resource: "token", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.CreateTokenRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "function-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "namespace-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "expires-at", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.CreateTokenRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.CreateToken(request) + + }, + } +} + +func functionTokenGet() *core.Command { + return &core.Command{ + Short: `Get a token`, + Long: `Get a token.`, + Namespace: "function", + Resource: "token", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetTokenRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "token-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.GetTokenRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetToken(request) + + }, + } +} + +func functionTokenList() *core.Command { + return &core.Command{ + Short: `List all tokens`, + Long: `List all tokens.`, + Namespace: "function", + Resource: "token", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListTokensRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "function-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "namespace-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.ListTokensRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + resp, err := api.ListTokens(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Tokens, nil + + }, + } +} + +func functionTokenDelete() *core.Command { + return &core.Command{ + Short: `Delete a token`, + Long: `Delete a token.`, + Namespace: "function", + Resource: "token", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.DeleteTokenRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "token-id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*function.DeleteTokenRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.DeleteToken(request) + + }, + } +} diff --git a/internal/namespaces/instance/v1/instance_cli.go b/internal/namespaces/instance/v1/instance_cli.go index c3af93d91e..3ec262b4be 100644 --- a/internal/namespaces/instance/v1/instance_cli.go +++ b/internal/namespaces/instance/v1/instance_cli.go @@ -1269,7 +1269,7 @@ func instanceSnapshotCreate() *core.Command { { Name: "volume-id", Short: `UUID of the volume`, - Required: true, + Required: false, Deprecated: false, Positional: false, },