Skip to content

Commit

Permalink
Merge pull request #187 from nyanshak/more-yaxis-fields
Browse files Browse the repository at this point in the history
Add support for units and includeZero in Yaxis
  • Loading branch information
nyanshak authored Nov 12, 2018
2 parents 456ae6c + dbd5726 commit f3f6d2f
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 18 deletions.
12 changes: 7 additions & 5 deletions dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ type GraphEvent struct {
}

type Yaxis struct {
Min *float64 `json:"min,omitempty"`
AutoMin bool `json:"-"`
Max *float64 `json:"max,omitempty"`
AutoMax bool `json:"-"`
Scale *string `json:"scale,omitempty"`
Min *float64 `json:"min,omitempty"`
AutoMin bool `json:"-"`
Max *float64 `json:"max,omitempty"`
AutoMax bool `json:"-"`
Scale *string `json:"scale,omitempty"`
IncludeZero *bool `json:"includeZero,omitempty"`
IncludeUnits *bool `json:"units,omitempty"`
}

// UnmarshalJSON is a Custom Unmarshal for Yaxis.Min/Yaxis.Max. If the datadog API
Expand Down
32 changes: 19 additions & 13 deletions dashboards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,33 @@ type YAxisTestSuite struct {

func (suite *YAxisTestSuite) SetupTest() {
// Custom Y.Min, Y.Max
suite.yJSON = []byte(`{"min":0,"max":1,"scale":"linear"}`)
suite.yJSON = []byte(`{"min":0,"max":1,"scale":"linear","includeZero":true,"units":true}`)
suite.yMarshalledJSON = suite.yJSON
yMinFloat := float64(0)
yMaxFloat := float64(1)
yScale := "linear"
yIncludeZero := true
yIncludeUnits := true
suite.y = Yaxis{
Min: &yMinFloat,
AutoMin: false,
Max: &yMaxFloat,
AutoMax: false,
Scale: &yScale,
Min: &yMinFloat,
AutoMin: false,
Max: &yMaxFloat,
AutoMax: false,
Scale: &yScale,
IncludeZero: &yIncludeZero,
IncludeUnits: &yIncludeUnits,
}
// Auto Y.Min, Y.Max
suite.yAutoMinMaxJSON = []byte(`{"min":"auto","max":"auto","scale":"linear"}`)
suite.yAutoMinMaxMarshalledJSON = []byte(`{"scale":"linear"}`)
suite.yAutoMinMaxJSON = []byte(`{"min":"auto","max":"auto","scale":"linear","includeZero":true,"units":true}`)
suite.yAutoMinMaxMarshalledJSON = []byte(`{"scale":"linear","includeZero":true,"units":true}`)
suite.yAutoMinMax = Yaxis{
Min: nil,
AutoMin: true,
Max: nil,
AutoMax: true,
Scale: &yScale,
Min: nil,
AutoMin: true,
Max: nil,
AutoMax: true,
Scale: &yScale,
IncludeZero: &yIncludeZero,
IncludeUnits: &yIncludeUnits,
}
}

Expand Down
62 changes: 62 additions & 0 deletions datadog-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10863,6 +10863,68 @@ func (w *Widget) SetY(v int) {
w.Y = &v
}

// GetIncludeUnits returns the IncludeUnits field if non-nil, zero value otherwise.
func (y *Yaxis) GetIncludeUnits() bool {
if y == nil || y.IncludeUnits == nil {
return false
}
return *y.IncludeUnits
}

// GetIncludeUnitsOk returns a tuple with the IncludeUnits field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (y *Yaxis) GetIncludeUnitsOk() (bool, bool) {
if y == nil || y.IncludeUnits == nil {
return false, false
}
return *y.IncludeUnits, true
}

// HasIncludeUnits returns a boolean if a field has been set.
func (y *Yaxis) HasIncludeUnits() bool {
if y != nil && y.IncludeUnits != nil {
return true
}

return false
}

// SetIncludeUnits allocates a new y.IncludeUnits and returns the pointer to it.
func (y *Yaxis) SetIncludeUnits(v bool) {
y.IncludeUnits = &v
}

// GetIncludeZero returns the IncludeZero field if non-nil, zero value otherwise.
func (y *Yaxis) GetIncludeZero() bool {
if y == nil || y.IncludeZero == nil {
return false
}
return *y.IncludeZero
}

// GetIncludeZeroOk returns a tuple with the IncludeZero field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (y *Yaxis) GetIncludeZeroOk() (bool, bool) {
if y == nil || y.IncludeZero == nil {
return false, false
}
return *y.IncludeZero, true
}

// HasIncludeZero returns a boolean if a field has been set.
func (y *Yaxis) HasIncludeZero() bool {
if y != nil && y.IncludeZero != nil {
return true
}

return false
}

// SetIncludeZero allocates a new y.IncludeZero and returns the pointer to it.
func (y *Yaxis) SetIncludeZero(v bool) {
y.IncludeZero = &v
}

// GetMax returns the Max field if non-nil, zero value otherwise.
func (y *Yaxis) GetMax() float64 {
if y == nil || y.Max == nil {
Expand Down

0 comments on commit f3f6d2f

Please sign in to comment.