Skip to content

Commit e026302

Browse files
committed
add signature for farm functions
1 parent a5af1e7 commit e026302

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

node-registrar/client/farm.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package client
2+
3+
import "fmt"
4+
5+
var ErrorFarmNotFround = fmt.Errorf("failed to get requested farm from node regiatrar")
6+
7+
func (c RegistrarClient) CreateFarm(farmName string, twinID uint64, dedicated bool) (farm Farm, err error) {
8+
return
9+
}
10+
11+
func (c RegistrarClient) UpdateFarm(farmID uint64, farmName string) (err error) {
12+
return
13+
}
14+
15+
func (c RegistrarClient) GetFarm(id uint64) (farm Farm, err error) {
16+
return
17+
}
18+
19+
func (c RegistrarClient) ListFarms(opts ...FarmOpts) (farms []Farm, err error) {
20+
return
21+
}
22+
23+
type farmCfg struct {
24+
farmName string
25+
farmID uint64
26+
twinID uint64
27+
page uint32
28+
size uint32
29+
}
30+
31+
type FarmOpts func(*farmCfg)
32+
33+
func FarmWithName(name string) FarmOpts {
34+
return func(n *farmCfg) {
35+
n.farmName = name
36+
}
37+
}
38+
39+
func FarmWithFarmID(id uint64) FarmOpts {
40+
return func(n *farmCfg) {
41+
n.farmID = id
42+
}
43+
}
44+
45+
func FarmWithTwinID(id uint64) FarmOpts {
46+
return func(n *farmCfg) {
47+
n.twinID = id
48+
}
49+
}
50+
51+
func FarmWithPage(page uint32) FarmOpts {
52+
return func(n *farmCfg) {
53+
n.page = page
54+
}
55+
}
56+
57+
func FarmWithSize(size uint32) FarmOpts {
58+
return func(n *farmCfg) {
59+
n.size = size
60+
}
61+
}

node-registrar/client/types.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package client
2+
3+
import (
4+
"time"
5+
)
6+
7+
type Account struct {
8+
TwinID uint64 `json:"twin_id"`
9+
Relays []string `json:"relays"` // Optional list of relay domains
10+
RMBEncKey string `json:"rmb_enc_key"` // Optional base64 encoded public key for rmb communication
11+
PublicKey string `json:"public_key"`
12+
}
13+
14+
type Farm struct {
15+
FarmID uint64 `json:"farm_id"`
16+
FarmName string `json:"farm_name"`
17+
TwinID uint64 `json:"twin_id"`
18+
Dedicated bool `json:"dedicated"`
19+
}
20+
21+
type Node struct {
22+
NodeID uint64 `json:"node_id"`
23+
FarmID uint64 `json:"farm_id"`
24+
TwinID uint64 `json:"twin_id"`
25+
Location Location `json:"location"`
26+
Resources Resources `json:"resources"`
27+
Interfaces []Interface `json:"interface"`
28+
SecureBoot bool `json:"secure_boot"`
29+
Virtualized bool `json:"virtualized"`
30+
SerialNumber string `json:"serial_number"`
31+
UptimeReports []UptimeReport `json:"uptime"`
32+
Approved bool
33+
}
34+
35+
type UptimeReport struct {
36+
ID uint64
37+
NodeID uint64 `json:"node_id"`
38+
Duration time.Duration `json:"duration"`
39+
Timestamp time.Time `json:"timestamp"`
40+
WasRestart bool `json:"was_restart"`
41+
}
42+
43+
type ZosVersion struct {
44+
Version string `json:"version"`
45+
SafeToUpgrade bool `json:"safe_to_upgrade"`
46+
}
47+
48+
type Interface struct {
49+
Name string `json:"name"`
50+
Mac string `json:"mac"`
51+
IPs string `json:"ips"`
52+
}
53+
54+
type Resources struct {
55+
HRU uint64 `json:"hru"`
56+
SRU uint64 `json:"sru"`
57+
CRU uint64 `json:"cru"`
58+
MRU uint64 `json:"mru"`
59+
}
60+
61+
type Location struct {
62+
Country string `json:"country"`
63+
City string `json:"city"`
64+
Longitude string `json:"longitude"`
65+
Latitude string `json:"latitude"`
66+
}

0 commit comments

Comments
 (0)