-
Notifications
You must be signed in to change notification settings - Fork 8
/
instance.go
44 lines (37 loc) · 1.3 KB
/
instance.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
37
38
39
40
41
42
43
44
package metadata
import "context"
// InstanceBackupsData contains information about
// the current Linode instance's backups enrollment.
type InstanceBackupsData struct {
Enabled bool `json:"enabled"`
Status *string `json:"status"`
}
// InstanceSpecsData contains various information about
// the specifications of the current Linode instance.
type InstanceSpecsData struct {
VCPUs int `json:"vcpus"`
Memory int `json:"memory"`
GPUs int `json:"gpus"`
Transfer int `json:"transfer"`
Disk int `json:"disk"`
}
// InstanceData contains various metadata about the current Linode instance.
type InstanceData struct {
ID int `json:"id"`
Label string `json:"label"`
Region string `json:"region"`
Type string `json:"type"`
HostUUID string `json:"host_uuid"`
Tags []string `json:"tags"`
Specs InstanceSpecsData `json:"specs"`
Backups InstanceBackupsData `json:"backups"`
}
// GetInstance gets various information about the current instance.
func (c *Client) GetInstance(ctx context.Context) (*InstanceData, error) {
req := c.R(ctx).SetResult(&InstanceData{})
resp, err := coupleAPIErrors(req.Get("instance"))
if err != nil {
return nil, err
}
return resp.Result().(*InstanceData), nil
}