Skip to content

Commit c2cbd30

Browse files
tdannenmullerThomas Dannenmuller
andauthored
Add billing_period filter to scaleway_billing_consumption table (#154)
Co-authored-by: Thomas Dannenmuller <thomas.dannenmuller@opendigitaleduction.com>
1 parent 8e330ed commit c2cbd30

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/tables/scaleway_billing_consumption.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Scaleway Billing Consumption tracks the costs of various scaleway products such
99

1010
**Important Notes**
1111
- This table requires an Organization ID to be configured in the `scaleway.spc` file.
12+
- You can optionally filter by `billing_period` (format: YYYY-MM) to query specific months.
1213

1314
## Table Usage Guide
1415

scaleway/table_scaleway_billing_consumption.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,19 @@ func tableScalewayBillingConsumption(_ context.Context) *plugin.Table {
2525
Name: "category_name",
2626
Require: plugin.Optional,
2727
},
28+
{
29+
Name: "billing_period",
30+
Require: plugin.Optional,
31+
},
2832
},
2933
},
3034
Columns: []*plugin.Column{
35+
{
36+
Name: "billing_period",
37+
Description: "The billing period filter used in the query (YYYY-MM format). Note: This reflects the filter value, not API data.",
38+
Type: proto.ColumnType_STRING,
39+
Transform: transform.FromQual("billing_period"),
40+
},
3141
{
3242
Name: "category_name",
3343
Description: "The CategoryName: name of consumption category.",
@@ -106,6 +116,10 @@ func listBillingConsumption(ctx context.Context, d *plugin.QueryData, _ *plugin.
106116
req.CategoryName = scw.StringPtr(quals["category_name"].GetStringValue())
107117
}
108118

119+
if quals["billing_period"] != nil {
120+
req.BillingPeriod = scw.StringPtr(quals["billing_period"].GetStringValue())
121+
}
122+
109123
// Retrieve the list of consumptions
110124
maxResult := int64(100)
111125

0 commit comments

Comments
 (0)