-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.go
More file actions
56 lines (52 loc) · 1.83 KB
/
node.go
File metadata and controls
56 lines (52 loc) · 1.83 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
package explorerclient
import (
"net/http"
"net/url"
)
// Node represents a node
type Node struct {
ID int64 `json:"id"`
Hostname string `json:"hostname"`
NodeID string `json:"node_id"`
NodeIDV1 string `json:"node_id_v1"`
FarmID int64 `json:"farm_id"`
OsVersion string `json:"os_version"`
Created Date `json:"created"`
Updated Date `json:"updated"`
Uptime int64 `json:"uptime"`
Address string `json:"address"`
Location Location `json:"location"`
TotalResources ResourceAmount `json:"total_resources"`
UsedResources ResourceAmount `json:"used_resources"`
ReservedResources ResourceAmount `json:"reserved_resources"`
Workloads WorkloadAmount `json:"workloads"`
Proofs []Proof `json:"proofs"`
Ifaces []Iface `json:"ifaces"`
PublicConfig *PublicIface `json:"public_config"`
FreeToUse bool `json:"free_to_use"`
Approved bool `json:"approved"`
PublicKeyHex string `json:"public_key_hex"`
WgPorts []int64 `json:"wg_ports"`
}
// ListNodes lists all nodes from on the explorer
func (cl *Client) ListNodes(f *NodeFilter, page *Pager) ([]Node, error) {
nodes := []Node{}
query := url.Values{}
f.Apply(query)
page.apply(query)
_, err := cl.get(cl.geturl("nodes"), query, &nodes, http.StatusOK)
if err != nil {
return nil, err
}
return nodes, nil
}
// GetNode returns the details of a single node
func (cl *Client) GetNode(id string) (*Node, error) {
node := &Node{}
query := url.Values{}
_, err := cl.get(cl.geturl("nodes", id), query, node, http.StatusOK)
if err != nil {
return nil, err
}
return node, nil
}