|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV1 |
| 6 | + |
| 7 | +import ( |
| 8 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 9 | +) |
| 10 | + |
| 11 | +// TimeseriesRequestStyle Define request widget style for timeseries widgets. |
| 12 | +type TimeseriesRequestStyle struct { |
| 13 | + // If true, the value is displayed as a label relative to the data point. |
| 14 | + HasValueLabels *bool `json:"has_value_labels,omitempty"` |
| 15 | + // Type of lines displayed. |
| 16 | + LineType *WidgetLineType `json:"line_type,omitempty"` |
| 17 | + // Width of line displayed. |
| 18 | + LineWidth *WidgetLineWidth `json:"line_width,omitempty"` |
| 19 | + // How to order series in timeseries visualizations. |
| 20 | + // - `tags`: Order series alphabetically by tag name (default behavior) |
| 21 | + // - `values`: Order series by their current metric values (typically descending) |
| 22 | + OrderBy *WidgetStyleOrderBy `json:"order_by,omitempty"` |
| 23 | + // Color palette to apply to the widget. |
| 24 | + Palette *string `json:"palette,omitempty"` |
| 25 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 26 | + UnparsedObject map[string]interface{} `json:"-"` |
| 27 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 28 | +} |
| 29 | + |
| 30 | +// NewTimeseriesRequestStyle instantiates a new TimeseriesRequestStyle object. |
| 31 | +// This constructor will assign default values to properties that have it defined, |
| 32 | +// and makes sure properties required by API are set, but the set of arguments |
| 33 | +// will change when the set of required properties is changed. |
| 34 | +func NewTimeseriesRequestStyle() *TimeseriesRequestStyle { |
| 35 | + this := TimeseriesRequestStyle{} |
| 36 | + return &this |
| 37 | +} |
| 38 | + |
| 39 | +// NewTimeseriesRequestStyleWithDefaults instantiates a new TimeseriesRequestStyle object. |
| 40 | +// This constructor will only assign default values to properties that have it defined, |
| 41 | +// but it doesn't guarantee that properties required by API are set. |
| 42 | +func NewTimeseriesRequestStyleWithDefaults() *TimeseriesRequestStyle { |
| 43 | + this := TimeseriesRequestStyle{} |
| 44 | + return &this |
| 45 | +} |
| 46 | + |
| 47 | +// GetHasValueLabels returns the HasValueLabels field value if set, zero value otherwise. |
| 48 | +func (o *TimeseriesRequestStyle) GetHasValueLabels() bool { |
| 49 | + if o == nil || o.HasValueLabels == nil { |
| 50 | + var ret bool |
| 51 | + return ret |
| 52 | + } |
| 53 | + return *o.HasValueLabels |
| 54 | +} |
| 55 | + |
| 56 | +// GetHasValueLabelsOk returns a tuple with the HasValueLabels field value if set, nil otherwise |
| 57 | +// and a boolean to check if the value has been set. |
| 58 | +func (o *TimeseriesRequestStyle) GetHasValueLabelsOk() (*bool, bool) { |
| 59 | + if o == nil || o.HasValueLabels == nil { |
| 60 | + return nil, false |
| 61 | + } |
| 62 | + return o.HasValueLabels, true |
| 63 | +} |
| 64 | + |
| 65 | +// HasHasValueLabels returns a boolean if a field has been set. |
| 66 | +func (o *TimeseriesRequestStyle) HasHasValueLabels() bool { |
| 67 | + return o != nil && o.HasValueLabels != nil |
| 68 | +} |
| 69 | + |
| 70 | +// SetHasValueLabels gets a reference to the given bool and assigns it to the HasValueLabels field. |
| 71 | +func (o *TimeseriesRequestStyle) SetHasValueLabels(v bool) { |
| 72 | + o.HasValueLabels = &v |
| 73 | +} |
| 74 | + |
| 75 | +// GetLineType returns the LineType field value if set, zero value otherwise. |
| 76 | +func (o *TimeseriesRequestStyle) GetLineType() WidgetLineType { |
| 77 | + if o == nil || o.LineType == nil { |
| 78 | + var ret WidgetLineType |
| 79 | + return ret |
| 80 | + } |
| 81 | + return *o.LineType |
| 82 | +} |
| 83 | + |
| 84 | +// GetLineTypeOk returns a tuple with the LineType field value if set, nil otherwise |
| 85 | +// and a boolean to check if the value has been set. |
| 86 | +func (o *TimeseriesRequestStyle) GetLineTypeOk() (*WidgetLineType, bool) { |
| 87 | + if o == nil || o.LineType == nil { |
| 88 | + return nil, false |
| 89 | + } |
| 90 | + return o.LineType, true |
| 91 | +} |
| 92 | + |
| 93 | +// HasLineType returns a boolean if a field has been set. |
| 94 | +func (o *TimeseriesRequestStyle) HasLineType() bool { |
| 95 | + return o != nil && o.LineType != nil |
| 96 | +} |
| 97 | + |
| 98 | +// SetLineType gets a reference to the given WidgetLineType and assigns it to the LineType field. |
| 99 | +func (o *TimeseriesRequestStyle) SetLineType(v WidgetLineType) { |
| 100 | + o.LineType = &v |
| 101 | +} |
| 102 | + |
| 103 | +// GetLineWidth returns the LineWidth field value if set, zero value otherwise. |
| 104 | +func (o *TimeseriesRequestStyle) GetLineWidth() WidgetLineWidth { |
| 105 | + if o == nil || o.LineWidth == nil { |
| 106 | + var ret WidgetLineWidth |
| 107 | + return ret |
| 108 | + } |
| 109 | + return *o.LineWidth |
| 110 | +} |
| 111 | + |
| 112 | +// GetLineWidthOk returns a tuple with the LineWidth field value if set, nil otherwise |
| 113 | +// and a boolean to check if the value has been set. |
| 114 | +func (o *TimeseriesRequestStyle) GetLineWidthOk() (*WidgetLineWidth, bool) { |
| 115 | + if o == nil || o.LineWidth == nil { |
| 116 | + return nil, false |
| 117 | + } |
| 118 | + return o.LineWidth, true |
| 119 | +} |
| 120 | + |
| 121 | +// HasLineWidth returns a boolean if a field has been set. |
| 122 | +func (o *TimeseriesRequestStyle) HasLineWidth() bool { |
| 123 | + return o != nil && o.LineWidth != nil |
| 124 | +} |
| 125 | + |
| 126 | +// SetLineWidth gets a reference to the given WidgetLineWidth and assigns it to the LineWidth field. |
| 127 | +func (o *TimeseriesRequestStyle) SetLineWidth(v WidgetLineWidth) { |
| 128 | + o.LineWidth = &v |
| 129 | +} |
| 130 | + |
| 131 | +// GetOrderBy returns the OrderBy field value if set, zero value otherwise. |
| 132 | +func (o *TimeseriesRequestStyle) GetOrderBy() WidgetStyleOrderBy { |
| 133 | + if o == nil || o.OrderBy == nil { |
| 134 | + var ret WidgetStyleOrderBy |
| 135 | + return ret |
| 136 | + } |
| 137 | + return *o.OrderBy |
| 138 | +} |
| 139 | + |
| 140 | +// GetOrderByOk returns a tuple with the OrderBy field value if set, nil otherwise |
| 141 | +// and a boolean to check if the value has been set. |
| 142 | +func (o *TimeseriesRequestStyle) GetOrderByOk() (*WidgetStyleOrderBy, bool) { |
| 143 | + if o == nil || o.OrderBy == nil { |
| 144 | + return nil, false |
| 145 | + } |
| 146 | + return o.OrderBy, true |
| 147 | +} |
| 148 | + |
| 149 | +// HasOrderBy returns a boolean if a field has been set. |
| 150 | +func (o *TimeseriesRequestStyle) HasOrderBy() bool { |
| 151 | + return o != nil && o.OrderBy != nil |
| 152 | +} |
| 153 | + |
| 154 | +// SetOrderBy gets a reference to the given WidgetStyleOrderBy and assigns it to the OrderBy field. |
| 155 | +func (o *TimeseriesRequestStyle) SetOrderBy(v WidgetStyleOrderBy) { |
| 156 | + o.OrderBy = &v |
| 157 | +} |
| 158 | + |
| 159 | +// GetPalette returns the Palette field value if set, zero value otherwise. |
| 160 | +func (o *TimeseriesRequestStyle) GetPalette() string { |
| 161 | + if o == nil || o.Palette == nil { |
| 162 | + var ret string |
| 163 | + return ret |
| 164 | + } |
| 165 | + return *o.Palette |
| 166 | +} |
| 167 | + |
| 168 | +// GetPaletteOk returns a tuple with the Palette field value if set, nil otherwise |
| 169 | +// and a boolean to check if the value has been set. |
| 170 | +func (o *TimeseriesRequestStyle) GetPaletteOk() (*string, bool) { |
| 171 | + if o == nil || o.Palette == nil { |
| 172 | + return nil, false |
| 173 | + } |
| 174 | + return o.Palette, true |
| 175 | +} |
| 176 | + |
| 177 | +// HasPalette returns a boolean if a field has been set. |
| 178 | +func (o *TimeseriesRequestStyle) HasPalette() bool { |
| 179 | + return o != nil && o.Palette != nil |
| 180 | +} |
| 181 | + |
| 182 | +// SetPalette gets a reference to the given string and assigns it to the Palette field. |
| 183 | +func (o *TimeseriesRequestStyle) SetPalette(v string) { |
| 184 | + o.Palette = &v |
| 185 | +} |
| 186 | + |
| 187 | +// MarshalJSON serializes the struct using spec logic. |
| 188 | +func (o TimeseriesRequestStyle) MarshalJSON() ([]byte, error) { |
| 189 | + toSerialize := map[string]interface{}{} |
| 190 | + if o.UnparsedObject != nil { |
| 191 | + return datadog.Marshal(o.UnparsedObject) |
| 192 | + } |
| 193 | + if o.HasValueLabels != nil { |
| 194 | + toSerialize["has_value_labels"] = o.HasValueLabels |
| 195 | + } |
| 196 | + if o.LineType != nil { |
| 197 | + toSerialize["line_type"] = o.LineType |
| 198 | + } |
| 199 | + if o.LineWidth != nil { |
| 200 | + toSerialize["line_width"] = o.LineWidth |
| 201 | + } |
| 202 | + if o.OrderBy != nil { |
| 203 | + toSerialize["order_by"] = o.OrderBy |
| 204 | + } |
| 205 | + if o.Palette != nil { |
| 206 | + toSerialize["palette"] = o.Palette |
| 207 | + } |
| 208 | + |
| 209 | + for key, value := range o.AdditionalProperties { |
| 210 | + toSerialize[key] = value |
| 211 | + } |
| 212 | + return datadog.Marshal(toSerialize) |
| 213 | +} |
| 214 | + |
| 215 | +// UnmarshalJSON deserializes the given payload. |
| 216 | +func (o *TimeseriesRequestStyle) UnmarshalJSON(bytes []byte) (err error) { |
| 217 | + all := struct { |
| 218 | + HasValueLabels *bool `json:"has_value_labels,omitempty"` |
| 219 | + LineType *WidgetLineType `json:"line_type,omitempty"` |
| 220 | + LineWidth *WidgetLineWidth `json:"line_width,omitempty"` |
| 221 | + OrderBy *WidgetStyleOrderBy `json:"order_by,omitempty"` |
| 222 | + Palette *string `json:"palette,omitempty"` |
| 223 | + }{} |
| 224 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 225 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 226 | + } |
| 227 | + additionalProperties := make(map[string]interface{}) |
| 228 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 229 | + datadog.DeleteKeys(additionalProperties, &[]string{"has_value_labels", "line_type", "line_width", "order_by", "palette"}) |
| 230 | + } else { |
| 231 | + return err |
| 232 | + } |
| 233 | + |
| 234 | + hasInvalidField := false |
| 235 | + o.HasValueLabels = all.HasValueLabels |
| 236 | + if all.LineType != nil && !all.LineType.IsValid() { |
| 237 | + hasInvalidField = true |
| 238 | + } else { |
| 239 | + o.LineType = all.LineType |
| 240 | + } |
| 241 | + if all.LineWidth != nil && !all.LineWidth.IsValid() { |
| 242 | + hasInvalidField = true |
| 243 | + } else { |
| 244 | + o.LineWidth = all.LineWidth |
| 245 | + } |
| 246 | + if all.OrderBy != nil && !all.OrderBy.IsValid() { |
| 247 | + hasInvalidField = true |
| 248 | + } else { |
| 249 | + o.OrderBy = all.OrderBy |
| 250 | + } |
| 251 | + o.Palette = all.Palette |
| 252 | + |
| 253 | + if len(additionalProperties) > 0 { |
| 254 | + o.AdditionalProperties = additionalProperties |
| 255 | + } |
| 256 | + |
| 257 | + if hasInvalidField { |
| 258 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 259 | + } |
| 260 | + |
| 261 | + return nil |
| 262 | +} |
0 commit comments