From dad08626019bb428c6168adf1393a45aa4b3c5ec Mon Sep 17 00:00:00 2001 From: Anatole Beuzon Date: Fri, 7 Sep 2018 17:46:32 -0400 Subject: [PATCH 1/4] fix: use string instead of int for rule.threshold --- datadog-accessors.go | 10 +++++----- screen_widgets.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/datadog-accessors.go b/datadog-accessors.go index 9422c86..e2197dc 100644 --- a/datadog-accessors.go +++ b/datadog-accessors.go @@ -5005,18 +5005,18 @@ func (r *Rule) SetColor(v string) { } // GetThreshold returns the Threshold field if non-nil, zero value otherwise. -func (r *Rule) GetThreshold() int { +func (r *Rule) GetThreshold() string { if r == nil || r.Threshold == nil { - return 0 + return "" } return *r.Threshold } // GetOkThreshold returns a tuple with the Threshold field if it's non-nil, zero value otherwise // and a boolean to check if the value has been set. -func (r *Rule) GetThresholdOk() (int, bool) { +func (r *Rule) GetThresholdOk() (string, bool) { if r == nil || r.Threshold == nil { - return 0, false + return "", false } return *r.Threshold, true } @@ -5031,7 +5031,7 @@ func (r *Rule) HasThreshold() bool { } // SetThreshold allocates a new r.Threshold and returns the pointer to it. -func (r *Rule) SetThreshold(v int) { +func (r *Rule) SetThreshold(v string) { r.Threshold = &v } diff --git a/screen_widgets.go b/screen_widgets.go index f3b77b7..dc4d96d 100644 --- a/screen_widgets.go +++ b/screen_widgets.go @@ -191,7 +191,7 @@ type Params struct { } type Rule struct { - Threshold *int `json:"threshold,omitempty"` + Threshold *string `json:"threshold,omitempty"` Timeframe *string `json:"timeframe,omitempty"` Color *string `json:"color,omitempty"` } From 1ae1ee78fbe5c821ce6db1f13e955e5071643880 Mon Sep 17 00:00:00 2001 From: Anatole Beuzon Date: Tue, 11 Sep 2018 19:08:09 -0400 Subject: [PATCH 2/4] fix: use float64 instead of string for rule.threshold --- datadog-accessors.go | 10 +++++----- screen_widgets.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/datadog-accessors.go b/datadog-accessors.go index e2197dc..e6af0a5 100644 --- a/datadog-accessors.go +++ b/datadog-accessors.go @@ -5005,18 +5005,18 @@ func (r *Rule) SetColor(v string) { } // GetThreshold returns the Threshold field if non-nil, zero value otherwise. -func (r *Rule) GetThreshold() string { +func (r *Rule) GetThreshold() float64 { if r == nil || r.Threshold == nil { - return "" + return 0 } return *r.Threshold } // GetOkThreshold returns a tuple with the Threshold field if it's non-nil, zero value otherwise // and a boolean to check if the value has been set. -func (r *Rule) GetThresholdOk() (string, bool) { +func (r *Rule) GetThresholdOk() (float64, bool) { if r == nil || r.Threshold == nil { - return "", false + return 0, false } return *r.Threshold, true } @@ -5031,7 +5031,7 @@ func (r *Rule) HasThreshold() bool { } // SetThreshold allocates a new r.Threshold and returns the pointer to it. -func (r *Rule) SetThreshold(v string) { +func (r *Rule) SetThreshold(v float64) { r.Threshold = &v } diff --git a/screen_widgets.go b/screen_widgets.go index dc4d96d..f7701bf 100644 --- a/screen_widgets.go +++ b/screen_widgets.go @@ -191,9 +191,9 @@ type Params struct { } type Rule struct { - Threshold *string `json:"threshold,omitempty"` - Timeframe *string `json:"timeframe,omitempty"` - Color *string `json:"color,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + Timeframe *string `json:"timeframe,omitempty"` + Color *string `json:"color,omitempty"` } type ScreenboardMonitor struct { From 47e5a2607c06113c7838cbac25f84f0db3f50920 Mon Sep 17 00:00:00 2001 From: Anatole Beuzon Date: Tue, 11 Sep 2018 19:14:21 -0400 Subject: [PATCH 3/4] Add undocumented warning for uptime widget --- integration/screen_widgets_test.go | 1 + screen_widgets.go | 1 + 2 files changed, 2 insertions(+) diff --git a/integration/screen_widgets_test.go b/integration/screen_widgets_test.go index b8752f9..d68d371 100644 --- a/integration/screen_widgets_test.go +++ b/integration/screen_widgets_test.go @@ -351,6 +351,7 @@ func TestWidgets(t *testing.T) { }, }, { + // Widget is undocumented, subject to breaking API changes, and without customer support Type: datadog.String("uptime"), X: datadog.Int(1), Y: datadog.Int(1), diff --git a/screen_widgets.go b/screen_widgets.go index f7701bf..08ca830 100644 --- a/screen_widgets.go +++ b/screen_widgets.go @@ -178,6 +178,7 @@ type Widget struct { Logset *string `json:"logset,omitempty"` // For Uptime + // Widget is undocumented, subject to breaking API changes, and without customer support Timeframes []*string `json:"timeframes,omitempty"` Rules map[string]*Rule `json:"rules,omitempty"` Monitor *ScreenboardMonitor `json:"monitor,omitempty"` From 93582c039880cd8f75245adb7db5d5bed8e3e34a Mon Sep 17 00:00:00 2001 From: Anatole Beuzon Date: Wed, 12 Sep 2018 15:16:23 -0400 Subject: [PATCH 4/4] fix: use json.Number instead of float64 for rule.threshold --- datadog-accessors.go | 10 +++++----- screen_widgets.go | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/datadog-accessors.go b/datadog-accessors.go index e6af0a5..0c42c2d 100644 --- a/datadog-accessors.go +++ b/datadog-accessors.go @@ -5005,18 +5005,18 @@ func (r *Rule) SetColor(v string) { } // GetThreshold returns the Threshold field if non-nil, zero value otherwise. -func (r *Rule) GetThreshold() float64 { +func (r *Rule) GetThreshold() json.Number { if r == nil || r.Threshold == nil { - return 0 + return "" } return *r.Threshold } // GetOkThreshold returns a tuple with the Threshold field if it's non-nil, zero value otherwise // and a boolean to check if the value has been set. -func (r *Rule) GetThresholdOk() (float64, bool) { +func (r *Rule) GetThresholdOk() (json.Number, bool) { if r == nil || r.Threshold == nil { - return 0, false + return "", false } return *r.Threshold, true } @@ -5031,7 +5031,7 @@ func (r *Rule) HasThreshold() bool { } // SetThreshold allocates a new r.Threshold and returns the pointer to it. -func (r *Rule) SetThreshold(v float64) { +func (r *Rule) SetThreshold(v json.Number) { r.Threshold = &v } diff --git a/screen_widgets.go b/screen_widgets.go index 08ca830..2e3dc0a 100644 --- a/screen_widgets.go +++ b/screen_widgets.go @@ -1,5 +1,7 @@ package datadog +import "encoding/json" + type TileDef struct { Events []TileDefEvent `json:"events,omitempty"` Markers []TileDefMarker `json:"markers,omitempty"` @@ -192,9 +194,9 @@ type Params struct { } type Rule struct { - Threshold *float64 `json:"threshold,omitempty"` - Timeframe *string `json:"timeframe,omitempty"` - Color *string `json:"color,omitempty"` + Threshold *json.Number `json:"threshold,omitempty"` + Timeframe *string `json:"timeframe,omitempty"` + Color *string `json:"color,omitempty"` } type ScreenboardMonitor struct {