forked from linode/linodego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodebalancer_stats.go
36 lines (30 loc) · 973 Bytes
/
nodebalancer_stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package linodego
import (
"context"
"fmt"
)
// NodeBalancerStats represents a nodebalancer stats object
type NodeBalancerStats struct {
Title string `json:"title"`
Data NodeBalancerStatsData `json:"data"`
}
// NodeBalancerStatsData represents a nodebalancer stats data object
type NodeBalancerStatsData struct {
Connections [][]float64 `json:"connections"`
Traffic StatsTraffic `json:"traffic"`
}
// StatsTraffic represents a Traffic stats object
type StatsTraffic struct {
In [][]float64 `json:"in"`
Out [][]float64 `json:"out"`
}
// GetNodeBalancerStats gets the template with the provided ID
func (c *Client) GetNodeBalancerStats(ctx context.Context, nodebalancerID int) (*NodeBalancerStats, error) {
e := fmt.Sprintf("nodebalancers/%d/stats", nodebalancerID)
req := c.R(ctx).SetResult(&NodeBalancerStats{})
r, err := coupleAPIErrors(req.Get(e))
if err != nil {
return nil, err
}
return r.Result().(*NodeBalancerStats), nil
}