From b2c2ceb3fa9ebe0561e07e2ff037e0c1758a9e09 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Tue, 5 Jul 2022 16:01:57 +0200 Subject: [PATCH] feat(serverless): add support for domain commands (#2396) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: RΓ©my LΓ©one --- ...usage-container-domain-create-usage.golden | 20 +++ ...usage-container-domain-delete-usage.golden | 19 +++ ...ll-usage-container-domain-get-usage.golden | 19 +++ ...l-usage-container-domain-list-usage.golden | 20 +++ ...st-all-usage-container-domain-usage.golden | 23 +++ .../test-all-usage-container-usage.golden | 1 + ...-usage-function-domain-create-usage.golden | 20 +++ ...-usage-function-domain-delete-usage.golden | 19 +++ ...all-usage-function-domain-get-usage.golden | 19 +++ ...ll-usage-function-domain-list-usage.golden | 20 +++ ...est-all-usage-function-domain-usage.golden | 23 +++ .../test-all-usage-function-usage.golden | 1 + docs/commands/container.md | 92 +++++++++++ docs/commands/function.md | 92 +++++++++++ go.mod | 2 +- go.sum | 4 +- .../container/v1beta1/container_cli.go | 147 ++++++++++++++++++ .../function/v1beta1/function_cli.go | 147 ++++++++++++++++++ 18 files changed, 685 insertions(+), 3 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-container-domain-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-domain-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-domain-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-domain-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-container-domain-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-domain-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-domain-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-domain-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-domain-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-function-domain-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-container-domain-create-usage.golden b/cmd/scw/testdata/test-all-usage-container-domain-create-usage.golden new file mode 100644 index 0000000000..38f4265069 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-domain-create-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a domain name binding. + +USAGE: + scw container domain create [arg=value ...] + +ARGS: + [hostname] + [container-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 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-domain-delete-usage.golden b/cmd/scw/testdata/test-all-usage-container-domain-delete-usage.golden new file mode 100644 index 0000000000..0bf348c88d --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-domain-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete a domain name binding. + +USAGE: + scw container domain delete [arg=value ...] + +ARGS: + domain-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-domain-get-usage.golden b/cmd/scw/testdata/test-all-usage-container-domain-get-usage.golden new file mode 100644 index 0000000000..1f0a833688 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-domain-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get a domain name binding. + +USAGE: + scw container domain get [arg=value ...] + +ARGS: + domain-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-domain-list-usage.golden b/cmd/scw/testdata/test-all-usage-container-domain-list-usage.golden new file mode 100644 index 0000000000..be83a5dd76 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-domain-list-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all domain name bindings. + +USAGE: + scw container domain list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc | hostname_asc | hostname_desc) + [container-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-domain-usage.golden b/cmd/scw/testdata/test-all-usage-container-domain-usage.golden new file mode 100644 index 0000000000..089f061cee --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-container-domain-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Domain management commands. + +USAGE: + scw container domain + +AVAILABLE COMMANDS: + create Create a domain name binding + delete Delete a domain name binding + get Get a domain name binding + list List all domain name bindings + +FLAGS: + -h, --help help for domain + +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 domain [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 a761aeb6b3..272a1be892 100644 --- a/cmd/scw/testdata/test-all-usage-container-usage.golden +++ b/cmd/scw/testdata/test-all-usage-container-usage.golden @@ -8,6 +8,7 @@ USAGE: AVAILABLE COMMANDS: container Container management commands cron Cron management commands + domain Domain management commands namespace Namespace management commands FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-function-domain-create-usage.golden b/cmd/scw/testdata/test-all-usage-function-domain-create-usage.golden new file mode 100644 index 0000000000..84c9c16a6e --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-domain-create-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create a domain name binding. + +USAGE: + scw function domain create [arg=value ...] + +ARGS: + [hostname] + [function-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 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-domain-delete-usage.golden b/cmd/scw/testdata/test-all-usage-function-domain-delete-usage.golden new file mode 100644 index 0000000000..3a054fec15 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-domain-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete a domain name binding. + +USAGE: + scw function domain delete [arg=value ...] + +ARGS: + domain-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-domain-get-usage.golden b/cmd/scw/testdata/test-all-usage-function-domain-get-usage.golden new file mode 100644 index 0000000000..ad904cf72d --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-domain-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get a domain name binding. + +USAGE: + scw function domain get [arg=value ...] + +ARGS: + domain-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-domain-list-usage.golden b/cmd/scw/testdata/test-all-usage-function-domain-list-usage.golden new file mode 100644 index 0000000000..a16aa6dce1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-domain-list-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all domain name bindings. + +USAGE: + scw function domain list [arg=value ...] + +ARGS: + [order-by] (created_at_asc | created_at_desc | hostname_asc | hostname_desc) + [function-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-domain-usage.golden b/cmd/scw/testdata/test-all-usage-function-domain-usage.golden new file mode 100644 index 0000000000..04367ea0c8 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-function-domain-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Domain management commands. + +USAGE: + scw function domain + +AVAILABLE COMMANDS: + create Create a domain name binding + delete Delete a domain name binding + get Get a domain name binding + list List all domain name bindings + +FLAGS: + -h, --help help for domain + +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 domain [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 89063701f3..ebe1a5dc1a 100644 --- a/cmd/scw/testdata/test-all-usage-function-usage.golden +++ b/cmd/scw/testdata/test-all-usage-function-usage.golden @@ -7,6 +7,7 @@ USAGE: AVAILABLE COMMANDS: cron Cron management commands + domain Domain management commands function Function management commands logs Logs management commands namespace Function namespace management commands diff --git a/docs/commands/container.md b/docs/commands/container.md index b522fc5ee2..70df20f5b3 100644 --- a/docs/commands/container.md +++ b/docs/commands/container.md @@ -13,6 +13,11 @@ Container as a Service API - [Delete an existing cron](#delete-an-existing-cron) - [Get a cron](#get-a-cron) - [List all your crons](#list-all-your-crons) +- [Domain management commands](#domain-management-commands) + - [Create a domain name binding](#create-a-domain-name-binding) + - [Delete a domain name binding](#delete-a-domain-name-binding) + - [Get a domain name binding](#get-a-domain-name-binding) + - [List all domain name bindings](#list-all-domain-name-bindings) - [Namespace management commands](#namespace-management-commands) - [Create a new namespace](#create-a-new-namespace) - [Delete an existing namespace](#delete-an-existing-namespace) @@ -250,6 +255,93 @@ scw container cron list [arg=value ...] +## Domain management commands + +Domain management commands. + + +### Create a domain name binding + +Create a domain name binding. + +**Usage:** + +``` +scw container domain create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| hostname | | | +| container-id | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Delete a domain name binding + +Delete a domain name binding. + +**Usage:** + +``` +scw container domain delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| domain-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 domain name binding + +Get a domain name binding. + +**Usage:** + +``` +scw container domain get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| domain-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 domain name bindings + +List all domain name bindings. + +**Usage:** + +``` +scw container domain list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| order-by | One of: `created_at_asc`, `created_at_desc`, `hostname_asc`, `hostname_desc` | | +| container-id | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + ## Namespace management commands Namespace management commands. diff --git a/docs/commands/function.md b/docs/commands/function.md index c0742d8b9f..b973de5c9b 100644 --- a/docs/commands/function.md +++ b/docs/commands/function.md @@ -6,6 +6,11 @@ Function as a Service API - [Delete an existing cron](#delete-an-existing-cron) - [Get a cron](#get-a-cron) - [List all your crons](#list-all-your-crons) +- [Domain management commands](#domain-management-commands) + - [Create a domain name binding](#create-a-domain-name-binding) + - [Delete a domain name binding](#delete-a-domain-name-binding) + - [Get a domain name binding](#get-a-domain-name-binding) + - [List all domain name bindings](#list-all-domain-name-bindings) - [Function management commands](#function-management-commands) - [Create a new function](#create-a-new-function) - [Delete a function](#delete-a-function) @@ -93,6 +98,93 @@ scw function cron list [arg=value ...] +## Domain management commands + +Domain management commands. + + +### Create a domain name binding + +Create a domain name binding. + +**Usage:** + +``` +scw function domain create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| hostname | | | +| function-id | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + +### Delete a domain name binding + +Delete a domain name binding. + +**Usage:** + +``` +scw function domain delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| domain-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 domain name binding + +Get a domain name binding. + +**Usage:** + +``` +scw function domain get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| domain-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 domain name bindings + +List all domain name bindings. + +**Usage:** + +``` +scw function domain list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| order-by | One of: `created_at_asc`, `created_at_desc`, `hostname_asc`, `hostname_desc` | | +| function-id | | | +| region | Default: `fr-par`
One of: `fr-par` | Region to target. If none is passed will use default region from the config | + + + ## Function management commands Function management commands. diff --git a/go.mod b/go.mod index b29d3503fe..56838bdd7f 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.12 github.com/mattn/go-isatty v0.0.14 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220701084505-e4e065be0a37 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220705125941-2d7ba21ff9de 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 4d9f5736ef..400e222a3f 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,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.20220701084505-e4e065be0a37 h1:lQW8Ia49Y8GKjnLFrCci7zcZjbkHm5+flcyTAzdw+YA= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220701084505-e4e065be0a37/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220705125941-2d7ba21ff9de h1:mxZByxAKZl4U2QEeb8WV4Rf4zTOYsXqsm8FdvnGfUYI= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20220705125941-2d7ba21ff9de/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 c4cc14b427..7baab3583f 100644 --- a/internal/namespaces/container/v1beta1/container_cli.go +++ b/internal/namespaces/container/v1beta1/container_cli.go @@ -23,6 +23,7 @@ func GetGeneratedCommands() *core.Commands { containerNamespace(), containerContainer(), containerCron(), + containerDomain(), containerNamespaceList(), containerNamespaceGet(), containerNamespaceCreate(), @@ -37,6 +38,10 @@ func GetGeneratedCommands() *core.Commands { containerCronList(), containerCronGet(), containerCronDelete(), + containerDomainList(), + containerDomainGet(), + containerDomainCreate(), + containerDomainDelete(), ) } func containerRoot() *core.Command { @@ -74,6 +79,15 @@ func containerCron() *core.Command { } } +func containerDomain() *core.Command { + return &core.Command{ + Short: `Domain management commands`, + Long: `Domain management commands.`, + Namespace: "container", + Resource: "domain", + } +} + func containerNamespaceList() *core.Command { return &core.Command{ Short: `List all your namespaces`, @@ -803,3 +817,136 @@ func containerCronDelete() *core.Command { }, } } + +func containerDomainList() *core.Command { + return &core.Command{ + Short: `List all domain name bindings`, + Long: `List all domain name bindings.`, + Namespace: "container", + Resource: "domain", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.ListDomainsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc", "hostname_asc", "hostname_desc"}, + }, + { + Name: "container-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.ListDomainsRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + resp, err := api.ListDomains(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Domains, nil + + }, + } +} + +func containerDomainGet() *core.Command { + return &core.Command{ + Short: `Get a domain name binding`, + Long: `Get a domain name binding.`, + Namespace: "container", + Resource: "domain", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.GetDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-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.GetDomainRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + return api.GetDomain(request) + + }, + } +} + +func containerDomainCreate() *core.Command { + return &core.Command{ + Short: `Create a domain name binding`, + Long: `Create a domain name binding.`, + Namespace: "container", + Resource: "domain", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.CreateDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "hostname", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "container-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.CreateDomainRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + return api.CreateDomain(request) + + }, + } +} + +func containerDomainDelete() *core.Command { + return &core.Command{ + Short: `Delete a domain name binding`, + Long: `Delete a domain name binding.`, + Namespace: "container", + Resource: "domain", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(container.DeleteDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-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.DeleteDomainRequest) + + client := core.ExtractClient(ctx) + api := container.NewAPI(client) + return api.DeleteDomain(request) + + }, + } +} diff --git a/internal/namespaces/function/v1beta1/function_cli.go b/internal/namespaces/function/v1beta1/function_cli.go index 9fdfea7a64..3592a36ec8 100644 --- a/internal/namespaces/function/v1beta1/function_cli.go +++ b/internal/namespaces/function/v1beta1/function_cli.go @@ -25,6 +25,7 @@ func GetGeneratedCommands() *core.Commands { functionCron(), functionRuntime(), functionLogs(), + functionDomain(), functionNamespaceList(), functionNamespaceGet(), functionNamespaceCreate(), @@ -43,6 +44,10 @@ func GetGeneratedCommands() *core.Commands { functionCronGet(), functionCronDelete(), functionLogsList(), + functionDomainList(), + functionDomainGet(), + functionDomainCreate(), + functionDomainDelete(), ) } func functionRoot() *core.Command { @@ -98,6 +103,15 @@ func functionLogs() *core.Command { } } +func functionDomain() *core.Command { + return &core.Command{ + Short: `Domain management commands`, + Long: `Domain management commands.`, + Namespace: "function", + Resource: "domain", + } +} + func functionNamespaceList() *core.Command { return &core.Command{ Short: `List all your namespaces`, @@ -953,3 +967,136 @@ func functionLogsList() *core.Command { }, } } + +func functionDomainList() *core.Command { + return &core.Command{ + Short: `List all domain name bindings`, + Long: `List all domain name bindings.`, + Namespace: "function", + Resource: "domain", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.ListDomainsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc", "hostname_asc", "hostname_desc"}, + }, + { + Name: "function-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.ListDomainsRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + resp, err := api.ListDomains(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Domains, nil + + }, + } +} + +func functionDomainGet() *core.Command { + return &core.Command{ + Short: `Get a domain name binding`, + Long: `Get a domain name binding.`, + Namespace: "function", + Resource: "domain", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.GetDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-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.GetDomainRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.GetDomain(request) + + }, + } +} + +func functionDomainCreate() *core.Command { + return &core.Command{ + Short: `Create a domain name binding`, + Long: `Create a domain name binding.`, + Namespace: "function", + Resource: "domain", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.CreateDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "hostname", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "function-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.CreateDomainRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.CreateDomain(request) + + }, + } +} + +func functionDomainDelete() *core.Command { + return &core.Command{ + Short: `Delete a domain name binding`, + Long: `Delete a domain name binding.`, + Namespace: "function", + Resource: "domain", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(function.DeleteDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-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.DeleteDomainRequest) + + client := core.ExtractClient(ctx) + api := function.NewAPI(client) + return api.DeleteDomain(request) + + }, + } +}