-
Notifications
You must be signed in to change notification settings - Fork 33
/
graph_defs.go
30 lines (25 loc) · 951 Bytes
/
graph_defs.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
package mackerel
import "net/http"
// GraphDefsParam parameters for posting graph definitions
type GraphDefsParam struct {
Name string `json:"name"`
DisplayName string `json:"displayName,omitempty"`
Unit string `json:"unit,omitempty"`
Metrics []*GraphDefsMetric `json:"metrics"`
}
// GraphDefsMetric graph metric
type GraphDefsMetric struct {
Name string `json:"name"`
DisplayName string `json:"displayName,omitempty"`
IsStacked bool `json:"isStacked"`
}
// CreateGraphDefs creates graph definitions.
func (c *Client) CreateGraphDefs(graphDefs []*GraphDefsParam) error {
_, err := requestPost[any](c, "/api/v0/graph-defs/create", graphDefs)
return err
}
// DeleteGraphDef deletes a graph definition.
func (c *Client) DeleteGraphDef(name string) error {
_, err := requestJSON[any](c, http.MethodDelete, "/api/v0/graph-defs", map[string]string{"name": name})
return err
}