Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20837,9 +20837,27 @@ components:
description: Color palette to apply to the widget.
type: string
type: object
TimeseriesWidgetAnomalyDetection:
description: Anomaly detection configuration for a timeseries widget.
properties:
detection_sensitivity:
$ref: "#/components/schemas/TimeseriesWidgetAnomalyDetectionSensitivity"
required:
- detection_sensitivity
type: object
TimeseriesWidgetAnomalyDetectionSensitivity:
description: Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection.
enum:
- never_detect
example: never_detect
type: string
x-enum-varnames:
- NEVER_DETECT
TimeseriesWidgetDefinition:
description: The timeseries visualization allows you to display the evolution of one or more metrics, log events, or Indexed Spans over time.
properties:
anomaly_detection:
$ref: "#/components/schemas/TimeseriesWidgetAnomalyDetection"
custom_links:
description: List of custom links.
items:
Expand Down
111 changes: 111 additions & 0 deletions api/datadogV1/model_timeseries_widget_anomaly_detection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// 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/DataDog/datadog-api-client-go/v2/api/datadog"
)

// TimeseriesWidgetAnomalyDetection Anomaly detection configuration for a timeseries widget.
type TimeseriesWidgetAnomalyDetection struct {
// Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection.
DetectionSensitivity TimeseriesWidgetAnomalyDetectionSensitivity `json:"detection_sensitivity"`
// 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{} `json:"-"`
}

// NewTimeseriesWidgetAnomalyDetection instantiates a new TimeseriesWidgetAnomalyDetection 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 NewTimeseriesWidgetAnomalyDetection(detectionSensitivity TimeseriesWidgetAnomalyDetectionSensitivity) *TimeseriesWidgetAnomalyDetection {
this := TimeseriesWidgetAnomalyDetection{}
this.DetectionSensitivity = detectionSensitivity
return &this
}

// NewTimeseriesWidgetAnomalyDetectionWithDefaults instantiates a new TimeseriesWidgetAnomalyDetection 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 NewTimeseriesWidgetAnomalyDetectionWithDefaults() *TimeseriesWidgetAnomalyDetection {
this := TimeseriesWidgetAnomalyDetection{}
return &this
}

// GetDetectionSensitivity returns the DetectionSensitivity field value.
func (o *TimeseriesWidgetAnomalyDetection) GetDetectionSensitivity() TimeseriesWidgetAnomalyDetectionSensitivity {
if o == nil {
var ret TimeseriesWidgetAnomalyDetectionSensitivity
return ret
}
return o.DetectionSensitivity
}

// GetDetectionSensitivityOk returns a tuple with the DetectionSensitivity field value
// and a boolean to check if the value has been set.
func (o *TimeseriesWidgetAnomalyDetection) GetDetectionSensitivityOk() (*TimeseriesWidgetAnomalyDetectionSensitivity, bool) {
if o == nil {
return nil, false
}
return &o.DetectionSensitivity, true
}

// SetDetectionSensitivity sets field value.
func (o *TimeseriesWidgetAnomalyDetection) SetDetectionSensitivity(v TimeseriesWidgetAnomalyDetectionSensitivity) {
o.DetectionSensitivity = v
}

