diff --git a/pkg/dashboards/dashboard.go b/pkg/dashboards/dashboard.go index 0395c5f8..7785848b 100644 --- a/pkg/dashboards/dashboard.go +++ b/pkg/dashboards/dashboard.go @@ -100,6 +100,7 @@ const getDashboardEntityQuery = `query ($guid: EntityGuid!) { } name options { + excluded ignoreTimeRange } nrqlQuery { diff --git a/pkg/dashboards/dashboards_api.go b/pkg/dashboards/dashboards_api.go index 18e0bac6..15da5c4d 100644 --- a/pkg/dashboards/dashboards_api.go +++ b/pkg/dashboards/dashboards_api.go @@ -2118,6 +2118,7 @@ const DashboardCreateMutation = `mutation( query } options { + excluded ignoreTimeRange } replacementStrategy @@ -4294,6 +4295,7 @@ const DashboardUpdateMutation = `mutation( query } options { + excluded ignoreTimeRange } replacementStrategy diff --git a/pkg/dashboards/dashboards_api_integration_test.go b/pkg/dashboards/dashboards_api_integration_test.go index cfa9edc2..52277e6e 100644 --- a/pkg/dashboards/dashboards_api_integration_test.go +++ b/pkg/dashboards/dashboards_api_integration_test.go @@ -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, @@ -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}, @@ -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)) @@ -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, @@ -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}, diff --git a/pkg/dashboards/types.go b/pkg/dashboards/types.go index f87b6ee7..7da90f52 100644 --- a/pkg/dashboards/types.go +++ b/pkg/dashboards/types.go @@ -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. diff --git a/pkg/entities/entities_api.go b/pkg/entities/entities_api.go index d5cc8b22..c0b63216 100644 --- a/pkg/entities/entities_api.go +++ b/pkg/entities/entities_api.go @@ -4002,6 +4002,7 @@ const getEntityQuery = `query( query } options { + excluded ignoreTimeRange } replacementStrategy diff --git a/pkg/entities/types.go b/pkg/entities/types.go index 44128db2..56b76e15 100644 --- a/pkg/entities/types.go +++ b/pkg/entities/types.go @@ -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"` }