-
Notifications
You must be signed in to change notification settings - Fork 0
/
calls.go
71 lines (52 loc) · 1.34 KB
/
calls.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package golangzerotierserviceapi
import (
"bytes"
"encoding/json"
)
func (c *Client) JoinNetwork(networkId string) (Network, error) {
var respMap Network
joinData := Join{
AllowDNS: true,
AllowDefault: true,
AllowManaged: true,
AllowGlobal: true,
}
dataJson, err := json.Marshal(joinData)
if err != nil {
return respMap, err
}
data := bytes.NewReader(dataJson)
respBody, err := c.MakePostRequest("/network/"+networkId, data)
if err != nil {
return respMap, err
}
// Unmarshal the JSON response into the respMap struct
if err := json.Unmarshal(respBody, &respMap); err != nil {
return respMap, err
}
return respMap, err
}
func (c *Client) LeaveNetwork(networkId string) (LeaveNetwork, error) {
var respMap LeaveNetwork
respBody, err := c.MakeDeleteRequest("/network/" + networkId)
if err != nil {
return respMap, err
}
// Unmarshal the JSON response into the respMap struct
if err := json.Unmarshal(respBody, &respMap); err != nil {
return respMap, err
}
return respMap, err
}
func (c *Client) GetNetworkStatus() (Status, error) {
var respMap Status
respBody, err := c.MakeGetRequest("/status")
if err != nil {
return respMap, err
}
// Unmarshal the JSON response into the respMap struct
if err := json.Unmarshal(respBody, &respMap); err != nil {
return respMap, err
}
return respMap, err
}