// MarshalJSON serializes the struct using spec logic.
func (o TimeseriesWidgetAnomalyDetection) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["detection_sensitivity"] = o.DetectionSensitivity

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *TimeseriesWidgetAnomalyDetection) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
DetectionSensitivity *TimeseriesWidgetAnomalyDetectionSensitivity `json:"detection_sensitivity"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.DetectionSensitivity == nil {
return fmt.Errorf("required field detection_sensitivity missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"detection_sensitivity"})
} else {
return err
}

hasInvalidField := false
if !all.DetectionSensitivity.IsValid() {
hasInvalidField = true
} else {
o.DetectionSensitivity = *all.DetectionSensitivity
}

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

if hasInvalidField {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}

return nil
}
Original file line number Diff line number Diff line change
@@ -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/DataDog/datadog-api-client-go/v2/api/datadog"
)

// TimeseriesWidgetAnomalyDetectionSensitivity Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection.
type TimeseriesWidgetAnomalyDetectionSensitivity string

// List of TimeseriesWidgetAnomalyDetectionSensitivity.
const (
TIMESERIESWIDGETANOMALYDETECTIONSENSITIVITY_NEVER_DETECT TimeseriesWidgetAnomalyDetectionSensitivity = "never_detect"
)

var allowedTimeseriesWidgetAnomalyDetectionSensitivityEnumValues = []TimeseriesWidgetAnomalyDetectionSensitivity{
TIMESERIESWIDGETANOMALYDETECTIONSENSITIVITY_NEVER_DETECT,
}

// GetAllowedValues reeturns the list of possible values.
func (v *TimeseriesWidgetAnomalyDetectionSensitivity) GetAllowedValues() []TimeseriesWidgetAnomalyDetectionSensitivity {
return allowedTimeseriesWidgetAnomalyDetectionSensitivityEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *TimeseriesWidgetAnomalyDetectionSensitivity) UnmarshalJSON(src []byte) error {
var value string
err := datadog.Unmarshal(src, &value)
if err != nil {
return err
}
*v = TimeseriesWidgetAnomalyDetectionSensitivity(value)
return nil
}

// NewTimeseriesWidgetAnomalyDetectionSensitivityFromValue returns a pointer to a valid TimeseriesWidgetAnomalyDetectionSensitivity
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewTimeseriesWidgetAnomalyDetectionSensitivityFromValue(v string) (*TimeseriesWidgetAnomalyDetectionSensitivity, error) {
ev := TimeseriesWidgetAnomalyDetectionSensitivity(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for TimeseriesWidgetAnomalyDetectionSensitivity: valid values are %v", v, allowedTimeseriesWidgetAnomalyDetectionSensitivityEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v TimeseriesWidgetAnomalyDetectionSensitivity) IsValid() bool {
for _, existing := range allowedTimeseriesWidgetAnomalyDetectionSensitivityEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to TimeseriesWidgetAnomalyDetectionSensitivity value.
func (v TimeseriesWidgetAnomalyDetectionSensitivity) Ptr() *TimeseriesWidgetAnomalyDetectionSensitivity {
return &v
}
72 changes: 55 additions & 17 deletions api/datadogV1/model_timeseries_widget_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

// TimeseriesWidgetDefinition The timeseries visualization allows you to display the evolution of one or more metrics, log events, or Indexed Spans over time.
type TimeseriesWidgetDefinition struct {
// Anomaly detection configuration for a timeseries widget.
AnomalyDetection *TimeseriesWidgetAnomalyDetection `json:"anomaly_detection,omitempty"`
// List of custom links.
CustomLinks []WidgetCustomLink `json:"custom_links,omitempty"`
// The description of the widget.
Expand Down Expand Up @@ -71,6 +73,34 @@ func NewTimeseriesWidgetDefinitionWithDefaults() *TimeseriesWidgetDefinition {
return &this
}

// GetAnomalyDetection returns the AnomalyDetection field value if set, zero value otherwise.
func (o *TimeseriesWidgetDefinition) GetAnomalyDetection() TimeseriesWidgetAnomalyDetection {
if o == nil || o.AnomalyDetection == nil {
var ret TimeseriesWidgetAnomalyDetection
return ret
}
return *o.AnomalyDetection
}

// GetAnomalyDetectionOk returns a tuple with the AnomalyDetection field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesWidgetDefinition) GetAnomalyDetectionOk() (*TimeseriesWidgetAnomalyDetection, bool) {
if o == nil || o.AnomalyDetection == nil {
return nil, false
}
return o.AnomalyDetection, true
}

// HasAnomalyDetection returns a boolean if a field has been set.
func (o *TimeseriesWidgetDefinition) HasAnomalyDetection() bool {
return o != nil && o.AnomalyDetection != nil
}

// SetAnomalyDetection gets a reference to the given TimeseriesWidgetAnomalyDetection and assigns it to the AnomalyDetection field.
func (o *TimeseriesWidgetDefinition) SetAnomalyDetection(v TimeseriesWidgetAnomalyDetection) {
o.AnomalyDetection = &v
}

// GetCustomLinks returns the CustomLinks field value if set, zero value otherwise.
func (o *TimeseriesWidgetDefinition) GetCustomLinks() []WidgetCustomLink {
if o == nil || o.CustomLinks == nil {
Expand Down Expand Up @@ -518,6 +548,9 @@ func (o TimeseriesWidgetDefinition) MarshalJSON() ([]byte, error) {
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.AnomalyDetection != nil {
toSerialize["anomaly_detection"] = o.AnomalyDetection
}
if o.CustomLinks != nil {
toSerialize["custom_links"] = o.CustomLinks
}
Expand Down Expand Up @@ -572,22 +605,23 @@ func (o TimeseriesWidgetDefinition) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *TimeseriesWidgetDefinition) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
CustomLinks []WidgetCustomLink `json:"custom_links,omitempty"`
Description *string `json:"description,omitempty"`
Events []WidgetEvent `json:"events,omitempty"`
LegendColumns []TimeseriesWidgetLegendColumn `json:"legend_columns,omitempty"`
LegendLayout *TimeseriesWidgetLegendLayout `json:"legend_layout,omitempty"`
LegendSize *string `json:"legend_size,omitempty"`
Markers []WidgetMarker `json:"markers,omitempty"`
Requests *[]TimeseriesWidgetRequest `json:"requests"`
RightYaxis *WidgetAxis `json:"right_yaxis,omitempty"`
ShowLegend *bool `json:"show_legend,omitempty"`
Time *WidgetTime `json:"time,omitempty"`
Title *string `json:"title,omitempty"`
TitleAlign *WidgetTextAlign `json:"title_align,omitempty"`
TitleSize *string `json:"title_size,omitempty"`
Type *TimeseriesWidgetDefinitionType `json:"type"`
Yaxis *WidgetAxis `json:"yaxis,omitempty"`
AnomalyDetection *TimeseriesWidgetAnomalyDetection `json:"anomaly_detection,omitempty"`
CustomLinks []WidgetCustomLink `json:"custom_links,omitempty"`
Description *string `json:"description,omitempty"`
Events []WidgetEvent `json:"events,omitempty"`
LegendColumns []TimeseriesWidgetLegendColumn `json:"legend_columns,omitempty"`
LegendLayout *TimeseriesWidgetLegendLayout `json:"legend_layout,omitempty"`
LegendSize *string `json:"legend_size,omitempty"`
Markers []WidgetMarker `json:"markers,omitempty"`
Requests *[]TimeseriesWidgetRequest `json:"requests"`
RightYaxis *WidgetAxis `json:"right_yaxis,omitempty"`
ShowLegend *bool `json:"show_legend,omitempty"`
Time *WidgetTime `json:"time,omitempty"`
Title *string `json:"title,omitempty"`
TitleAlign *WidgetTextAlign `json:"title_align,omitempty"`
TitleSize *string `json:"title_size,omitempty"`
Type *TimeseriesWidgetDefinitionType `json:"type"`
Yaxis *WidgetAxis `json:"yaxis,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -600,12 +634,16 @@ func (o *TimeseriesWidgetDefinition) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"custom_links", "description", "events", "legend_columns", "legend_layout", "legend_size", "markers", "requests", "right_yaxis", "show_legend", "time", "title", "title_align", "title_size", "type", "yaxis"})
datadog.DeleteKeys(additionalProperties, &[]string{"anomaly_detection", "custom_links", "description", "events", "legend_columns", "legend_layout", "legend_size", "markers", "requests", "right_yaxis", "show_legend", "time", "title", "title_align", "title_size", "type", "yaxis"})
} else {
return err
}

hasInvalidField := false
if all.AnomalyDetection != nil && all.AnomalyDetection.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
o.AnomalyDetection = all.AnomalyDetection
o.CustomLinks = all.CustomLinks
o.Description = all.Description
o.Events = all.Events
Expand Down
Loading