forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metric_cluster.go
57 lines (44 loc) · 1.19 KB
/
metric_cluster.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package circonus
import (
"fmt"
"github.com/circonus-labs/circonus-gometrics/api"
"github.com/hashicorp/errwrap"
)
type circonusMetricCluster struct {
api.MetricCluster
}
func newMetricCluster() circonusMetricCluster {
return circonusMetricCluster{
MetricCluster: api.MetricCluster{},
}
}
func loadMetricCluster(ctxt *providerContext, cid api.CIDType) (circonusMetricCluster, error) {
var mc circonusMetricCluster
cmc, err := ctxt.client.FetchMetricCluster(cid, "")
if err != nil {
return circonusMetricCluster{}, err
}
mc.MetricCluster = *cmc
return mc, nil
}
func (mc *circonusMetricCluster) Create(ctxt *providerContext) error {
cmc, err := ctxt.client.CreateMetricCluster(&mc.MetricCluster)
if err != nil {
return err
}
mc.CID = cmc.CID
return nil
}
func (mc *circonusMetricCluster) Update(ctxt *providerContext) error {
_, err := ctxt.client.UpdateMetricCluster(&mc.MetricCluster)
if err != nil {
return errwrap.Wrapf(fmt.Sprintf("Unable to update stream group %s: {{err}}", mc.CID), err)
}
return nil
}
func (mc *circonusMetricCluster) Validate() error {
if len(mc.Queries) < 1 {
return fmt.Errorf("there must be at least one stream group query present")
}
return nil
}