author | Mikael Berthe <mikael@lilotux.net> |
Tue, 20 Mar 2018 13:11:26 +0100 | |
changeset 211 | 12f0761e6442 |
parent 210 | 3f1f5cb7ae70 |
child 221 | f9228d1f4267 |
permissions | -rw-r--r-- |
130 | 1 |
/* |
207 | 2 |
Copyright 2017-2018 Mikael Berthe |
130 | 3 |
|
4 |
Licensed under the MIT license. Please see the LICENSE file is this directory. |
|
5 |
*/ |
|
6 |
||
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
7 |
package madon |
112 | 8 |
|
9 |
import ( |
|
10 |
"github.com/sendgrid/rest" |
|
11 |
) |
|
12 |
||
13 |
// GetCurrentInstance returns current instance information |
|
138
23d3a518d0ad
Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents:
130
diff
changeset
|
14 |
func (mc *Client) GetCurrentInstance() (*Instance, error) { |
112 | 15 |
var i Instance |
155 | 16 |
if err := mc.apiCall("instance", rest.Get, nil, nil, nil, &i); err != nil { |
120 | 17 |
return nil, err |
112 | 18 |
} |
19 |
return &i, nil |
|
20 |
} |
|
210
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
21 |
|
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
22 |
// GetInstancePeers returns current instance peers |
211
12f0761e6442
Add new type InstancePeer
Mikael Berthe <mikael@lilotux.net>
parents:
210
diff
changeset
|
23 |
func (mc *Client) GetInstancePeers() ([]InstancePeer, error) { |
12f0761e6442
Add new type InstancePeer
Mikael Berthe <mikael@lilotux.net>
parents:
210
diff
changeset
|
24 |
var peers []InstancePeer |
210
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
25 |
if err := mc.apiCall("instance/peers", rest.Get, nil, nil, nil, &peers); err != nil { |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
26 |
return nil, err |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
27 |
} |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
28 |
return peers, nil |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
29 |
} |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
30 |
|
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
31 |
// GetInstanceActivity returns current instance activity |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
32 |
func (mc *Client) GetInstanceActivity() (interface{}, error) { |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
33 |
var activity interface{} |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
34 |
if err := mc.apiCall("instance/activity", rest.Get, nil, nil, nil, &activity); err != nil { |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
35 |
return nil, err |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
36 |
} |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
37 |
return activity, nil |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
38 |
} |