From 6b5591d5faa010bc0bcfe107be1b51f3e230d8a0 Mon Sep 17 00:00:00 2001 From: Cory G Watson Date: Thu, 11 Jul 2019 12:30:34 -0700 Subject: [PATCH] Adjust pointers and clean up types for dash groups --- dashboard/model_charts_single_filter.go | 6 ++++-- dashboard/model_charts_web_ui_filter.go | 4 +++- dashboard/model_event_overlay_filter.go | 4 +++- dashboard/model_simple_dashboard_model.go | 8 ++++---- dashboard_group/model_dashboard_config.go | 2 +- dashboard_group/model_filter.go | 4 +++- dashboard_group/model_filters.go | 5 ++--- dashboard_group/model_search_result.go | 2 +- dashboard_group/model_web_ui_filter.go | 11 ++++------- {dashboard => util}/string_or_slice.go | 2 +- 10 files changed, 26 insertions(+), 22 deletions(-) rename {dashboard => util}/string_or_slice.go (96%) diff --git a/dashboard/model_charts_single_filter.go b/dashboard/model_charts_single_filter.go index f3bd548..86c84da 100644 --- a/dashboard/model_charts_single_filter.go +++ b/dashboard/model_charts_single_filter.go @@ -9,6 +9,8 @@ package dashboard +import "github.com/signalfx/signalfx-go/util" + // A single filter object to apply to the charts in the dashboard. The filter specifies a default or user-defined dimension or custom property. You can either include or exclude all the data that matches the dimension or custom property. type ChartsSingleFilter struct { // Flag that indicates how the filter should operate. If `true`, data that matches the criteria is _excluded_ from charts; otherwise, data that matches the criteria is included. @@ -16,6 +18,6 @@ type ChartsSingleFilter struct { // Name of the dimension or custom property to match to the data.
**Note:** If the dimension or custom property doesn't exist in any of the charts for the dashboard, and `ChartsFilterObject.NOT` is `true`, the system doesn't display any data in the charts. Property string `json:"property"` // A list of values to compare to the value of the dimension or custom property specified in `ChartsFilterObject.property`. If the list contains more than one value, the filter becomes a set of queries between the value of `property` and each element of `value`. The system joins these queries with an implicit OR. - Value StringOrSlice `json:"value"` - ApplyIfExists bool `json:"applyIfExists,omitempty"` + Value util.StringOrSlice `json:"value"` + ApplyIfExists bool `json:"applyIfExists,omitempty"` } diff --git a/dashboard/model_charts_web_ui_filter.go b/dashboard/model_charts_web_ui_filter.go index 755b544..9e1dbd5 100644 --- a/dashboard/model_charts_web_ui_filter.go +++ b/dashboard/model_charts_web_ui_filter.go @@ -9,6 +9,8 @@ package dashboard +import "github.com/signalfx/signalfx-go/util" + // The specification for a filter that appears in the web UI. The filter compares the value of a dimension or custom property to a value specified in this filter. You can specify the following in the filter:
* A default value * A list of suggested values to display in the web UI * A flag that controls user input; if set to `true`, users are limited to the default and suggested values.
You can also force users to choose this filter in order to see data in the dashboard's charts. type ChartsWebUiFilter struct { // A label for the filter. The system displays this label in the area preceding the input textarea for the filter in the web UI.
**Note:** A good way to indicate that the string is a label is to append a space and a colon (\":\") to it. @@ -25,5 +27,5 @@ type ChartsWebUiFilter struct { // Flag that controls the values allowed in the filter. If `true`, the only allowable values are those specified in the `ChartsWebUIFilter.preferredSuggestsions` array; otherwise, any value is allowed. Restricted bool `json:"restricted,omitempty"` // A list of values to compare to the value of the dimension or custom property specified in `ChartsWebUIFilter.property`. If the list contains more than one value, the filter becomes a set of queries between the value of `property` and each element of `value`. The system joins these queries with an implicit OR. - Value StringOrSlice `json:"value"` + Value util.StringOrSlice `json:"value"` } diff --git a/dashboard/model_event_overlay_filter.go b/dashboard/model_event_overlay_filter.go index d0e59fe..5dd79e4 100644 --- a/dashboard/model_event_overlay_filter.go +++ b/dashboard/model_event_overlay_filter.go @@ -9,6 +9,8 @@ package dashboard +import "github.com/signalfx/signalfx-go/util" + // Object containing a filter to apply to event overlays, in the form of a comparison expression. Each term in the expression tries to match the values of a dimension or custom property to criteria you specify. Based on the match results, you can include or exclude an event. type EventOverlayFilter struct { // Controls the action of the filter. If set to `true`, then the system only selects events that *don't* match the filter. @@ -16,5 +18,5 @@ type EventOverlayFilter struct { // The custom property or dimension name that provides the value to test in the filter.
If the name you specify isn't defined in one or more of the events associated with the dashboard, the filter never matches anything. If the `NOT` property for this filter is set to `true` and the filter never matches, all event overlays are suppressed. Property string `json:"property"` // An array of values to test against the specified property. If any of the values match, the system includes the event.
**Note:** You must specify at least one element. - Value StringOrSlice `json:"value"` + Value util.StringOrSlice `json:"value"` } diff --git a/dashboard/model_simple_dashboard_model.go b/dashboard/model_simple_dashboard_model.go index 41f0af7..c6005d3 100644 --- a/dashboard/model_simple_dashboard_model.go +++ b/dashboard/model_simple_dashboard_model.go @@ -16,7 +16,7 @@ import ( // Dashboard object that describes the properties needed for a simple dashboard that's specified only by the charts it contains type SimpleDashboardModel struct { ChartDensity DashboardChartDensity `json:"chartDensity,omitempty"` - Charts []chart.Chart `json:"charts,omitempty"` + Charts []*chart.Chart `json:"charts,omitempty"` // The dashboard creation date and time, in the form of a Unix time value (milliseconds since the Unix epoch 1970-01-01 00:00:00 UTC+0). The system sets this value, and you can't modify it. Created int64 `json:"created,omitempty"` // SignalFx-assigned user ID of the user that created the dashboard. If the system created this dashboard, the value is \"AAAAAAAAAA\". The system sets this value, and you can't modify it. @@ -28,8 +28,8 @@ type SimpleDashboardModel struct { // Reserved for system use DiscoveryOptions map[string]interface{} `json:"discoveryOptions,omitempty"` // Array of event overlay definitions that you can apply to all of the charts of this dashboard. When you apply the overlays, the system displays all the active events that match the specified search term and any specified filter on all the charts in the dashboard. The display uses the color you specify for the overlay and, if selected, vertical lines that mark the event.
**Note:** The objects in this array correspond to the *suggested* event overlays specified in the web UI, and they're not automatically applied as active overlays. To set default active event overlays, use the `selectedEventOverlays` property instead. - EventOverlays []EventOverlayFilter `json:"eventOverlays,omitempty"` - Filters ChartsFilters `json:"filters,omitempty"` + EventOverlays []*EventOverlayFilter `json:"eventOverlays,omitempty"` + Filters ChartsFilters `json:"filters,omitempty"` // ID of an existing dashboard group to associate with this dashboard. If you don't specify a value, the system creates a new dashboard group and assigns its ID to this property during the create process. GroupId string `json:"groupId,omitempty"` // The dashboard's SignalFx-assigned ID. This value is \"read-only\" for a create request. The system assigns it and returns it to you in the response. @@ -45,7 +45,7 @@ type SimpleDashboardModel struct { // The displayed name of the chart in the dashboard Name string `json:"name,omitempty"` // Array of event overlays that are currently active for the charts in this dashboard. For each overlay, the system displays the active events that match the overlay search term and optional feature, using the the overlay's color and event line settings. To set options for inactive overlays so you can apply them at a later time, use the `eventOverlays` property instead. - SelectedEventOverlays []ChartEventOverlay `json:"selectedEventOverlays,omitempty"` + SelectedEventOverlays []*ChartEventOverlay `json:"selectedEventOverlays,omitempty"` // An array that contains tag values. You can use tags to search for or filter charts. One use is to tag charts that are in production with the value `prod`.
**NOTE:** You can't have more than 50 tags per chart. Tags []string `json:"tags,omitempty"` } diff --git a/dashboard_group/model_dashboard_config.go b/dashboard_group/model_dashboard_config.go index 9776f91..a99adeb 100644 --- a/dashboard_group/model_dashboard_config.go +++ b/dashboard_group/model_dashboard_config.go @@ -8,7 +8,7 @@ type DashboardConfig struct { // String that provides a description override for a mirrored dashboard DescriptionOverride string `json:"descriptionOverride,omitempty"` // Filter and dashboard variable overrides for the mirrored dashboard - FiltersOverride Filters `json:"filters,omitempty"` + FiltersOverride *Filters `json:"filters,omitempty"` // String that overrides the name of the dashboard specified in dashboardId. This property is primarily intended to provide a unique name for a mirrored dashboard. NameOverride string `json:"nameOverride,omitempty"` } diff --git a/dashboard_group/model_filter.go b/dashboard_group/model_filter.go index 85ef837..90b9e12 100644 --- a/dashboard_group/model_filter.go +++ b/dashboard_group/model_filter.go @@ -9,6 +9,8 @@ package dashboard_group +import "github.com/signalfx/signalfx-go/util" + // A single filter object to apply to the charts in the dashboard. The filter specifies a default or user-defined dimension or custom property. You can either include or exclude all the data that matches the dimension or custom property. type Filter struct { // Flag that indicates how the filter should operate. If `true`, data that matches the criteria is _excluded_ from charts; otherwise, data that matches the criteria is included. @@ -16,5 +18,5 @@ type Filter struct { // Name of the dimension or custom property to match to the data.
**Note:** If the dimension or custom property doesn't exist in any of the charts for the dashboard, and `ChartsFilterObject.NOT` is `true`, the system doesn't display any data in the charts. Property string `json:"property"` // A list of values to compare to the value of the dimension or custom property specified in `ChartsFilterObject.property`. If the list contains more than one value, the filter becomes a set of queries between the value of `property` and each element of `value`. The system joins these queries with an implicit OR. - Value []string `json:"value"` + Values util.StringOrSlice `json:"value"` } diff --git a/dashboard_group/model_filters.go b/dashboard_group/model_filters.go index a6bf2a5..b20c4c9 100644 --- a/dashboard_group/model_filters.go +++ b/dashboard_group/model_filters.go @@ -12,8 +12,7 @@ package dashboard_group // Specifies the properties of filters to apply to the cloned dashboard.
This is an *optional* property that you only need to use if you want to override the `filters` property of the dashboard you're cloning. Filters give you fine-grained control over the data displayed in the charts in the dashboard. You can specify *ad hoc* filters or save them as variables for repeated use of the filter criteria.
You can also use filters to apply a custom time window to all of the charts in the dashboard. type Filters struct { // List of filter objects to apply to the charts in the dashboard. Each object specifies a single filter for a default or user-defined dimension or custom property. - Sources []Filter `json:"sources,omitempty"` - Time FiltersTime `json:"time,omitempty"` + Sources []*Filter `json:"sources,omitempty"` // Array of web UI-oriented filters that appear at the top of the dashboard. For each filter you can specify a name and a label for the dimension or custom property to filter against, a list of suggested comparison values to display in the web UI, and other properties that control the web UI display. To see a more detailed description of the options, see the property descriptions for the `ChartsWebUIFilter` model. - Variables []WebUiFilter `json:"variables,omitempty"` + Variables []*WebUiFilter `json:"variables,omitempty"` } diff --git a/dashboard_group/model_search_result.go b/dashboard_group/model_search_result.go index 8fdab9c..2aa654a 100644 --- a/dashboard_group/model_search_result.go +++ b/dashboard_group/model_search_result.go @@ -13,5 +13,5 @@ type SearchResult struct { // Number of dashboard group objects that matched the provided search criteria.
**Note:** This value is a count of the total number of objects in the result set. The number of objects that the system returns is affected by the `limit` and `offset` query parameters. In summary:
* `count`: Size of result set * number of returned objects: * (`limit` - `offset`) >= `count`: `count` * (`limit` - `offset`) < `count`: `limit` - `offset` Count int32 `json:"count,omitempty"` // Array of dashboard group objects that the system returns as the result of the request. These objects represent dashboard groups that match the search query. The number and location of the objects within the result set depend on the query parameters you specify in the request. To learn more, see the top-level description of the API and the description of the `count` response property. - Results []DashboardGroup `json:"results,omitempty"` + Results []*DashboardGroup `json:"results,omitempty"` } diff --git a/dashboard_group/model_web_ui_filter.go b/dashboard_group/model_web_ui_filter.go index dd92730..bc162d2 100644 --- a/dashboard_group/model_web_ui_filter.go +++ b/dashboard_group/model_web_ui_filter.go @@ -9,18 +9,15 @@ package dashboard_group +import "github.com/signalfx/signalfx-go/util" + // The specification for a filter that appears in the web UI. The filter compares the value of a dimension or custom property to a value specified in this filter. You can specify the following in the filter:
* A default value * A list of suggested values to display in the web UI * A flag that controls user input; if set to `true`, users are limited to the default and suggested values.
You can also force users to choose this filter in order to see data in the dashboard's charts. type WebUiFilter struct { - // A label for the filter. The system displays this label in the area preceding the input textarea for the filter in the web UI.
**Note:** A good way to indicate that the string is a label is to append a space and a colon (\":\") to it. - Alias string `json:"alias,omitempty"` // Array of strings containing values to place at the top of the **Suggested Values** dropdown in web UI for the dashboard. If `ChartsWebUIFilter.restricted` is `true`, the filter must use one of the values in this array; users only have a choice of selecting a value from this array. - PreferredSuggestions []string `json:"preferredSuggestions,omitempty"` + PreferredSuggestions util.StringOrSlice `json:"preferredSuggestions,omitempty"` // Name of a custom property or dimension to filter against.
**Note:** If the dimension or custom property doesn't exist in any of the charts for the dashboard, the system doesn't display any data in the charts. Property string `json:"property"` // Flag that controls the display of chart data. If `true`, users must use this filter in order to see data; otherwise, users can delete the filter. - Required bool `json:"required,omitempty"` - // Flag that controls the values allowed in the filter. If `true`, the only allowable values are those specified in the `ChartsWebUIFilter.preferredSuggestions` array; otherwise, any value is allowed. - Restricted bool `json:"restricted,omitempty"` // A list of values to compare to the value of the dimension or custom property specified in `ChartsWebUIFilter.property`. If the list contains more than one value, the filter becomes a set of queries between the value of `property` and each element of `value`. The system joins these queries with an implicit OR. - Value []string `json:"value"` + Value util.StringOrSlice `json:"value"` } diff --git a/dashboard/string_or_slice.go b/util/string_or_slice.go similarity index 96% rename from dashboard/string_or_slice.go rename to util/string_or_slice.go index 1536f58..c9a6714 100644 --- a/dashboard/string_or_slice.go +++ b/util/string_or_slice.go @@ -1,4 +1,4 @@ -package dashboard +package util import "encoding/json"