Skip to content

Use json.Number for Screenboard.Width and ConditionalFormat.Value #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions datadog-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ func (c *ConditionalFormat) SetPalette(v string) {
}

// GetValue returns the Value field if non-nil, zero value otherwise.
func (c *ConditionalFormat) GetValue() string {
func (c *ConditionalFormat) GetValue() json.Number {
if c == nil || c.Value == nil {
return ""
}
Expand All @@ -860,7 +860,7 @@ func (c *ConditionalFormat) GetValue() string {

// GetValueOk returns a tuple with the Value field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (c *ConditionalFormat) GetValueOk() (string, bool) {
func (c *ConditionalFormat) GetValueOk() (json.Number, bool) {
if c == nil || c.Value == nil {
return "", false
}
Expand All @@ -877,7 +877,7 @@ func (c *ConditionalFormat) HasValue() bool {
}

// SetValue allocates a new c.Value and returns the pointer to it.
func (c *ConditionalFormat) SetValue(v string) {
func (c *ConditionalFormat) SetValue(v json.Number) {
c.Value = &v
}

Expand Down Expand Up @@ -6555,18 +6555,18 @@ func (s *Screenboard) SetTitle(v string) {
}

// GetWidth returns the Width field if non-nil, zero value otherwise.
func (s *Screenboard) GetWidth() int {
func (s *Screenboard) GetWidth() json.Number {
if s == nil || s.Width == nil {
return 0
return ""
}
return *s.Width
}

// GetWidthOk returns a tuple with the Width field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *Screenboard) GetWidthOk() (int, bool) {
func (s *Screenboard) GetWidthOk() (json.Number, bool) {
if s == nil || s.Width == nil {
return 0, false
return "", false
}
return *s.Width, true
}
Expand All @@ -6581,7 +6581,7 @@ func (s *Screenboard) HasWidth() bool {
}

// SetWidth allocates a new s.Width and returns the pointer to it.
func (s *Screenboard) SetWidth(v int) {
func (s *Screenboard) SetWidth(v json.Number) {
s.Width = &v
}

Expand Down
5 changes: 3 additions & 2 deletions integration/screen_widgets_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -84,7 +85,7 @@ func TestWidgets(t *testing.T) {
ConditionalFormats: []datadog.ConditionalFormat{
{
Comparator: datadog.String(">="),
Value: datadog.String("1"),
Value: datadog.JsonNumber(json.Number("1")),
Palette: datadog.String("white_on_red"),
}},
Aggregator: datadog.String("max"),
Expand Down Expand Up @@ -122,7 +123,7 @@ func TestWidgets(t *testing.T) {
ConditionalFormats: []datadog.ConditionalFormat{
{
Comparator: datadog.String(">"),
Value: datadog.String("4"),
Value: datadog.JsonNumber(json.Number("4")),
Palette: datadog.String("white_on_green"),
}},
}},
Expand Down
5 changes: 3 additions & 2 deletions integration/screenboards_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration

import (
"encoding/json"
"testing"

"github.com/zorkian/go-datadog-api"
Expand Down Expand Up @@ -94,7 +95,7 @@ func getTestScreenboard() *datadog.Screenboard {
return &datadog.Screenboard{
Title: datadog.String("___Test-Board___"),
Height: datadog.Int(600),
Width: datadog.Int(800),
Width: datadog.JsonNumber(json.Number("800")),
Widgets: []datadog.Widget{},
}
}
Expand Down Expand Up @@ -129,7 +130,7 @@ func assertScreenboardEquals(t *testing.T, actual, expected *datadog.Screenboard
t.Errorf("Screenboard title does not match: %s != %s", *actual.Title, *expected.Title)
}
if *actual.Width != *expected.Width {
t.Errorf("Screenboard width does not match: %d != %d", *actual.Width, *expected.Width)
t.Errorf("Screenboard width does not match: %s != %s", *actual.Width, *expected.Width)
}
if *actual.Height != *expected.Height {
t.Errorf("Screenboard width does not match: %d != %d", *actual.Height, *expected.Height)
Expand Down
12 changes: 6 additions & 6 deletions screen_widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ type TileDefRequest struct {
}

type ConditionalFormat struct {
Color *string `json:"color,omitempty"`
Palette *string `json:"palette,omitempty"`
Comparator *string `json:"comparator,omitempty"`
Invert *bool `json:"invert,omitempty"`
Value *string `json:"value,omitempty"`
ImageURL *string `json:"image_url,omitempty"`
Color *string `json:"color,omitempty"`
Palette *string `json:"palette,omitempty"`
Comparator *string `json:"comparator,omitempty"`
Invert *bool `json:"invert,omitempty"`
Value *json.Number `json:"value,omitempty"`
ImageURL *string `json:"image_url,omitempty"`
}

type TileDefRequestStyle struct {
Expand Down
3 changes: 2 additions & 1 deletion screenboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package datadog

import (
"encoding/json"
"fmt"
)

Expand All @@ -18,7 +19,7 @@ type Screenboard struct {
Id *int `json:"id,omitempty"`
Title *string `json:"board_title,omitempty"`
Height *int `json:"height,omitempty"`
Width *int `json:"width,omitempty"`
Width *json.Number `json:"width,omitempty"`
Shared *bool `json:"shared,omitempty"`
TemplateVariables []TemplateVariable `json:"template_variables,omitempty"`
Widgets []Widget `json:"widgets"`
Expand Down
5 changes: 3 additions & 2 deletions screenboards_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog

import (
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -42,9 +43,9 @@ func TestGetScreenboard(t *testing.T) {
t.Fatalf("expect height %d. Got %d", expectedHeight, height)
}

expectedWidth := 1024
expectedWidth := json.Number("1024")
if width := screenboard.GetWidth(); width != expectedWidth {
t.Fatalf("expect width %d. Got %d", expectedWidth, width)
t.Fatalf("expect width %s. Got %s", expectedWidth, width)
}

expectedReadOnly := false
Expand Down