Skip to content

Commit

Permalink
feat(dashboards): Added a new field in dashboards -> variable -> opti…
Browse files Browse the repository at this point in the history
…ons called <excluded>

Co-authored-by: Vinay Reddy Godhala <[email protected]>
  • Loading branch information
shashank-reddy-nr and vinay-newrelic authored Oct 28, 2024
1 parent 07a0a44 commit dd261af
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/dashboards/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const getDashboardEntityQuery = `query ($guid: EntityGuid!) {
}
name
options {
excluded
ignoreTimeRange
}
nrqlQuery {
Expand Down
2 changes: 2 additions & 0 deletions pkg/dashboards/dashboards_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions pkg/dashboards/dashboards_api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {

// Test vars
dashboardName := "newrelic-client-go test-dashboard-" + mock.RandSeq(5)
ignoreTimeRangeValue := true
excludedValue := true
dashboardInput := DashboardInput{
Description: "Test description",
Name: dashboardName,
Expand Down Expand Up @@ -314,7 +316,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
},
Name: "variable",
Options: &DashboardVariableOptionsInput{
IgnoreTimeRange: true,
IgnoreTimeRange: &ignoreTimeRangeValue,
Excluded: &excludedValue,
},
NRQLQuery: &DashboardVariableNRQLQueryInput{
AccountIDs: []int{testAccountID},
Expand Down Expand Up @@ -347,10 +350,12 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
assert.Equal(t, dashboardInput.Name, dash.Name)
assert.Equal(t, entities.DashboardEntityPermissions(string(dashboardInput.Permissions)), dash.Permissions)

if dash.Variables[0].Options.IgnoreTimeRange != dashboardInput.Variables[0].Options.IgnoreTimeRange {
t.Errorf("Expected value to be %v but got %v\n", dashboardInput.Variables[0].Options.IgnoreTimeRange, dash.Variables[0].Options.IgnoreTimeRange)
if dash.Variables[0].Options.IgnoreTimeRange != *dashboardInput.Variables[0].Options.IgnoreTimeRange {
t.Errorf("Expected value to be %v but got %v\n", *dashboardInput.Variables[0].Options.IgnoreTimeRange, dash.Variables[0].Options.IgnoreTimeRange)
}
if dash.Variables[0].Options.Excluded != *dashboardInput.Variables[0].Options.Excluded {
t.Errorf("Expected value to be %v but got %v\n", *dashboardInput.Variables[0].Options.Excluded, dash.Variables[0].Options.Excluded)
}

// Input and Pages are different types so we can not easily compare them...
assert.Equal(t, len(dashboardInput.Pages), len(dash.Pages))
require.Equal(t, 1, len(dash.Pages))
Expand All @@ -362,6 +367,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
assert.Greater(t, len(dash.Pages[0].Widgets[0].RawConfiguration), 1)

// Test: DashboardUpdate
ignoreTimeRangeValue = false
excludedValue = false
updatedDashboard := DashboardInput{
Name: dash.Name,
Permissions: result.EntityResult.Permissions,
Expand Down Expand Up @@ -396,7 +403,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
},
Name: "variableUpdated",
Options: &DashboardVariableOptionsInput{
IgnoreTimeRange: true,
IgnoreTimeRange: &ignoreTimeRangeValue,
Excluded: &excludedValue,
},
NRQLQuery: &DashboardVariableNRQLQueryInput{
AccountIDs: []int{testAccountID},
Expand Down
6 changes: 5 additions & 1 deletion pkg/dashboards/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,18 @@ type DashboardVariableNRQLQueryInput struct {

// DashboardVariableOptions - Options applied to the variable.
type DashboardVariableOptions struct {
// With this turned on, query condition defined with the variable will not be included in the query.
Excluded bool `json:"excluded,omitempty"`
// Only applies to variables of type NRQL. With this turned on, the time range for the NRQL query will override the time picker on dashboards and other pages. Turn this off to use the time picker as normal.
IgnoreTimeRange bool `json:"ignoreTimeRange,omitempty"`
}

// DashboardVariableOptionsInput - Options applied to the variable
type DashboardVariableOptionsInput struct {
// With this turned on, query condition defined with the variable will not be included in the query.
Excluded *bool `json:"excluded,omitempty"`
// Only applies to variables of type NRQL. With this turned on, the time range for the NRQL query will override the time picker on dashboards and other pages. Turn this off to use the time picker as normal.
IgnoreTimeRange bool `json:"ignoreTimeRange"`
IgnoreTimeRange *bool `json:"ignoreTimeRange,omitempty"`
}

// DashboardWidgetConfigurationInput - Typed configuration for known visualizations. At most one may be populated.
Expand Down
1 change: 1 addition & 0 deletions pkg/entities/entities_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/entities/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5312,6 +5312,8 @@ type DashboardVariableNRQLQuery struct {

// DashboardVariableOptions - Options applied to the variable.
type DashboardVariableOptions struct {
// With this turned on, query condition defined with the variable will not be included in the query.
Excluded bool `json:"excluded,omitempty"`
// Only applies to variables of type NRQL. With this turned on, the time range for the NRQL query will override the time picker on dashboards and other pages. Turn this off to use the time picker as normal.
IgnoreTimeRange bool `json:"ignoreTimeRange,omitempty"`
}
Expand Down

0 comments on commit dd261af

Please sign in to comment.