-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmetrics.go
More file actions
38 lines (27 loc) · 747 Bytes
/
metrics.go
File metadata and controls
38 lines (27 loc) · 747 Bytes
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
package coreclient
import (
"bytes"
"encoding/json"
"github.com/datarhei/core-client-go/v16/api"
)
func (r *restclient) MetricsList() ([]api.MetricsDescription, error) {
descriptions := []api.MetricsDescription{}
data, err := r.call("GET", "/v3/metrics", "application/json", nil)
if err != nil {
return descriptions, err
}
err = json.Unmarshal(data, &descriptions)
return descriptions, err
}
func (r *restclient) Metrics(query api.MetricsQuery) (api.MetricsResponse, error) {
var m api.MetricsResponse
var buf bytes.Buffer
e := json.NewEncoder(&buf)
e.Encode(query)
data, err := r.call("POST", "/v3/metrics", "application/json", &buf)
if err != nil {
return m, err
}
err = json.Unmarshal(data, &m)
return m, err
}