From f2a23aef808ad2bce05403e399b1a15a59f5adf4 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 11 Oct 2022 07:56:00 +0000 Subject: [PATCH 01/12] feat: update generated APIs --- ...est-all-usage-instance-server-usage.golden | 4 +- docs/commands/instance.md | 4 +- .../v1alpha1/transactional_email_cli.go | 551 ++++++++++++++++++ 3 files changed, 555 insertions(+), 4 deletions(-) create mode 100644 internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go diff --git a/cmd/scw/testdata/test-all-usage-instance-server-usage.golden b/cmd/scw/testdata/test-all-usage-instance-server-usage.golden index 0203ab0416..f1a550ebbd 100644 --- a/cmd/scw/testdata/test-all-usage-instance-server-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-server-usage.golden @@ -13,12 +13,12 @@ Different instance ranges are proposed: Refer to the [Development Instance offer details](https://www.scaleway.com/en/virtual-instances/play2/) for more information. -* The General Purpose instances range is the solution for production workloads. Powerful +* The **General Purpose** instances range is the solution for production workloads. Powerful AMD EPYC CPUs back those instances and offer up to 48 Cores, 256GB of RAM and storage options up to 600GB of replicated local NVMe SSD storage and/or up to 10TB of Block Storage. Refer to the [General Purpose offer details](https://www.scaleway.com/en/virtual-instances/pro2/) for more information. -* The Enterprise instances range is the solution for most demanding workloads and +* The **Enterprise** instances range is the solution for most demanding workloads and mission-critical applications. Powerful AMD EPYC CPUs back those instances and offer up to 96 Cores, 384GB of RAM and up to 10TB of Block Storage. Refer to the [Enterprise offer details](https://www.scaleway.com/en/virtual-instances/enterprise/) for more information. diff --git a/docs/commands/instance.md b/docs/commands/instance.md index 16a5c41d07..ccff10f5cf 100644 --- a/docs/commands/instance.md +++ b/docs/commands/instance.md @@ -1199,12 +1199,12 @@ Different instance ranges are proposed: Refer to the [Development Instance offer details](https://www.scaleway.com/en/virtual-instances/play2/) for more information. -* The General Purpose instances range is the solution for production workloads. Powerful +* The **General Purpose** instances range is the solution for production workloads. Powerful AMD EPYC CPUs back those instances and offer up to 48 Cores, 256GB of RAM and storage options up to 600GB of replicated local NVMe SSD storage and/or up to 10TB of Block Storage. Refer to the [General Purpose offer details](https://www.scaleway.com/en/virtual-instances/pro2/) for more information. -* The Enterprise instances range is the solution for most demanding workloads and +* The **Enterprise** instances range is the solution for most demanding workloads and mission-critical applications. Powerful AMD EPYC CPUs back those instances and offer up to 96 Cores, 384GB of RAM and up to 10TB of Block Storage. Refer to the [Enterprise offer details](https://www.scaleway.com/en/virtual-instances/enterprise/) for more information. diff --git a/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go b/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go new file mode 100644 index 0000000000..60b62fa32c --- /dev/null +++ b/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go @@ -0,0 +1,551 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +package transactional_email + +import ( + "context" + "reflect" + + "github.com/scaleway/scaleway-cli/v2/internal/core" + "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +// always import dependencies +var ( + _ = scw.RegionFrPar +) + +func GetGeneratedCommands() *core.Commands { + return core.NewCommands( + temRoot(), + temEmail(), + temDomain(), + temEmailCreate(), + temEmailGet(), + temEmailList(), + temEmailGetStatistics(), + temEmailCancel(), + temDomainCreate(), + temDomainGet(), + temDomainList(), + temDomainRevoke(), + temDomainCheck(), + ) +} +func temRoot() *core.Command { + return &core.Command{ + Short: `Tem`, + Long: ``, + Namespace: "tem", + } +} + +func temEmail() *core.Command { + return &core.Command{ + Short: `Email management commands`, + Long: `Email management commands.`, + Namespace: "tem", + Resource: "email", + } +} + +func temDomain() *core.Command { + return &core.Command{ + Short: `Domain management commands`, + Long: `Domain management commands.`, + Namespace: "tem", + Resource: "domain", + } +} + +func temEmailCreate() *core.Command { + return &core.Command{ + Short: `Send an email`, + Long: `Send an email.`, + Namespace: "tem", + Resource: "email", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.CreateEmailRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "from.email", + Short: `Email address`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "from.name", + Short: `Optional display name`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "to.{index}.email", + Short: `Email address`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "to.{index}.name", + Short: `Optional display name`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "cc.{index}.email", + Short: `Email address`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "cc.{index}.name", + Short: `Optional display name`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "bcc.{index}.email", + Short: `Email address`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "bcc.{index}.name", + Short: `Optional display name`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "subject", + Short: `Message subject`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "text", + Short: `Text content`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "html", + Short: `HTML content`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.ProjectIDArgSpec(), + { + Name: "attachments.{index}.name", + Short: `Filename of the attachment`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "attachments.{index}.type", + Short: `MIME type of the attachment (Currently only allow, text files, pdf and html files)`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "attachments.{index}.content", + Short: `Content of the attachment, encoded in base64`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "send-before", + Short: `Maximum date to deliver mail`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.CreateEmailRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.CreateEmail(request) + + }, + } +} + +func temEmailGet() *core.Command { + return &core.Command{ + Short: `Get information about an email`, + Long: `Get information about an email.`, + Namespace: "tem", + Resource: "email", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.GetEmailRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "email-id", + Short: `ID of the email to retrieve`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.GetEmailRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.GetEmail(request) + + }, + } +} + +func temEmailList() *core.Command { + return &core.Command{ + Short: `List emails sent from a domain and/or for a project and/or for an organization`, + Long: `List emails sent from a domain and/or for a project and/or for an organization.`, + Namespace: "tem", + Resource: "email", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.ListEmailsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "project-id", + Short: `Optional ID of the project in which to list the emails`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "domain-id", + Short: `Optional ID of the domain for which to list the emails`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "since", + Short: `Optional, list emails created after this date`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "until", + Short: `Optional, list emails created before this date`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "mail-from", + Short: `Optional, list emails sent with this ` + "`" + `mail_from` + "`" + ` sender's address`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "mail-to", + Short: `Optional, list emails sent with this ` + "`" + `mail_to` + "`" + ` recipient's address`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "statuses.{index}", + Short: `Optional, list emails having any of this status`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown", "new", "sending", "sent", "failed", "canceled"}, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.ListEmailsRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + resp, err := api.ListEmails(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Emails, nil + + }, + } +} + +func temEmailGetStatistics() *core.Command { + return &core.Command{ + Short: `Get statistics on the email statuses`, + Long: `Get statistics on the email statuses.`, + Namespace: "tem", + Resource: "email", + Verb: "get-statistics", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.GetStatisticsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "project-id", + Short: `Optional, count emails for this project`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "domain-id", + Short: `Optional, count emails send from this domain (must be coherent with the ` + "`" + `project_id` + "`" + ` and the ` + "`" + `organization_id` + "`" + `)`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "since", + Short: `Optional, count emails created after this date`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "until", + Short: `Optional, count emails created before this date`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "mail-from", + Short: `Optional, count emails sent with this ` + "`" + `mail_from` + "`" + ` sender's address`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.GetStatisticsRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.GetStatistics(request) + + }, + } +} + +func temEmailCancel() *core.Command { + return &core.Command{ + Short: `Try to cancel an email if it has not yet been sent`, + Long: `Try to cancel an email if it has not yet been sent.`, + Namespace: "tem", + Resource: "email", + Verb: "cancel", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.CancelEmailRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "email-id", + Short: `ID of the email to cancel`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.CancelEmailRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.CancelEmail(request) + + }, + } +} + +func temDomainCreate() *core.Command { + return &core.Command{ + Short: `Register a domain in a project`, + Long: `Register a domain in a project.`, + Namespace: "tem", + Resource: "domain", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.CreateDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + { + Name: "domain-name", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.CreateDomainRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.CreateDomain(request) + + }, + } +} + +func temDomainGet() *core.Command { + return &core.Command{ + Short: `Get information about a domain`, + Long: `Get information about a domain.`, + Namespace: "tem", + Resource: "domain", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.GetDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-id", + Short: `ID of the domain`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.GetDomainRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.GetDomain(request) + + }, + } +} + +func temDomainList() *core.Command { + return &core.Command{ + Short: `List domains in a project and/or in an organization`, + Long: `List domains in a project and/or in an organization.`, + Namespace: "tem", + Resource: "domain", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.ListDomainsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "project-id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "status.{index}", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"unknown", "checked", "unchecked", "invalid", "locked", "revoked", "pending"}, + }, + { + Name: "organization-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.ListDomainsRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + resp, err := api.ListDomains(request, scw.WithAllPages()) + if err != nil { + return nil, err + } + return resp.Domains, nil + + }, + } +} + +func temDomainRevoke() *core.Command { + return &core.Command{ + Short: `Revoke a domain`, + Long: `Revoke a domain.`, + Namespace: "tem", + Resource: "domain", + Verb: "revoke", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.RevokeDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-id", + Short: `ID of the domain to revoke`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.RevokeDomainRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.RevokeDomain(request) + + }, + } +} + +func temDomainCheck() *core.Command { + return &core.Command{ + Short: `Ask for an immediate check of a domain (DNS check)`, + Long: `Ask for an immediate check of a domain (DNS check).`, + Namespace: "tem", + Resource: "domain", + Verb: "check", + // Deprecated: false, + ArgsType: reflect.TypeOf(transactional_email.CheckDomainRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "domain-id", + Short: `ID of the domain to check`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*transactional_email.CheckDomainRequest) + + client := core.ExtractClient(ctx) + api := transactional_email.NewAPI(client) + return api.CheckDomain(request) + + }, + } +} From 890e8b2902ae97fa55be55dbdfcb041035d883b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Tue, 11 Oct 2022 15:42:03 +0200 Subject: [PATCH 02/12] Fix --- ...est-all-usage-instance-server-usage.golden | 4 +-- ...st-all-usage-tem-domain-check-usage.golden | 19 +++++++++++ ...t-all-usage-tem-domain-create-usage.golden | 20 +++++++++++ ...test-all-usage-tem-domain-get-usage.golden | 19 +++++++++++ ...est-all-usage-tem-domain-list-usage.golden | 21 ++++++++++++ ...t-all-usage-tem-domain-revoke-usage.golden | 19 +++++++++++ .../test-all-usage-tem-domain-usage.golden | 24 +++++++++++++ ...st-all-usage-tem-email-cancel-usage.golden | 19 +++++++++++ ...st-all-usage-tem-email-create-usage.golden | 34 +++++++++++++++++++ ...sage-tem-email-get-statistics-usage.golden | 23 +++++++++++++ .../test-all-usage-tem-email-get-usage.golden | 19 +++++++++++ ...test-all-usage-tem-email-list-usage.golden | 25 ++++++++++++++ .../test-all-usage-tem-email-usage.golden | 24 +++++++++++++ .../testdata/test-all-usage-tem-usage.golden | 21 ++++++++++++ cmd/scw/testdata/test-main-usage-usage.golden | 1 + internal/namespaces/get_commands.go | 3 ++ .../transactional_email/v1alpha1/custom.go | 11 ++++++ 17 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-domain-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-domain-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-domain-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-email-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-email-get-statistics-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-email-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-email-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-tem-usage.golden create mode 100644 internal/namespaces/transactional_email/v1alpha1/custom.go diff --git a/cmd/scw/testdata/test-all-usage-instance-server-usage.golden b/cmd/scw/testdata/test-all-usage-instance-server-usage.golden index f1a550ebbd..0203ab0416 100644 --- a/cmd/scw/testdata/test-all-usage-instance-server-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-server-usage.golden @@ -13,12 +13,12 @@ Different instance ranges are proposed: Refer to the [Development Instance offer details](https://www.scaleway.com/en/virtual-instances/play2/) for more information. -* The **General Purpose** instances range is the solution for production workloads. Powerful +* The General Purpose instances range is the solution for production workloads. Powerful AMD EPYC CPUs back those instances and offer up to 48 Cores, 256GB of RAM and storage options up to 600GB of replicated local NVMe SSD storage and/or up to 10TB of Block Storage. Refer to the [General Purpose offer details](https://www.scaleway.com/en/virtual-instances/pro2/) for more information. -* The **Enterprise** instances range is the solution for most demanding workloads and +* The Enterprise instances range is the solution for most demanding workloads and mission-critical applications. Powerful AMD EPYC CPUs back those instances and offer up to 96 Cores, 384GB of RAM and up to 10TB of Block Storage. Refer to the [Enterprise offer details](https://www.scaleway.com/en/virtual-instances/enterprise/) for more information. diff --git a/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden new file mode 100644 index 0000000000..7bc8f9bb35 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Ask for an immediate check of a domain (DNS check). + +USAGE: + scw tem domain check [arg=value ...] + +ARGS: + domain-id ID of the domain to check + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for check + +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-tem-domain-create-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-create-usage.golden new file mode 100644 index 0000000000..2d7751a1b7 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-domain-create-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Register a domain in a project. + +USAGE: + scw tem domain create [arg=value ...] + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + [domain-name] + [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-tem-domain-get-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden new file mode 100644 index 0000000000..e2bb8afe0f --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get information about a domain. + +USAGE: + scw tem domain get [arg=value ...] + +ARGS: + domain-id ID of the domain + [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-tem-domain-list-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-list-usage.golden new file mode 100644 index 0000000000..fc0f0b457c --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-domain-list-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List domains in a project and/or in an organization. + +USAGE: + scw tem domain list [arg=value ...] + +ARGS: + [project-id] + [status.{index}] (unknown | checked | unchecked | invalid | locked | revoked | pending) + [organization-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-tem-domain-revoke-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden new file mode 100644 index 0000000000..7e13b5a8df --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Revoke a domain. + +USAGE: + scw tem domain revoke [arg=value ...] + +ARGS: + domain-id ID of the domain to revoke + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for revoke + +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-tem-domain-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-usage.golden new file mode 100644 index 0000000000..848735ac23 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-domain-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Domain management commands. + +USAGE: + scw tem domain + +AVAILABLE COMMANDS: + check Ask for an immediate check of a domain (DNS check) + create Register a domain in a project + get Get information about a domain + list List domains in a project and/or in an organization + revoke Revoke a domain + +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 tem domain [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden new file mode 100644 index 0000000000..f2515502c9 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Try to cancel an email if it has not yet been sent. + +USAGE: + scw tem email cancel [arg=value ...] + +ARGS: + email-id ID of the email to cancel + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par) + +FLAGS: + -h, --help help for cancel + +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-tem-email-create-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-create-usage.golden new file mode 100644 index 0000000000..3148a26792 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-email-create-usage.golden @@ -0,0 +1,34 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Send an email. + +USAGE: + scw tem email create [arg=value ...] + +ARGS: + [from.email] Email address + [from.name] Optional display name + [to.{index}.email] Email address + [to.{index}.name] Optional display name + [cc.{index}.email] Email address + [cc.{index}.name] Optional display name + [bcc.{index}.email] Email address + [bcc.{index}.name] Optional display name + [subject] Message subject + [text] Text content + [html] HTML content + [project-id] Project ID to use. If none is passed the default project ID will be used + [attachments.{index}.name] Filename of the attachment + [attachments.{index}.type] MIME type of the attachment (Currently only allow, text files, pdf and html files) + [attachments.{index}.content] Content of the attachment, encoded in base64 + [send-before] Maximum date to deliver mail + [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-tem-email-get-statistics-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-get-statistics-usage.golden new file mode 100644 index 0000000000..92b44bd910 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-email-get-statistics-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get statistics on the email statuses. + +USAGE: + scw tem email get-statistics [arg=value ...] + +ARGS: + [project-id] Optional, count emails for this project + [domain-id] Optional, count emails send from this domain (must be coherent with the `project_id` and the `organization_id`) + [since] Optional, count emails created after this date + [until] Optional, count emails created before this date + [mail-from] Optional, count emails sent with this `mail_from` sender's address + [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-statistics + +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-tem-email-get-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden new file mode 100644 index 0000000000..fac5dd60b1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get information about an email. + +USAGE: + scw tem email get [arg=value ...] + +ARGS: + email-id ID of the email to retrieve + [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-tem-email-list-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-list-usage.golden new file mode 100644 index 0000000000..1a75c607fa --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-email-list-usage.golden @@ -0,0 +1,25 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List emails sent from a domain and/or for a project and/or for an organization. + +USAGE: + scw tem email list [arg=value ...] + +ARGS: + [project-id] Optional ID of the project in which to list the emails + [domain-id] Optional ID of the domain for which to list the emails + [since] Optional, list emails created after this date + [until] Optional, list emails created before this date + [mail-from] Optional, list emails sent with this `mail_from` sender's address + [mail-to] Optional, list emails sent with this `mail_to` recipient's address + [statuses.{index}] Optional, list emails having any of this status (unknown | new | sending | sent | failed | canceled) + [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-tem-email-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-usage.golden new file mode 100644 index 0000000000..57f78151c8 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-email-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Email management commands. + +USAGE: + scw tem email + +AVAILABLE COMMANDS: + cancel Try to cancel an email if it has not yet been sent + create Send an email + get Get information about an email + get-statistics Get statistics on the email statuses + list List emails sent from a domain and/or for a project and/or for an organization + +FLAGS: + -h, --help help for email + +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 tem email [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-tem-usage.golden b/cmd/scw/testdata/test-all-usage-tem-usage.golden new file mode 100644 index 0000000000..b9a3b5c3bf --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-tem-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Tem + +USAGE: + scw tem + +AVAILABLE COMMANDS: + domain Domain management commands + email Email management commands + +FLAGS: + -h, --help help for tem + +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 tem [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-main-usage-usage.golden b/cmd/scw/testdata/test-main-usage-usage.golden index 357635084e..7ba2a10d35 100644 --- a/cmd/scw/testdata/test-main-usage-usage.golden +++ b/cmd/scw/testdata/test-main-usage-usage.golden @@ -27,6 +27,7 @@ AVAILABLE COMMANDS: redis Managed Database for Redisβ„’ API registry Container registry API shell Start shell mode + tem Tem version Display cli version vpc VPC API vpc-gw VPC Public Gateway API diff --git a/internal/namespaces/get_commands.go b/internal/namespaces/get_commands.go index a54824ef93..599d789df7 100644 --- a/internal/namespaces/get_commands.go +++ b/internal/namespaces/get_commands.go @@ -27,6 +27,7 @@ import ( "github.com/scaleway/scaleway-cli/v2/internal/namespaces/redis/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/registry/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/shell" + transactional_email "github.com/scaleway/scaleway-cli/v2/internal/namespaces/transactional_email/v1alpha1" versionNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/version" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpc/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpcgw/v1" @@ -65,6 +66,8 @@ func GetCommands(beta ...bool) *core.Commands { commands.Merge(vpcgw.GetCommands()) commands.Merge(redis.GetCommands()) commands.Merge(shell.GetCommands()) + commands.Merge(transactional_email.GetCommands()) + if len(beta) == 1 && beta[0] { commands.Merge(iam.GetCommands()) commands.Merge(accountv2.GetCommands()) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/transactional_email/v1alpha1/custom.go new file mode 100644 index 0000000000..ca70fb2cbb --- /dev/null +++ b/internal/namespaces/transactional_email/v1alpha1/custom.go @@ -0,0 +1,11 @@ +package transactional_email + +import ( + "github.com/scaleway/scaleway-cli/v2/internal/core" +) + +func GetCommands() *core.Commands { + cmds := GetGeneratedCommands() + + return cmds +} From f85bc107de0b9bbe79088d3c0a010f1284741d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 13 Oct 2022 17:46:18 +0200 Subject: [PATCH 03/12] Add marshallers --- .../transactional_email/v1alpha1/custom.go | 5 +++++ .../v1alpha1/custom_domain.go | 18 ++++++++++++++++++ .../v1alpha1/custom_email.go | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 internal/namespaces/transactional_email/v1alpha1/custom_domain.go create mode 100644 internal/namespaces/transactional_email/v1alpha1/custom_email.go diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/transactional_email/v1alpha1/custom.go index ca70fb2cbb..97c9b8e2c4 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom.go @@ -2,10 +2,15 @@ package transactional_email import ( "github.com/scaleway/scaleway-cli/v2/internal/core" + "github.com/scaleway/scaleway-cli/v2/internal/human" + transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) func GetCommands() *core.Commands { cmds := GetGeneratedCommands() + human.RegisterMarshalerFunc(transactional_email.DomainStatus(""), human.EnumMarshalFunc(domainStatusMarshalSpecs)) + human.RegisterMarshalerFunc(transactional_email.EmailStatus(""), human.EnumMarshalFunc(emailStatusMarshalSpecs)) + return cmds } diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go new file mode 100644 index 0000000000..855ee9e63d --- /dev/null +++ b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go @@ -0,0 +1,18 @@ +package transactional_email + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/v2/internal/human" + transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" +) + +var ( + domainStatusMarshalSpecs = human.EnumMarshalSpecs{ + transactional_email.DomainStatusChecked: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "checked"}, + transactional_email.DomainStatusInvalid: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "invalid"}, + transactional_email.DomainStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "locked"}, + transactional_email.DomainStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "pending"}, + transactional_email.DomainStatusRevoked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "revoked"}, + transactional_email.DomainStatusUnchecked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "unchecked"}, + } +) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_email.go b/internal/namespaces/transactional_email/v1alpha1/custom_email.go new file mode 100644 index 0000000000..cba1317349 --- /dev/null +++ b/internal/namespaces/transactional_email/v1alpha1/custom_email.go @@ -0,0 +1,17 @@ +package transactional_email + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/v2/internal/human" + transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" +) + +var ( + emailStatusMarshalSpecs = human.EnumMarshalSpecs{ + transactional_email.EmailStatusFailed: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "failed"}, + transactional_email.EmailStatusCanceled: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "canceled"}, + transactional_email.EmailStatusSending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "sending"}, + transactional_email.EmailStatusSent: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "sent"}, + transactional_email.EmailStatusNew: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "new"}, + } +) From 493ccfb35976db2feeea1e998718ac0678cea185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 13 Oct 2022 17:50:23 +0200 Subject: [PATCH 04/12] Fix --- internal/namespaces/transactional_email/v1alpha1/custom.go | 2 +- .../namespaces/transactional_email/v1alpha1/custom_domain.go | 2 +- .../namespaces/transactional_email/v1alpha1/custom_email.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/transactional_email/v1alpha1/custom.go index 97c9b8e2c4..990631aec7 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom.go @@ -3,7 +3,7 @@ package transactional_email import ( "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) func GetCommands() *core.Commands { diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go index 855ee9e63d..67acb2c458 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go @@ -3,7 +3,7 @@ package transactional_email import ( "github.com/fatih/color" "github.com/scaleway/scaleway-cli/v2/internal/human" - transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) var ( diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_email.go b/internal/namespaces/transactional_email/v1alpha1/custom_email.go index cba1317349..b784e4d235 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom_email.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom_email.go @@ -3,7 +3,7 @@ package transactional_email import ( "github.com/fatih/color" "github.com/scaleway/scaleway-cli/v2/internal/human" - transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) var ( From 3cbbb402260ba394e870c70c17903ab581faecc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 13 Oct 2022 17:53:08 +0200 Subject: [PATCH 05/12] FIx --- internal/namespaces/get_commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/namespaces/get_commands.go b/internal/namespaces/get_commands.go index 599d789df7..a18e462ece 100644 --- a/internal/namespaces/get_commands.go +++ b/internal/namespaces/get_commands.go @@ -27,7 +27,7 @@ import ( "github.com/scaleway/scaleway-cli/v2/internal/namespaces/redis/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/registry/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/shell" - transactional_email "github.com/scaleway/scaleway-cli/v2/internal/namespaces/transactional_email/v1alpha1" + "github.com/scaleway/scaleway-cli/v2/internal/namespaces/transactional_email/v1alpha1" versionNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/version" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpc/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpcgw/v1" From c29c42b388101df06cd158ad9d780467e3d9af2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 13 Oct 2022 17:54:03 +0200 Subject: [PATCH 06/12] Fix --- docs/commands/instance.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/commands/instance.md b/docs/commands/instance.md index ccff10f5cf..16a5c41d07 100644 --- a/docs/commands/instance.md +++ b/docs/commands/instance.md @@ -1199,12 +1199,12 @@ Different instance ranges are proposed: Refer to the [Development Instance offer details](https://www.scaleway.com/en/virtual-instances/play2/) for more information. -* The **General Purpose** instances range is the solution for production workloads. Powerful +* The General Purpose instances range is the solution for production workloads. Powerful AMD EPYC CPUs back those instances and offer up to 48 Cores, 256GB of RAM and storage options up to 600GB of replicated local NVMe SSD storage and/or up to 10TB of Block Storage. Refer to the [General Purpose offer details](https://www.scaleway.com/en/virtual-instances/pro2/) for more information. -* The **Enterprise** instances range is the solution for most demanding workloads and +* The Enterprise instances range is the solution for most demanding workloads and mission-critical applications. Powerful AMD EPYC CPUs back those instances and offer up to 96 Cores, 384GB of RAM and up to 10TB of Block Storage. Refer to the [Enterprise offer details](https://www.scaleway.com/en/virtual-instances/enterprise/) for more information. From 6e8a7de82010d7617dbf4c1db16e476161ba8928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 14 Oct 2022 15:52:59 +0200 Subject: [PATCH 07/12] FIx --- .../transactional_email/v1alpha1/custom.go | 2 ++ .../transactional_email/v1alpha1/custom_domain.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/transactional_email/v1alpha1/custom.go index 990631aec7..ff56c08e3a 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom.go @@ -12,5 +12,7 @@ func GetCommands() *core.Commands { human.RegisterMarshalerFunc(transactional_email.DomainStatus(""), human.EnumMarshalFunc(domainStatusMarshalSpecs)) human.RegisterMarshalerFunc(transactional_email.EmailStatus(""), human.EnumMarshalFunc(emailStatusMarshalSpecs)) + cmds.MustFind("tem", "domain", "get").Override(domainGetBuilder) + return cmds } diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go index 67acb2c458..e99409fd0a 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go @@ -2,6 +2,7 @@ package transactional_email import ( "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) @@ -16,3 +17,16 @@ var ( transactional_email.DomainStatusUnchecked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "unchecked"}, } ) + +func domainGetBuilder(c *core.Command) *core.Command { + c.View = &core.View{ + Sections: []*core.ViewSection{ + { + FieldName: "Statistics", + Title: "Statistics", + }, + }, + } + + return c +} From d3a787899a30586593ba1cdd8fba35c1d0b65553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 14 Oct 2022 17:14:33 +0200 Subject: [PATCH 08/12] FIx --- internal/namespaces/transactional_email/v1alpha1/custom.go | 2 +- .../namespaces/transactional_email/v1alpha1/custom_domain.go | 2 +- .../transactional_email/v1alpha1/transactional_email_cli.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/transactional_email/v1alpha1/custom.go index ff56c08e3a..992e505686 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom.go @@ -3,7 +3,7 @@ package transactional_email import ( "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) func GetCommands() *core.Commands { diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go index e99409fd0a..9fd4562851 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go @@ -4,7 +4,7 @@ import ( "github.com/fatih/color" "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) var ( diff --git a/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go b/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go index 60b62fa32c..40d198290a 100644 --- a/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go +++ b/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go @@ -8,7 +8,7 @@ import ( "reflect" "github.com/scaleway/scaleway-cli/v2/internal/core" - "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" "github.com/scaleway/scaleway-sdk-go/scw" ) From 58aa749c376c9636f71589d1d9abede9463e3a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 14 Oct 2022 17:21:10 +0200 Subject: [PATCH 09/12] Fix --- .../transactional_email/v1alpha1/custom.go | 6 +++--- .../transactional_email/v1alpha1/custom_domain.go | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/transactional_email/v1alpha1/custom.go index 992e505686..24ce1192c0 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom.go @@ -3,14 +3,14 @@ package transactional_email import ( "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + tem "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) func GetCommands() *core.Commands { cmds := GetGeneratedCommands() - human.RegisterMarshalerFunc(transactional_email.DomainStatus(""), human.EnumMarshalFunc(domainStatusMarshalSpecs)) - human.RegisterMarshalerFunc(transactional_email.EmailStatus(""), human.EnumMarshalFunc(emailStatusMarshalSpecs)) + human.RegisterMarshalerFunc(tem.DomainStatus(""), human.EnumMarshalFunc(domainStatusMarshalSpecs)) + human.RegisterMarshalerFunc(tem.EmailStatus(""), human.EnumMarshalFunc(emailStatusMarshalSpecs)) cmds.MustFind("tem", "domain", "get").Override(domainGetBuilder) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go index 9fd4562851..e15fc924ac 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go +++ b/internal/namespaces/transactional_email/v1alpha1/custom_domain.go @@ -4,17 +4,17 @@ import ( "github.com/fatih/color" "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + tem "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" ) var ( domainStatusMarshalSpecs = human.EnumMarshalSpecs{ - transactional_email.DomainStatusChecked: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "checked"}, - transactional_email.DomainStatusInvalid: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "invalid"}, - transactional_email.DomainStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "locked"}, - transactional_email.DomainStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "pending"}, - transactional_email.DomainStatusRevoked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "revoked"}, - transactional_email.DomainStatusUnchecked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "unchecked"}, + tem.DomainStatusChecked: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "checked"}, + tem.DomainStatusInvalid: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "invalid"}, + tem.DomainStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "locked"}, + tem.DomainStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "pending"}, + tem.DomainStatusRevoked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "revoked"}, + tem.DomainStatusUnchecked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "unchecked"}, } ) From 69f8a9c47d0e688c0f2ab9c2dbeb1d717a82723d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 21 Oct 2022 15:03:03 +0200 Subject: [PATCH 10/12] Fix --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3e08daf024..a1f492b94c 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,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.20221018125033-9a8efc64603d + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20221021090213-af5c083146b1 github.com/spf13/cobra v1.6.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.0 diff --git a/go.sum b/go.sum index aa45401d35..36a767e431 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw 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.20221018125033-9a8efc64603d h1:qzG2GUFDAjQbjY3/SQNG1gPfbUPmZBWAMAC0IQfpNjU= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20221018125033-9a8efc64603d/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20221021090213-af5c083146b1 h1:iIJOeHT9KHf8gqt8iFVPuPBkIQddUket5AyFdfrv0Jg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9.0.20221021090213-af5c083146b1/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.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= From 543561a88fdfeba51542ba8217e058503a0002b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 21 Oct 2022 15:06:50 +0200 Subject: [PATCH 11/12] Fix --- internal/namespaces/get_commands.go | 4 +- .../v1alpha1/custom.go | 4 +- .../v1alpha1/custom_domain.go | 4 +- .../namespaces/tem/v1alpha1/custom_email.go | 17 + .../v1alpha1/custom_email.go | 17 - .../v1alpha1/transactional_email_cli.go | 551 ------------------ 6 files changed, 23 insertions(+), 574 deletions(-) rename internal/namespaces/{transactional_email => tem}/v1alpha1/custom.go (81%) rename internal/namespaces/{transactional_email => tem}/v1alpha1/custom_domain.go (90%) create mode 100644 internal/namespaces/tem/v1alpha1/custom_email.go delete mode 100644 internal/namespaces/transactional_email/v1alpha1/custom_email.go delete mode 100644 internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go diff --git a/internal/namespaces/get_commands.go b/internal/namespaces/get_commands.go index a18e462ece..64a542690d 100644 --- a/internal/namespaces/get_commands.go +++ b/internal/namespaces/get_commands.go @@ -27,7 +27,7 @@ import ( "github.com/scaleway/scaleway-cli/v2/internal/namespaces/redis/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/registry/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/shell" - "github.com/scaleway/scaleway-cli/v2/internal/namespaces/transactional_email/v1alpha1" + tem "github.com/scaleway/scaleway-cli/v2/internal/namespaces/tem/v1alpha1" versionNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/version" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpc/v1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/vpcgw/v1" @@ -66,7 +66,7 @@ func GetCommands(beta ...bool) *core.Commands { commands.Merge(vpcgw.GetCommands()) commands.Merge(redis.GetCommands()) commands.Merge(shell.GetCommands()) - commands.Merge(transactional_email.GetCommands()) + commands.Merge(tem.GetCommands()) if len(beta) == 1 && beta[0] { commands.Merge(iam.GetCommands()) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom.go b/internal/namespaces/tem/v1alpha1/custom.go similarity index 81% rename from internal/namespaces/transactional_email/v1alpha1/custom.go rename to internal/namespaces/tem/v1alpha1/custom.go index 24ce1192c0..a4845b04f1 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom.go +++ b/internal/namespaces/tem/v1alpha1/custom.go @@ -1,9 +1,9 @@ -package transactional_email +package tem import ( "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - tem "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + tem "github.com/scaleway/scaleway-sdk-go/api/tem/v1alpha1" ) func GetCommands() *core.Commands { diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go b/internal/namespaces/tem/v1alpha1/custom_domain.go similarity index 90% rename from internal/namespaces/transactional_email/v1alpha1/custom_domain.go rename to internal/namespaces/tem/v1alpha1/custom_domain.go index e15fc924ac..41207c6983 100644 --- a/internal/namespaces/transactional_email/v1alpha1/custom_domain.go +++ b/internal/namespaces/tem/v1alpha1/custom_domain.go @@ -1,10 +1,10 @@ -package transactional_email +package tem import ( "github.com/fatih/color" "github.com/scaleway/scaleway-cli/v2/internal/core" "github.com/scaleway/scaleway-cli/v2/internal/human" - tem "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" + tem "github.com/scaleway/scaleway-sdk-go/api/tem/v1alpha1" ) var ( diff --git a/internal/namespaces/tem/v1alpha1/custom_email.go b/internal/namespaces/tem/v1alpha1/custom_email.go new file mode 100644 index 0000000000..e27503d122 --- /dev/null +++ b/internal/namespaces/tem/v1alpha1/custom_email.go @@ -0,0 +1,17 @@ +package tem + +import ( + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/v2/internal/human" + tem "github.com/scaleway/scaleway-sdk-go/api/tem/v1alpha1" +) + +var ( + emailStatusMarshalSpecs = human.EnumMarshalSpecs{ + tem.EmailStatusFailed: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "failed"}, + tem.EmailStatusCanceled: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "canceled"}, + tem.EmailStatusSending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "sending"}, + tem.EmailStatusSent: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "sent"}, + tem.EmailStatusNew: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "new"}, + } +) diff --git a/internal/namespaces/transactional_email/v1alpha1/custom_email.go b/internal/namespaces/transactional_email/v1alpha1/custom_email.go deleted file mode 100644 index b784e4d235..0000000000 --- a/internal/namespaces/transactional_email/v1alpha1/custom_email.go +++ /dev/null @@ -1,17 +0,0 @@ -package transactional_email - -import ( - "github.com/fatih/color" - "github.com/scaleway/scaleway-cli/v2/internal/human" - "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" -) - -var ( - emailStatusMarshalSpecs = human.EnumMarshalSpecs{ - transactional_email.EmailStatusFailed: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "failed"}, - transactional_email.EmailStatusCanceled: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "canceled"}, - transactional_email.EmailStatusSending: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "sending"}, - transactional_email.EmailStatusSent: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "sent"}, - transactional_email.EmailStatusNew: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "new"}, - } -) diff --git a/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go b/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go deleted file mode 100644 index 40d198290a..0000000000 --- a/internal/namespaces/transactional_email/v1alpha1/transactional_email_cli.go +++ /dev/null @@ -1,551 +0,0 @@ -// This file was automatically generated. DO NOT EDIT. -// If you have any remark or suggestion do not hesitate to open an issue. - -package transactional_email - -import ( - "context" - "reflect" - - "github.com/scaleway/scaleway-cli/v2/internal/core" - transactional_email "github.com/scaleway/scaleway-sdk-go/api/transactional_email/v1alpha1" - "github.com/scaleway/scaleway-sdk-go/scw" -) - -// always import dependencies -var ( - _ = scw.RegionFrPar -) - -func GetGeneratedCommands() *core.Commands { - return core.NewCommands( - temRoot(), - temEmail(), - temDomain(), - temEmailCreate(), - temEmailGet(), - temEmailList(), - temEmailGetStatistics(), - temEmailCancel(), - temDomainCreate(), - temDomainGet(), - temDomainList(), - temDomainRevoke(), - temDomainCheck(), - ) -} -func temRoot() *core.Command { - return &core.Command{ - Short: `Tem`, - Long: ``, - Namespace: "tem", - } -} - -func temEmail() *core.Command { - return &core.Command{ - Short: `Email management commands`, - Long: `Email management commands.`, - Namespace: "tem", - Resource: "email", - } -} - -func temDomain() *core.Command { - return &core.Command{ - Short: `Domain management commands`, - Long: `Domain management commands.`, - Namespace: "tem", - Resource: "domain", - } -} - -func temEmailCreate() *core.Command { - return &core.Command{ - Short: `Send an email`, - Long: `Send an email.`, - Namespace: "tem", - Resource: "email", - Verb: "create", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.CreateEmailRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "from.email", - Short: `Email address`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "from.name", - Short: `Optional display name`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "to.{index}.email", - Short: `Email address`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "to.{index}.name", - Short: `Optional display name`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "cc.{index}.email", - Short: `Email address`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "cc.{index}.name", - Short: `Optional display name`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "bcc.{index}.email", - Short: `Email address`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "bcc.{index}.name", - Short: `Optional display name`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "subject", - Short: `Message subject`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "text", - Short: `Text content`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "html", - Short: `HTML content`, - Required: false, - Deprecated: false, - Positional: false, - }, - core.ProjectIDArgSpec(), - { - Name: "attachments.{index}.name", - Short: `Filename of the attachment`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "attachments.{index}.type", - Short: `MIME type of the attachment (Currently only allow, text files, pdf and html files)`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "attachments.{index}.content", - Short: `Content of the attachment, encoded in base64`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "send-before", - Short: `Maximum date to deliver mail`, - Required: false, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.CreateEmailRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.CreateEmail(request) - - }, - } -} - -func temEmailGet() *core.Command { - return &core.Command{ - Short: `Get information about an email`, - Long: `Get information about an email.`, - Namespace: "tem", - Resource: "email", - Verb: "get", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.GetEmailRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "email-id", - Short: `ID of the email to retrieve`, - Required: true, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.GetEmailRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.GetEmail(request) - - }, - } -} - -func temEmailList() *core.Command { - return &core.Command{ - Short: `List emails sent from a domain and/or for a project and/or for an organization`, - Long: `List emails sent from a domain and/or for a project and/or for an organization.`, - Namespace: "tem", - Resource: "email", - Verb: "list", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.ListEmailsRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "project-id", - Short: `Optional ID of the project in which to list the emails`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "domain-id", - Short: `Optional ID of the domain for which to list the emails`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "since", - Short: `Optional, list emails created after this date`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "until", - Short: `Optional, list emails created before this date`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "mail-from", - Short: `Optional, list emails sent with this ` + "`" + `mail_from` + "`" + ` sender's address`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "mail-to", - Short: `Optional, list emails sent with this ` + "`" + `mail_to` + "`" + ` recipient's address`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "statuses.{index}", - Short: `Optional, list emails having any of this status`, - Required: false, - Deprecated: false, - Positional: false, - EnumValues: []string{"unknown", "new", "sending", "sent", "failed", "canceled"}, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.ListEmailsRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - resp, err := api.ListEmails(request, scw.WithAllPages()) - if err != nil { - return nil, err - } - return resp.Emails, nil - - }, - } -} - -func temEmailGetStatistics() *core.Command { - return &core.Command{ - Short: `Get statistics on the email statuses`, - Long: `Get statistics on the email statuses.`, - Namespace: "tem", - Resource: "email", - Verb: "get-statistics", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.GetStatisticsRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "project-id", - Short: `Optional, count emails for this project`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "domain-id", - Short: `Optional, count emails send from this domain (must be coherent with the ` + "`" + `project_id` + "`" + ` and the ` + "`" + `organization_id` + "`" + `)`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "since", - Short: `Optional, count emails created after this date`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "until", - Short: `Optional, count emails created before this date`, - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "mail-from", - Short: `Optional, count emails sent with this ` + "`" + `mail_from` + "`" + ` sender's address`, - Required: false, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.GetStatisticsRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.GetStatistics(request) - - }, - } -} - -func temEmailCancel() *core.Command { - return &core.Command{ - Short: `Try to cancel an email if it has not yet been sent`, - Long: `Try to cancel an email if it has not yet been sent.`, - Namespace: "tem", - Resource: "email", - Verb: "cancel", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.CancelEmailRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "email-id", - Short: `ID of the email to cancel`, - Required: true, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.CancelEmailRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.CancelEmail(request) - - }, - } -} - -func temDomainCreate() *core.Command { - return &core.Command{ - Short: `Register a domain in a project`, - Long: `Register a domain in a project.`, - Namespace: "tem", - Resource: "domain", - Verb: "create", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.CreateDomainRequest{}), - ArgSpecs: core.ArgSpecs{ - core.ProjectIDArgSpec(), - { - Name: "domain-name", - Required: false, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.CreateDomainRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.CreateDomain(request) - - }, - } -} - -func temDomainGet() *core.Command { - return &core.Command{ - Short: `Get information about a domain`, - Long: `Get information about a domain.`, - Namespace: "tem", - Resource: "domain", - Verb: "get", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.GetDomainRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "domain-id", - Short: `ID of the domain`, - Required: true, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.GetDomainRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.GetDomain(request) - - }, - } -} - -func temDomainList() *core.Command { - return &core.Command{ - Short: `List domains in a project and/or in an organization`, - Long: `List domains in a project and/or in an organization.`, - Namespace: "tem", - Resource: "domain", - Verb: "list", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.ListDomainsRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "project-id", - Required: false, - Deprecated: false, - Positional: false, - }, - { - Name: "status.{index}", - Required: false, - Deprecated: false, - Positional: false, - EnumValues: []string{"unknown", "checked", "unchecked", "invalid", "locked", "revoked", "pending"}, - }, - { - Name: "organization-id", - Required: false, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.ListDomainsRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - resp, err := api.ListDomains(request, scw.WithAllPages()) - if err != nil { - return nil, err - } - return resp.Domains, nil - - }, - } -} - -func temDomainRevoke() *core.Command { - return &core.Command{ - Short: `Revoke a domain`, - Long: `Revoke a domain.`, - Namespace: "tem", - Resource: "domain", - Verb: "revoke", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.RevokeDomainRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "domain-id", - Short: `ID of the domain to revoke`, - Required: true, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.RevokeDomainRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.RevokeDomain(request) - - }, - } -} - -func temDomainCheck() *core.Command { - return &core.Command{ - Short: `Ask for an immediate check of a domain (DNS check)`, - Long: `Ask for an immediate check of a domain (DNS check).`, - Namespace: "tem", - Resource: "domain", - Verb: "check", - // Deprecated: false, - ArgsType: reflect.TypeOf(transactional_email.CheckDomainRequest{}), - ArgSpecs: core.ArgSpecs{ - { - Name: "domain-id", - Short: `ID of the domain to check`, - Required: true, - Deprecated: false, - Positional: false, - }, - core.RegionArgSpec(scw.RegionFrPar), - }, - Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { - request := args.(*transactional_email.CheckDomainRequest) - - client := core.ExtractClient(ctx) - api := transactional_email.NewAPI(client) - return api.CheckDomain(request) - - }, - } -} From fe9efc1b69312ee43beb3c66ad0e5ce64cc857ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Fri, 21 Oct 2022 15:14:25 +0200 Subject: [PATCH 12/12] Fix --- cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden | 2 +- cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden | 2 +- cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden | 2 +- cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden | 2 +- cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden index 7bc8f9bb35..defc53b649 100644 --- a/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden +++ b/cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden @@ -3,7 +3,7 @@ Ask for an immediate check of a domain (DNS check). USAGE: - scw tem domain check [arg=value ...] + scw tem domain check [arg=value ...] ARGS: domain-id ID of the domain to check diff --git a/cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden index e2bb8afe0f..79116abb85 100644 --- a/cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden +++ b/cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden @@ -3,7 +3,7 @@ Get information about a domain. USAGE: - scw tem domain get [arg=value ...] + scw tem domain get [arg=value ...] ARGS: domain-id ID of the domain diff --git a/cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden b/cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden index 7e13b5a8df..10d206eb65 100644 --- a/cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden +++ b/cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden @@ -3,7 +3,7 @@ Revoke a domain. USAGE: - scw tem domain revoke [arg=value ...] + scw tem domain revoke [arg=value ...] ARGS: domain-id ID of the domain to revoke diff --git a/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden index f2515502c9..90fd8ce863 100644 --- a/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden +++ b/cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden @@ -3,7 +3,7 @@ Try to cancel an email if it has not yet been sent. USAGE: - scw tem email cancel [arg=value ...] + scw tem email cancel [arg=value ...] ARGS: email-id ID of the email to cancel diff --git a/cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden b/cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden index fac5dd60b1..6ecc2d7b7c 100644 --- a/cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden +++ b/cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden @@ -3,7 +3,7 @@ Get information about an email. USAGE: - scw tem email get [arg=value ...] + scw tem email get [arg=value ...] ARGS: email-id ID of the email to retrieve