Skip to content

Commit f06e865

Browse files
Create v2 monthly transfer struct and function with 64 bits variables (#713)
* Create v2 monthly transfer struct and function with 64 bits variables * Add test * Clean up * Fix test
1 parent 8544eb1 commit f06e865

6 files changed

Lines changed: 215 additions & 69 deletions

File tree

instances.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type InstanceTransfer struct {
120120
}
121121

122122
// MonthlyInstanceTransferStats pool stats for a Linode Instance network transfer statistics for a specific month
123+
// Deprecated: use MonthlyInstanceTransferStatsV2 for new implementations
123124
type MonthlyInstanceTransferStats struct {
124125
// The amount of inbound public network traffic received by this Linode, in bytes, for a specific year/month.
125126
BytesIn int `json:"bytes_in"`
@@ -131,6 +132,18 @@ type MonthlyInstanceTransferStats struct {
131132
BytesTotal int `json:"bytes_total"`
132133
}
133134

135+
// MonthlyInstanceTransferStatsV2 pool stats for a Linode Instance network transfer statistics for a specific month
136+
type MonthlyInstanceTransferStatsV2 struct {
137+
// The amount of inbound public network traffic received by this Linode, in bytes, for a specific year/month.
138+
BytesIn uint64 `json:"bytes_in"`
139+
140+
// The amount of outbound public network traffic sent by this Linode, in bytes, for a specific year/month.
141+
BytesOut uint64 `json:"bytes_out"`
142+
143+
// The total amount of public network traffic sent and received by this Linode, in bytes, for a specific year/month.
144+
BytesTotal uint64 `json:"bytes_total"`
145+
}
146+
134147
// InstancePlacementGroup represents information about the placement group
135148
// this Linode is a part of.
136149
type InstancePlacementGroup struct {
@@ -320,6 +333,12 @@ func (c *Client) GetInstanceTransferMonthly(ctx context.Context, linodeID, year,
320333
return doGETRequest[MonthlyInstanceTransferStats](ctx, c, e)
321334
}
322335

336+
// GetInstanceTransferMonthlyV2 gets the instance's network transfer pool statistics for a specific month.
337+
func (c *Client) GetInstanceTransferMonthlyV2(ctx context.Context, linodeID, year, month int) (*MonthlyInstanceTransferStatsV2, error) {
338+
e := formatAPIPath("linode/instances/%d/transfer/%d/%d", linodeID, year, month)
339+
return doGETRequest[MonthlyInstanceTransferStatsV2](ctx, c, e)
340+
}
341+
323342
// CreateInstance creates a Linode instance
324343
func (c *Client) CreateInstance(ctx context.Context, opts InstanceCreateOptions) (*Instance, error) {
325344
return doPOSTRequest[Instance](ctx, c, "linode/instances", opts)

0 commit comments

Comments
 (0)