Skip to content

Commit 3e5272a

Browse files
Monitobkindermoumoutequantumsheep
authored
feat(billing): add billing command (#2931)
Co-authored-by: Olivier Cano <kindermoumoute@users.noreply.github.com> Co-authored-by: Nathanael Demacon <ndemacon@scaleway.com>
1 parent 4aa9160 commit 3e5272a

10 files changed

Lines changed: 409 additions & 2 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ To enable beta features, you can set `SCW_ENABLE_BETA=1` in your environment.
120120
| `applesilicon` | Apple silicon API | [CLI](./docs/commands/apple-silicon.md) / [API](https://developers.scaleway.com/en/products/apple-silicon/api/) |
121121
| `autocomplete` | Autocomplete related commands | [CLI](./docs/commands/autocomplete.md) |
122122
| `baremetal` | Baremetal API | [CLI](./docs/commands/baremetal.md) / [API](https://developers.scaleway.com/en/products/baremetal/api/) |
123+
| `billing` | Billing API | [CLI](./docs/commands/billing.md) / [API](https://developers.scaleway.com/en/products/billing/api/) |
123124
| `cockpit` | Cockpit API | [CLI](./docs/commands/cockpit.md) / [API](https://developers.scaleway.com/en/products/cockpit/api/) |
124125
| `config` | Config file management | [CLI](./docs/commands/config.md) |
125126
| `container` | Serverless Container API | [CLI](./docs/commands/container.md) / [API](https://developers.scaleway.com/en/products/containers/api/) |
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Download billing resources.
4+
5+
USAGE:
6+
scw billing invoice download [arg=value ...]
7+
8+
ARGS:
9+
invoice-id Invoice ID
10+
[file-path=./] Wanted file path
11+
[file-type=pdf] Wanted file extension
12+
[force-replace=false] Force file replacement
13+
14+
FLAGS:
15+
-h, --help help for download
16+
17+
GLOBAL FLAGS:
18+
-c, --config string The path to the config file
19+
-D, --debug Enable debug mode
20+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
21+
-p, --profile string The config profile to use
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
List billing resources.
4+
5+
USAGE:
6+
scw billing invoice list [arg=value ...]
7+
8+
ARGS:
9+
[started-after] Invoice's `start_date` is greater or equal to `started_after`
10+
[started-before] Invoice's `start_date` precedes `started_before`
11+
[invoice-type] Invoice type. It can either be `periodic` or `purchase` (unknown_type | periodic | purchase)
12+
[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)
13+
[organization-id] Organization ID to filter for, only invoices from this Organization will be returned
14+
15+
FLAGS:
16+
-h, --help help for list
17+
18+
GLOBAL FLAGS:
19+
-c, --config string The path to the config file
20+
-D, --debug Enable debug mode
21+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
22+
-p, --profile string The config profile to use
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Invoices management commands.
4+
5+
USAGE:
6+
scw billing invoice <command>
7+
8+
AVAILABLE COMMANDS:
9+
download Download billing resources
10+
list List billing resources
11+
12+
FLAGS:
13+
-h, --help help for invoice
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use
20+
21+
Use "scw billing invoice [command] --help" for more information about a command.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Billing API.
4+
5+
USAGE:
6+
scw billing <command>
7+
8+
AVAILABLE COMMANDS:
9+
invoice Invoices management commands
10+
11+
FLAGS:
12+
-h, --help help for billing
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
19+
20+
Use "scw billing [command] --help" for more information about a command.

cmd/scw/testdata/test-main-usage-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ AVAILABLE COMMANDS:
88
apple-silicon Apple silicon API
99
autocomplete Autocomplete related commands
1010
baremetal Elastic Metal API
11+
billing This API allows you to query your consumption
1112
cockpit Cockpit API
1213
container Container as a Service API
1314
dns Domains and DNS API

docs/commands/billing.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!-- DO NOT EDIT: this file is automatically generated using scw-doc-gen -->
2+
# Documentation for `scw billing`
3+
Billing API.
4+
5+
- [Invoices management commands](#invoices-management-commands)
6+
- [Download billing resources](#download-billing-resources)
7+
- [List billing resources](#list-billing-resources)
8+
9+
10+
## Invoices management commands
11+
12+
Invoices management commands.
13+
14+
15+
### Download billing resources
16+
17+
Download billing resources.
18+
19+
**Usage:**
20+
21+
```
22+
scw billing invoice download [arg=value ...]
23+
```
24+
25+
26+
**Args:**
27+
28+
| Name | | Description |
29+
|------|---|-------------|
30+
| invoice-id | Required | Invoice ID |
31+
| file-path | Default: `./` | Wanted file path |
32+
| file-type | Default: `pdf` | Wanted file extension |
33+
| force-replace | Default: `false` | Force file replacement |
34+
35+
36+
37+
### List billing resources
38+
39+
List billing resources.
40+
41+
**Usage:**
42+
43+
```
44+
scw billing invoice list [arg=value ...]
45+
```
46+
47+
48+
**Args:**
49+
50+
| Name | | Description |
51+
|------|---|-------------|
52+
| started-after | | Invoice's `start_date` is greater or equal to `started_after` |
53+
| started-before | | Invoice's `start_date` precedes `started_before` |
54+
| invoice-type | One of: `unknown_type`, `periodic`, `purchase` | Invoice type. It can either be `periodic` or `purchase` |
55+
| 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 |
56+
| organization-id | | Organization ID to filter for, only invoices from this Organization will be returned |
57+
58+
59+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package billing
2+
3+
import (
4+
"github.com/fatih/color"
5+
"github.com/scaleway/scaleway-cli/v2/internal/core"
6+
"github.com/scaleway/scaleway-cli/v2/internal/human"
7+
billing "github.com/scaleway/scaleway-sdk-go/api/billing/v2alpha1"
8+
)
9+
10+
var (
11+
invoiceTypeMarshalSpecs = human.EnumMarshalSpecs{
12+
billing.DownloadInvoiceRequestFileTypePdf: &human.EnumMarshalSpec{Attribute: color.FgHiBlue, Value: "pdf"},
13+
}
14+
)
15+
16+
func GetCommands() *core.Commands {
17+
cmds := GetGeneratedCommands()
18+
19+
human.RegisterMarshalerFunc(billing.DownloadInvoiceRequestFileType("pdf"), human.EnumMarshalFunc(invoiceTypeMarshalSpecs))
20+
cmds.MustFind("billing", "invoice", "download").Override(buildDownloadCommand)
21+
return cmds
22+
}

0 commit comments

Comments
 (0)