diff --git a/.apigentools-info b/.apigentools-info index a3b04aa13d7..dfad967bc6e 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.5", - "regenerated": "2023-09-07 17:53:18.139172", - "spec_repo_commit": "40dbfff2" + "regenerated": "2023-09-08 13:34:43.333547", + "spec_repo_commit": "e0828d3f" }, "v2": { "apigentools_version": "1.6.5", - "regenerated": "2023-09-07 17:53:18.152354", - "spec_repo_commit": "40dbfff2" + "regenerated": "2023-09-08 13:34:43.388925", + "spec_repo_commit": "e0828d3f" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e32b062880a..49717e5c878 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -12030,6 +12030,174 @@ components: items: $ref: '#/components/schemas/SlackIntegrationChannel' type: array + SplitConfig: + description: Encapsulates all user choices about how to split a graph. + properties: + limit: + description: Maximum number of graphs to display in the widget. + example: 24 + format: int64 + maximum: 100 + minimum: 1 + type: integer + sort: + $ref: '#/components/schemas/SplitSort' + split_dimensions: + description: The dimension(s) on which to split the graph + items: + $ref: '#/components/schemas/SplitDimension' + maxItems: 1 + minItems: 1 + type: array + static_splits: + description: Manual selection of tags making split graph widget static + items: + $ref: '#/components/schemas/SplitVectorEntry' + maxItems: 100 + minItems: 1 + type: array + required: + - split_dimensions + - limit + - sort + type: object + SplitConfigSortCompute: + description: Defines the metric and aggregation used as the sort value. + properties: + aggregation: + description: The metric to use for sorting graphs. + example: sum + type: string + metric: + description: How to aggregate the sort metric for the purposes of ordering. + example: system.cpu.user + type: string + required: + - aggregation + - metric + type: object + SplitDimension: + description: The property by which the graph splits + example: + one_graph_per: service + properties: + one_graph_per: + description: The system interprets this attribute differently depending + on the data source of the query being split. For metrics, it's a tag. + For the events platform, it's an attribute or tag. + example: service + type: string + required: + - one_graph_per + type: object + SplitGraphSourceWidgetDefinition: + description: The original widget we are splitting on. + oneOf: + - $ref: '#/components/schemas/ChangeWidgetDefinition' + - $ref: '#/components/schemas/GeomapWidgetDefinition' + - $ref: '#/components/schemas/QueryValueWidgetDefinition' + - $ref: '#/components/schemas/ScatterPlotWidgetDefinition' + - $ref: '#/components/schemas/SunburstWidgetDefinition' + - $ref: '#/components/schemas/TimeseriesWidgetDefinition' + - $ref: '#/components/schemas/ToplistWidgetDefinition' + - $ref: '#/components/schemas/TreeMapWidgetDefinition' + SplitGraphVizSize: + description: Size of the individual graphs in the split. + enum: + - xs + - sm + - md + - lg + example: sm + type: string + x-enum-varnames: + - XS + - SM + - MD + - LG + SplitGraphWidgetDefinition: + description: 'The split graph widget allows you to create repeating units of + a graph - one for each value in a group (for example: one per service) + + ' + properties: + has_uniform_y_axes: + description: Normalize y axes across graphs + type: boolean + size: + $ref: '#/components/schemas/SplitGraphVizSize' + source_widget_definition: + $ref: '#/components/schemas/SplitGraphSourceWidgetDefinition' + split_config: + $ref: '#/components/schemas/SplitConfig' + time: + $ref: '#/components/schemas/WidgetTime' + title: + description: Title of your widget. + type: string + title_align: + $ref: '#/components/schemas/WidgetTextAlign' + title_size: + description: Size of the title. + type: string + type: + $ref: '#/components/schemas/SplitGraphWidgetDefinitionType' + required: + - size + - type + - source_widget_definition + - split_config + type: object + SplitGraphWidgetDefinitionType: + default: split_group + description: Type of the split graph widget + enum: + - split_group + example: split_group + type: string + x-enum-varnames: + - SPLIT_GROUP + SplitSort: + description: Controls the order in which graphs appear in the split. + properties: + compute: + $ref: '#/components/schemas/SplitConfigSortCompute' + order: + $ref: '#/components/schemas/WidgetSort' + required: + - order + type: object + SplitVectorEntry: + description: The widget displays one graph for each entry in this parameter. + example: + - tag_key: demo + tag_values: + - env + items: + $ref: '#/components/schemas/SplitVectorEntryItem' + type: array + SplitVectorEntryItem: + description: The split graph list contains a graph for each value of the split + dimension. + minLength: 1 + properties: + tag_key: + description: The tag key. + example: demo + minLength: 1 + type: string + tag_values: + description: The tag values. + example: + - env + items: + minLength: 1 + type: string + type: array + required: + - tag_key + - tag_values + type: object SuccessfulSignalUpdateResponse: description: Updated signal data following a successfully performed update. properties: @@ -19486,30 +19654,31 @@ components: - $ref: '#/components/schemas/EventStreamWidgetDefinition' - $ref: '#/components/schemas/EventTimelineWidgetDefinition' - $ref: '#/components/schemas/FreeTextWidgetDefinition' + - $ref: '#/components/schemas/FunnelWidgetDefinition' - $ref: '#/components/schemas/GeomapWidgetDefinition' - $ref: '#/components/schemas/GroupWidgetDefinition' - $ref: '#/components/schemas/HeatMapWidgetDefinition' - $ref: '#/components/schemas/HostMapWidgetDefinition' - $ref: '#/components/schemas/IFrameWidgetDefinition' - $ref: '#/components/schemas/ImageWidgetDefinition' + - $ref: '#/components/schemas/ListStreamWidgetDefinition' - $ref: '#/components/schemas/LogStreamWidgetDefinition' - $ref: '#/components/schemas/MonitorSummaryWidgetDefinition' - $ref: '#/components/schemas/NoteWidgetDefinition' - $ref: '#/components/schemas/QueryValueWidgetDefinition' - $ref: '#/components/schemas/RunWorkflowWidgetDefinition' - - $ref: '#/components/schemas/ScatterPlotWidgetDefinition' - - $ref: '#/components/schemas/SLOWidgetDefinition' - $ref: '#/components/schemas/SLOListWidgetDefinition' + - $ref: '#/components/schemas/SLOWidgetDefinition' + - $ref: '#/components/schemas/ScatterPlotWidgetDefinition' - $ref: '#/components/schemas/ServiceMapWidgetDefinition' - $ref: '#/components/schemas/ServiceSummaryWidgetDefinition' + - $ref: '#/components/schemas/SplitGraphWidgetDefinition' - $ref: '#/components/schemas/SunburstWidgetDefinition' - $ref: '#/components/schemas/TableWidgetDefinition' - $ref: '#/components/schemas/TimeseriesWidgetDefinition' - $ref: '#/components/schemas/ToplistWidgetDefinition' - - $ref: '#/components/schemas/TreeMapWidgetDefinition' - - $ref: '#/components/schemas/ListStreamWidgetDefinition' - - $ref: '#/components/schemas/FunnelWidgetDefinition' - $ref: '#/components/schemas/TopologyMapWidgetDefinition' + - $ref: '#/components/schemas/TreeMapWidgetDefinition' WidgetDisplayType: description: Type of display to use for the request. enum: diff --git a/api/datadogV1/model_split_config.go b/api/datadogV1/model_split_config.go new file mode 100644 index 00000000000..a074131f12c --- /dev/null +++ b/api/datadogV1/model_split_config.go @@ -0,0 +1,211 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SplitConfig Encapsulates all user choices about how to split a graph. +type SplitConfig struct { + // Maximum number of graphs to display in the widget. + Limit int64 `json:"limit"` + // Controls the order in which graphs appear in the split. + Sort SplitSort `json:"sort"` + // The dimension(s) on which to split the graph + SplitDimensions []SplitDimension `json:"split_dimensions"` + // Manual selection of tags making split graph widget static + StaticSplits [][]SplitVectorEntryItem `json:"static_splits,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSplitConfig instantiates a new SplitConfig object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSplitConfig(limit int64, sort SplitSort, splitDimensions []SplitDimension) *SplitConfig { + this := SplitConfig{} + this.Limit = limit + this.Sort = sort + this.SplitDimensions = splitDimensions + return &this +} + +// NewSplitConfigWithDefaults instantiates a new SplitConfig object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSplitConfigWithDefaults() *SplitConfig { + this := SplitConfig{} + return &this +} + +// GetLimit returns the Limit field value. +func (o *SplitConfig) GetLimit() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value +// and a boolean to check if the value has been set. +func (o *SplitConfig) GetLimitOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Limit, true +} + +// SetLimit sets field value. +func (o *SplitConfig) SetLimit(v int64) { + o.Limit = v +} + +// GetSort returns the Sort field value. +func (o *SplitConfig) GetSort() SplitSort { + if o == nil { + var ret SplitSort + return ret + } + return o.Sort +} + +// GetSortOk returns a tuple with the Sort field value +// and a boolean to check if the value has been set. +func (o *SplitConfig) GetSortOk() (*SplitSort, bool) { + if o == nil { + return nil, false + } + return &o.Sort, true +} + +// SetSort sets field value. +func (o *SplitConfig) SetSort(v SplitSort) { + o.Sort = v +} + +// GetSplitDimensions returns the SplitDimensions field value. +func (o *SplitConfig) GetSplitDimensions() []SplitDimension { + if o == nil { + var ret []SplitDimension + return ret + } + return o.SplitDimensions +} + +// GetSplitDimensionsOk returns a tuple with the SplitDimensions field value +// and a boolean to check if the value has been set. +func (o *SplitConfig) GetSplitDimensionsOk() (*[]SplitDimension, bool) { + if o == nil { + return nil, false + } + return &o.SplitDimensions, true +} + +// SetSplitDimensions sets field value. +func (o *SplitConfig) SetSplitDimensions(v []SplitDimension) { + o.SplitDimensions = v +} + +// GetStaticSplits returns the StaticSplits field value if set, zero value otherwise. +func (o *SplitConfig) GetStaticSplits() [][]SplitVectorEntryItem { + if o == nil || o.StaticSplits == nil { + var ret [][]SplitVectorEntryItem + return ret + } + return o.StaticSplits +} + +// GetStaticSplitsOk returns a tuple with the StaticSplits field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitConfig) GetStaticSplitsOk() (*[][]SplitVectorEntryItem, bool) { + if o == nil || o.StaticSplits == nil { + return nil, false + } + return &o.StaticSplits, true +} + +// HasStaticSplits returns a boolean if a field has been set. +func (o *SplitConfig) HasStaticSplits() bool { + return o != nil && o.StaticSplits != nil +} + +// SetStaticSplits gets a reference to the given [][]SplitVectorEntryItem and assigns it to the StaticSplits field. +func (o *SplitConfig) SetStaticSplits(v [][]SplitVectorEntryItem) { + o.StaticSplits = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SplitConfig) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["limit"] = o.Limit + toSerialize["sort"] = o.Sort + toSerialize["split_dimensions"] = o.SplitDimensions + if o.StaticSplits != nil { + toSerialize["static_splits"] = o.StaticSplits + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SplitConfig) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Limit *int64 `json:"limit"` + Sort *SplitSort `json:"sort"` + SplitDimensions *[]SplitDimension `json:"split_dimensions"` + StaticSplits [][]SplitVectorEntryItem `json:"static_splits,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Limit == nil { + return fmt.Errorf("required field limit missing") + } + if all.Sort == nil { + return fmt.Errorf("required field sort missing") + } + if all.SplitDimensions == nil { + return fmt.Errorf("required field split_dimensions missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"limit", "sort", "split_dimensions", "static_splits"}) + } else { + return err + } + + hasInvalidField := false + o.Limit = *all.Limit + if all.Sort.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Sort = *all.Sort + o.SplitDimensions = *all.SplitDimensions + o.StaticSplits = all.StaticSplits + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV1/model_split_config_sort_compute.go b/api/datadogV1/model_split_config_sort_compute.go new file mode 100644 index 00000000000..3507425a0e5 --- /dev/null +++ b/api/datadogV1/model_split_config_sort_compute.go @@ -0,0 +1,135 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SplitConfigSortCompute Defines the metric and aggregation used as the sort value. +type SplitConfigSortCompute struct { + // The metric to use for sorting graphs. + Aggregation string `json:"aggregation"` + // How to aggregate the sort metric for the purposes of ordering. + Metric string `json:"metric"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSplitConfigSortCompute instantiates a new SplitConfigSortCompute object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSplitConfigSortCompute(aggregation string, metric string) *SplitConfigSortCompute { + this := SplitConfigSortCompute{} + this.Aggregation = aggregation + this.Metric = metric + return &this +} + +// NewSplitConfigSortComputeWithDefaults instantiates a new SplitConfigSortCompute object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSplitConfigSortComputeWithDefaults() *SplitConfigSortCompute { + this := SplitConfigSortCompute{} + return &this +} + +// GetAggregation returns the Aggregation field value. +func (o *SplitConfigSortCompute) GetAggregation() string { + if o == nil { + var ret string + return ret + } + return o.Aggregation +} + +// GetAggregationOk returns a tuple with the Aggregation field value +// and a boolean to check if the value has been set. +func (o *SplitConfigSortCompute) GetAggregationOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Aggregation, true +} + +// SetAggregation sets field value. +func (o *SplitConfigSortCompute) SetAggregation(v string) { + o.Aggregation = v +} + +// GetMetric returns the Metric field value. +func (o *SplitConfigSortCompute) GetMetric() string { + if o == nil { + var ret string + return ret + } + return o.Metric +} + +// GetMetricOk returns a tuple with the Metric field value +// and a boolean to check if the value has been set. +func (o *SplitConfigSortCompute) GetMetricOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Metric, true +} + +// SetMetric sets field value. +func (o *SplitConfigSortCompute) SetMetric(v string) { + o.Metric = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SplitConfigSortCompute) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["aggregation"] = o.Aggregation + toSerialize["metric"] = o.Metric + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SplitConfigSortCompute) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Aggregation *string `json:"aggregation"` + Metric *string `json:"metric"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Aggregation == nil { + return fmt.Errorf("required field aggregation missing") + } + if all.Metric == nil { + return fmt.Errorf("required field metric missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"aggregation", "metric"}) + } else { + return err + } + o.Aggregation = *all.Aggregation + o.Metric = *all.Metric + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV1/model_split_dimension.go b/api/datadogV1/model_split_dimension.go new file mode 100644 index 00000000000..7498b1d2628 --- /dev/null +++ b/api/datadogV1/model_split_dimension.go @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SplitDimension The property by which the graph splits +type SplitDimension struct { + // The system interprets this attribute differently depending on the data source of the query being split. For metrics, it's a tag. For the events platform, it's an attribute or tag. + OneGraphPer string `json:"one_graph_per"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSplitDimension instantiates a new SplitDimension object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSplitDimension(oneGraphPer string) *SplitDimension { + this := SplitDimension{} + this.OneGraphPer = oneGraphPer + return &this +} + +// NewSplitDimensionWithDefaults instantiates a new SplitDimension object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSplitDimensionWithDefaults() *SplitDimension { + this := SplitDimension{} + return &this +} + +// GetOneGraphPer returns the OneGraphPer field value. +func (o *SplitDimension) GetOneGraphPer() string { + if o == nil { + var ret string + return ret + } + return o.OneGraphPer +} + +// GetOneGraphPerOk returns a tuple with the OneGraphPer field value +// and a boolean to check if the value has been set. +func (o *SplitDimension) GetOneGraphPerOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.OneGraphPer, true +} + +// SetOneGraphPer sets field value. +func (o *SplitDimension) SetOneGraphPer(v string) { + o.OneGraphPer = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SplitDimension) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["one_graph_per"] = o.OneGraphPer + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SplitDimension) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + OneGraphPer *string `json:"one_graph_per"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.OneGraphPer == nil { + return fmt.Errorf("required field one_graph_per missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"one_graph_per"}) + } else { + return err + } + o.OneGraphPer = *all.OneGraphPer + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV1/model_split_graph_source_widget_definition.go b/api/datadogV1/model_split_graph_source_widget_definition.go new file mode 100644 index 00000000000..c6dd2cbcd2f --- /dev/null +++ b/api/datadogV1/model_split_graph_source_widget_definition.go @@ -0,0 +1,297 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "github.com/goccy/go-json" +) + +// SplitGraphSourceWidgetDefinition - The original widget we are splitting on. +type SplitGraphSourceWidgetDefinition struct { + ChangeWidgetDefinition *ChangeWidgetDefinition + GeomapWidgetDefinition *GeomapWidgetDefinition + QueryValueWidgetDefinition *QueryValueWidgetDefinition + ScatterPlotWidgetDefinition *ScatterPlotWidgetDefinition + SunburstWidgetDefinition *SunburstWidgetDefinition + TimeseriesWidgetDefinition *TimeseriesWidgetDefinition + ToplistWidgetDefinition *ToplistWidgetDefinition + TreeMapWidgetDefinition *TreeMapWidgetDefinition + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// ChangeWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns ChangeWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func ChangeWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *ChangeWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{ChangeWidgetDefinition: v} +} + +// GeomapWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns GeomapWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func GeomapWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *GeomapWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{GeomapWidgetDefinition: v} +} + +// QueryValueWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns QueryValueWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func QueryValueWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *QueryValueWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{QueryValueWidgetDefinition: v} +} + +// ScatterPlotWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns ScatterPlotWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func ScatterPlotWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *ScatterPlotWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{ScatterPlotWidgetDefinition: v} +} + +// SunburstWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns SunburstWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func SunburstWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *SunburstWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{SunburstWidgetDefinition: v} +} + +// TimeseriesWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns TimeseriesWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func TimeseriesWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *TimeseriesWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{TimeseriesWidgetDefinition: v} +} + +// ToplistWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns ToplistWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func ToplistWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *ToplistWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{ToplistWidgetDefinition: v} +} + +// TreeMapWidgetDefinitionAsSplitGraphSourceWidgetDefinition is a convenience function that returns TreeMapWidgetDefinition wrapped in SplitGraphSourceWidgetDefinition. +func TreeMapWidgetDefinitionAsSplitGraphSourceWidgetDefinition(v *TreeMapWidgetDefinition) SplitGraphSourceWidgetDefinition { + return SplitGraphSourceWidgetDefinition{TreeMapWidgetDefinition: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *SplitGraphSourceWidgetDefinition) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into ChangeWidgetDefinition + err = json.Unmarshal(data, &obj.ChangeWidgetDefinition) + if err == nil { + if obj.ChangeWidgetDefinition != nil && obj.ChangeWidgetDefinition.UnparsedObject == nil { + jsonChangeWidgetDefinition, _ := json.Marshal(obj.ChangeWidgetDefinition) + if string(jsonChangeWidgetDefinition) == "{}" { // empty struct + obj.ChangeWidgetDefinition = nil + } else { + match++ + } + } else { + obj.ChangeWidgetDefinition = nil + } + } else { + obj.ChangeWidgetDefinition = nil + } + + // try to unmarshal data into GeomapWidgetDefinition + err = json.Unmarshal(data, &obj.GeomapWidgetDefinition) + if err == nil { + if obj.GeomapWidgetDefinition != nil && obj.GeomapWidgetDefinition.UnparsedObject == nil { + jsonGeomapWidgetDefinition, _ := json.Marshal(obj.GeomapWidgetDefinition) + if string(jsonGeomapWidgetDefinition) == "{}" { // empty struct + obj.GeomapWidgetDefinition = nil + } else { + match++ + } + } else { + obj.GeomapWidgetDefinition = nil + } + } else { + obj.GeomapWidgetDefinition = nil + } + + // try to unmarshal data into QueryValueWidgetDefinition + err = json.Unmarshal(data, &obj.QueryValueWidgetDefinition) + if err == nil { + if obj.QueryValueWidgetDefinition != nil && obj.QueryValueWidgetDefinition.UnparsedObject == nil { + jsonQueryValueWidgetDefinition, _ := json.Marshal(obj.QueryValueWidgetDefinition) + if string(jsonQueryValueWidgetDefinition) == "{}" { // empty struct + obj.QueryValueWidgetDefinition = nil + } else { + match++ + } + } else { + obj.QueryValueWidgetDefinition = nil + } + } else { + obj.QueryValueWidgetDefinition = nil + } + + // try to unmarshal data into ScatterPlotWidgetDefinition + err = json.Unmarshal(data, &obj.ScatterPlotWidgetDefinition) + if err == nil { + if obj.ScatterPlotWidgetDefinition != nil && obj.ScatterPlotWidgetDefinition.UnparsedObject == nil { + jsonScatterPlotWidgetDefinition, _ := json.Marshal(obj.ScatterPlotWidgetDefinition) + if string(jsonScatterPlotWidgetDefinition) == "{}" { // empty struct + obj.ScatterPlotWidgetDefinition = nil + } else { + match++ + } + } else { + obj.ScatterPlotWidgetDefinition = nil + } + } else { + obj.ScatterPlotWidgetDefinition = nil + } + + // try to unmarshal data into SunburstWidgetDefinition + err = json.Unmarshal(data, &obj.SunburstWidgetDefinition) + if err == nil { + if obj.SunburstWidgetDefinition != nil && obj.SunburstWidgetDefinition.UnparsedObject == nil { + jsonSunburstWidgetDefinition, _ := json.Marshal(obj.SunburstWidgetDefinition) + if string(jsonSunburstWidgetDefinition) == "{}" { // empty struct + obj.SunburstWidgetDefinition = nil + } else { + match++ + } + } else { + obj.SunburstWidgetDefinition = nil + } + } else { + obj.SunburstWidgetDefinition = nil + } + + // try to unmarshal data into TimeseriesWidgetDefinition + err = json.Unmarshal(data, &obj.TimeseriesWidgetDefinition) + if err == nil { + if obj.TimeseriesWidgetDefinition != nil && obj.TimeseriesWidgetDefinition.UnparsedObject == nil { + jsonTimeseriesWidgetDefinition, _ := json.Marshal(obj.TimeseriesWidgetDefinition) + if string(jsonTimeseriesWidgetDefinition) == "{}" { // empty struct + obj.TimeseriesWidgetDefinition = nil + } else { + match++ + } + } else { + obj.TimeseriesWidgetDefinition = nil + } + } else { + obj.TimeseriesWidgetDefinition = nil + } + + // try to unmarshal data into ToplistWidgetDefinition + err = json.Unmarshal(data, &obj.ToplistWidgetDefinition) + if err == nil { + if obj.ToplistWidgetDefinition != nil && obj.ToplistWidgetDefinition.UnparsedObject == nil { + jsonToplistWidgetDefinition, _ := json.Marshal(obj.ToplistWidgetDefinition) + if string(jsonToplistWidgetDefinition) == "{}" { // empty struct + obj.ToplistWidgetDefinition = nil + } else { + match++ + } + } else { + obj.ToplistWidgetDefinition = nil + } + } else { + obj.ToplistWidgetDefinition = nil + } + + // try to unmarshal data into TreeMapWidgetDefinition + err = json.Unmarshal(data, &obj.TreeMapWidgetDefinition) + if err == nil { + if obj.TreeMapWidgetDefinition != nil && obj.TreeMapWidgetDefinition.UnparsedObject == nil { + jsonTreeMapWidgetDefinition, _ := json.Marshal(obj.TreeMapWidgetDefinition) + if string(jsonTreeMapWidgetDefinition) == "{}" { // empty struct + obj.TreeMapWidgetDefinition = nil + } else { + match++ + } + } else { + obj.TreeMapWidgetDefinition = nil + } + } else { + obj.TreeMapWidgetDefinition = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.ChangeWidgetDefinition = nil + obj.GeomapWidgetDefinition = nil + obj.QueryValueWidgetDefinition = nil + obj.ScatterPlotWidgetDefinition = nil + obj.SunburstWidgetDefinition = nil + obj.TimeseriesWidgetDefinition = nil + obj.ToplistWidgetDefinition = nil + obj.TreeMapWidgetDefinition = nil + return json.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj SplitGraphSourceWidgetDefinition) MarshalJSON() ([]byte, error) { + if obj.ChangeWidgetDefinition != nil { + return json.Marshal(&obj.ChangeWidgetDefinition) + } + + if obj.GeomapWidgetDefinition != nil { + return json.Marshal(&obj.GeomapWidgetDefinition) + } + + if obj.QueryValueWidgetDefinition != nil { + return json.Marshal(&obj.QueryValueWidgetDefinition) + } + + if obj.ScatterPlotWidgetDefinition != nil { + return json.Marshal(&obj.ScatterPlotWidgetDefinition) + } + + if obj.SunburstWidgetDefinition != nil { + return json.Marshal(&obj.SunburstWidgetDefinition) + } + + if obj.TimeseriesWidgetDefinition != nil { + return json.Marshal(&obj.TimeseriesWidgetDefinition) + } + + if obj.ToplistWidgetDefinition != nil { + return json.Marshal(&obj.ToplistWidgetDefinition) + } + + if obj.TreeMapWidgetDefinition != nil { + return json.Marshal(&obj.TreeMapWidgetDefinition) + } + + if obj.UnparsedObject != nil { + return json.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *SplitGraphSourceWidgetDefinition) GetActualInstance() interface{} { + if obj.ChangeWidgetDefinition != nil { + return obj.ChangeWidgetDefinition + } + + if obj.GeomapWidgetDefinition != nil { + return obj.GeomapWidgetDefinition + } + + if obj.QueryValueWidgetDefinition != nil { + return obj.QueryValueWidgetDefinition + } + + if obj.ScatterPlotWidgetDefinition != nil { + return obj.ScatterPlotWidgetDefinition + } + + if obj.SunburstWidgetDefinition != nil { + return obj.SunburstWidgetDefinition + } + + if obj.TimeseriesWidgetDefinition != nil { + return obj.TimeseriesWidgetDefinition + } + + if obj.ToplistWidgetDefinition != nil { + return obj.ToplistWidgetDefinition + } + + if obj.TreeMapWidgetDefinition != nil { + return obj.TreeMapWidgetDefinition + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV1/model_split_graph_viz_size.go b/api/datadogV1/model_split_graph_viz_size.go new file mode 100644 index 00000000000..786a1f990d9 --- /dev/null +++ b/api/datadogV1/model_split_graph_viz_size.go @@ -0,0 +1,70 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" +) + +// SplitGraphVizSize Size of the individual graphs in the split. +type SplitGraphVizSize string + +// List of SplitGraphVizSize. +const ( + SPLITGRAPHVIZSIZE_XS SplitGraphVizSize = "xs" + SPLITGRAPHVIZSIZE_SM SplitGraphVizSize = "sm" + SPLITGRAPHVIZSIZE_MD SplitGraphVizSize = "md" + SPLITGRAPHVIZSIZE_LG SplitGraphVizSize = "lg" +) + +var allowedSplitGraphVizSizeEnumValues = []SplitGraphVizSize{ + SPLITGRAPHVIZSIZE_XS, + SPLITGRAPHVIZSIZE_SM, + SPLITGRAPHVIZSIZE_MD, + SPLITGRAPHVIZSIZE_LG, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SplitGraphVizSize) GetAllowedValues() []SplitGraphVizSize { + return allowedSplitGraphVizSizeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SplitGraphVizSize) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SplitGraphVizSize(value) + return nil +} + +// NewSplitGraphVizSizeFromValue returns a pointer to a valid SplitGraphVizSize +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSplitGraphVizSizeFromValue(v string) (*SplitGraphVizSize, error) { + ev := SplitGraphVizSize(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SplitGraphVizSize: valid values are %v", v, allowedSplitGraphVizSizeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SplitGraphVizSize) IsValid() bool { + for _, existing := range allowedSplitGraphVizSizeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SplitGraphVizSize value. +func (v SplitGraphVizSize) Ptr() *SplitGraphVizSize { + return &v +} diff --git a/api/datadogV1/model_split_graph_widget_definition.go b/api/datadogV1/model_split_graph_widget_definition.go new file mode 100644 index 00000000000..e8237180a10 --- /dev/null +++ b/api/datadogV1/model_split_graph_widget_definition.go @@ -0,0 +1,400 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SplitGraphWidgetDefinition The split graph widget allows you to create repeating units of a graph - one for each value in a group (for example: one per service) +type SplitGraphWidgetDefinition struct { + // Normalize y axes across graphs + HasUniformYAxes *bool `json:"has_uniform_y_axes,omitempty"` + // Size of the individual graphs in the split. + Size SplitGraphVizSize `json:"size"` + // The original widget we are splitting on. + SourceWidgetDefinition SplitGraphSourceWidgetDefinition `json:"source_widget_definition"` + // Encapsulates all user choices about how to split a graph. + SplitConfig SplitConfig `json:"split_config"` + // Time setting for the widget. + Time *WidgetTime `json:"time,omitempty"` + // Title of your widget. + Title *string `json:"title,omitempty"` + // How to align the text on the widget. + TitleAlign *WidgetTextAlign `json:"title_align,omitempty"` + // Size of the title. + TitleSize *string `json:"title_size,omitempty"` + // Type of the split graph widget + Type SplitGraphWidgetDefinitionType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSplitGraphWidgetDefinition instantiates a new SplitGraphWidgetDefinition object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSplitGraphWidgetDefinition(size SplitGraphVizSize, sourceWidgetDefinition SplitGraphSourceWidgetDefinition, splitConfig SplitConfig, typeVar SplitGraphWidgetDefinitionType) *SplitGraphWidgetDefinition { + this := SplitGraphWidgetDefinition{} + this.Size = size + this.SourceWidgetDefinition = sourceWidgetDefinition + this.SplitConfig = splitConfig + this.Type = typeVar + return &this +} + +// NewSplitGraphWidgetDefinitionWithDefaults instantiates a new SplitGraphWidgetDefinition object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSplitGraphWidgetDefinitionWithDefaults() *SplitGraphWidgetDefinition { + this := SplitGraphWidgetDefinition{} + var typeVar SplitGraphWidgetDefinitionType = SPLITGRAPHWIDGETDEFINITIONTYPE_SPLIT_GROUP + this.Type = typeVar + return &this +} + +// GetHasUniformYAxes returns the HasUniformYAxes field value if set, zero value otherwise. +func (o *SplitGraphWidgetDefinition) GetHasUniformYAxes() bool { + if o == nil || o.HasUniformYAxes == nil { + var ret bool + return ret + } + return *o.HasUniformYAxes +} + +// GetHasUniformYAxesOk returns a tuple with the HasUniformYAxes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetHasUniformYAxesOk() (*bool, bool) { + if o == nil || o.HasUniformYAxes == nil { + return nil, false + } + return o.HasUniformYAxes, true +} + +// HasHasUniformYAxes returns a boolean if a field has been set. +func (o *SplitGraphWidgetDefinition) HasHasUniformYAxes() bool { + return o != nil && o.HasUniformYAxes != nil +} + +// SetHasUniformYAxes gets a reference to the given bool and assigns it to the HasUniformYAxes field. +func (o *SplitGraphWidgetDefinition) SetHasUniformYAxes(v bool) { + o.HasUniformYAxes = &v +} + +// GetSize returns the Size field value. +func (o *SplitGraphWidgetDefinition) GetSize() SplitGraphVizSize { + if o == nil { + var ret SplitGraphVizSize + return ret + } + return o.Size +} + +// GetSizeOk returns a tuple with the Size field value +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetSizeOk() (*SplitGraphVizSize, bool) { + if o == nil { + return nil, false + } + return &o.Size, true +} + +// SetSize sets field value. +func (o *SplitGraphWidgetDefinition) SetSize(v SplitGraphVizSize) { + o.Size = v +} + +// GetSourceWidgetDefinition returns the SourceWidgetDefinition field value. +func (o *SplitGraphWidgetDefinition) GetSourceWidgetDefinition() SplitGraphSourceWidgetDefinition { + if o == nil { + var ret SplitGraphSourceWidgetDefinition + return ret + } + return o.SourceWidgetDefinition +} + +// GetSourceWidgetDefinitionOk returns a tuple with the SourceWidgetDefinition field value +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetSourceWidgetDefinitionOk() (*SplitGraphSourceWidgetDefinition, bool) { + if o == nil { + return nil, false + } + return &o.SourceWidgetDefinition, true +} + +// SetSourceWidgetDefinition sets field value. +func (o *SplitGraphWidgetDefinition) SetSourceWidgetDefinition(v SplitGraphSourceWidgetDefinition) { + o.SourceWidgetDefinition = v +} + +// GetSplitConfig returns the SplitConfig field value. +func (o *SplitGraphWidgetDefinition) GetSplitConfig() SplitConfig { + if o == nil { + var ret SplitConfig + return ret + } + return o.SplitConfig +} + +// GetSplitConfigOk returns a tuple with the SplitConfig field value +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetSplitConfigOk() (*SplitConfig, bool) { + if o == nil { + return nil, false + } + return &o.SplitConfig, true +} + +// SetSplitConfig sets field value. +func (o *SplitGraphWidgetDefinition) SetSplitConfig(v SplitConfig) { + o.SplitConfig = v +} + +// GetTime returns the Time field value if set, zero value otherwise. +func (o *SplitGraphWidgetDefinition) GetTime() WidgetTime { + if o == nil || o.Time == nil { + var ret WidgetTime + return ret + } + return *o.Time +} + +// GetTimeOk returns a tuple with the Time field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetTimeOk() (*WidgetTime, bool) { + if o == nil || o.Time == nil { + return nil, false + } + return o.Time, true +} + +// HasTime returns a boolean if a field has been set. +func (o *SplitGraphWidgetDefinition) HasTime() bool { + return o != nil && o.Time != nil +} + +// SetTime gets a reference to the given WidgetTime and assigns it to the Time field. +func (o *SplitGraphWidgetDefinition) SetTime(v WidgetTime) { + o.Time = &v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *SplitGraphWidgetDefinition) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *SplitGraphWidgetDefinition) HasTitle() bool { + return o != nil && o.Title != nil +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *SplitGraphWidgetDefinition) SetTitle(v string) { + o.Title = &v +} + +// GetTitleAlign returns the TitleAlign field value if set, zero value otherwise. +func (o *SplitGraphWidgetDefinition) GetTitleAlign() WidgetTextAlign { + if o == nil || o.TitleAlign == nil { + var ret WidgetTextAlign + return ret + } + return *o.TitleAlign +} + +// GetTitleAlignOk returns a tuple with the TitleAlign field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetTitleAlignOk() (*WidgetTextAlign, bool) { + if o == nil || o.TitleAlign == nil { + return nil, false + } + return o.TitleAlign, true +} + +// HasTitleAlign returns a boolean if a field has been set. +func (o *SplitGraphWidgetDefinition) HasTitleAlign() bool { + return o != nil && o.TitleAlign != nil +} + +// SetTitleAlign gets a reference to the given WidgetTextAlign and assigns it to the TitleAlign field. +func (o *SplitGraphWidgetDefinition) SetTitleAlign(v WidgetTextAlign) { + o.TitleAlign = &v +} + +// GetTitleSize returns the TitleSize field value if set, zero value otherwise. +func (o *SplitGraphWidgetDefinition) GetTitleSize() string { + if o == nil || o.TitleSize == nil { + var ret string + return ret + } + return *o.TitleSize +} + +// GetTitleSizeOk returns a tuple with the TitleSize field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetTitleSizeOk() (*string, bool) { + if o == nil || o.TitleSize == nil { + return nil, false + } + return o.TitleSize, true +} + +// HasTitleSize returns a boolean if a field has been set. +func (o *SplitGraphWidgetDefinition) HasTitleSize() bool { + return o != nil && o.TitleSize != nil +} + +// SetTitleSize gets a reference to the given string and assigns it to the TitleSize field. +func (o *SplitGraphWidgetDefinition) SetTitleSize(v string) { + o.TitleSize = &v +} + +// GetType returns the Type field value. +func (o *SplitGraphWidgetDefinition) GetType() SplitGraphWidgetDefinitionType { + if o == nil { + var ret SplitGraphWidgetDefinitionType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SplitGraphWidgetDefinition) GetTypeOk() (*SplitGraphWidgetDefinitionType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SplitGraphWidgetDefinition) SetType(v SplitGraphWidgetDefinitionType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SplitGraphWidgetDefinition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.HasUniformYAxes != nil { + toSerialize["has_uniform_y_axes"] = o.HasUniformYAxes + } + toSerialize["size"] = o.Size + toSerialize["source_widget_definition"] = o.SourceWidgetDefinition + toSerialize["split_config"] = o.SplitConfig + if o.Time != nil { + toSerialize["time"] = o.Time + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + if o.TitleAlign != nil { + toSerialize["title_align"] = o.TitleAlign + } + if o.TitleSize != nil { + toSerialize["title_size"] = o.TitleSize + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SplitGraphWidgetDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + HasUniformYAxes *bool `json:"has_uniform_y_axes,omitempty"` + Size *SplitGraphVizSize `json:"size"` + SourceWidgetDefinition *SplitGraphSourceWidgetDefinition `json:"source_widget_definition"` + SplitConfig *SplitConfig `json:"split_config"` + Time *WidgetTime `json:"time,omitempty"` + Title *string `json:"title,omitempty"` + TitleAlign *WidgetTextAlign `json:"title_align,omitempty"` + TitleSize *string `json:"title_size,omitempty"` + Type *SplitGraphWidgetDefinitionType `json:"type"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Size == nil { + return fmt.Errorf("required field size missing") + } + if all.SourceWidgetDefinition == nil { + return fmt.Errorf("required field source_widget_definition missing") + } + if all.SplitConfig == nil { + return fmt.Errorf("required field split_config missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"has_uniform_y_axes", "size", "source_widget_definition", "split_config", "time", "title", "title_align", "title_size", "type"}) + } else { + return err + } + + hasInvalidField := false + o.HasUniformYAxes = all.HasUniformYAxes + if !all.Size.IsValid() { + hasInvalidField = true + } else { + o.Size = *all.Size + } + o.SourceWidgetDefinition = *all.SourceWidgetDefinition + if all.SplitConfig.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.SplitConfig = *all.SplitConfig + if all.Time != nil && all.Time.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Time = all.Time + o.Title = all.Title + if all.TitleAlign != nil && !all.TitleAlign.IsValid() { + hasInvalidField = true + } else { + o.TitleAlign = all.TitleAlign + } + o.TitleSize = all.TitleSize + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV1/model_split_graph_widget_definition_type.go b/api/datadogV1/model_split_graph_widget_definition_type.go new file mode 100644 index 00000000000..120a03bd432 --- /dev/null +++ b/api/datadogV1/model_split_graph_widget_definition_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" +) + +// SplitGraphWidgetDefinitionType Type of the split graph widget +type SplitGraphWidgetDefinitionType string + +// List of SplitGraphWidgetDefinitionType. +const ( + SPLITGRAPHWIDGETDEFINITIONTYPE_SPLIT_GROUP SplitGraphWidgetDefinitionType = "split_group" +) + +var allowedSplitGraphWidgetDefinitionTypeEnumValues = []SplitGraphWidgetDefinitionType{ + SPLITGRAPHWIDGETDEFINITIONTYPE_SPLIT_GROUP, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SplitGraphWidgetDefinitionType) GetAllowedValues() []SplitGraphWidgetDefinitionType { + return allowedSplitGraphWidgetDefinitionTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SplitGraphWidgetDefinitionType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SplitGraphWidgetDefinitionType(value) + return nil +} + +// NewSplitGraphWidgetDefinitionTypeFromValue returns a pointer to a valid SplitGraphWidgetDefinitionType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSplitGraphWidgetDefinitionTypeFromValue(v string) (*SplitGraphWidgetDefinitionType, error) { + ev := SplitGraphWidgetDefinitionType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SplitGraphWidgetDefinitionType: valid values are %v", v, allowedSplitGraphWidgetDefinitionTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SplitGraphWidgetDefinitionType) IsValid() bool { + for _, existing := range allowedSplitGraphWidgetDefinitionTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SplitGraphWidgetDefinitionType value. +func (v SplitGraphWidgetDefinitionType) Ptr() *SplitGraphWidgetDefinitionType { + return &v +} diff --git a/api/datadogV1/model_split_sort.go b/api/datadogV1/model_split_sort.go new file mode 100644 index 00000000000..3ebe1c1261e --- /dev/null +++ b/api/datadogV1/model_split_sort.go @@ -0,0 +1,151 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SplitSort Controls the order in which graphs appear in the split. +type SplitSort struct { + // Defines the metric and aggregation used as the sort value. + Compute *SplitConfigSortCompute `json:"compute,omitempty"` + // Widget sorting methods. + Order WidgetSort `json:"order"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSplitSort instantiates a new SplitSort object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSplitSort(order WidgetSort) *SplitSort { + this := SplitSort{} + this.Order = order + return &this +} + +// NewSplitSortWithDefaults instantiates a new SplitSort object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSplitSortWithDefaults() *SplitSort { + this := SplitSort{} + return &this +} + +// GetCompute returns the Compute field value if set, zero value otherwise. +func (o *SplitSort) GetCompute() SplitConfigSortCompute { + if o == nil || o.Compute == nil { + var ret SplitConfigSortCompute + return ret + } + return *o.Compute +} + +// GetComputeOk returns a tuple with the Compute field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SplitSort) GetComputeOk() (*SplitConfigSortCompute, bool) { + if o == nil || o.Compute == nil { + return nil, false + } + return o.Compute, true +} + +// HasCompute returns a boolean if a field has been set. +func (o *SplitSort) HasCompute() bool { + return o != nil && o.Compute != nil +} + +// SetCompute gets a reference to the given SplitConfigSortCompute and assigns it to the Compute field. +func (o *SplitSort) SetCompute(v SplitConfigSortCompute) { + o.Compute = &v +} + +// GetOrder returns the Order field value. +func (o *SplitSort) GetOrder() WidgetSort { + if o == nil { + var ret WidgetSort + return ret + } + return o.Order +} + +// GetOrderOk returns a tuple with the Order field value +// and a boolean to check if the value has been set. +func (o *SplitSort) GetOrderOk() (*WidgetSort, bool) { + if o == nil { + return nil, false + } + return &o.Order, true +} + +// SetOrder sets field value. +func (o *SplitSort) SetOrder(v WidgetSort) { + o.Order = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SplitSort) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Compute != nil { + toSerialize["compute"] = o.Compute + } + toSerialize["order"] = o.Order + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SplitSort) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Compute *SplitConfigSortCompute `json:"compute,omitempty"` + Order *WidgetSort `json:"order"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Order == nil { + return fmt.Errorf("required field order missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"compute", "order"}) + } else { + return err + } + + hasInvalidField := false + if all.Compute != nil && all.Compute.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Compute = all.Compute + if !all.Order.IsValid() { + hasInvalidField = true + } else { + o.Order = *all.Order + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV1/model_split_vector_entry_item.go b/api/datadogV1/model_split_vector_entry_item.go new file mode 100644 index 00000000000..2ffa3291c8e --- /dev/null +++ b/api/datadogV1/model_split_vector_entry_item.go @@ -0,0 +1,135 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV1 + +import ( + "fmt" + + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SplitVectorEntryItem The split graph list contains a graph for each value of the split dimension. +type SplitVectorEntryItem struct { + // The tag key. + TagKey string `json:"tag_key"` + // The tag values. + TagValues []string `json:"tag_values"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewSplitVectorEntryItem instantiates a new SplitVectorEntryItem object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewSplitVectorEntryItem(tagKey string, tagValues []string) *SplitVectorEntryItem { + this := SplitVectorEntryItem{} + this.TagKey = tagKey + this.TagValues = tagValues + return &this +} + +// NewSplitVectorEntryItemWithDefaults instantiates a new SplitVectorEntryItem object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewSplitVectorEntryItemWithDefaults() *SplitVectorEntryItem { + this := SplitVectorEntryItem{} + return &this +} + +// GetTagKey returns the TagKey field value. +func (o *SplitVectorEntryItem) GetTagKey() string { + if o == nil { + var ret string + return ret + } + return o.TagKey +} + +// GetTagKeyOk returns a tuple with the TagKey field value +// and a boolean to check if the value has been set. +func (o *SplitVectorEntryItem) GetTagKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.TagKey, true +} + +// SetTagKey sets field value. +func (o *SplitVectorEntryItem) SetTagKey(v string) { + o.TagKey = v +} + +// GetTagValues returns the TagValues field value. +func (o *SplitVectorEntryItem) GetTagValues() []string { + if o == nil { + var ret []string + return ret + } + return o.TagValues +} + +// GetTagValuesOk returns a tuple with the TagValues field value +// and a boolean to check if the value has been set. +func (o *SplitVectorEntryItem) GetTagValuesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.TagValues, true +} + +// SetTagValues sets field value. +func (o *SplitVectorEntryItem) SetTagValues(v []string) { + o.TagValues = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SplitVectorEntryItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["tag_key"] = o.TagKey + toSerialize["tag_values"] = o.TagValues + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SplitVectorEntryItem) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + TagKey *string `json:"tag_key"` + TagValues *[]string `json:"tag_values"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + if all.TagKey == nil { + return fmt.Errorf("required field tag_key missing") + } + if all.TagValues == nil { + return fmt.Errorf("required field tag_values missing") + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"tag_key", "tag_values"}) + } else { + return err + } + o.TagKey = *all.TagKey + o.TagValues = *all.TagValues + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV1/model_widget_definition.go b/api/datadogV1/model_widget_definition.go index f13d963f50a..b2cbdd4f269 100644 --- a/api/datadogV1/model_widget_definition.go +++ b/api/datadogV1/model_widget_definition.go @@ -18,30 +18,31 @@ type WidgetDefinition struct { EventStreamWidgetDefinition *EventStreamWidgetDefinition EventTimelineWidgetDefinition *EventTimelineWidgetDefinition FreeTextWidgetDefinition *FreeTextWidgetDefinition + FunnelWidgetDefinition *FunnelWidgetDefinition GeomapWidgetDefinition *GeomapWidgetDefinition GroupWidgetDefinition *GroupWidgetDefinition HeatMapWidgetDefinition *HeatMapWidgetDefinition HostMapWidgetDefinition *HostMapWidgetDefinition IFrameWidgetDefinition *IFrameWidgetDefinition ImageWidgetDefinition *ImageWidgetDefinition + ListStreamWidgetDefinition *ListStreamWidgetDefinition LogStreamWidgetDefinition *LogStreamWidgetDefinition MonitorSummaryWidgetDefinition *MonitorSummaryWidgetDefinition NoteWidgetDefinition *NoteWidgetDefinition QueryValueWidgetDefinition *QueryValueWidgetDefinition RunWorkflowWidgetDefinition *RunWorkflowWidgetDefinition - ScatterPlotWidgetDefinition *ScatterPlotWidgetDefinition - SLOWidgetDefinition *SLOWidgetDefinition SLOListWidgetDefinition *SLOListWidgetDefinition + SLOWidgetDefinition *SLOWidgetDefinition + ScatterPlotWidgetDefinition *ScatterPlotWidgetDefinition ServiceMapWidgetDefinition *ServiceMapWidgetDefinition ServiceSummaryWidgetDefinition *ServiceSummaryWidgetDefinition + SplitGraphWidgetDefinition *SplitGraphWidgetDefinition SunburstWidgetDefinition *SunburstWidgetDefinition TableWidgetDefinition *TableWidgetDefinition TimeseriesWidgetDefinition *TimeseriesWidgetDefinition ToplistWidgetDefinition *ToplistWidgetDefinition - TreeMapWidgetDefinition *TreeMapWidgetDefinition - ListStreamWidgetDefinition *ListStreamWidgetDefinition - FunnelWidgetDefinition *FunnelWidgetDefinition TopologyMapWidgetDefinition *TopologyMapWidgetDefinition + TreeMapWidgetDefinition *TreeMapWidgetDefinition // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject interface{} @@ -87,6 +88,11 @@ func FreeTextWidgetDefinitionAsWidgetDefinition(v *FreeTextWidgetDefinition) Wid return WidgetDefinition{FreeTextWidgetDefinition: v} } +// FunnelWidgetDefinitionAsWidgetDefinition is a convenience function that returns FunnelWidgetDefinition wrapped in WidgetDefinition. +func FunnelWidgetDefinitionAsWidgetDefinition(v *FunnelWidgetDefinition) WidgetDefinition { + return WidgetDefinition{FunnelWidgetDefinition: v} +} + // GeomapWidgetDefinitionAsWidgetDefinition is a convenience function that returns GeomapWidgetDefinition wrapped in WidgetDefinition. func GeomapWidgetDefinitionAsWidgetDefinition(v *GeomapWidgetDefinition) WidgetDefinition { return WidgetDefinition{GeomapWidgetDefinition: v} @@ -117,6 +123,11 @@ func ImageWidgetDefinitionAsWidgetDefinition(v *ImageWidgetDefinition) WidgetDef return WidgetDefinition{ImageWidgetDefinition: v} } +// ListStreamWidgetDefinitionAsWidgetDefinition is a convenience function that returns ListStreamWidgetDefinition wrapped in WidgetDefinition. +func ListStreamWidgetDefinitionAsWidgetDefinition(v *ListStreamWidgetDefinition) WidgetDefinition { + return WidgetDefinition{ListStreamWidgetDefinition: v} +} + // LogStreamWidgetDefinitionAsWidgetDefinition is a convenience function that returns LogStreamWidgetDefinition wrapped in WidgetDefinition. func LogStreamWidgetDefinitionAsWidgetDefinition(v *LogStreamWidgetDefinition) WidgetDefinition { return WidgetDefinition{LogStreamWidgetDefinition: v} @@ -142,9 +153,9 @@ func RunWorkflowWidgetDefinitionAsWidgetDefinition(v *RunWorkflowWidgetDefinitio return WidgetDefinition{RunWorkflowWidgetDefinition: v} } -// ScatterPlotWidgetDefinitionAsWidgetDefinition is a convenience function that returns ScatterPlotWidgetDefinition wrapped in WidgetDefinition. -func ScatterPlotWidgetDefinitionAsWidgetDefinition(v *ScatterPlotWidgetDefinition) WidgetDefinition { - return WidgetDefinition{ScatterPlotWidgetDefinition: v} +// SLOListWidgetDefinitionAsWidgetDefinition is a convenience function that returns SLOListWidgetDefinition wrapped in WidgetDefinition. +func SLOListWidgetDefinitionAsWidgetDefinition(v *SLOListWidgetDefinition) WidgetDefinition { + return WidgetDefinition{SLOListWidgetDefinition: v} } // SLOWidgetDefinitionAsWidgetDefinition is a convenience function that returns SLOWidgetDefinition wrapped in WidgetDefinition. @@ -152,9 +163,9 @@ func SLOWidgetDefinitionAsWidgetDefinition(v *SLOWidgetDefinition) WidgetDefinit return WidgetDefinition{SLOWidgetDefinition: v} } -// SLOListWidgetDefinitionAsWidgetDefinition is a convenience function that returns SLOListWidgetDefinition wrapped in WidgetDefinition. -func SLOListWidgetDefinitionAsWidgetDefinition(v *SLOListWidgetDefinition) WidgetDefinition { - return WidgetDefinition{SLOListWidgetDefinition: v} +// ScatterPlotWidgetDefinitionAsWidgetDefinition is a convenience function that returns ScatterPlotWidgetDefinition wrapped in WidgetDefinition. +func ScatterPlotWidgetDefinitionAsWidgetDefinition(v *ScatterPlotWidgetDefinition) WidgetDefinition { + return WidgetDefinition{ScatterPlotWidgetDefinition: v} } // ServiceMapWidgetDefinitionAsWidgetDefinition is a convenience function that returns ServiceMapWidgetDefinition wrapped in WidgetDefinition. @@ -167,6 +178,11 @@ func ServiceSummaryWidgetDefinitionAsWidgetDefinition(v *ServiceSummaryWidgetDef return WidgetDefinition{ServiceSummaryWidgetDefinition: v} } +// SplitGraphWidgetDefinitionAsWidgetDefinition is a convenience function that returns SplitGraphWidgetDefinition wrapped in WidgetDefinition. +func SplitGraphWidgetDefinitionAsWidgetDefinition(v *SplitGraphWidgetDefinition) WidgetDefinition { + return WidgetDefinition{SplitGraphWidgetDefinition: v} +} + // SunburstWidgetDefinitionAsWidgetDefinition is a convenience function that returns SunburstWidgetDefinition wrapped in WidgetDefinition. func SunburstWidgetDefinitionAsWidgetDefinition(v *SunburstWidgetDefinition) WidgetDefinition { return WidgetDefinition{SunburstWidgetDefinition: v} @@ -187,26 +203,16 @@ func ToplistWidgetDefinitionAsWidgetDefinition(v *ToplistWidgetDefinition) Widge return WidgetDefinition{ToplistWidgetDefinition: v} } -// TreeMapWidgetDefinitionAsWidgetDefinition is a convenience function that returns TreeMapWidgetDefinition wrapped in WidgetDefinition. -func TreeMapWidgetDefinitionAsWidgetDefinition(v *TreeMapWidgetDefinition) WidgetDefinition { - return WidgetDefinition{TreeMapWidgetDefinition: v} -} - -// ListStreamWidgetDefinitionAsWidgetDefinition is a convenience function that returns ListStreamWidgetDefinition wrapped in WidgetDefinition. -func ListStreamWidgetDefinitionAsWidgetDefinition(v *ListStreamWidgetDefinition) WidgetDefinition { - return WidgetDefinition{ListStreamWidgetDefinition: v} -} - -// FunnelWidgetDefinitionAsWidgetDefinition is a convenience function that returns FunnelWidgetDefinition wrapped in WidgetDefinition. -func FunnelWidgetDefinitionAsWidgetDefinition(v *FunnelWidgetDefinition) WidgetDefinition { - return WidgetDefinition{FunnelWidgetDefinition: v} -} - // TopologyMapWidgetDefinitionAsWidgetDefinition is a convenience function that returns TopologyMapWidgetDefinition wrapped in WidgetDefinition. func TopologyMapWidgetDefinitionAsWidgetDefinition(v *TopologyMapWidgetDefinition) WidgetDefinition { return WidgetDefinition{TopologyMapWidgetDefinition: v} } +// TreeMapWidgetDefinitionAsWidgetDefinition is a convenience function that returns TreeMapWidgetDefinition wrapped in WidgetDefinition. +func TreeMapWidgetDefinitionAsWidgetDefinition(v *TreeMapWidgetDefinition) WidgetDefinition { + return WidgetDefinition{TreeMapWidgetDefinition: v} +} + // UnmarshalJSON turns data into one of the pointers in the struct. func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { var err error @@ -347,6 +353,23 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.FreeTextWidgetDefinition = nil } + // try to unmarshal data into FunnelWidgetDefinition + err = json.Unmarshal(data, &obj.FunnelWidgetDefinition) + if err == nil { + if obj.FunnelWidgetDefinition != nil && obj.FunnelWidgetDefinition.UnparsedObject == nil { + jsonFunnelWidgetDefinition, _ := json.Marshal(obj.FunnelWidgetDefinition) + if string(jsonFunnelWidgetDefinition) == "{}" { // empty struct + obj.FunnelWidgetDefinition = nil + } else { + match++ + } + } else { + obj.FunnelWidgetDefinition = nil + } + } else { + obj.FunnelWidgetDefinition = nil + } + // try to unmarshal data into GeomapWidgetDefinition err = json.Unmarshal(data, &obj.GeomapWidgetDefinition) if err == nil { @@ -449,6 +472,23 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.ImageWidgetDefinition = nil } + // try to unmarshal data into ListStreamWidgetDefinition + err = json.Unmarshal(data, &obj.ListStreamWidgetDefinition) + if err == nil { + if obj.ListStreamWidgetDefinition != nil && obj.ListStreamWidgetDefinition.UnparsedObject == nil { + jsonListStreamWidgetDefinition, _ := json.Marshal(obj.ListStreamWidgetDefinition) + if string(jsonListStreamWidgetDefinition) == "{}" { // empty struct + obj.ListStreamWidgetDefinition = nil + } else { + match++ + } + } else { + obj.ListStreamWidgetDefinition = nil + } + } else { + obj.ListStreamWidgetDefinition = nil + } + // try to unmarshal data into LogStreamWidgetDefinition err = json.Unmarshal(data, &obj.LogStreamWidgetDefinition) if err == nil { @@ -534,21 +574,21 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.RunWorkflowWidgetDefinition = nil } - // try to unmarshal data into ScatterPlotWidgetDefinition - err = json.Unmarshal(data, &obj.ScatterPlotWidgetDefinition) + // try to unmarshal data into SLOListWidgetDefinition + err = json.Unmarshal(data, &obj.SLOListWidgetDefinition) if err == nil { - if obj.ScatterPlotWidgetDefinition != nil && obj.ScatterPlotWidgetDefinition.UnparsedObject == nil { - jsonScatterPlotWidgetDefinition, _ := json.Marshal(obj.ScatterPlotWidgetDefinition) - if string(jsonScatterPlotWidgetDefinition) == "{}" { // empty struct - obj.ScatterPlotWidgetDefinition = nil + if obj.SLOListWidgetDefinition != nil && obj.SLOListWidgetDefinition.UnparsedObject == nil { + jsonSLOListWidgetDefinition, _ := json.Marshal(obj.SLOListWidgetDefinition) + if string(jsonSLOListWidgetDefinition) == "{}" { // empty struct + obj.SLOListWidgetDefinition = nil } else { match++ } } else { - obj.ScatterPlotWidgetDefinition = nil + obj.SLOListWidgetDefinition = nil } } else { - obj.ScatterPlotWidgetDefinition = nil + obj.SLOListWidgetDefinition = nil } // try to unmarshal data into SLOWidgetDefinition @@ -568,21 +608,21 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.SLOWidgetDefinition = nil } - // try to unmarshal data into SLOListWidgetDefinition - err = json.Unmarshal(data, &obj.SLOListWidgetDefinition) + // try to unmarshal data into ScatterPlotWidgetDefinition + err = json.Unmarshal(data, &obj.ScatterPlotWidgetDefinition) if err == nil { - if obj.SLOListWidgetDefinition != nil && obj.SLOListWidgetDefinition.UnparsedObject == nil { - jsonSLOListWidgetDefinition, _ := json.Marshal(obj.SLOListWidgetDefinition) - if string(jsonSLOListWidgetDefinition) == "{}" { // empty struct - obj.SLOListWidgetDefinition = nil + if obj.ScatterPlotWidgetDefinition != nil && obj.ScatterPlotWidgetDefinition.UnparsedObject == nil { + jsonScatterPlotWidgetDefinition, _ := json.Marshal(obj.ScatterPlotWidgetDefinition) + if string(jsonScatterPlotWidgetDefinition) == "{}" { // empty struct + obj.ScatterPlotWidgetDefinition = nil } else { match++ } } else { - obj.SLOListWidgetDefinition = nil + obj.ScatterPlotWidgetDefinition = nil } } else { - obj.SLOListWidgetDefinition = nil + obj.ScatterPlotWidgetDefinition = nil } // try to unmarshal data into ServiceMapWidgetDefinition @@ -619,6 +659,23 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.ServiceSummaryWidgetDefinition = nil } + // try to unmarshal data into SplitGraphWidgetDefinition + err = json.Unmarshal(data, &obj.SplitGraphWidgetDefinition) + if err == nil { + if obj.SplitGraphWidgetDefinition != nil && obj.SplitGraphWidgetDefinition.UnparsedObject == nil { + jsonSplitGraphWidgetDefinition, _ := json.Marshal(obj.SplitGraphWidgetDefinition) + if string(jsonSplitGraphWidgetDefinition) == "{}" { // empty struct + obj.SplitGraphWidgetDefinition = nil + } else { + match++ + } + } else { + obj.SplitGraphWidgetDefinition = nil + } + } else { + obj.SplitGraphWidgetDefinition = nil + } + // try to unmarshal data into SunburstWidgetDefinition err = json.Unmarshal(data, &obj.SunburstWidgetDefinition) if err == nil { @@ -687,72 +744,38 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.ToplistWidgetDefinition = nil } - // try to unmarshal data into TreeMapWidgetDefinition - err = json.Unmarshal(data, &obj.TreeMapWidgetDefinition) - if err == nil { - if obj.TreeMapWidgetDefinition != nil && obj.TreeMapWidgetDefinition.UnparsedObject == nil { - jsonTreeMapWidgetDefinition, _ := json.Marshal(obj.TreeMapWidgetDefinition) - if string(jsonTreeMapWidgetDefinition) == "{}" { // empty struct - obj.TreeMapWidgetDefinition = nil - } else { - match++ - } - } else { - obj.TreeMapWidgetDefinition = nil - } - } else { - obj.TreeMapWidgetDefinition = nil - } - - // try to unmarshal data into ListStreamWidgetDefinition - err = json.Unmarshal(data, &obj.ListStreamWidgetDefinition) - if err == nil { - if obj.ListStreamWidgetDefinition != nil && obj.ListStreamWidgetDefinition.UnparsedObject == nil { - jsonListStreamWidgetDefinition, _ := json.Marshal(obj.ListStreamWidgetDefinition) - if string(jsonListStreamWidgetDefinition) == "{}" { // empty struct - obj.ListStreamWidgetDefinition = nil - } else { - match++ - } - } else { - obj.ListStreamWidgetDefinition = nil - } - } else { - obj.ListStreamWidgetDefinition = nil - } - - // try to unmarshal data into FunnelWidgetDefinition - err = json.Unmarshal(data, &obj.FunnelWidgetDefinition) + // try to unmarshal data into TopologyMapWidgetDefinition + err = json.Unmarshal(data, &obj.TopologyMapWidgetDefinition) if err == nil { - if obj.FunnelWidgetDefinition != nil && obj.FunnelWidgetDefinition.UnparsedObject == nil { - jsonFunnelWidgetDefinition, _ := json.Marshal(obj.FunnelWidgetDefinition) - if string(jsonFunnelWidgetDefinition) == "{}" { // empty struct - obj.FunnelWidgetDefinition = nil + if obj.TopologyMapWidgetDefinition != nil && obj.TopologyMapWidgetDefinition.UnparsedObject == nil { + jsonTopologyMapWidgetDefinition, _ := json.Marshal(obj.TopologyMapWidgetDefinition) + if string(jsonTopologyMapWidgetDefinition) == "{}" { // empty struct + obj.TopologyMapWidgetDefinition = nil } else { match++ } } else { - obj.FunnelWidgetDefinition = nil + obj.TopologyMapWidgetDefinition = nil } } else { - obj.FunnelWidgetDefinition = nil + obj.TopologyMapWidgetDefinition = nil } - // try to unmarshal data into TopologyMapWidgetDefinition - err = json.Unmarshal(data, &obj.TopologyMapWidgetDefinition) + // try to unmarshal data into TreeMapWidgetDefinition + err = json.Unmarshal(data, &obj.TreeMapWidgetDefinition) if err == nil { - if obj.TopologyMapWidgetDefinition != nil && obj.TopologyMapWidgetDefinition.UnparsedObject == nil { - jsonTopologyMapWidgetDefinition, _ := json.Marshal(obj.TopologyMapWidgetDefinition) - if string(jsonTopologyMapWidgetDefinition) == "{}" { // empty struct - obj.TopologyMapWidgetDefinition = nil + if obj.TreeMapWidgetDefinition != nil && obj.TreeMapWidgetDefinition.UnparsedObject == nil { + jsonTreeMapWidgetDefinition, _ := json.Marshal(obj.TreeMapWidgetDefinition) + if string(jsonTreeMapWidgetDefinition) == "{}" { // empty struct + obj.TreeMapWidgetDefinition = nil } else { match++ } } else { - obj.TopologyMapWidgetDefinition = nil + obj.TreeMapWidgetDefinition = nil } } else { - obj.TopologyMapWidgetDefinition = nil + obj.TreeMapWidgetDefinition = nil } if match != 1 { // more than 1 match @@ -765,30 +788,31 @@ func (obj *WidgetDefinition) UnmarshalJSON(data []byte) error { obj.EventStreamWidgetDefinition = nil obj.EventTimelineWidgetDefinition = nil obj.FreeTextWidgetDefinition = nil + obj.FunnelWidgetDefinition = nil obj.GeomapWidgetDefinition = nil obj.GroupWidgetDefinition = nil obj.HeatMapWidgetDefinition = nil obj.HostMapWidgetDefinition = nil obj.IFrameWidgetDefinition = nil obj.ImageWidgetDefinition = nil + obj.ListStreamWidgetDefinition = nil obj.LogStreamWidgetDefinition = nil obj.MonitorSummaryWidgetDefinition = nil obj.NoteWidgetDefinition = nil obj.QueryValueWidgetDefinition = nil obj.RunWorkflowWidgetDefinition = nil - obj.ScatterPlotWidgetDefinition = nil - obj.SLOWidgetDefinition = nil obj.SLOListWidgetDefinition = nil + obj.SLOWidgetDefinition = nil + obj.ScatterPlotWidgetDefinition = nil obj.ServiceMapWidgetDefinition = nil obj.ServiceSummaryWidgetDefinition = nil + obj.SplitGraphWidgetDefinition = nil obj.SunburstWidgetDefinition = nil obj.TableWidgetDefinition = nil obj.TimeseriesWidgetDefinition = nil obj.ToplistWidgetDefinition = nil - obj.TreeMapWidgetDefinition = nil - obj.ListStreamWidgetDefinition = nil - obj.FunnelWidgetDefinition = nil obj.TopologyMapWidgetDefinition = nil + obj.TreeMapWidgetDefinition = nil return json.Unmarshal(data, &obj.UnparsedObject) } return nil // exactly one match @@ -828,6 +852,10 @@ func (obj WidgetDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(&obj.FreeTextWidgetDefinition) } + if obj.FunnelWidgetDefinition != nil { + return json.Marshal(&obj.FunnelWidgetDefinition) + } + if obj.GeomapWidgetDefinition != nil { return json.Marshal(&obj.GeomapWidgetDefinition) } @@ -852,6 +880,10 @@ func (obj WidgetDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(&obj.ImageWidgetDefinition) } + if obj.ListStreamWidgetDefinition != nil { + return json.Marshal(&obj.ListStreamWidgetDefinition) + } + if obj.LogStreamWidgetDefinition != nil { return json.Marshal(&obj.LogStreamWidgetDefinition) } @@ -872,16 +904,16 @@ func (obj WidgetDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(&obj.RunWorkflowWidgetDefinition) } - if obj.ScatterPlotWidgetDefinition != nil { - return json.Marshal(&obj.ScatterPlotWidgetDefinition) + if obj.SLOListWidgetDefinition != nil { + return json.Marshal(&obj.SLOListWidgetDefinition) } if obj.SLOWidgetDefinition != nil { return json.Marshal(&obj.SLOWidgetDefinition) } - if obj.SLOListWidgetDefinition != nil { - return json.Marshal(&obj.SLOListWidgetDefinition) + if obj.ScatterPlotWidgetDefinition != nil { + return json.Marshal(&obj.ScatterPlotWidgetDefinition) } if obj.ServiceMapWidgetDefinition != nil { @@ -892,6 +924,10 @@ func (obj WidgetDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(&obj.ServiceSummaryWidgetDefinition) } + if obj.SplitGraphWidgetDefinition != nil { + return json.Marshal(&obj.SplitGraphWidgetDefinition) + } + if obj.SunburstWidgetDefinition != nil { return json.Marshal(&obj.SunburstWidgetDefinition) } @@ -908,22 +944,14 @@ func (obj WidgetDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(&obj.ToplistWidgetDefinition) } - if obj.TreeMapWidgetDefinition != nil { - return json.Marshal(&obj.TreeMapWidgetDefinition) - } - - if obj.ListStreamWidgetDefinition != nil { - return json.Marshal(&obj.ListStreamWidgetDefinition) - } - - if obj.FunnelWidgetDefinition != nil { - return json.Marshal(&obj.FunnelWidgetDefinition) - } - if obj.TopologyMapWidgetDefinition != nil { return json.Marshal(&obj.TopologyMapWidgetDefinition) } + if obj.TreeMapWidgetDefinition != nil { + return json.Marshal(&obj.TreeMapWidgetDefinition) + } + if obj.UnparsedObject != nil { return json.Marshal(obj.UnparsedObject) } @@ -964,6 +992,10 @@ func (obj *WidgetDefinition) GetActualInstance() interface{} { return obj.FreeTextWidgetDefinition } + if obj.FunnelWidgetDefinition != nil { + return obj.FunnelWidgetDefinition + } + if obj.GeomapWidgetDefinition != nil { return obj.GeomapWidgetDefinition } @@ -988,6 +1020,10 @@ func (obj *WidgetDefinition) GetActualInstance() interface{} { return obj.ImageWidgetDefinition } + if obj.ListStreamWidgetDefinition != nil { + return obj.ListStreamWidgetDefinition + } + if obj.LogStreamWidgetDefinition != nil { return obj.LogStreamWidgetDefinition } @@ -1008,16 +1044,16 @@ func (obj *WidgetDefinition) GetActualInstance() interface{} { return obj.RunWorkflowWidgetDefinition } - if obj.ScatterPlotWidgetDefinition != nil { - return obj.ScatterPlotWidgetDefinition + if obj.SLOListWidgetDefinition != nil { + return obj.SLOListWidgetDefinition } if obj.SLOWidgetDefinition != nil { return obj.SLOWidgetDefinition } - if obj.SLOListWidgetDefinition != nil { - return obj.SLOListWidgetDefinition + if obj.ScatterPlotWidgetDefinition != nil { + return obj.ScatterPlotWidgetDefinition } if obj.ServiceMapWidgetDefinition != nil { @@ -1028,6 +1064,10 @@ func (obj *WidgetDefinition) GetActualInstance() interface{} { return obj.ServiceSummaryWidgetDefinition } + if obj.SplitGraphWidgetDefinition != nil { + return obj.SplitGraphWidgetDefinition + } + if obj.SunburstWidgetDefinition != nil { return obj.SunburstWidgetDefinition } @@ -1044,22 +1084,14 @@ func (obj *WidgetDefinition) GetActualInstance() interface{} { return obj.ToplistWidgetDefinition } - if obj.TreeMapWidgetDefinition != nil { - return obj.TreeMapWidgetDefinition - } - - if obj.ListStreamWidgetDefinition != nil { - return obj.ListStreamWidgetDefinition - } - - if obj.FunnelWidgetDefinition != nil { - return obj.FunnelWidgetDefinition - } - if obj.TopologyMapWidgetDefinition != nil { return obj.TopologyMapWidgetDefinition } + if obj.TreeMapWidgetDefinition != nil { + return obj.TreeMapWidgetDefinition + } + // all schemas are nil return nil } diff --git a/examples/v1/dashboards/CreateDashboard_2278756614.go b/examples/v1/dashboards/CreateDashboard_2278756614.go new file mode 100644 index 00000000000..87bf5b997b0 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_2278756614.go @@ -0,0 +1,119 @@ +// Create a new dashboard with split graph widget + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.Dashboard{ + Title: "Example-Dashboard", + Description: *datadog.NewNullableString(datadog.PtrString("")), + Widgets: []datadogV1.Widget{ + { + Layout: &datadogV1.WidgetLayout{ + X: 0, + Y: 0, + Width: 12, + Height: 8, + }, + Definition: datadogV1.WidgetDefinition{ + SplitGraphWidgetDefinition: &datadogV1.SplitGraphWidgetDefinition{ + Title: datadog.PtrString(""), + TitleSize: datadog.PtrString("16"), + TitleAlign: datadogV1.WIDGETTEXTALIGN_LEFT.Ptr(), + Type: datadogV1.SPLITGRAPHWIDGETDEFINITIONTYPE_SPLIT_GROUP, + SourceWidgetDefinition: datadogV1.SplitGraphSourceWidgetDefinition{ + TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{ + Title: datadog.PtrString(""), + TitleSize: datadog.PtrString("16"), + TitleAlign: datadogV1.WIDGETTEXTALIGN_LEFT.Ptr(), + Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES, + Requests: []datadogV1.TimeseriesWidgetRequest{ + { + ResponseFormat: datadogV1.FORMULAANDFUNCTIONRESPONSEFORMAT_TIMESERIES.Ptr(), + Queries: []datadogV1.FormulaAndFunctionQueryDefinition{ + datadogV1.FormulaAndFunctionQueryDefinition{ + FormulaAndFunctionMetricQueryDefinition: &datadogV1.FormulaAndFunctionMetricQueryDefinition{ + Name: "query1", + DataSource: datadogV1.FORMULAANDFUNCTIONMETRICDATASOURCE_METRICS, + Query: "avg:system.cpu.user{*}", + }}, + }, + Style: &datadogV1.WidgetRequestStyle{ + Palette: datadog.PtrString("dog_classic"), + LineType: datadogV1.WIDGETLINETYPE_SOLID.Ptr(), + LineWidth: datadogV1.WIDGETLINEWIDTH_NORMAL.Ptr(), + }, + DisplayType: datadogV1.WIDGETDISPLAYTYPE_LINE.Ptr(), + }, + }, + }}, + SplitConfig: datadogV1.SplitConfig{ + SplitDimensions: []datadogV1.SplitDimension{ + { + OneGraphPer: "service", + }, + }, + Limit: 24, + Sort: datadogV1.SplitSort{ + Compute: &datadogV1.SplitConfigSortCompute{ + Aggregation: "sum", + Metric: "system.cpu.user", + }, + Order: datadogV1.WIDGETSORT_DESCENDING, + }, + StaticSplits: [][]datadogV1.SplitVectorEntryItem{ + { + { + TagKey: "service", + TagValues: []string{ + "cassandra", + }, + }, + { + TagKey: "datacenter", + TagValues: []string{}, + }, + }, + { + { + TagKey: "demo", + TagValues: []string{ + "env", + }, + }, + }, + }, + }, + Size: datadogV1.SPLITGRAPHVIZSIZE_MD, + HasUniformYAxes: datadog.PtrBool(true), + }}, + }, + }, + TemplateVariables: []datadogV1.DashboardTemplateVariable{}, + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + IsReadOnly: datadog.PtrBool(false), + NotifyList: *datadog.NewNullableList(&[]string{}), + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewDashboardsApi(apiClient) + resp, r, err := api.CreateDashboard(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_split_graph_widget.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_split_graph_widget.freeze new file mode 100644 index 00000000000..aded6308429 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_split_graph_widget.freeze @@ -0,0 +1 @@ +2023-08-31T16:46:43.557Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_split_graph_widget.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_split_graph_widget.yaml new file mode 100644 index 00000000000..1f4c01a9794 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_split_graph_widget.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"description":"","is_read_only":false,"layout_type":"ordered","notify_list":[],"template_variables":[],"title":"Test-Create_a_new_dashboard_with_split_graph_widget-1693500403","widgets":[{"definition":{"has_uniform_y_axes":true,"size":"md","source_widget_definition":{"requests":[{"display_type":"line","queries":[{"data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*}"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"title":"","title_align":"left","title_size":"16","type":"timeseries"},"split_config":{"limit":24,"sort":{"compute":{"aggregation":"sum","metric":"system.cpu.user"},"order":"desc"},"split_dimensions":[{"one_graph_per":"service"}],"static_splits":[[{"tag_key":"service","tag_values":["cassandra"]},{"tag_key":"datacenter","tag_values":[]}],[{"tag_key":"demo","tag_values":["env"]}]]},"title":"","title_align":"left","title_size":"16","type":"split_group"},"layout":{"height":8,"width":12,"x":0,"y":0}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"id":"qyj-uu8-yqk","title":"Test-Create_a_new_dashboard_with_split_graph_widget-1693500403","description":"","author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/qyj-uu8-yqk/test-createanewdashboardwithsplitgraphwidget-1693500403","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"has_uniform_y_axes":true,"size":"md","source_widget_definition":{"requests":[{"display_type":"line","queries":[{"data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*}"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"title":"","title_align":"left","title_size":"16","type":"timeseries"},"split_config":{"limit":24,"sort":{"compute":{"aggregation":"sum","metric":"system.cpu.user"},"order":"desc"},"split_dimensions":[{"one_graph_per":"service"}],"static_splits":[[{"tag_key":"service","tag_values":["cassandra"]},{"tag_key":"datacenter","tag_values":[]}],[{"tag_key":"demo","tag_values":["env"]}]]},"title":"","title_align":"left","title_size":"16","type":"split_group"},"layout":{"height":8,"width":12,"x":0,"y":0},"id":6079376078836256}],"notify_list":[],"created_at":"2023-08-31T16:46:44.294228+00:00","modified_at":"2023-08-31T16:46:44.294228+00:00","restricted_roles":[]} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/qyj-uu8-yqk + response: + body: '{"deleted_dashboard_id":"qyj-uu8-yqk"} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index 89f45dbe1f9..940a1e310f2 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -618,6 +618,21 @@ Feature: Dashboards And the response "widgets[0].definition.slo_id" is equal to "{{ slo.data[0].id }}" And the response "widgets[0].definition.additional_query_filters" is equal to "!host:excluded_host" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with split graph widget + Given new "CreateDashboard" request + And body from file "dashboards_json_payload/split_graph_widget.json" + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.type" is equal to "split_group" + And the response "widgets[0].definition.source_widget_definition" is equal to {"title":"","title_size":"16","title_align":"left","type":"timeseries","requests":[{"response_format":"timeseries","queries":[{"name":"query1","data_source":"metrics","query":"avg:system.cpu.user{*}"}],"style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]} + And the response "widgets[0].definition.split_config.split_dimensions" is equal to [{"one_graph_per": "service"}] + And the response "widgets[0].definition.split_config.limit" is equal to 24 + And the response "widgets[0].definition.split_config.sort" is equal to {"compute": {"aggregation": "sum", "metric": "system.cpu.user"}, "order": "desc"} + And the response "widgets[0].definition.split_config.static_splits" is equal to [[{"tag_key":"service","tag_values":["cassandra"]},{"tag_key":"datacenter","tag_values":[]}],[{"tag_key":"demo","tag_values":["env"]}]] + And the response "widgets[0].definition.size" is equal to "md" + And the response "widgets[0].definition.has_uniform_y_axes" is equal to true + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with sunburst widget and metrics data Given new "CreateDashboard" request diff --git a/tests/scenarios/features/v1/dashboards_json_payload/split_graph_widget.json b/tests/scenarios/features/v1/dashboards_json_payload/split_graph_widget.json new file mode 100644 index 00000000000..d0a18a5ad97 --- /dev/null +++ b/tests/scenarios/features/v1/dashboards_json_payload/split_graph_widget.json @@ -0,0 +1,51 @@ +{ + "title":"{{ unique }}", + "description":"", + "widgets":[ + { + "layout":{ + "x":0, + "y":0, + "width":12, + "height":8 + }, + "definition":{ + "title": "", + "title_size": "16", + "title_align": "left", + "type": "split_group", + "source_widget_definition": { + "title": "", + "title_size": "16", + "title_align": "left", + "type": "timeseries", + "requests": [ + { + "response_format": "timeseries", + "queries": [ + {"name": "query1", "data_source": "metrics", "query": "avg:system.cpu.user{*}"} + ], + "style": {"palette": "dog_classic", "line_type": "solid", "line_width": "normal"}, + "display_type": "line" + } + ] + }, + "split_config": { + "split_dimensions":[{"one_graph_per": "service"}], + "limit": 24, + "sort": {"compute": {"aggregation": "sum", "metric": "system.cpu.user"}, "order": "desc"}, + "static_splits": [ + [{"tag_key": "service", "tag_values": ["cassandra"]}, {"tag_key": "datacenter", "tag_values": []}], + [{"tag_key": "demo", "tag_values": ["env"]}] + ] + }, + "size": "md", + "has_uniform_y_axes": true + } + } + ], + "template_variables":[], + "layout_type":"ordered", + "is_read_only":false, + "notify_list":[] + } \ No newline at end of file