From 09fd0fd9d221019e505d1373fcbc9a1a10d78cf2 Mon Sep 17 00:00:00 2001 From: Mark Hintz Date: Mon, 12 Aug 2019 11:14:49 -0400 Subject: [PATCH] [dashboard widget] Add table widget (#258) --- board_widgets.go | 40 +++- datadog-accessors.go | 434 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 471 insertions(+), 3 deletions(-) diff --git a/board_widgets.go b/board_widgets.go index d96ef7f..4264576 100644 --- a/board_widgets.go +++ b/board_widgets.go @@ -31,6 +31,7 @@ const ( MANAGE_STATUS_WIDGET = "manage_status" NOTE_WIDGET = "note" QUERY_VALUE_WIDGET = "query_value" + QUERY_TABLE_WIDGET = "query_table" SCATTERPLOT_WIDGET = "scatterplot" TIMESERIES_WIDGET = "timeseries" TOPLIST_WIDGET = "toplist" @@ -89,6 +90,8 @@ func (widget *BoardWidget) GetWidgetType() (string, error) { return NOTE_WIDGET, nil case QueryValueDefinition: return QUERY_VALUE_WIDGET, nil + case QueryTableDefinition: + return QUERY_TABLE_WIDGET, nil case ScatterplotDefinition: return SCATTERPLOT_WIDGET, nil case TimeseriesDefinition: @@ -238,7 +241,7 @@ type HeatmapRequest struct { ProcessQuery *WidgetProcessQuery `json:"process_query,omitempty"` } -// HostmapDefinition represents the definition for a Heatmap widget +// HostmapDefinition represents the definition for a Hostmap widget type HostmapDefinition struct { Type *string `json:"type"` Requests *HostmapRequests `json:"requests"` @@ -346,7 +349,29 @@ type QueryValueRequest struct { ProcessQuery *WidgetProcessQuery `json:"process_query,omitempty"` } -// ScatterplotDefinition represents the definition for a Heatmap widget +// QueryTableDefinition represents the definition for a Table widget +type QueryTableDefinition struct { + Type *string `json:"type"` + Requests []QueryTableRequest `json:"requests"` + Title *string `json:"title,omitempty"` + TitleSize *string `json:"title_size,omitempty"` + TitleAlign *string `json:"title_align,omitempty"` + Time *WidgetTime `json:"time,omitempty"` +} +type QueryTableRequest struct { + Alias *string `json:"alias,omitempty"` + ConditionalFormats []WidgetConditionalFormat `json:"conditional_formats,omitempty"` + Aggregator *string `json:"aggregator,omitempty"` + Limit *int `json:"limit,omitempty"` + Order *string `json:"order,omitempty"` + // A QueryTableRequest should implement exactly one of the following query types + MetricQuery *string `json:"q,omitempty"` + ApmQuery *WidgetApmOrLogQuery `json:"apm_query,omitempty"` + LogQuery *WidgetApmOrLogQuery `json:"log_query,omitempty"` + ProcessQuery *WidgetProcessQuery `json:"process_query,omitempty"` +} + +// ScatterplotDefinition represents the definition for a Scatterplot widget type ScatterplotDefinition struct { Type *string `json:"type"` Requests *ScatterplotRequests `json:"requests"` @@ -401,7 +426,7 @@ type TimeseriesRequestStyle struct { LineWidth *string `json:"line_width,omitempty"` } -// ToplistDefinition represents the definition for a Distribution widget +// ToplistDefinition represents the definition for a Top list widget type ToplistDefinition struct { Type *string `json:"type"` Requests []ToplistRequest `json:"requests"` @@ -599,6 +624,14 @@ func (widget *BoardWidget) UnmarshalJSON(data []byte) error { return err } widget.Definition = queryValueWidget.Definition + case QUERY_TABLE_WIDGET: + var queryTableWidget struct { + Definition QueryTableDefinition `json:"definition"` + } + if err := json.Unmarshal(data, &queryTableWidget); err != nil { + return err + } + widget.Definition = queryTableWidget.Definition case SCATTERPLOT_WIDGET: var scatterplotWidget struct { Definition ScatterplotDefinition `json:"definition"` @@ -678,6 +711,7 @@ type WidgetConditionalFormat struct { ImageUrl *string `json:"image_url,omitempty"` HideValue *bool `json:"hide_value,omitempty"` Timeframe *string `json:"timeframe,omitempty"` + Metric *string `json:"metric,omitempty"` } // WidgetApmOrLogQuery represents an APM or a Log query diff --git a/datadog-accessors.go b/datadog-accessors.go index 4787f10..96f859c 100644 --- a/datadog-accessors.go +++ b/datadog-accessors.go @@ -12445,6 +12445,409 @@ func (q *QueryConfig) SetTimeRange(v TimeRange) { q.TimeRange = &v } +// GetTime returns the Time field if non-nil, zero value otherwise. +func (q *QueryTableDefinition) GetTime() WidgetTime { + if q == nil || q.Time == nil { + return WidgetTime{} + } + return *q.Time +} + +// GetTimeOk returns a tuple with the Time field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableDefinition) GetTimeOk() (WidgetTime, bool) { + if q == nil || q.Time == nil { + return WidgetTime{}, false + } + return *q.Time, true +} + +// HasTime returns a boolean if a field has been set. +func (q *QueryTableDefinition) HasTime() bool { + if q != nil && q.Time != nil { + return true + } + + return false +} + +// SetTime allocates a new q.Time and returns the pointer to it. +func (q *QueryTableDefinition) SetTime(v WidgetTime) { + q.Time = &v +} + +// GetTitle returns the Title field if non-nil, zero value otherwise. +func (q *QueryTableDefinition) GetTitle() string { + if q == nil || q.Title == nil { + return "" + } + return *q.Title +} + +// GetTitleOk returns a tuple with the Title field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableDefinition) GetTitleOk() (string, bool) { + if q == nil || q.Title == nil { + return "", false + } + return *q.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (q *QueryTableDefinition) HasTitle() bool { + if q != nil && q.Title != nil { + return true + } + + return false +} + +// SetTitle allocates a new q.Title and returns the pointer to it. +func (q *QueryTableDefinition) SetTitle(v string) { + q.Title = &v +} + +// GetTitleAlign returns the TitleAlign field if non-nil, zero value otherwise. +func (q *QueryTableDefinition) GetTitleAlign() string { + if q == nil || q.TitleAlign == nil { + return "" + } + return *q.TitleAlign +} + +// GetTitleAlignOk returns a tuple with the TitleAlign field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableDefinition) GetTitleAlignOk() (string, bool) { + if q == nil || q.TitleAlign == nil { + return "", false + } + return *q.TitleAlign, true +} + +// HasTitleAlign returns a boolean if a field has been set. +func (q *QueryTableDefinition) HasTitleAlign() bool { + if q != nil && q.TitleAlign != nil { + return true + } + + return false +} + +// SetTitleAlign allocates a new q.TitleAlign and returns the pointer to it. +func (q *QueryTableDefinition) SetTitleAlign(v string) { + q.TitleAlign = &v +} + +// GetTitleSize returns the TitleSize field if non-nil, zero value otherwise. +func (q *QueryTableDefinition) GetTitleSize() string { + if q == nil || q.TitleSize == nil { + return "" + } + return *q.TitleSize +} + +// GetTitleSizeOk returns a tuple with the TitleSize field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableDefinition) GetTitleSizeOk() (string, bool) { + if q == nil || q.TitleSize == nil { + return "", false + } + return *q.TitleSize, true +} + +// HasTitleSize returns a boolean if a field has been set. +func (q *QueryTableDefinition) HasTitleSize() bool { + if q != nil && q.TitleSize != nil { + return true + } + + return false +} + +// SetTitleSize allocates a new q.TitleSize and returns the pointer to it. +func (q *QueryTableDefinition) SetTitleSize(v string) { + q.TitleSize = &v +} + +// GetType returns the Type field if non-nil, zero value otherwise. +func (q *QueryTableDefinition) GetType() string { + if q == nil || q.Type == nil { + return "" + } + return *q.Type +} + +// GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableDefinition) GetTypeOk() (string, bool) { + if q == nil || q.Type == nil { + return "", false + } + return *q.Type, true +} + +// HasType returns a boolean if a field has been set. +func (q *QueryTableDefinition) HasType() bool { + if q != nil && q.Type != nil { + return true + } + + return false +} + +// SetType allocates a new q.Type and returns the pointer to it. +func (q *QueryTableDefinition) SetType(v string) { + q.Type = &v +} + +// GetAggregator returns the Aggregator field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetAggregator() string { + if q == nil || q.Aggregator == nil { + return "" + } + return *q.Aggregator +} + +// GetAggregatorOk returns a tuple with the Aggregator field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetAggregatorOk() (string, bool) { + if q == nil || q.Aggregator == nil { + return "", false + } + return *q.Aggregator, true +} + +// HasAggregator returns a boolean if a field has been set. +func (q *QueryTableRequest) HasAggregator() bool { + if q != nil && q.Aggregator != nil { + return true + } + + return false +} + +// SetAggregator allocates a new q.Aggregator and returns the pointer to it. +func (q *QueryTableRequest) SetAggregator(v string) { + q.Aggregator = &v +} + +// GetAlias returns the Alias field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetAlias() string { + if q == nil || q.Alias == nil { + return "" + } + return *q.Alias +} + +// GetAliasOk returns a tuple with the Alias field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetAliasOk() (string, bool) { + if q == nil || q.Alias == nil { + return "", false + } + return *q.Alias, true +} + +// HasAlias returns a boolean if a field has been set. +func (q *QueryTableRequest) HasAlias() bool { + if q != nil && q.Alias != nil { + return true + } + + return false +} + +// SetAlias allocates a new q.Alias and returns the pointer to it. +func (q *QueryTableRequest) SetAlias(v string) { + q.Alias = &v +} + +// GetApmQuery returns the ApmQuery field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetApmQuery() WidgetApmOrLogQuery { + if q == nil || q.ApmQuery == nil { + return WidgetApmOrLogQuery{} + } + return *q.ApmQuery +} + +// GetApmQueryOk returns a tuple with the ApmQuery field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetApmQueryOk() (WidgetApmOrLogQuery, bool) { + if q == nil || q.ApmQuery == nil { + return WidgetApmOrLogQuery{}, false + } + return *q.ApmQuery, true +} + +// HasApmQuery returns a boolean if a field has been set. +func (q *QueryTableRequest) HasApmQuery() bool { + if q != nil && q.ApmQuery != nil { + return true + } + + return false +} + +// SetApmQuery allocates a new q.ApmQuery and returns the pointer to it. +func (q *QueryTableRequest) SetApmQuery(v WidgetApmOrLogQuery) { + q.ApmQuery = &v +} + +// GetLimit returns the Limit field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetLimit() int { + if q == nil || q.Limit == nil { + return 0 + } + return *q.Limit +} + +// GetLimitOk returns a tuple with the Limit field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetLimitOk() (int, bool) { + if q == nil || q.Limit == nil { + return 0, false + } + return *q.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (q *QueryTableRequest) HasLimit() bool { + if q != nil && q.Limit != nil { + return true + } + + return false +} + +// SetLimit allocates a new q.Limit and returns the pointer to it. +func (q *QueryTableRequest) SetLimit(v int) { + q.Limit = &v +} + +// GetLogQuery returns the LogQuery field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetLogQuery() WidgetApmOrLogQuery { + if q == nil || q.LogQuery == nil { + return WidgetApmOrLogQuery{} + } + return *q.LogQuery +} + +// GetLogQueryOk returns a tuple with the LogQuery field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetLogQueryOk() (WidgetApmOrLogQuery, bool) { + if q == nil || q.LogQuery == nil { + return WidgetApmOrLogQuery{}, false + } + return *q.LogQuery, true +} + +// HasLogQuery returns a boolean if a field has been set. +func (q *QueryTableRequest) HasLogQuery() bool { + if q != nil && q.LogQuery != nil { + return true + } + + return false +} + +// SetLogQuery allocates a new q.LogQuery and returns the pointer to it. +func (q *QueryTableRequest) SetLogQuery(v WidgetApmOrLogQuery) { + q.LogQuery = &v +} + +// GetMetricQuery returns the MetricQuery field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetMetricQuery() string { + if q == nil || q.MetricQuery == nil { + return "" + } + return *q.MetricQuery +} + +// GetMetricQueryOk returns a tuple with the MetricQuery field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetMetricQueryOk() (string, bool) { + if q == nil || q.MetricQuery == nil { + return "", false + } + return *q.MetricQuery, true +} + +// HasMetricQuery returns a boolean if a field has been set. +func (q *QueryTableRequest) HasMetricQuery() bool { + if q != nil && q.MetricQuery != nil { + return true + } + + return false +} + +// SetMetricQuery allocates a new q.MetricQuery and returns the pointer to it. +func (q *QueryTableRequest) SetMetricQuery(v string) { + q.MetricQuery = &v +} + +// GetOrder returns the Order field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetOrder() string { + if q == nil || q.Order == nil { + return "" + } + return *q.Order +} + +// GetOrderOk returns a tuple with the Order field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetOrderOk() (string, bool) { + if q == nil || q.Order == nil { + return "", false + } + return *q.Order, true +} + +// HasOrder returns a boolean if a field has been set. +func (q *QueryTableRequest) HasOrder() bool { + if q != nil && q.Order != nil { + return true + } + + return false +} + +// SetOrder allocates a new q.Order and returns the pointer to it. +func (q *QueryTableRequest) SetOrder(v string) { + q.Order = &v +} + +// GetProcessQuery returns the ProcessQuery field if non-nil, zero value otherwise. +func (q *QueryTableRequest) GetProcessQuery() WidgetProcessQuery { + if q == nil || q.ProcessQuery == nil { + return WidgetProcessQuery{} + } + return *q.ProcessQuery +} + +// GetProcessQueryOk returns a tuple with the ProcessQuery field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (q *QueryTableRequest) GetProcessQueryOk() (WidgetProcessQuery, bool) { + if q == nil || q.ProcessQuery == nil { + return WidgetProcessQuery{}, false + } + return *q.ProcessQuery, true +} + +// HasProcessQuery returns a boolean if a field has been set. +func (q *QueryTableRequest) HasProcessQuery() bool { + if q != nil && q.ProcessQuery != nil { + return true + } + + return false +} + +// SetProcessQuery allocates a new q.ProcessQuery and returns the pointer to it. +func (q *QueryTableRequest) SetProcessQuery(v WidgetProcessQuery) { + q.ProcessQuery = &v +} + // GetAutoscale returns the Autoscale field if non-nil, zero value otherwise. func (q *QueryValueDefinition) GetAutoscale() bool { if q == nil || q.Autoscale == nil { @@ -23047,6 +23450,37 @@ func (w *WidgetConditionalFormat) SetImageUrl(v string) { w.ImageUrl = &v } +// GetMetric returns the Metric field if non-nil, zero value otherwise. +func (w *WidgetConditionalFormat) GetMetric() string { + if w == nil || w.Metric == nil { + return "" + } + return *w.Metric +} + +// GetMetricOk returns a tuple with the Metric field if it's non-nil, zero value otherwise +// and a boolean to check if the value has been set. +func (w *WidgetConditionalFormat) GetMetricOk() (string, bool) { + if w == nil || w.Metric == nil { + return "", false + } + return *w.Metric, true +} + +// HasMetric returns a boolean if a field has been set. +func (w *WidgetConditionalFormat) HasMetric() bool { + if w != nil && w.Metric != nil { + return true + } + + return false +} + +// SetMetric allocates a new w.Metric and returns the pointer to it. +func (w *WidgetConditionalFormat) SetMetric(v string) { + w.Metric = &v +} + // GetPalette returns the Palette field if non-nil, zero value otherwise. func (w *WidgetConditionalFormat) GetPalette() string { if w == nil || w.Palette == nil {