Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ To enable beta features, you can set `SCW_ENABLE_BETA=1` in your environment.
| `applesilicon` | Apple silicon API | [CLI](./docs/commands/apple-silicon.md) / [API](https://developers.scaleway.com/en/products/apple-silicon/api/) |
| `autocomplete` | Autocomplete related commands | [CLI](./docs/commands/autocomplete.md) |
| `baremetal` | Baremetal API | [CLI](./docs/commands/baremetal.md) / [API](https://developers.scaleway.com/en/products/baremetal/api/) |
| `billing` | Billing API | [CLI](./docs/commands/billing.md) / [API](https://developers.scaleway.com/en/products/billing/api/) |
| `cockpit` | Cockpit API | [CLI](./docs/commands/cockpit.md) / [API](https://developers.scaleway.com/en/products/cockpit/api/) |
| `config` | Config file management | [CLI](./docs/commands/config.md) |
| `container` | Serverless Container API | [CLI](./docs/commands/container.md) / [API](https://developers.scaleway.com/en/products/containers/api/) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Download billing resources.

USAGE:
scw billing invoice download [arg=value ...]

ARGS:
invoice-id Invoice ID
[file-path=/tmp/] Wanted file path
[file-type=pdf] Wanted file extension
[force-replace=false] Force file replacement

FLAGS:
-h, --help help for download

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,22 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
List billing resources.

USAGE:
scw billing invoice list [arg=value ...]

ARGS:
[started-after] Invoice's `start_date` is greater or equal to `started_after`
[started-before] Invoice's `start_date` precedes `started_before`
[invoice-type] Invoice type. It can either be `periodic` or `purchase` (unknown_type | periodic | purchase)
[order-by] How invoices are ordered in the response (invoice_number_desc | invoice_number_asc | start_date_desc | start_date_asc | issued_date_desc | issued_date_asc | due_date_desc | due_date_asc | total_untaxed_desc | total_untaxed_asc | total_taxed_desc | total_taxed_asc | invoice_type_desc | invoice_type_asc)
[organization-id] Organization ID to filter for, only invoices from this Organization will be returned

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

USAGE:
scw billing invoice <command>

AVAILABLE COMMANDS:
download Download billing resources
list List billing resources

FLAGS:
-h, --help help for invoice

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 invoice [command] --help" for more information about a command.
20 changes: 20 additions & 0 deletions cmd/scw/testdata/test-all-usage-billing-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Billing API.

USAGE:
scw billing <command>

AVAILABLE COMMANDS:
invoice Invoices management commands

FLAGS:
-h, --help help for billing

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.
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 @@ -8,6 +8,7 @@ AVAILABLE COMMANDS:
apple-silicon Apple silicon API
autocomplete Autocomplete related commands
baremetal Elastic Metal API
billing This API allows you to query your consumption
cockpit Cockpit API
container Container as a Service API
dns Domains and DNS API
Expand Down
59 changes: 59 additions & 0 deletions docs/commands/billing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!-- DO NOT EDIT: this file is automatically generated using scw-doc-gen -->
# Documentation for `scw billing`
Billing API.

- [Invoices management commands](#invoices-management-commands)
- [Download billing resources](#download-billing-resources)
- [List billing resources](#list-billing-resources)


## Invoices management commands

Invoices management commands.


### Download billing resources

Download billing resources.

**Usage:**

```
scw billing invoice download [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| invoice-id | Required | Invoice ID |
| file-path | Default: `/tmp/` | Wanted file path |
| file-type | Default: `pdf` | Wanted file extension |
| force-replace | Default: `false` | Force file replacement |



### List billing resources

List billing resources.

**Usage:**

```
scw billing invoice list [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| started-after | | Invoice's `start_date` is greater or equal to `started_after` |
| started-before | | Invoice's `start_date` precedes `started_before` |
| invoice-type | One of: `unknown_type`, `periodic`, `purchase` | Invoice type. It can either be `periodic` or `purchase` |
| order-by | One of: `invoice_number_desc`, `invoice_number_asc`, `start_date_desc`, `start_date_asc`, `issued_date_desc`, `issued_date_asc`, `due_date_desc`, `due_date_asc`, `total_untaxed_desc`, `total_untaxed_asc`, `total_taxed_desc`, `total_taxed_asc`, `invoice_type_desc`, `invoice_type_asc` | How invoices are ordered in the response |
| organization-id | | Organization ID to filter for, only invoices from this Organization will be returned |



22 changes: 22 additions & 0 deletions internal/namespaces/billing/v2alpha1/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package billing

import (
"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/human"
billing "github.com/scaleway/scaleway-sdk-go/api/billing/v2alpha1"
)

var (
invoiceTypeMarshalSpecs = human.EnumMarshalSpecs{
billing.DownloadInvoiceRequestFileTypePdf: &human.EnumMarshalSpec{Attribute: color.FgHiBlue, Value: "pdf"},
}
)

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

human.RegisterMarshalerFunc(billing.DownloadInvoiceRequestFileType("pdf"), human.EnumMarshalFunc(invoiceTypeMarshalSpecs))
cmds.MustFind("billing", "invoice", "download").Override(buildDownloadCommand)
return cmds
}
Loading