Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-domain-check-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Ask for an immediate check of a domain (DNS check).

USAGE:
scw tem domain check <domain-id ...> [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
20 changes: 20 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-domain-create-usage.golden
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-domain-get-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get information about a domain.

USAGE:
scw tem domain get <domain-id ...> [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
21 changes: 21 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-domain-list-usage.golden
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-domain-revoke-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Revoke a domain.

USAGE:
scw tem domain revoke <domain-id ...> [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
24 changes: 24 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-domain-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Domain management commands.

USAGE:
scw tem domain <command>

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.
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-email-cancel-usage.golden
Original file line number Diff line number Diff line change
@@ -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 <email-id ...> [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
34 changes: 34 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-email-create-usage.golden
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-email-get-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get information about an email.

USAGE:
scw tem email get <email-id ...> [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
25 changes: 25 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-email-list-usage.golden
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-email-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Email management commands.

USAGE:
scw tem email <command>

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.
21 changes: 21 additions & 0 deletions cmd/scw/testdata/test-all-usage-tem-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Tem

USAGE:
scw tem <command>

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.
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-main-usage-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
3 changes: 3 additions & 0 deletions internal/namespaces/get_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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"
Expand Down Expand Up @@ -65,6 +66,8 @@ func GetCommands(beta ...bool) *core.Commands {
commands.Merge(vpcgw.GetCommands())
commands.Merge(redis.GetCommands())
commands.Merge(shell.GetCommands())
commands.Merge(tem.GetCommands())

if len(beta) == 1 && beta[0] {
commands.Merge(iam.GetCommands())
commands.Merge(accountv2.GetCommands())
Expand Down
18 changes: 18 additions & 0 deletions internal/namespaces/tem/v1alpha1/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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/tem/v1alpha1"
)

func GetCommands() *core.Commands {
cmds := GetGeneratedCommands()

human.RegisterMarshalerFunc(tem.DomainStatus(""), human.EnumMarshalFunc(domainStatusMarshalSpecs))
human.RegisterMarshalerFunc(tem.EmailStatus(""), human.EnumMarshalFunc(emailStatusMarshalSpecs))

cmds.MustFind("tem", "domain", "get").Override(domainGetBuilder)

return cmds
}
32 changes: 32 additions & 0 deletions internal/namespaces/tem/v1alpha1/custom_domain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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/tem/v1alpha1"
)

var (
domainStatusMarshalSpecs = human.EnumMarshalSpecs{
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"},
}
)

func domainGetBuilder(c *core.Command) *core.Command {
c.View = &core.View{
Sections: []*core.ViewSection{
{
FieldName: "Statistics",
Title: "Statistics",
},
},
}

return c
}
Loading