From ccc1068b6974548be6c93953a16663bdff9ae262 Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Mon, 9 Feb 2026 11:55:37 +0100 Subject: [PATCH 1/4] Add dns task list command to retrieve task IDs for domain operations --- .../test-all-usage-dns-task-list-usage.golden | 35 ++++ .../test-all-usage-dns-task-usage.golden | 21 ++ .../testdata/test-all-usage-dns-usage.golden | 1 + internal/namespaces/domain/v2beta1/custom.go | 6 + .../namespaces/domain/v2beta1/custom_task.go | 181 ++++++++++++++++++ 5 files changed, 244 insertions(+) create mode 100644 cmd/scw/testdata/test-all-usage-dns-task-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-dns-task-usage.golden create mode 100644 internal/namespaces/domain/v2beta1/custom_task.go diff --git a/cmd/scw/testdata/test-all-usage-dns-task-list-usage.golden b/cmd/scw/testdata/test-all-usage-dns-task-list-usage.golden new file mode 100644 index 0000000000..022f5abd75 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-dns-task-list-usage.golden @@ -0,0 +1,35 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Retrieve a list of tasks for domain operations (creation, transfer, renewal, etc.). +This is useful for tracking operations and retrieving task IDs needed for Terraform imports. + +USAGE: + scw dns task list [arg=value ...] + +EXAMPLES: + List all tasks + scw dns task list + + List tasks for a specific domain + scw dns task list domain=example.com + + List tasks with create_domain type + scw dns task list types.0=create_domain + +ARGS: + [project-id] Project ID to use. If none is passed the default project ID will be used + [organization-id] Organization ID to filter on + [domain] Domain name to filter on + [types.{index}] Task types to filter on (unknown | create_domain | create_external_domain | renew_domain | transfer_domain | trade_domain | lock_domain_transfer | unlock_domain_transfer | enable_dnssec | disable_dnssec | update_domain | update_contact | delete_domain | cancel_task | generate_ssl_certificate | renew_ssl_certificate | send_message | delete_domain_expired | delete_external_domain | create_host | update_host | delete_host | move_project | transfer_online_domain) + [statuses.{index}] Task statuses to filter on (unavailable | new | waiting_payment | pending | success | error) + [order-by=domain_desc] Sort order of the returned tasks (domain_desc | domain_asc) + +FLAGS: + -h, --help help for list + --list-sub-commands List all subcommands + +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-dns-task-usage.golden b/cmd/scw/testdata/test-all-usage-dns-task-usage.golden new file mode 100644 index 0000000000..a35474a4bf --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-dns-task-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +DNS tasks management. + +USAGE: + scw dns task + +AVAILABLE COMMANDS: + list List DNS tasks + +FLAGS: + -h, --help help for task + --list-sub-commands List all subcommands + +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 dns task [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-dns-usage.golden b/cmd/scw/testdata/test-all-usage-dns-usage.golden index 963d0f064c..50d9a26104 100644 --- a/cmd/scw/testdata/test-all-usage-dns-usage.golden +++ b/cmd/scw/testdata/test-all-usage-dns-usage.golden @@ -8,6 +8,7 @@ USAGE: AVAILABLE COMMANDS: certificate TLS certificate management record DNS records management + task DNS tasks management tsig-key Transaction SIGnature key management version DNS zones version management zone DNS Zones management diff --git a/internal/namespaces/domain/v2beta1/custom.go b/internal/namespaces/domain/v2beta1/custom.go index a757a839e0..3bb0ab9260 100644 --- a/internal/namespaces/domain/v2beta1/custom.go +++ b/internal/namespaces/domain/v2beta1/custom.go @@ -44,6 +44,8 @@ func GetCommands() *core.Commands { dnsRecordAddCommand(), dnsRecordSetCommand(), dnsRecordDeleteCommand(), + dnsTask(), + dnsTaskListCommand(), )) cmds.MustFind("dns", "zone", "import").ArgSpecs.GetByName("bind-source.content").CanLoadFile = true @@ -56,6 +58,10 @@ func GetCommands() *core.Commands { domain.SSLCertificateStatus(""), human.EnumMarshalFunc(certificateStatusMarshalSpecs), ) + human.RegisterMarshalerFunc( + domain.TaskStatus(""), + human.EnumMarshalFunc(taskStatusMarshalSpecs), + ) return cmds } diff --git a/internal/namespaces/domain/v2beta1/custom_task.go b/internal/namespaces/domain/v2beta1/custom_task.go new file mode 100644 index 0000000000..ed0f489d7a --- /dev/null +++ b/internal/namespaces/domain/v2beta1/custom_task.go @@ -0,0 +1,181 @@ +package domain + +import ( + "context" + "reflect" + + "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/v2/core" + "github.com/scaleway/scaleway-cli/v2/core/human" + domain "github.com/scaleway/scaleway-sdk-go/api/domain/v2beta1" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +// +// Marshalers +// + +var ( + taskStatusMarshalSpecs = human.EnumMarshalSpecs{ + domain.TaskStatusSuccess: &human.EnumMarshalSpec{Attribute: color.FgGreen}, + domain.TaskStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed}, + domain.TaskStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + domain.TaskStatusNew: &human.EnumMarshalSpec{Attribute: color.FgCyan}, + domain.TaskStatusWaitingPayment: &human.EnumMarshalSpec{Attribute: color.FgYellow}, + } +) + +// +// Commands +// + +func dnsTask() *core.Command { + return &core.Command{ + Short: `DNS tasks management`, + Long: `DNS tasks management.`, + Namespace: "dns", + Resource: "task", + } +} + +func dnsTaskListCommand() *core.Command { + return &core.Command{ + Short: `List DNS tasks`, + Long: `Retrieve a list of tasks for domain operations (creation, transfer, renewal, etc.). +This is useful for tracking operations and retrieving task IDs needed for Terraform imports.`, + Namespace: "dns", + Resource: "task", + Verb: "list", + ArgsType: reflect.TypeOf(domain.RegistrarAPIListTasksRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ProjectIDArgSpec(), + { + Name: "organization-id", + Short: `Organization ID to filter on`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "domain", + Short: `Domain name to filter on`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "types.{index}", + Short: `Task types to filter on`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{ + "unknown", + "create_domain", + "create_external_domain", + "renew_domain", + "transfer_domain", + "trade_domain", + "lock_domain_transfer", + "unlock_domain_transfer", + "enable_dnssec", + "disable_dnssec", + "update_domain", + "update_contact", + "delete_domain", + "cancel_task", + "generate_ssl_certificate", + "renew_ssl_certificate", + "send_message", + "delete_domain_expired", + "delete_external_domain", + "create_host", + "update_host", + "delete_host", + "move_project", + "transfer_online_domain", + }, + }, + { + Name: "statuses.{index}", + Short: `Task statuses to filter on`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{ + "unavailable", + "new", + "waiting_payment", + "pending", + "success", + "error", + }, + }, + { + Name: "order-by", + Short: `Sort order of the returned tasks`, + Required: false, + Deprecated: false, + Positional: false, + Default: core.DefaultValueSetter("domain_desc"), + EnumValues: []string{ + "domain_desc", + "domain_asc", + }, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*domain.RegistrarAPIListTasksRequest) + + client := core.ExtractClient(ctx) + api := domain.NewRegistrarAPI(client) + opts := []scw.RequestOption{scw.WithAllPages()} + resp, err := api.ListTasks(request, opts...) + if err != nil { + return nil, err + } + + return resp.Tasks, nil + }, + View: &core.View{Fields: []*core.ViewField{ + { + FieldName: "ID", + }, + { + FieldName: "Domain", + }, + { + FieldName: "Type", + }, + { + FieldName: "Status", + }, + { + FieldName: "StartedAt", + }, + { + FieldName: "UpdatedAt", + }, + { + FieldName: "Message", + }, + { + FieldName: "ProjectID", + }, + }}, + Examples: []*core.Example{ + { + Short: "List all tasks", + ArgsJSON: `{}`, + }, + { + Short: "List tasks for a specific domain", + ArgsJSON: `{"domain": "example.com"}`, + }, + { + Short: "List tasks with create_domain type", + ArgsJSON: `{"types": ["create_domain"]}`, + }, + }, + } +} From 11a63e1ac265692c5b42dbfd5939c428b907725a Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Mon, 23 Feb 2026 17:06:56 +0100 Subject: [PATCH 2/4] Fix gci and gofumpt lint errors in custom_task.go --- .../namespaces/domain/v2beta1/custom_task.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/namespaces/domain/v2beta1/custom_task.go b/internal/namespaces/domain/v2beta1/custom_task.go index ed0f489d7a..cc3c2e1916 100644 --- a/internal/namespaces/domain/v2beta1/custom_task.go +++ b/internal/namespaces/domain/v2beta1/custom_task.go @@ -5,6 +5,7 @@ import ( "reflect" "github.com/fatih/color" + "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" domain "github.com/scaleway/scaleway-sdk-go/api/domain/v2beta1" @@ -15,15 +16,13 @@ import ( // Marshalers // -var ( - taskStatusMarshalSpecs = human.EnumMarshalSpecs{ - domain.TaskStatusSuccess: &human.EnumMarshalSpec{Attribute: color.FgGreen}, - domain.TaskStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed}, - domain.TaskStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue}, - domain.TaskStatusNew: &human.EnumMarshalSpec{Attribute: color.FgCyan}, - domain.TaskStatusWaitingPayment: &human.EnumMarshalSpec{Attribute: color.FgYellow}, - } -) +var taskStatusMarshalSpecs = human.EnumMarshalSpecs{ + domain.TaskStatusSuccess: &human.EnumMarshalSpec{Attribute: color.FgGreen}, + domain.TaskStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed}, + domain.TaskStatusPending: &human.EnumMarshalSpec{Attribute: color.FgBlue}, + domain.TaskStatusNew: &human.EnumMarshalSpec{Attribute: color.FgCyan}, + domain.TaskStatusWaitingPayment: &human.EnumMarshalSpec{Attribute: color.FgYellow}, +} // // Commands From 022bfbc419e59237917b58030ae8b9e9c5e4f8ed Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Mon, 23 Feb 2026 17:13:18 +0100 Subject: [PATCH 3/4] Regenerate dns docs with task list command --- docs/commands/dns.md | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/docs/commands/dns.md b/docs/commands/dns.md index 2d4b2fde73..892a41a9e5 100644 --- a/docs/commands/dns.md +++ b/docs/commands/dns.md @@ -16,6 +16,8 @@ This API allows you to manage your domains, DNS zones and records. - [List name servers within a DNS zone](#list-name-servers-within-a-dns-zone) - [Update a DNS record](#update-a-dns-record) - [Update name servers within a DNS zone](#update-name-servers-within-a-dns-zone) +- [DNS tasks management](#dns-tasks-management) + - [List DNS tasks](#list-dns-tasks) - [Transaction SIGnature key management](#transaction-signature-key-management) - [Delete the DNS zone's TSIG key](#delete-the-dns-zone's-tsig-key) - [Get the DNS zone's TSIG key](#get-the-dns-zone's-tsig-key) @@ -433,6 +435,56 @@ scw dns record update-nameservers [arg=value ...] +## DNS tasks management + +DNS tasks management. + + +### List DNS tasks + +Retrieve a list of tasks for domain operations (creation, transfer, renewal, etc.). +This is useful for tracking operations and retrieving task IDs needed for Terraform imports. + +**Usage:** + +``` +scw dns task list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| project-id | | Project ID to use. If none is passed the default project ID will be used | +| organization-id | | Organization ID to filter on | +| domain | | Domain name to filter on | +| types.{index} | One of: `unknown`, `create_domain`, `create_external_domain`, `renew_domain`, `transfer_domain`, `trade_domain`, `lock_domain_transfer`, `unlock_domain_transfer`, `enable_dnssec`, `disable_dnssec`, `update_domain`, `update_contact`, `delete_domain`, `cancel_task`, `generate_ssl_certificate`, `renew_ssl_certificate`, `send_message`, `delete_domain_expired`, `delete_external_domain`, `create_host`, `update_host`, `delete_host`, `move_project`, `transfer_online_domain` | Task types to filter on | +| statuses.{index} | One of: `unavailable`, `new`, `waiting_payment`, `pending`, `success`, `error` | Task statuses to filter on | +| order-by | Default: `domain_desc`
One of: `domain_desc`, `domain_asc` | Sort order of the returned tasks | + + +**Examples:** + + +List all tasks +``` +scw dns task list +``` + +List tasks for a specific domain +``` +scw dns task list domain=example.com +``` + +List tasks with create_domain type +``` +scw dns task list types.0=create_domain +``` + + + + ## Transaction SIGnature key management Transaction SIGnature key management. From bcf749057aca8bdabffa5db808748fdb2011f9cf Mon Sep 17 00:00:00 2001 From: Jonathan Remy Date: Mon, 23 Feb 2026 18:04:40 +0100 Subject: [PATCH 4/4] Fix gci import formatting in custom_task.go --- internal/namespaces/domain/v2beta1/custom_task.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/namespaces/domain/v2beta1/custom_task.go b/internal/namespaces/domain/v2beta1/custom_task.go index cc3c2e1916..3e32653700 100644 --- a/internal/namespaces/domain/v2beta1/custom_task.go +++ b/internal/namespaces/domain/v2beta1/custom_task.go @@ -5,7 +5,6 @@ import ( "reflect" "github.com/fatih/color" - "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" domain "github.com/scaleway/scaleway-sdk-go/api/domain/v2beta1"