author | Mikael Berthe <mikael@lilotux.net> |
Mon, 30 May 2022 18:45:45 +0200 | |
changeset 256 | 6d748fac6eb2 |
parent 239 | ca5639b4768e |
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 |
238
1c0042e76902
Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
16 |
if err := mc.apiCall("v1/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 |
221
f9228d1f4267
instance activity: Add a WeekActivity type
Mikael Berthe <mikael@lilotux.net>
parents:
211
diff
changeset
|
23 |
// The peers are defined as the domains of users the instance has previously |
f9228d1f4267
instance activity: Add a WeekActivity type
Mikael Berthe <mikael@lilotux.net>
parents:
211
diff
changeset
|
24 |
// resolved. |
211
12f0761e6442
Add new type InstancePeer
Mikael Berthe <mikael@lilotux.net>
parents:
210
diff
changeset
|
25 |
func (mc *Client) GetInstancePeers() ([]InstancePeer, error) { |
12f0761e6442
Add new type InstancePeer
Mikael Berthe <mikael@lilotux.net>
parents:
210
diff
changeset
|
26 |
var peers []InstancePeer |
238
1c0042e76902
Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
27 |
if err := mc.apiCall("v1/instance/peers", rest.Get, nil, nil, nil, &peers); err != nil { |
210
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
28 |
return nil, err |
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 |
return peers, nil |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
31 |
} |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
32 |
|
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
33 |
// GetInstanceActivity returns current instance activity |
238
1c0042e76902
Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
34 |
// The activity contains the counts of active users, locally posted statuses, |
1c0042e76902
Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
35 |
// and new registrations in weekly buckets. |
221
f9228d1f4267
instance activity: Add a WeekActivity type
Mikael Berthe <mikael@lilotux.net>
parents:
211
diff
changeset
|
36 |
func (mc *Client) GetInstanceActivity() ([]WeekActivity, error) { |
f9228d1f4267
instance activity: Add a WeekActivity type
Mikael Berthe <mikael@lilotux.net>
parents:
211
diff
changeset
|
37 |
var activity []WeekActivity |
238
1c0042e76902
Do not use a global API version
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
38 |
if err := mc.apiCall("v1/instance/activity", rest.Get, nil, nil, nil, &activity); err != nil { |
210
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
39 |
return nil, err |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
40 |
} |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
41 |
return activity, nil |
3f1f5cb7ae70
Initial instance statistics (peers/activity) support
Mikael Berthe <mikael@lilotux.net>
parents:
207
diff
changeset
|
42 |
} |