Skip to content

Commit b04c74e

Browse files
committed
Accept strings and integers as AlertID
1 parent ff651de commit b04c74e

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

datadog-accessors.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9097,18 +9097,18 @@ func (u *User) SetVerified(v bool) {
90979097
}
90989098

90999099
// GetAlertID returns the AlertID field if non-nil, zero value otherwise.
9100-
func (w *Widget) GetAlertID() int {
9100+
func (w *Widget) GetAlertID() StrIntD {
91019101
if w == nil || w.AlertID == nil {
9102-
return 0
9102+
return ""
91039103
}
91049104
return *w.AlertID
91059105
}
91069106

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

91259125
// SetAlertID allocates a new w.AlertID and returns the pointer to it.
9126-
func (w *Widget) SetAlertID(v int) {
9126+
func (w *Widget) SetAlertID(v StrIntD) {
91279127
w.AlertID = &v
91289128
}
91299129

integration/screen_widgets_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func TestWidgets(t *testing.T) {
222222
TitleText: datadog.String("Test title"),
223223
TitleSize: datadog.Int(16),
224224
TitleAlign: datadog.String("right"),
225-
AlertID: datadog.Int(123456),
225+
AlertID: datadog.StrInt("123456"),
226226
VizType: datadog.String("toplist"),
227227
Time: &datadog.Time{
228228
LiveSpan: datadog.String("15m"),
@@ -238,7 +238,7 @@ func TestWidgets(t *testing.T) {
238238
TitleText: datadog.String("Test title"),
239239
TitleSize: datadog.Int(16),
240240
TitleAlign: datadog.String("right"),
241-
AlertID: datadog.Int(123456),
241+
AlertID: datadog.StrInt("123456"),
242242
TextSize: datadog.String("fill_height"),
243243
TextAlign: datadog.String("right"),
244244
Precision: datadog.StrInt("*"),

screen_widgets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ type Widget struct {
118118
FontSize *string `json:"font_size,omitempty"`
119119

120120
// For AlertValue, AlertGraph widgets
121-
AlertID *int `json:"alert_id,omitempty"`
122-
AutoRefresh *bool `json:"auto_refresh,omitempty"`
121+
AlertID *StrIntD `json:"alert_id,omitempty"`
122+
AutoRefresh *bool `json:"auto_refresh,omitempty"`
123123

124124
// For Timeseries, QueryValue, Toplist widgets
125125
Legend *bool `json:"legend,omitempty"`

screenboards_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ func TestGetScreenboard(t *testing.T) {
217217
},
218218
},
219219
},
220+
{
221+
file: "screenboard_response_alert_id",
222+
want: &Screenboard{
223+
Widgets: []Widget{
224+
{
225+
Type: String("alert_value"),
226+
AlertID: StrInt("2156443"),
227+
},
228+
},
229+
},
230+
},
220231
}
221232
for _, tt := range tests {
222233
t.Run(tt.file, func(t *testing.T) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"widgets": [
3+
{
4+
"alert_id": "2156443",
5+
"type": "alert_value"
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)