Skip to content

Commit b46f97c

Browse files
feat(billing): enable cli billing (#2911)
Co-authored-by: jaime Bernabe <[email protected]>
1 parent f5685ee commit b46f97c

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
4+
package billing
5+
6+
import (
7+
"context"
8+
"reflect"
9+
10+
"github.com/scaleway/scaleway-cli/v2/internal/core"
11+
"github.com/scaleway/scaleway-sdk-go/api/billing/v2alpha1"
12+
"github.com/scaleway/scaleway-sdk-go/scw"
13+
)
14+
15+
// always import dependencies
16+
var (
17+
_ = scw.RegionFrPar
18+
)
19+
20+
func GetGeneratedCommands() *core.Commands {
21+
return core.NewCommands(
22+
billingRoot(),
23+
billingInvoice(),
24+
billingInvoiceList(),
25+
billingInvoiceDownload(),
26+
)
27+
}
28+
func billingRoot() *core.Command {
29+
return &core.Command{
30+
Short: `This API allows you to query your consumption`,
31+
Long: `Billing API.`,
32+
Namespace: "billing",
33+
}
34+
}
35+
36+
func billingInvoice() *core.Command {
37+
return &core.Command{
38+
Short: `Invoices management commands`,
39+
Long: `Invoices management commands.`,
40+
Namespace: "billing",
41+
Resource: "invoice",
42+
}
43+
}
44+
45+
func billingInvoiceList() *core.Command {
46+
return &core.Command{
47+
Short: `List billing resources`,
48+
Long: `List billing resources.`,
49+
Namespace: "billing",
50+
Resource: "invoice",
51+
Verb: "list",
52+
// Deprecated: false,
53+
ArgsType: reflect.TypeOf(billing.ListInvoicesRequest{}),
54+
ArgSpecs: core.ArgSpecs{
55+
{
56+
Name: "started-after",
57+
Short: `Invoice's ` + "`" + `start_date` + "`" + ` is greater or equal to ` + "`" + `started_after` + "`" + ``,
58+
Required: false,
59+
Deprecated: false,
60+
Positional: false,
61+
},
62+
{
63+
Name: "started-before",
64+
Short: `Invoice's ` + "`" + `start_date` + "`" + ` precedes ` + "`" + `started_before` + "`" + ``,
65+
Required: false,
66+
Deprecated: false,
67+
Positional: false,
68+
},
69+
{
70+
Name: "invoice-type",
71+
Short: `Invoice type. It can either be ` + "`" + `periodic` + "`" + ` or ` + "`" + `purchase` + "`" + ``,
72+
Required: false,
73+
Deprecated: false,
74+
Positional: false,
75+
EnumValues: []string{"unknown_type", "periodic", "purchase"},
76+
},
77+
{
78+
Name: "order-by",
79+
Short: `How invoices are ordered in the response`,
80+
Required: false,
81+
Deprecated: false,
82+
Positional: false,
83+
EnumValues: []string{"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"},
84+
},
85+
{
86+
Name: "organization-id",
87+
Short: `Organization ID to filter for, only invoices from this Organization will be returned`,
88+
Required: false,
89+
Deprecated: false,
90+
Positional: false,
91+
},
92+
},
93+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
94+
request := args.(*billing.ListInvoicesRequest)
95+
96+
client := core.ExtractClient(ctx)
97+
api := billing.NewAPI(client)
98+
opts := []scw.RequestOption{scw.WithAllPages()}
99+
resp, err := api.ListInvoices(request, opts...)
100+
if err != nil {
101+
return nil, err
102+
}
103+
return resp.Invoices, nil
104+
105+
},
106+
}
107+
}
108+
109+
func billingInvoiceDownload() *core.Command {
110+
return &core.Command{
111+
Short: `Download billing resources`,
112+
Long: `Download billing resources.`,
113+
Namespace: "billing",
114+
Resource: "invoice",
115+
Verb: "download",
116+
// Deprecated: false,
117+
ArgsType: reflect.TypeOf(billing.DownloadInvoiceRequest{}),
118+
ArgSpecs: core.ArgSpecs{
119+
{
120+
Name: "invoice-id",
121+
Short: `Invoice ID`,
122+
Required: true,
123+
Deprecated: false,
124+
Positional: false,
125+
},
126+
{
127+
Name: "file-type",
128+
Short: `Wanted file type`,
129+
Required: false,
130+
Deprecated: false,
131+
Positional: false,
132+
EnumValues: []string{"pdf"},
133+
},
134+
},
135+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
136+
request := args.(*billing.DownloadInvoiceRequest)
137+
138+
client := core.ExtractClient(ctx)
139+
api := billing.NewAPI(client)
140+
return api.DownloadInvoice(request)
141+
142+
},
143+
}
144+
}

0 commit comments

Comments
 (0)