mirror of
https://github.com/datarhei/core.git
synced 2025-10-07 08:51:04 +08:00
Add basic node handling
This commit is contained in:
25
client/metrics.go
Normal file
25
client/metrics.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/datarhei/core/v16/http/api"
|
||||
)
|
||||
|
||||
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", "/metrics", "application/json", &buf)
|
||||
if err != nil {
|
||||
return m, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &m)
|
||||
|
||||
return m, err
|
||||
}
|
Reference in New Issue
Block a user