From ea8094124e9ddade79948708783afd94b666f90a Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 18 Jun 2026 12:29:15 +0000 Subject: [PATCH 1/2] feat: update generated APIs --- go.mod | 2 +- go.sum | 4 +- internal/namespaces/billing/v2/billing_cli.go | 496 ++++++++++++++++++ ...t-pool-remove-label-remove-existing.golden | 2 + ...emove-startup-taint-remove-existing.golden | 2 + ...t-pool-remove-taint-remove-existing.golden | 2 + .../test-pool-set-label-set-empty.golden | 2 + ...st-pool-set-startup-taint-set-empty.golden | 2 + .../test-pool-set-taint-set-empty.golden | 2 + 9 files changed, 511 insertions(+), 3 deletions(-) create mode 100644 internal/namespaces/billing/v2/billing_cli.go diff --git a/go.mod b/go.mod index a6ab5b36f6..44036933a9 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/moby/moby/client v0.4.1 github.com/modelcontextprotocol/go-sdk v1.6.1 github.com/opencontainers/go-digest v1.0.0 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260617090821-fa699c591cad + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260618090426-c6672b4c0eb5 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 diff --git a/go.sum b/go.sum index 636b997b7e..77e32b7ec0 100644 --- a/go.sum +++ b/go.sum @@ -475,8 +475,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260617090821-fa699c591cad h1:0DtI9Bvsxac7CfLUiMbk4RvK3526cmcf+k4jxgeCcHg= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260617090821-fa699c591cad/go.mod h1:Q02gKOXqKfaCTpImuDgOLzlGin79ZoxxKKEhXHKSrPw= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260618090426-c6672b4c0eb5 h1:qchgDXlQZasvQVCN0Sm603SKtTTYuKbiDZ7TicEtOms= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260618090426-c6672b4c0eb5/go.mod h1:Q02gKOXqKfaCTpImuDgOLzlGin79ZoxxKKEhXHKSrPw= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM= github.com/secure-systems-lab/go-securesystemslib v0.11.0 h1:iuCR9kcMFD4QurdKrGvPLoKZLv9YvwPYVr0473BdtFs= diff --git a/internal/namespaces/billing/v2/billing_cli.go b/internal/namespaces/billing/v2/billing_cli.go new file mode 100644 index 0000000000..7f1e17af0c --- /dev/null +++ b/internal/namespaces/billing/v2/billing_cli.go @@ -0,0 +1,496 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +package billing + +import ( + "context" + "reflect" + + "github.com/scaleway/scaleway-cli/v2/core" + "github.com/scaleway/scaleway-sdk-go/api/billing/v2" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +// always import dependencies +var ( + _ = scw.RegionFrPar +) + +func GetGeneratedCommands() *core.Commands { + return core.NewCommands( + billingRoot(), + billingBudget(), + billingBudgetAlert(), + billingBudgetAlertNotification(), + billingBudgetList(), + billingBudgetGet(), + billingBudgetCreate(), + billingBudgetUpdate(), + billingBudgetDelete(), + billingBudgetAlertCreate(), + billingBudgetAlertUpdate(), + billingBudgetAlertDelete(), + billingBudgetAlertNotificationCreate(), + billingBudgetAlertNotificationUpdate(), + billingBudgetAlertNotificationDelete(), + ) +} + +func billingRoot() *core.Command { + return &core.Command{ + Short: `This API allows you to query billing related objects`, + Long: `This API allows you to query billing related objects.`, + Namespace: "billing", + } +} + +func billingBudget() *core.Command { + return &core.Command{ + Short: `Budget management commands`, + Long: `Budget management commands.`, + Namespace: "billing", + Resource: "budget", + } +} + +func billingBudgetAlert() *core.Command { + return &core.Command{ + Short: `Budget alerts management commands`, + Long: `Budget alerts management commands.`, + Namespace: "billing", + Resource: "budget-alert", + } +} + +func billingBudgetAlertNotification() *core.Command { + return &core.Command{ + Short: `Budget alert notification management commands`, + Long: `Budget alert notification management commands.`, + Namespace: "billing", + Resource: "budget-alert-notification", + } +} + +func billingBudgetList() *core.Command { + return &core.Command{ + Short: `List your budgets, filtering by ` + "`" + `organization_id` + "`" + `.`, + Long: `List your budgets, filtering by ` + "`" + `organization_id` + "`" + `.`, + Namespace: "billing", + Resource: "budget", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.ListBudgetsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "organization-id", + Short: `Filter by organization ID`, + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.ListBudgetsRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + opts := []scw.RequestOption{scw.WithAllPages()} + resp, err := api.ListBudgets(request, opts...) + if err != nil { + return nil, err + } + + return resp.Budgets, nil + }, + } +} + +func billingBudgetGet() *core.Command { + return &core.Command{ + Short: `Fetch a budget.`, + Long: `Fetch a budget.`, + Namespace: "billing", + Resource: "budget", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.GetBudgetRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-id", + Short: `The ID of the budget`, + Required: true, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.GetBudgetRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.GetBudget(request) + }, + } +} + +func billingBudgetCreate() *core.Command { + return &core.Command{ + Short: `Create a new budget.`, + Long: `Create a new budget.`, + Namespace: "billing", + Resource: "budget", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.CreateBudgetRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "consumption-limit", + Short: `Cost limit for the budget`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "enabled", + Short: `Whether the budget is enabled or not`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.OrganizationIDArgSpec(), + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.CreateBudgetRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.CreateBudget(request) + }, + } +} + +func billingBudgetUpdate() *core.Command { + return &core.Command{ + Short: `Update a budget.`, + Long: `Update a budget.`, + Namespace: "billing", + Resource: "budget", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.UpdateBudgetRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-id", + Short: `The ID of the budget to update`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "consumption-limit", + Short: `Cost limit for the budget`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "enabled", + Short: `Whether the budget will be enabled or not`, + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.UpdateBudgetRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.UpdateBudget(request) + }, + } +} + +func billingBudgetDelete() *core.Command { + return &core.Command{ + Short: `Delete a budget.`, + Long: `Delete a budget.`, + Namespace: "billing", + Resource: "budget", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.DeleteBudgetRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-id", + Short: `The ID of the budget to delete`, + Required: true, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.DeleteBudgetRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + e = api.DeleteBudget(request) + if e != nil { + return nil, e + } + + return &core.SuccessResult{ + Resource: "budget", + Verb: "delete", + }, nil + }, + } +} + +func billingBudgetAlertCreate() *core.Command { + return &core.Command{ + Short: `Create a new budget alert.`, + Long: `Create a new budget alert.`, + Namespace: "billing", + Resource: "budget-alert", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.CreateBudgetAlertRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-id", + Short: `The ID of the budget to create alert for`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "threshold", + Short: `Threshold above which the alert is sent`, + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.CreateBudgetAlertRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.CreateBudgetAlert(request) + }, + } +} + +func billingBudgetAlertUpdate() *core.Command { + return &core.Command{ + Short: `Update a budget alert.`, + Long: `Update a budget alert.`, + Namespace: "billing", + Resource: "budget-alert", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.UpdateBudgetAlertRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-alert-id", + Short: `The ID of the budget alert to update`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "threshold", + Short: `Threshold above which the alert is sent`, + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.UpdateBudgetAlertRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.UpdateBudgetAlert(request) + }, + } +} + +func billingBudgetAlertDelete() *core.Command { + return &core.Command{ + Short: `Delete a budget alert.`, + Long: `Delete a budget alert.`, + Namespace: "billing", + Resource: "budget-alert", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.DeleteBudgetAlertRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-alert-id", + Short: `The ID of the budget alert to delete`, + Required: true, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.DeleteBudgetAlertRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + e = api.DeleteBudgetAlert(request) + if e != nil { + return nil, e + } + + return &core.SuccessResult{ + Resource: "budget-alert", + Verb: "delete", + }, nil + }, + } +} + +func billingBudgetAlertNotificationCreate() *core.Command { + return &core.Command{ + Short: `Create a new budget alert notification.`, + Long: `Create a new budget alert notification.`, + Namespace: "billing", + Resource: "budget-alert-notification", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.CreateBudgetAlertNotificationRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-alert-id", + Short: `The ID of the budget alert to create notification for`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "sms-phone-numbers.{index}", + Short: `List of phone numbers to receive sms notifications`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "email-addresses.{index}", + Short: `List of email addresses to receive email notifications`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "webhook-urls.{index}", + Short: `List of webhook url to receive webhook notifications`, + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.CreateBudgetAlertNotificationRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.CreateBudgetAlertNotification(request) + }, + } +} + +func billingBudgetAlertNotificationUpdate() *core.Command { + return &core.Command{ + Short: `Update a budget alert notification.`, + Long: `Update a budget alert notification.`, + Namespace: "billing", + Resource: "budget-alert-notification", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.UpdateBudgetAlertNotificationRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-alert-notification-id", + Short: `The ID of the budget alert notification to update`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "sms-phone-numbers.{index}", + Short: `List of phone numbers to receive sms notifications`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "email-addresses.{index}", + Short: `List of email addresses to receive email notifications`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "webhook-urls.{index}", + Short: `List of webhook url to receive webhook notifications`, + Required: false, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.UpdateBudgetAlertNotificationRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + + return api.UpdateBudgetAlertNotification(request) + }, + } +} + +func billingBudgetAlertNotificationDelete() *core.Command { + return &core.Command{ + Short: `Delete a budget alert notification.`, + Long: `Delete a budget alert notification.`, + Namespace: "billing", + Resource: "budget-alert-notification", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(billing.DeleteBudgetAlertNotificationRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "budget-alert-notification-id", + Short: `The ID of the budget alert notification to delete`, + Required: true, + Deprecated: false, + Positional: false, + }, + }, + Run: func(ctx context.Context, args any) (i any, e error) { + request := args.(*billing.DeleteBudgetAlertNotificationRequest) + + client := core.ExtractClient(ctx) + api := billing.NewAPI(client) + e = api.DeleteBudgetAlertNotification(request) + if e != nil { + return nil, e + } + + return &core.SuccessResult{ + Resource: "budget-alert-notification", + Verb: "delete", + }, nil + }, + } +} diff --git a/internal/namespaces/k8s/v1/testdata/test-pool-remove-label-remove-existing.golden b/internal/namespaces/k8s/v1/testdata/test-pool-remove-label-remove-existing.golden index 99fb12c21e..baf75995b1 100644 --- a/internal/namespaces/k8s/v1/testdata/test-pool-remove-label-remove-existing.golden +++ b/internal/namespaces/k8s/v1/testdata/test-pool-remove-label-remove-existing.golden @@ -19,6 +19,7 @@ RootVolumeType l_ssd RootVolumeSize 40 GB PublicIPDisabled false SecurityGroupID 8bcdc1ce-cda4-4e8f-859f-2aa0aa86e957 +PrivateNetworkID - Region fr-par Upgrade Policy: @@ -64,5 +65,6 @@ KEY VALUE EFFECT "labels": {}, "taints": [], "startup_taints": [], + "private_network_id": "", "region": "fr-par" } diff --git a/internal/namespaces/k8s/v1/testdata/test-pool-remove-startup-taint-remove-existing.golden b/internal/namespaces/k8s/v1/testdata/test-pool-remove-startup-taint-remove-existing.golden index 014032e6c9..8a5b492bf6 100644 --- a/internal/namespaces/k8s/v1/testdata/test-pool-remove-startup-taint-remove-existing.golden +++ b/internal/namespaces/k8s/v1/testdata/test-pool-remove-startup-taint-remove-existing.golden @@ -19,6 +19,7 @@ RootVolumeType l_ssd RootVolumeSize 40 GB PublicIPDisabled false SecurityGroupID 8bcdc1ce-cda4-4e8f-859f-2aa0aa86e957 +PrivateNetworkID - Region fr-par Upgrade Policy: @@ -64,5 +65,6 @@ KEY VALUE EFFECT "labels": {}, "taints": [], "startup_taints": [], + "private_network_id": "", "region": "fr-par" } diff --git a/internal/namespaces/k8s/v1/testdata/test-pool-remove-taint-remove-existing.golden b/internal/namespaces/k8s/v1/testdata/test-pool-remove-taint-remove-existing.golden index 253d139f43..0db8260ce3 100644 --- a/internal/namespaces/k8s/v1/testdata/test-pool-remove-taint-remove-existing.golden +++ b/internal/namespaces/k8s/v1/testdata/test-pool-remove-taint-remove-existing.golden @@ -19,6 +19,7 @@ RootVolumeType l_ssd RootVolumeSize 40 GB PublicIPDisabled false SecurityGroupID 8bcdc1ce-cda4-4e8f-859f-2aa0aa86e957 +PrivateNetworkID - Region fr-par Upgrade Policy: @@ -64,5 +65,6 @@ KEY VALUE EFFECT "labels": {}, "taints": [], "startup_taints": [], + "private_network_id": "", "region": "fr-par" } diff --git a/internal/namespaces/k8s/v1/testdata/test-pool-set-label-set-empty.golden b/internal/namespaces/k8s/v1/testdata/test-pool-set-label-set-empty.golden index 63ef413df5..8b2e48a635 100644 --- a/internal/namespaces/k8s/v1/testdata/test-pool-set-label-set-empty.golden +++ b/internal/namespaces/k8s/v1/testdata/test-pool-set-label-set-empty.golden @@ -19,6 +19,7 @@ RootVolumeType l_ssd RootVolumeSize 40 GB PublicIPDisabled false SecurityGroupID 8bcdc1ce-cda4-4e8f-859f-2aa0aa86e957 +PrivateNetworkID - Region fr-par Upgrade Policy: @@ -66,5 +67,6 @@ KEY VALUE EFFECT }, "taints": [], "startup_taints": [], + "private_network_id": "", "region": "fr-par" } diff --git a/internal/namespaces/k8s/v1/testdata/test-pool-set-startup-taint-set-empty.golden b/internal/namespaces/k8s/v1/testdata/test-pool-set-startup-taint-set-empty.golden index 2413b65ba1..f62b837f69 100644 --- a/internal/namespaces/k8s/v1/testdata/test-pool-set-startup-taint-set-empty.golden +++ b/internal/namespaces/k8s/v1/testdata/test-pool-set-startup-taint-set-empty.golden @@ -19,6 +19,7 @@ RootVolumeType l_ssd RootVolumeSize 40 GB PublicIPDisabled false SecurityGroupID 8bcdc1ce-cda4-4e8f-859f-2aa0aa86e957 +PrivateNetworkID - Region fr-par Upgrade Policy: @@ -71,5 +72,6 @@ foo bar NoSchedule "effect": "NoSchedule" } ], + "private_network_id": "", "region": "fr-par" } diff --git a/internal/namespaces/k8s/v1/testdata/test-pool-set-taint-set-empty.golden b/internal/namespaces/k8s/v1/testdata/test-pool-set-taint-set-empty.golden index 2bd9327738..5559b0add5 100644 --- a/internal/namespaces/k8s/v1/testdata/test-pool-set-taint-set-empty.golden +++ b/internal/namespaces/k8s/v1/testdata/test-pool-set-taint-set-empty.golden @@ -19,6 +19,7 @@ RootVolumeType l_ssd RootVolumeSize 40 GB PublicIPDisabled false SecurityGroupID 8bcdc1ce-cda4-4e8f-859f-2aa0aa86e957 +PrivateNetworkID - Region fr-par Upgrade Policy: @@ -71,5 +72,6 @@ KEY VALUE EFFECT } ], "startup_taints": [], + "private_network_id": "", "region": "fr-par" } From 14b018f09c774be906ce4401f981c55a2032df25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 18 Jun 2026 15:40:17 +0200 Subject: [PATCH 2/2] fix --- ...e-billing-budget-alert-create-usage.golden | 20 ++ ...e-billing-budget-alert-delete-usage.golden | 19 ++ ...get-alert-notification-create-usage.golden | 22 ++ ...get-alert-notification-delete-usage.golden | 19 ++ ...get-alert-notification-update-usage.golden | 22 ++ ...ing-budget-alert-notification-usage.golden | 23 ++ ...e-billing-budget-alert-update-usage.golden | 20 ++ ...ll-usage-billing-budget-alert-usage.golden | 23 ++ ...l-usage-billing-budget-create-usage.golden | 21 ++ ...l-usage-billing-budget-delete-usage.golden | 19 ++ ...-all-usage-billing-budget-get-usage.golden | 19 ++ ...all-usage-billing-budget-list-usage.golden | 19 ++ ...l-usage-billing-budget-update-usage.golden | 21 ++ ...test-all-usage-billing-budget-usage.golden | 25 ++ .../test-all-usage-billing-usage#01.golden | 27 ++ .../test-all-usage-billing-usage.golden | 11 +- commands/commands.go | 6 +- docs/commands/billing.md | 254 +++++++++++++++++- internal/namespaces/billing/v2/custom.go | 11 + 19 files changed, 593 insertions(+), 8 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-update-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-update-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-alert-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-create-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-delete-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-get-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-list-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-update-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-budget-usage.golden create mode 100644 cmd/scw/testdata/test-all-usage-billing-usage#01.golden create mode 100644 internal/namespaces/billing/v2/custom.go diff --git a/cmd/scw/testdata/test-all-usage-billing-budget-alert-create-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-create-usage.golden new file mode 100644 index 0000000000..d439c2c8d0 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-create-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Create a new budget alert. + +USAGE: + scw billing budget-alert create [arg=value ...] + +ARGS: + [budget-id] The ID of the budget to create alert for + [threshold] Threshold above which the alert is sent + +FLAGS: + -h, --help help for create + --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-billing-budget-alert-delete-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-delete-usage.golden new file mode 100644 index 0000000000..5cc96f2684 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Delete a budget alert. + +USAGE: + scw billing budget-alert delete [arg=value ...] + +ARGS: + budget-alert-id The ID of the budget alert to delete + +FLAGS: + -h, --help help for delete + --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-billing-budget-alert-notification-create-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-create-usage.golden new file mode 100644 index 0000000000..03132b84d1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-create-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Create a new budget alert notification. + +USAGE: + scw billing budget-alert-notification create [arg=value ...] + +ARGS: + [budget-alert-id] The ID of the budget alert to create notification for + [sms-phone-numbers.{index}] List of phone numbers to receive sms notifications + [email-addresses.{index}] List of email addresses to receive email notifications + [webhook-urls.{index}] List of webhook url to receive webhook notifications + +FLAGS: + -h, --help help for create + --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-billing-budget-alert-notification-delete-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-delete-usage.golden new file mode 100644 index 0000000000..1171e776cf --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Delete a budget alert notification. + +USAGE: + scw billing budget-alert-notification delete [arg=value ...] + +ARGS: + budget-alert-notification-id The ID of the budget alert notification to delete + +FLAGS: + -h, --help help for delete + --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-billing-budget-alert-notification-update-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-update-usage.golden new file mode 100644 index 0000000000..cb620ca1b0 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-update-usage.golden @@ -0,0 +1,22 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Update a budget alert notification. + +USAGE: + scw billing budget-alert-notification update [arg=value ...] + +ARGS: + budget-alert-notification-id The ID of the budget alert notification to update + [sms-phone-numbers.{index}] List of phone numbers to receive sms notifications + [email-addresses.{index}] List of email addresses to receive email notifications + [webhook-urls.{index}] List of webhook url to receive webhook notifications + +FLAGS: + -h, --help help for update + --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-billing-budget-alert-notification-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-usage.golden new file mode 100644 index 0000000000..c433b46540 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-notification-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Budget alert notification management commands. + +USAGE: + scw billing budget-alert-notification + +AVAILABLE COMMANDS: + create Create a new budget alert notification. + delete Delete a budget alert notification. + update Update a budget alert notification. + +FLAGS: + -h, --help help for budget-alert-notification + --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 billing budget-alert-notification [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-billing-budget-alert-update-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-update-usage.golden new file mode 100644 index 0000000000..d4adba5b43 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-update-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Update a budget alert. + +USAGE: + scw billing budget-alert update [arg=value ...] + +ARGS: + budget-alert-id The ID of the budget alert to update + [threshold] Threshold above which the alert is sent + +FLAGS: + -h, --help help for update + --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-billing-budget-alert-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-alert-usage.golden new file mode 100644 index 0000000000..c1ce78bb49 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-alert-usage.golden @@ -0,0 +1,23 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Budget alerts management commands. + +USAGE: + scw billing budget-alert + +AVAILABLE COMMANDS: + create Create a new budget alert. + delete Delete a budget alert. + update Update a budget alert. + +FLAGS: + -h, --help help for budget-alert + --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 billing budget-alert [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-billing-budget-create-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-create-usage.golden new file mode 100644 index 0000000000..eb3396468a --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-create-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Create a new budget. + +USAGE: + scw billing budget create [arg=value ...] + +ARGS: + [consumption-limit] Cost limit for the budget + [enabled] Whether the budget is enabled or not + [organization-id] Organization ID to use. If none is passed the default organization ID will be used + +FLAGS: + -h, --help help for create + --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-billing-budget-delete-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-delete-usage.golden new file mode 100644 index 0000000000..928b8f8daa --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-delete-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Delete a budget. + +USAGE: + scw billing budget delete [arg=value ...] + +ARGS: + budget-id The ID of the budget to delete + +FLAGS: + -h, --help help for delete + --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-billing-budget-get-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-get-usage.golden new file mode 100644 index 0000000000..ae10eec02a --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Fetch a budget. + +USAGE: + scw billing budget get [arg=value ...] + +ARGS: + budget-id The ID of the budget + +FLAGS: + -h, --help help for get + --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-billing-budget-list-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-list-usage.golden new file mode 100644 index 0000000000..c97259c5e7 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-list-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +List your budgets, filtering by `organization_id`. + +USAGE: + scw billing budget list [arg=value ...] + +ARGS: + [organization-id] Filter by organization ID + +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-billing-budget-update-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-update-usage.golden new file mode 100644 index 0000000000..ec06465a66 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-update-usage.golden @@ -0,0 +1,21 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Update a budget. + +USAGE: + scw billing budget update [arg=value ...] + +ARGS: + budget-id The ID of the budget to update + [consumption-limit] Cost limit for the budget + [enabled] Whether the budget will be enabled or not + +FLAGS: + -h, --help help for update + --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-billing-budget-usage.golden b/cmd/scw/testdata/test-all-usage-billing-budget-usage.golden new file mode 100644 index 0000000000..c4bdd0cf81 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-budget-usage.golden @@ -0,0 +1,25 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +Budget management commands. + +USAGE: + scw billing budget + +AVAILABLE COMMANDS: + create Create a new budget. + delete Delete a budget. + get Fetch a budget. + list List your budgets, filtering by `organization_id`. + update Update a budget. + +FLAGS: + -h, --help help for budget + --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 billing budget [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-billing-usage#01.golden b/cmd/scw/testdata/test-all-usage-billing-usage#01.golden new file mode 100644 index 0000000000..95fbb7b038 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-billing-usage#01.golden @@ -0,0 +1,27 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +This API allows you to manage and query your Scaleway billing and consumption. + +USAGE: + scw billing + +AVAILABLE COMMANDS: + budget Budget management commands + budget-alert Budget alerts management commands + budget-alert-notification Budget alert notification management commands + charge + consumption Consumption management commands + discount Discount management commands + invoice Invoice management commands + +FLAGS: + -h, --help help for billing + --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 billing [command] --help" for more information about a command. diff --git a/cmd/scw/testdata/test-all-usage-billing-usage.golden b/cmd/scw/testdata/test-all-usage-billing-usage.golden index eb5ab0bd98..95fbb7b038 100644 --- a/cmd/scw/testdata/test-all-usage-billing-usage.golden +++ b/cmd/scw/testdata/test-all-usage-billing-usage.golden @@ -6,10 +6,13 @@ USAGE: scw billing AVAILABLE COMMANDS: - charge - consumption Consumption management commands - discount Discount management commands - invoice Invoice management commands + budget Budget management commands + budget-alert Budget alerts management commands + budget-alert-notification Budget alert notification management commands + charge + consumption Consumption management commands + discount Discount management commands + invoice Invoice management commands FLAGS: -h, --help help for billing diff --git a/commands/commands.go b/commands/commands.go index f356a03d3f..51297cc7f0 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -10,7 +10,8 @@ import ( audit_trail "github.com/scaleway/scaleway-cli/v2/internal/namespaces/audit_trail/v1alpha1" autocompleteNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/autocomplete" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/baremetal/v1" - billing "github.com/scaleway/scaleway-cli/v2/internal/namespaces/billing/v2beta1" + "github.com/scaleway/scaleway-cli/v2/internal/namespaces/billing/v2" + billingV2beta1 "github.com/scaleway/scaleway-cli/v2/internal/namespaces/billing/v2beta1" block "github.com/scaleway/scaleway-cli/v2/internal/namespaces/block/v1alpha1" "github.com/scaleway/scaleway-cli/v2/internal/namespaces/cockpit/v1" configNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/config" @@ -110,7 +111,7 @@ func GetCommands() *core.Commands { tem.GetCommands(), alias.GetCommands(), webhosting.GetCommands(), - billing.GetCommands(), + billingV2beta1.GetCommands(), mnq.GetCommands(), block.GetCommands(), ipam.GetCommands(), @@ -130,6 +131,7 @@ func GetCommands() *core.Commands { product_catalog.GetCommands(), mcp.GetCommands(), search.GetCommands(), + billing.GetCommands(), ) if beta { diff --git a/docs/commands/billing.md b/docs/commands/billing.md index 8cc5fa8dcf..9ea04185a1 100644 --- a/docs/commands/billing.md +++ b/docs/commands/billing.md @@ -1,7 +1,21 @@ # Documentation for `scw billing` -This API allows you to manage and query your Scaleway billing and consumption. - +This API allows you to query billing related objects. + +- [Budget management commands](#budget-management-commands) + - [Create a new budget.](#create-a-new-budget.) + - [Delete a budget.](#delete-a-budget.) + - [Fetch a budget.](#fetch-a-budget.) + - [List your budgets, filtering by `organization_id`.](#list-your-budgets,-filtering-by-`organization_id`.) + - [Update a budget.](#update-a-budget.) +- [Budget alerts management commands](#budget-alerts-management-commands) + - [Create a new budget alert.](#create-a-new-budget-alert.) + - [Delete a budget alert.](#delete-a-budget-alert.) + - [Update a budget alert.](#update-a-budget-alert.) +- [Budget alert notification management commands](#budget-alert-notification-management-commands) + - [Create a new budget alert notification.](#create-a-new-budget-alert-notification.) + - [Delete a budget alert notification.](#delete-a-budget-alert-notification.) + - [Update a budget alert notification.](#update-a-budget-alert-notification.) - [](#) - [List charges](#list-charges) - [Consumption management commands](#consumption-management-commands) @@ -16,6 +30,242 @@ This API allows you to manage and query your Scaleway billing and consumption. - [List invoices](#list-invoices) +## Budget management commands + +Budget management commands. + + +### Create a new budget. + +Create a new budget. + +**Usage:** + +```shell +scw billing budget create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| consumption-limit | | Cost limit for the budget | +| enabled | | Whether the budget is enabled or not | +| organization-id | | Organization ID to use. If none is passed the default organization ID will be used | + + + +### Delete a budget. + +Delete a budget. + +**Usage:** + +```shell +scw billing budget delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-id | Required | The ID of the budget to delete | + + + +### Fetch a budget. + +Fetch a budget. + +**Usage:** + +```shell +scw billing budget get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-id | Required | The ID of the budget | + + + +### List your budgets, filtering by `organization_id`. + +List your budgets, filtering by `organization_id`. + +**Usage:** + +```shell +scw billing budget list [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| organization-id | | Filter by organization ID | + + + +### Update a budget. + +Update a budget. + +**Usage:** + +```shell +scw billing budget update [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-id | Required | The ID of the budget to update | +| consumption-limit | | Cost limit for the budget | +| enabled | | Whether the budget will be enabled or not | + + + +## Budget alerts management commands + +Budget alerts management commands. + + +### Create a new budget alert. + +Create a new budget alert. + +**Usage:** + +```shell +scw billing budget-alert create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-id | | The ID of the budget to create alert for | +| threshold | | Threshold above which the alert is sent | + + + +### Delete a budget alert. + +Delete a budget alert. + +**Usage:** + +```shell +scw billing budget-alert delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-alert-id | Required | The ID of the budget alert to delete | + + + +### Update a budget alert. + +Update a budget alert. + +**Usage:** + +```shell +scw billing budget-alert update [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-alert-id | Required | The ID of the budget alert to update | +| threshold | | Threshold above which the alert is sent | + + + +## Budget alert notification management commands + +Budget alert notification management commands. + + +### Create a new budget alert notification. + +Create a new budget alert notification. + +**Usage:** + +```shell +scw billing budget-alert-notification create [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-alert-id | | The ID of the budget alert to create notification for | +| sms-phone-numbers.{index} | | List of phone numbers to receive sms notifications | +| email-addresses.{index} | | List of email addresses to receive email notifications | +| webhook-urls.{index} | | List of webhook url to receive webhook notifications | + + + +### Delete a budget alert notification. + +Delete a budget alert notification. + +**Usage:** + +```shell +scw billing budget-alert-notification delete [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-alert-notification-id | Required | The ID of the budget alert notification to delete | + + + +### Update a budget alert notification. + +Update a budget alert notification. + +**Usage:** + +```shell +scw billing budget-alert-notification update [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| budget-alert-notification-id | Required | The ID of the budget alert notification to update | +| sms-phone-numbers.{index} | | List of phone numbers to receive sms notifications | +| email-addresses.{index} | | List of email addresses to receive email notifications | +| webhook-urls.{index} | | List of webhook url to receive webhook notifications | + + + ## diff --git a/internal/namespaces/billing/v2/custom.go b/internal/namespaces/billing/v2/custom.go new file mode 100644 index 0000000000..e3c4ad5277 --- /dev/null +++ b/internal/namespaces/billing/v2/custom.go @@ -0,0 +1,11 @@ +package billing + +import ( + "github.com/scaleway/scaleway-cli/v2/core" +) + +func GetCommands() *core.Commands { + cmds := GetGeneratedCommands() + + return cmds +}