Skip to content

Commit 213a136

Browse files
committed
Accept integers for ConditionalFormat.Value
1 parent f39b58b commit 213a136

File tree

4 files changed

+170
-9
lines changed

4 files changed

+170
-9
lines changed

datadog-accessors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ func (c *ConditionalFormat) SetPalette(v string) {
851851
}
852852

853853
// GetValue returns the Value field if non-nil, zero value otherwise.
854-
func (c *ConditionalFormat) GetValue() string {
854+
func (c *ConditionalFormat) GetValue() StrintD {
855855
if c == nil || c.Value == nil {
856856
return ""
857857
}
@@ -860,7 +860,7 @@ func (c *ConditionalFormat) GetValue() string {
860860

861861
// GetValueOk returns a tuple with the Value field if it's non-nil, zero value otherwise
862862
// and a boolean to check if the value has been set.
863-
func (c *ConditionalFormat) GetValueOk() (string, bool) {
863+
func (c *ConditionalFormat) GetValueOk() (StrintD, bool) {
864864
if c == nil || c.Value == nil {
865865
return "", false
866866
}
@@ -877,7 +877,7 @@ func (c *ConditionalFormat) HasValue() bool {
877877
}
878878

879879
// SetValue allocates a new c.Value and returns the pointer to it.
880-
func (c *ConditionalFormat) SetValue(v string) {
880+
func (c *ConditionalFormat) SetValue(v StrintD) {
881881
c.Value = &v
882882
}
883883

screen_widgets.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ type TileDefRequest struct {
5656
}
5757

5858
type ConditionalFormat struct {
59-
Color *string `json:"color,omitempty"`
60-
Palette *string `json:"palette,omitempty"`
61-
Comparator *string `json:"comparator,omitempty"`
62-
Invert *bool `json:"invert,omitempty"`
63-
Value *string `json:"value,omitempty"`
64-
ImageURL *string `json:"image_url,omitempty"`
59+
Color *string `json:"color,omitempty"`
60+
Palette *string `json:"palette,omitempty"`
61+
Comparator *string `json:"comparator,omitempty"`
62+
Invert *bool `json:"invert,omitempty"`
63+
Value *StrintD `json:"value,omitempty"`
64+
ImageURL *string `json:"image_url,omitempty"`
6565
}
6666

6767
type TileDefRequestStyle struct {

screenboards_test.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,89 @@ func TestGetScreenboard(t *testing.T) {
7575
},
7676
},
7777
},
78+
{
79+
file: "screenboard_response_conditional_format",
80+
want: &Screenboard{
81+
Id: Int(334488),
82+
Title: String("OrderCapture ScreenBoard"),
83+
Widgets: []Widget{
84+
{
85+
Type: String("query_value"),
86+
TileDef: &TileDef{
87+
Viz: String("query_value"),
88+
Requests: []TileDefRequest{
89+
{
90+
ConditionalFormats: []ConditionalFormat{
91+
// string values in JSON
92+
{
93+
Palette: String("white_on_red"),
94+
Comparator: String(">"),
95+
Value: Strint("1000"),
96+
},
97+
{
98+
Palette: String("white_on_yellow"),
99+
Comparator: String(">="),
100+
Value: Strint("200"),
101+
},
102+
{
103+
Palette: String("white_on_green"),
104+
Comparator: String("<"),
105+
Value: Strint("200"),
106+
},
107+
},
108+
},
109+
},
110+
},
111+
},
112+
{
113+
Type: String("query_value"),
114+
TileDef: &TileDef{
115+
Viz: String("query_value"),
116+
Requests: []TileDefRequest{
117+
{
118+
ConditionalFormats: []ConditionalFormat{
119+
// null values in JSON
120+
{
121+
Palette: String("white_on_red"),
122+
Comparator: String(">"),
123+
Value: nil,
124+
},
125+
{
126+
Palette: String("white_on_yellow"),
127+
Comparator: String(">="),
128+
Value: nil,
129+
},
130+
{
131+
Palette: String("white_on_green"),
132+
Comparator: String("<"),
133+
Value: nil,
134+
},
135+
},
136+
},
137+
},
138+
},
139+
},
140+
{
141+
Type: String("toplist"),
142+
TileDef: &TileDef{
143+
Viz: String("toplist"),
144+
Requests: []TileDefRequest{
145+
{
146+
ConditionalFormats: []ConditionalFormat{
147+
// number value in JSON
148+
{
149+
Palette: String("white_on_red"),
150+
Comparator: String(">"),
151+
Value: Strint("1"),
152+
},
153+
},
154+
},
155+
},
156+
},
157+
},
158+
},
159+
},
160+
},
78161
}
79162
for _, tt := range tests {
80163
t.Run(tt.file, func(t *testing.T) {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"new_id": "zcw-f49-698",
3+
"id": 334488,
4+
"widgets": [
5+
{
6+
"tile_def": {
7+
"viz": "query_value",
8+
"requests": [
9+
{
10+
"conditional_formats": [
11+
{
12+
"palette": "white_on_red",
13+
"comparator": ">",
14+
"value": "1000"
15+
},
16+
{
17+
"palette": "white_on_yellow",
18+
"comparator": ">=",
19+
"value": "200"
20+
},
21+
{
22+
"palette": "white_on_green",
23+
"comparator": "<",
24+
"value": "200"
25+
}
26+
]
27+
}
28+
]
29+
},
30+
"type": "query_value"
31+
},
32+
{
33+
"tile_def": {
34+
"viz": "query_value",
35+
"requests": [
36+
{
37+
"conditional_formats": [
38+
{
39+
"palette": "white_on_red",
40+
"value": null,
41+
"comparator": ">"
42+
},
43+
{
44+
"palette": "white_on_yellow",
45+
"value": null,
46+
"comparator": ">="
47+
},
48+
{
49+
"palette": "white_on_green",
50+
"value": null,
51+
"comparator": "<"
52+
}
53+
]
54+
}
55+
]
56+
},
57+
"type": "query_value"
58+
},
59+
{
60+
"tile_def": {
61+
"viz": "toplist",
62+
"requests": [
63+
{
64+
"conditional_formats": [
65+
{
66+
"palette": "white_on_red",
67+
"comparator": ">",
68+
"value": 1
69+
}
70+
]
71+
}
72+
]
73+
},
74+
"type": "toplist"
75+
}
76+
],
77+
"board_title": "OrderCapture ScreenBoard"
78+
}

0 commit comments

Comments
 (0)