diff --git a/vendor/github.com/henrikhodne/go-librato/librato/alerts.go b/vendor/github.com/henrikhodne/go-librato/librato/alerts.go index 88aac98..4080cd8 100644 --- a/vendor/github.com/henrikhodne/go-librato/librato/alerts.go +++ b/vendor/github.com/henrikhodne/go-librato/librato/alerts.go @@ -23,6 +23,8 @@ type Alert struct { Description *string `json:"description,omitempty"` Active *bool `json:"active,omitempty"` RearmSeconds *uint `json:"rearm_seconds,omitempty"` + // Required for older "mixed mode" source & tags Librato accounts + Md *bool `json:"md,omitempty"` } func (a Alert) String() string { @@ -31,13 +33,21 @@ func (a Alert) String() string { // AlertCondition represents an alert trigger condition. type AlertCondition struct { - Type *string `json:"type,omitempty"` - MetricName *string `json:"metric_name,omitempty"` - Source *string `json:"source,omitempty"` - DetectReset *bool `json:"detect_reset,omitempty"` - Threshold *float64 `json:"threshold,omitempty"` - SummaryFunction *string `json:"summary_function,omitempty"` - Duration *uint `json:"duration,omitempty"` + ID *uint `json:"id,omitempty"` + Type *string `json:"type"` + MetricName *string `json:"metric_name"` + Source *string `json:"source,omitempty"` + Tags []AlertConditionTagSet `json:"tags,omitempty"` + DetectReset *bool `json:"detect_reset,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + SummaryFunction *string `json:"summary_function,omitempty"` + Duration *uint `json:"duration,omitempty"` +} + +type AlertConditionTagSet struct { + Name *string `json:"name"` + Grouped *bool `json:"grouped,omitempty"` + Values []*string `json:"values"` } // AlertAttributes represents the attributes of an alert. diff --git a/vendor/github.com/henrikhodne/go-librato/librato/client.go b/vendor/github.com/henrikhodne/go-librato/librato/client.go index 924454d..edfc1dd 100644 --- a/vendor/github.com/henrikhodne/go-librato/librato/client.go +++ b/vendor/github.com/henrikhodne/go-librato/librato/client.go @@ -161,6 +161,33 @@ type ErrorResponse struct { Errors ErrorResponseMessages `json:"errors"` } +// RenderErrorFromArray returns a string with the parameter errors +func RenderErrorFromArray(errors []interface{}) string { + buf := new(bytes.Buffer) + + for _, err := range errors { + fmt.Fprintf(buf, " %s,", err.(string)) + } + + return buf.String() +} + +// RenderErrorFromMap returns a string with the parameter errors +// (e.g. from Conditions) +func RenderErrorFromMap(errors map[string]interface{}) string { + buf := new(bytes.Buffer) + + for cond, condErrs := range errors { + fmt.Fprintf(buf, " %s:", cond) + for _, err := range condErrs.([]interface{}) { + fmt.Fprintf(buf, " %s,", err.(string)) + } + + } + + return buf.String() +} + func (er *ErrorResponse) Error() string { buf := new(bytes.Buffer) @@ -168,8 +195,13 @@ func (er *ErrorResponse) Error() string { buf.WriteString(" Parameter errors:") for param, errs := range er.Errors.Params { fmt.Fprintf(buf, " %s:", param) - for _, err := range errs { - fmt.Fprintf(buf, " %s,", err) + switch errs.(type) { + case []interface{}: + buf.WriteString(RenderErrorFromArray(errs.([]interface{}))) + case map[string]interface{}: + buf.WriteString(RenderErrorFromMap(errs.(map[string]interface{}))) + default: + buf.WriteString(" could not parse parameter errors") } } buf.WriteString(".") @@ -202,9 +234,13 @@ func (er *ErrorResponse) Error() string { // ErrorResponseMessages contains error messages returned from the Librato API. type ErrorResponseMessages struct { - Params map[string][]string `json:"params,omitempty"` - Request []string `json:"request,omitempty"` - System []string `json:"system,omitempty"` + Params map[string]interface{} `json:"params,omitempty"` + Request []string `json:"request,omitempty"` + System []string `json:"system,omitempty"` +} + +type ConditionParamError struct { + Condition map[string][]string `json:"conditions,omitempty"` } // CheckResponse checks the API response for errors; and returns them if diff --git a/vendor/vendor.json b/vendor/vendor.json index 43d2c69..8fe9608 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -495,10 +495,10 @@ "revisionTime": "2016-07-20T23:31:40Z" }, { - "checksumSHA1": "era7cPiPrCcdoEeHB+kNNYLODfg=", + "checksumSHA1": "o9U0fbkAJEUAszp4RHNjrCZaaX0=", "path": "github.com/henrikhodne/go-librato/librato", - "revision": "f82d1c74e11de20191cc53b762a2217d582b0596", - "revisionTime": "2017-06-05T03:23:04Z" + "revision": "92cd9647dc6914b228205c03def7f57f7248fbe8", + "revisionTime": "2017-06-25T18:27:10Z" }, { "checksumSHA1": "0ZrwvB6KoGPj2PoDNSEJwxQ6Mog=",