instance_stats.go raw

   1  package linodego
   2  
   3  import (
   4  	"context"
   5  )
   6  
   7  // StatsNet represents a network stats object
   8  type StatsNet struct {
   9  	In         [][]float64 `json:"in"`
  10  	Out        [][]float64 `json:"out"`
  11  	PrivateIn  [][]float64 `json:"private_in"`
  12  	PrivateOut [][]float64 `json:"private_out"`
  13  }
  14  
  15  // StatsIO represents an IO stats object
  16  type StatsIO struct {
  17  	IO   [][]float64 `json:"io"`
  18  	Swap [][]float64 `json:"swap"`
  19  }
  20  
  21  // InstanceStatsData represents an instance stats data object
  22  type InstanceStatsData struct {
  23  	CPU   [][]float64 `json:"cpu"`
  24  	IO    StatsIO     `json:"io"`
  25  	NetV4 StatsNet    `json:"netv4"`
  26  	NetV6 StatsNet    `json:"netv6"`
  27  }
  28  
  29  // InstanceStats represents an instance stats object
  30  type InstanceStats struct {
  31  	Title string            `json:"title"`
  32  	Data  InstanceStatsData `json:"data"`
  33  }
  34  
  35  // GetInstanceStats gets the template with the provided ID
  36  func (c *Client) GetInstanceStats(ctx context.Context, linodeID int) (*InstanceStats, error) {
  37  	e := formatAPIPath("linode/instances/%d/stats", linodeID)
  38  	return doGETRequest[InstanceStats](ctx, c, e)
  39  }
  40  
  41  // GetInstanceStatsByDate gets the template with the provided ID, year, and month
  42  func (c *Client) GetInstanceStatsByDate(ctx context.Context, linodeID int, year int, month int) (*InstanceStats, error) {
  43  	e := formatAPIPath("linode/instances/%d/stats/%d/%d", linodeID, year, month)
  44  	return doGETRequest[InstanceStats](ctx, c, e)
  45  }
  46