-
Notifications
You must be signed in to change notification settings - Fork 4
/
session.go
41 lines (29 loc) · 884 Bytes
/
session.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
package coreclient
import (
"encoding/json"
"net/url"
"strings"
"github.com/datarhei/core-client-go/v16/api"
)
func (r *restclient) Sessions(collectors []string) (api.SessionsSummary, error) {
var sessions api.SessionsSummary
values := url.Values{}
values.Set("collectors", strings.Join(collectors, ","))
data, err := r.call("GET", "/v3/sessions?"+values.Encode(), "", nil)
if err != nil {
return sessions, err
}
err = json.Unmarshal(data, &sessions)
return sessions, err
}
func (r *restclient) SessionsActive(collectors []string) (api.SessionsActive, error) {
var sessions api.SessionsActive
values := url.Values{}
values.Set("collectors", strings.Join(collectors, ","))
data, err := r.call("GET", "/v3/sessions/active?"+values.Encode(), "", nil)
if err != nil {
return sessions, err
}
err = json.Unmarshal(data, &sessions)
return sessions, err
}