Skip to content

Commit

Permalink
Accept strings and integers as AlertID
Browse files Browse the repository at this point in the history
  • Loading branch information
mrwonko committed Mar 4, 2019
1 parent ff651de commit b04c74e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
10 changes: 5 additions & 5 deletions datadog-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9097,18 +9097,18 @@ func (u *User) SetVerified(v bool) {
}

// GetAlertID returns the AlertID field if non-nil, zero value otherwise.
func (w *Widget) GetAlertID() int {
func (w *Widget) GetAlertID() StrIntD {
if w == nil || w.AlertID == nil {
return 0
return ""
}
return *w.AlertID
}

// GetAlertIDOk returns a tuple with the AlertID field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (w *Widget) GetAlertIDOk() (int, bool) {
func (w *Widget) GetAlertIDOk() (StrIntD, bool) {
if w == nil || w.AlertID == nil {
return 0, false
return "", false
}
return *w.AlertID, true
}
Expand All @@ -9123,7 +9123,7 @@ func (w *Widget) HasAlertID() bool {
}

// SetAlertID allocates a new w.AlertID and returns the pointer to it.
func (w *Widget) SetAlertID(v int) {
func (w *Widget) SetAlertID(v StrIntD) {
w.AlertID = &v
}

Expand Down
4 changes: 2 additions & 2 deletions integration/screen_widgets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func TestWidgets(t *testing.T) {
TitleText: datadog.String("Test title"),
TitleSize: datadog.Int(16),
TitleAlign: datadog.String("right"),
AlertID: datadog.Int(123456),
AlertID: datadog.StrInt("123456"),
VizType: datadog.String("toplist"),
Time: &datadog.Time{
LiveSpan: datadog.String("15m"),
Expand All @@ -238,7 +238,7 @@ func TestWidgets(t *testing.T) {
TitleText: datadog.String("Test title"),
TitleSize: datadog.Int(16),
TitleAlign: datadog.String("right"),
AlertID: datadog.Int(123456),
AlertID: datadog.StrInt("123456"),
TextSize: datadog.String("fill_height"),
TextAlign: datadog.String("right"),
Precision: datadog.StrInt("*"),
Expand Down
4 changes: 2 additions & 2 deletions screen_widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ type Widget struct {
FontSize *string `json:"font_size,omitempty"`

// For AlertValue, AlertGraph widgets
AlertID *int `json:"alert_id,omitempty"`
AutoRefresh *bool `json:"auto_refresh,omitempty"`
AlertID *StrIntD `json:"alert_id,omitempty"`
AutoRefresh *bool `json:"auto_refresh,omitempty"`

// For Timeseries, QueryValue, Toplist widgets
Legend *bool `json:"legend,omitempty"`
Expand Down
11 changes: 11 additions & 0 deletions screenboards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ func TestGetScreenboard(t *testing.T) {
},
},
},
{
file: "screenboard_response_alert_id",
want: &Screenboard{
Widgets: []Widget{
{
Type: String("alert_value"),
AlertID: StrInt("2156443"),
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.file, func(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions testdata/fixtures/screenboard_response_alert_id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"widgets": [
{
"alert_id": "2156443",
"type": "alert_value"
}
]
}

0 comments on commit b04c74e

Please sign in to comment.