provider/librato: Update based on Librato API changes (#15060)
* Update the vendored librato client * Update librato API endpoints - update API methods - fix a few lint errors
This commit is contained in:
parent
fa1a6ab419
commit
9000f2fc31
|
@ -23,61 +23,61 @@ func resourceLibratoAlert() *schema.Resource {
|
||||||
Delete: resourceLibratoAlertDelete,
|
Delete: resourceLibratoAlertDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
},
|
},
|
||||||
"description": &schema.Schema{
|
"description": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"active": &schema.Schema{
|
"active": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: true,
|
Default: true,
|
||||||
},
|
},
|
||||||
"rearm_seconds": &schema.Schema{
|
"rearm_seconds": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: 600,
|
Default: 600,
|
||||||
},
|
},
|
||||||
"services": &schema.Schema{
|
"services": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Schema{Type: schema.TypeString},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
Set: schema.HashString,
|
Set: schema.HashString,
|
||||||
},
|
},
|
||||||
"condition": &schema.Schema{
|
"condition": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"type": &schema.Schema{
|
"type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"metric_name": &schema.Schema{
|
"metric_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"source": &schema.Schema{
|
"source": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"detect_reset": &schema.Schema{
|
"detect_reset": {
|
||||||
Type: schema.TypeBool,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"duration": &schema.Schema{
|
"duration": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"threshold": &schema.Schema{
|
"threshold": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"summary_function": &schema.Schema{
|
"summary_function": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
@ -85,12 +85,12 @@ func resourceLibratoAlert() *schema.Resource {
|
||||||
},
|
},
|
||||||
Set: resourceLibratoAlertConditionsHash,
|
Set: resourceLibratoAlertConditionsHash,
|
||||||
},
|
},
|
||||||
"attributes": &schema.Schema{
|
"attributes": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"runbook_url": &schema.Schema{
|
"runbook_url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
@ -112,9 +112,9 @@ func resourceLibratoAlertConditionsHash(v interface{}) int {
|
||||||
buf.WriteString(fmt.Sprintf("%s-", source.(string)))
|
buf.WriteString(fmt.Sprintf("%s-", source.(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_reset, present := m["detect_reset"]
|
detectReset, present := m["detect_reset"]
|
||||||
if present {
|
if present {
|
||||||
buf.WriteString(fmt.Sprintf("%t-", detect_reset.(bool)))
|
buf.WriteString(fmt.Sprintf("%t-", detectReset.(bool)))
|
||||||
}
|
}
|
||||||
|
|
||||||
duration, present := m["duration"]
|
duration, present := m["duration"]
|
||||||
|
@ -127,9 +127,9 @@ func resourceLibratoAlertConditionsHash(v interface{}) int {
|
||||||
buf.WriteString(fmt.Sprintf("%f-", threshold.(float64)))
|
buf.WriteString(fmt.Sprintf("%f-", threshold.(float64)))
|
||||||
}
|
}
|
||||||
|
|
||||||
summary_function, present := m["summary_function"]
|
summaryFunction, present := m["summary_function"]
|
||||||
if present {
|
if present {
|
||||||
buf.WriteString(fmt.Sprintf("%s-", summary_function.(string)))
|
buf.WriteString(fmt.Sprintf("%s-", summaryFunction.(string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashcode.String(buf.String())
|
return hashcode.String(buf.String())
|
||||||
|
@ -413,9 +413,9 @@ func resourceLibratoAlertUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Updating Librato alert: %s", alert)
|
log.Printf("[INFO] Updating Librato alert: %s", alert)
|
||||||
_, err = client.Alerts.Edit(uint(alertID), alert)
|
_, updErr := client.Alerts.Update(uint(alertID), alert)
|
||||||
if err != nil {
|
if updErr != nil {
|
||||||
return fmt.Errorf("Error updating Librato alert: %s", err)
|
return fmt.Errorf("Error updating Librato alert: %s", updErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Updated Librato alert %d", alertID)
|
log.Printf("[INFO] Updated Librato alert %d", alertID)
|
||||||
|
@ -429,9 +429,9 @@ func resourceLibratoAlertUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
ContinuousTargetOccurence: 5,
|
ContinuousTargetOccurence: 5,
|
||||||
Refresh: func() (interface{}, string, error) {
|
Refresh: func() (interface{}, string, error) {
|
||||||
log.Printf("[DEBUG] Checking if Librato Alert %d was updated yet", alertID)
|
log.Printf("[DEBUG] Checking if Librato Alert %d was updated yet", alertID)
|
||||||
changedAlert, _, err := client.Alerts.Get(uint(alertID))
|
changedAlert, _, getErr := client.Alerts.Get(uint(alertID))
|
||||||
if err != nil {
|
if getErr != nil {
|
||||||
return changedAlert, "", err
|
return changedAlert, "", getErr
|
||||||
}
|
}
|
||||||
isEqual := reflect.DeepEqual(*fullAlert, *changedAlert)
|
isEqual := reflect.DeepEqual(*fullAlert, *changedAlert)
|
||||||
log.Printf("[DEBUG] Updated Librato Alert %d match: %t", alertID, isEqual)
|
log.Printf("[DEBUG] Updated Librato Alert %d match: %t", alertID, isEqual)
|
||||||
|
|
|
@ -151,7 +151,7 @@ func resourceLibratoMetricCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
metric.Attributes = attributes
|
metric.Attributes = attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := client.Metrics.Edit(&metric)
|
_, err := client.Metrics.Update(&metric)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[INFO] ERROR creating Metric: %s", err)
|
log.Printf("[INFO] ERROR creating Metric: %s", err)
|
||||||
return fmt.Errorf("Error creating Librato metric: %s", err)
|
return fmt.Errorf("Error creating Librato metric: %s", err)
|
||||||
|
@ -280,7 +280,7 @@ func resourceLibratoMetricUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
|
|
||||||
log.Printf("[INFO] Updating Librato metric: %v", structToString(metric))
|
log.Printf("[INFO] Updating Librato metric: %v", structToString(metric))
|
||||||
|
|
||||||
_, err := client.Metrics.Edit(metric)
|
_, err := client.Metrics.Update(metric)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error updating Librato metric: %s", err)
|
return fmt.Errorf("Error updating Librato metric: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,23 +21,23 @@ func resourceLibratoService() *schema.Resource {
|
||||||
Delete: resourceLibratoServiceDelete,
|
Delete: resourceLibratoServiceDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"id": &schema.Schema{
|
"id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
"type": &schema.Schema{
|
"type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"title": &schema.Schema{
|
"title": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"settings": &schema.Schema{
|
"settings": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
StateFunc: normalizeJson,
|
StateFunc: normalizeJSON,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func resourceLibratoServicesFlatten(settings map[string]string) (string, error)
|
||||||
return string(byteArray), nil
|
return string(byteArray), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeJson(jsonString interface{}) string {
|
func normalizeJSON(jsonString interface{}) string {
|
||||||
if jsonString == nil || jsonString == "" {
|
if jsonString == nil || jsonString == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ func resourceLibratoServiceCreate(d *schema.ResourceData, meta interface{}) erro
|
||||||
service.Title = librato.String(v.(string))
|
service.Title = librato.String(v.(string))
|
||||||
}
|
}
|
||||||
if v, ok := d.GetOk("settings"); ok {
|
if v, ok := d.GetOk("settings"); ok {
|
||||||
res, err := resourceLibratoServicesExpandSettings(normalizeJson(v.(string)))
|
res, expandErr := resourceLibratoServicesExpandSettings(normalizeJSON(v.(string)))
|
||||||
if err != nil {
|
if expandErr != nil {
|
||||||
return fmt.Errorf("Error expanding Librato service settings: %s", err)
|
return fmt.Errorf("Error expanding Librato service settings: %s", expandErr)
|
||||||
}
|
}
|
||||||
service.Settings = res
|
service.Settings = res
|
||||||
}
|
}
|
||||||
|
@ -174,16 +174,16 @@ func resourceLibratoServiceUpdate(d *schema.ResourceData, meta interface{}) erro
|
||||||
fullService.Title = service.Title
|
fullService.Title = service.Title
|
||||||
}
|
}
|
||||||
if d.HasChange("settings") {
|
if d.HasChange("settings") {
|
||||||
res, err := resourceLibratoServicesExpandSettings(normalizeJson(d.Get("settings").(string)))
|
res, getErr := resourceLibratoServicesExpandSettings(normalizeJSON(d.Get("settings").(string)))
|
||||||
if err != nil {
|
if getErr != nil {
|
||||||
return fmt.Errorf("Error expanding Librato service settings: %s", err)
|
return fmt.Errorf("Error expanding Librato service settings: %s", getErr)
|
||||||
}
|
}
|
||||||
service.Settings = res
|
service.Settings = res
|
||||||
fullService.Settings = res
|
fullService.Settings = res
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] Updating Librato Service %d: %s", serviceID, service)
|
log.Printf("[INFO] Updating Librato Service %d: %s", serviceID, service)
|
||||||
_, err = client.Services.Edit(uint(serviceID), service)
|
_, err = client.Services.Update(uint(serviceID), service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error updating Librato service: %s", err)
|
return fmt.Errorf("Error updating Librato service: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -198,9 +198,9 @@ func resourceLibratoServiceUpdate(d *schema.ResourceData, meta interface{}) erro
|
||||||
ContinuousTargetOccurence: 5,
|
ContinuousTargetOccurence: 5,
|
||||||
Refresh: func() (interface{}, string, error) {
|
Refresh: func() (interface{}, string, error) {
|
||||||
log.Printf("[DEBUG] Checking if Librato Service %d was updated yet", serviceID)
|
log.Printf("[DEBUG] Checking if Librato Service %d was updated yet", serviceID)
|
||||||
changedService, _, err := client.Services.Get(uint(serviceID))
|
changedService, _, getErr := client.Services.Get(uint(serviceID))
|
||||||
if err != nil {
|
if getErr != nil {
|
||||||
return changedService, "", err
|
return changedService, "", getErr
|
||||||
}
|
}
|
||||||
isEqual := reflect.DeepEqual(*fullService, *changedService)
|
isEqual := reflect.DeepEqual(*fullService, *changedService)
|
||||||
log.Printf("[DEBUG] Updated Librato Service %d match: %t", serviceID, isEqual)
|
log.Printf("[DEBUG] Updated Librato Service %d match: %t", serviceID, isEqual)
|
||||||
|
|
|
@ -19,12 +19,12 @@ func resourceLibratoSpace() *schema.Resource {
|
||||||
Delete: resourceLibratoSpaceDelete,
|
Delete: resourceLibratoSpaceDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: false,
|
ForceNew: false,
|
||||||
},
|
},
|
||||||
"id": &schema.Schema{
|
"id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
@ -97,7 +97,7 @@ func resourceLibratoSpaceUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
if d.HasChange("name") {
|
if d.HasChange("name") {
|
||||||
newName := d.Get("name").(string)
|
newName := d.Get("name").(string)
|
||||||
log.Printf("[INFO] Modifying name space attribute for %d: %#v", id, newName)
|
log.Printf("[INFO] Modifying name space attribute for %d: %#v", id, newName)
|
||||||
if _, err = client.Spaces.Edit(uint(id), &librato.Space{Name: &newName}); err != nil {
|
if _, err = client.Spaces.Update(uint(id), &librato.Space{Name: &newName}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,98 +23,98 @@ func resourceLibratoSpaceChart() *schema.Resource {
|
||||||
Delete: resourceLibratoSpaceChartDelete,
|
Delete: resourceLibratoSpaceChartDelete,
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"space_id": &schema.Schema{
|
"space_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"type": &schema.Schema{
|
"type": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"min": &schema.Schema{
|
"min": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Default: math.NaN(),
|
Default: math.NaN(),
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"max": &schema.Schema{
|
"max": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Default: math.NaN(),
|
Default: math.NaN(),
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"label": &schema.Schema{
|
"label": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"related_space": &schema.Schema{
|
"related_space": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"stream": &schema.Schema{
|
"stream": {
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"metric": &schema.Schema{
|
"metric": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ConflictsWith: []string{"stream.composite"},
|
ConflictsWith: []string{"stream.composite"},
|
||||||
},
|
},
|
||||||
"source": &schema.Schema{
|
"source": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ConflictsWith: []string{"stream.composite"},
|
ConflictsWith: []string{"stream.composite"},
|
||||||
},
|
},
|
||||||
"group_function": &schema.Schema{
|
"group_function": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ConflictsWith: []string{"stream.composite"},
|
ConflictsWith: []string{"stream.composite"},
|
||||||
},
|
},
|
||||||
"composite": &schema.Schema{
|
"composite": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ConflictsWith: []string{"stream.metric", "stream.source", "stream.group_function"},
|
ConflictsWith: []string{"stream.metric", "stream.source", "stream.group_function"},
|
||||||
},
|
},
|
||||||
"summary_function": &schema.Schema{
|
"summary_function": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"name": &schema.Schema{
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"color": &schema.Schema{
|
"color": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"units_short": &schema.Schema{
|
"units_short": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"units_long": &schema.Schema{
|
"units_long": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"min": &schema.Schema{
|
"min": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Default: math.NaN(),
|
Default: math.NaN(),
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"max": &schema.Schema{
|
"max": {
|
||||||
Type: schema.TypeFloat,
|
Type: schema.TypeFloat,
|
||||||
Default: math.NaN(),
|
Default: math.NaN(),
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"transform_function": &schema.Schema{
|
"transform_function": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"period": &schema.Schema{
|
"period": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
@ -420,7 +420,7 @@ func resourceLibratoSpaceChartUpdate(d *schema.ResourceData, meta interface{}) e
|
||||||
fullChart.Streams = streams
|
fullChart.Streams = streams
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.Spaces.EditChart(spaceID, uint(chartID), spaceChart)
|
_, err = client.Spaces.UpdateChart(spaceID, uint(chartID), spaceChart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error updating Librato space chart %s: %s", *spaceChart.Name, err)
|
return fmt.Errorf("Error updating Librato space chart %s: %s", *spaceChart.Name, err)
|
||||||
}
|
}
|
||||||
|
@ -434,9 +434,9 @@ func resourceLibratoSpaceChartUpdate(d *schema.ResourceData, meta interface{}) e
|
||||||
ContinuousTargetOccurence: 5,
|
ContinuousTargetOccurence: 5,
|
||||||
Refresh: func() (interface{}, string, error) {
|
Refresh: func() (interface{}, string, error) {
|
||||||
log.Printf("[DEBUG] Checking if Librato Space Chart %d was updated yet", chartID)
|
log.Printf("[DEBUG] Checking if Librato Space Chart %d was updated yet", chartID)
|
||||||
changedChart, _, err := client.Spaces.GetChart(spaceID, uint(chartID))
|
changedChart, _, getErr := client.Spaces.GetChart(spaceID, uint(chartID))
|
||||||
if err != nil {
|
if getErr != nil {
|
||||||
return changedChart, "", err
|
return changedChart, "", getErr
|
||||||
}
|
}
|
||||||
isEqual := reflect.DeepEqual(*fullChart, *changedChart)
|
isEqual := reflect.DeepEqual(*fullChart, *changedChart)
|
||||||
log.Printf("[DEBUG] Updated Librato Space Chart %d match: %t", chartID, isEqual)
|
log.Printf("[DEBUG] Updated Librato Space Chart %d match: %t", chartID, isEqual)
|
||||||
|
|
|
@ -83,10 +83,10 @@ func (a *AlertsService) Create(alert *Alert) (*Alert, *http.Response, error) {
|
||||||
return al, resp, err
|
return al, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit an alert.
|
// Update an alert.
|
||||||
//
|
//
|
||||||
// Librato API docs: https://www.librato.com/docs/api/?shell#update-alert
|
// Librato API docs: https://www.librato.com/docs/api/?shell#update-alert
|
||||||
func (a *AlertsService) Edit(alertID uint, alert *Alert) (*http.Response, error) {
|
func (a *AlertsService) Update(alertID uint, alert *Alert) (*http.Response, error) {
|
||||||
u := fmt.Sprintf("alerts/%d", alertID)
|
u := fmt.Sprintf("alerts/%d", alertID)
|
||||||
req, err := a.client.NewRequest("PUT", u, alert)
|
req, err := a.client.NewRequest("PUT", u, alert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -100,9 +100,9 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ
|
||||||
var buf io.ReadWriter
|
var buf io.ReadWriter
|
||||||
if body != nil {
|
if body != nil {
|
||||||
buf = new(bytes.Buffer)
|
buf = new(bytes.Buffer)
|
||||||
err := json.NewEncoder(buf).Encode(body)
|
encodeErr := json.NewEncoder(buf).Encode(body)
|
||||||
if err != nil {
|
if encodeErr != nil {
|
||||||
return nil, err
|
return nil, encodeErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ type MetricAttributes struct {
|
||||||
DisplayUnitsLong string `json:"display_units_long"`
|
DisplayUnitsLong string `json:"display_units_long"`
|
||||||
DisplayUnitsShort string `json:"display_units_short"`
|
DisplayUnitsShort string `json:"display_units_short"`
|
||||||
DisplayStacked bool `json:"display_stacked"`
|
DisplayStacked bool `json:"display_stacked"`
|
||||||
DisplayTransform string `json:"display_transform"`
|
|
||||||
CreatedByUA string `json:"created_by_ua,omitempty"`
|
CreatedByUA string `json:"created_by_ua,omitempty"`
|
||||||
GapDetection bool `json:"gap_detection,omitempty"`
|
GapDetection bool `json:"gap_detection,omitempty"`
|
||||||
Aggregate bool `json:"aggregate,omitempty"`
|
Aggregate bool `json:"aggregate,omitempty"`
|
||||||
|
@ -136,10 +135,10 @@ type GaugeMeasurement struct {
|
||||||
SumSquares *float64 `json:"sum_squares,omitempty"`
|
SumSquares *float64 `json:"sum_squares,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit metrics
|
// Create metrics
|
||||||
//
|
//
|
||||||
// Librato API docs: https://www.librato.com/docs/api/#create-a-measurement
|
// Librato API docs: https://www.librato.com/docs/api/#create-a-measurement
|
||||||
func (m *MetricsService) Submit(measurements *MeasurementSubmission) (*http.Response, error) {
|
func (m *MetricsService) Create(measurements *MeasurementSubmission) (*http.Response, error) {
|
||||||
req, err := m.client.NewRequest("POST", "/metrics", measurements)
|
req, err := m.client.NewRequest("POST", "/metrics", measurements)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -148,10 +147,10 @@ func (m *MetricsService) Submit(measurements *MeasurementSubmission) (*http.Resp
|
||||||
return m.client.Do(req, nil)
|
return m.client.Do(req, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit a metric.
|
// Update a metric.
|
||||||
//
|
//
|
||||||
// Librato API docs: https://www.librato.com/docs/api/#update-a-metric-by-name
|
// Librato API docs: https://www.librato.com/docs/api/#update-a-metric-by-name
|
||||||
func (m *MetricsService) Edit(metric *Metric) (*http.Response, error) {
|
func (m *MetricsService) Update(metric *Metric) (*http.Response, error) {
|
||||||
u := fmt.Sprintf("metrics/%s", *metric.Name)
|
u := fmt.Sprintf("metrics/%s", *metric.Name)
|
||||||
|
|
||||||
req, err := m.client.NewRequest("PUT", u, metric)
|
req, err := m.client.NewRequest("PUT", u, metric)
|
||||||
|
|
|
@ -63,10 +63,10 @@ func (s *ServicesService) Create(service *Service) (*Service, *http.Response, er
|
||||||
return sv, resp, err
|
return sv, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit a service.
|
// Update a service.
|
||||||
//
|
//
|
||||||
// Librato API docs: https://www.librato.com/docs/api/#update-a-service
|
// Librato API docs: https://www.librato.com/docs/api/#update-a-service
|
||||||
func (s *ServicesService) Edit(serviceID uint, service *Service) (*http.Response, error) {
|
func (s *ServicesService) Update(serviceID uint, service *Service) (*http.Response, error) {
|
||||||
u := fmt.Sprintf("services/%d", serviceID)
|
u := fmt.Sprintf("services/%d", serviceID)
|
||||||
req, err := s.client.NewRequest("PUT", u, service)
|
req, err := s.client.NewRequest("PUT", u, service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -96,10 +96,10 @@ func (s *SpacesService) Create(space *Space) (*Space, *http.Response, error) {
|
||||||
return sp, resp, err
|
return sp, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit a space.
|
// Update a space.
|
||||||
//
|
//
|
||||||
// Librato API docs: http://dev.librato.com/v1/put/spaces/:id
|
// Librato API docs: http://dev.librato.com/v1/put/spaces/:id
|
||||||
func (s *SpacesService) Edit(spaceID uint, space *Space) (*http.Response, error) {
|
func (s *SpacesService) Update(spaceID uint, space *Space) (*http.Response, error) {
|
||||||
u := fmt.Sprintf("spaces/%d", spaceID)
|
u := fmt.Sprintf("spaces/%d", spaceID)
|
||||||
req, err := s.client.NewRequest("PUT", u, space)
|
req, err := s.client.NewRequest("PUT", u, space)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -91,10 +91,10 @@ func (s *SpacesService) GetChart(spaceID, chartID uint) (*SpaceChart, *http.Resp
|
||||||
return c, resp, err
|
return c, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EditChart edits a chart.
|
// UpdateChart updates a chart.
|
||||||
//
|
//
|
||||||
// Librato API docs: http://dev.librato.com/v1/put/spaces/:id/charts/:id
|
// Librato API docs: http://dev.librato.com/v1/put/spaces/:id/charts/:id
|
||||||
func (s *SpacesService) EditChart(spaceID, chartID uint, chart *SpaceChart) (*http.Response, error) {
|
func (s *SpacesService) UpdateChart(spaceID, chartID uint, chart *SpaceChart) (*http.Response, error) {
|
||||||
u := fmt.Sprintf("spaces/%d/charts/%d", spaceID, chartID)
|
u := fmt.Sprintf("spaces/%d/charts/%d", spaceID, chartID)
|
||||||
req, err := s.client.NewRequest("PUT", u, chart)
|
req, err := s.client.NewRequest("PUT", u, chart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -2287,10 +2287,10 @@
|
||||||
"revisionTime": "2016-07-20T23:31:40Z"
|
"revisionTime": "2016-07-20T23:31:40Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "HtxHX0u0oN+aiTN1Pd67Y4ilMdI=",
|
"checksumSHA1": "era7cPiPrCcdoEeHB+kNNYLODfg=",
|
||||||
"path": "github.com/henrikhodne/go-librato/librato",
|
"path": "github.com/henrikhodne/go-librato/librato",
|
||||||
"revision": "1bca649ee479cdfcf2e19f30ecb74b6f23345e5a",
|
"revision": "f82d1c74e11de20191cc53b762a2217d582b0596",
|
||||||
"revisionTime": "2017-05-13T14:06:44Z"
|
"revisionTime": "2017-06-05T03:23:04Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "K6exl2ouL7d8cR2i378EzZOdRVI=",
|
"checksumSHA1": "K6exl2ouL7d8cR2i378EzZOdRVI=",
|
||||||
|
|
Loading…
Reference in New Issue