|
| 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 datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// RetentionFilterUpdateAttributes The object describing the configuration of the retention filter to create/update. |
| 14 | +type RetentionFilterUpdateAttributes struct { |
| 15 | + // Enable/Disable the retention filter. |
| 16 | + Enabled bool `json:"enabled"` |
| 17 | + // The spans filter. Spans matching this filter will be indexed and stored. |
| 18 | + Filter SpansFilterCreate `json:"filter"` |
| 19 | + // The type of retention filter. |
| 20 | + FilterType RetentionFilterAllType `json:"filter_type"` |
| 21 | + // The name of the retention filter. |
| 22 | + Name string `json:"name"` |
| 23 | + // Sample rate to apply to spans going through this retention filter, |
| 24 | + // a value of 1.0 keeps all spans matching the query. |
| 25 | + Rate float64 `json:"rate"` |
| 26 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 27 | + UnparsedObject map[string]interface{} `json:"-"` |
| 28 | + AdditionalProperties map[string]interface{} |
| 29 | +} |
| 30 | + |
| 31 | +// NewRetentionFilterUpdateAttributes instantiates a new RetentionFilterUpdateAttributes object. |
| 32 | +// This constructor will assign default values to properties that have it defined, |
| 33 | +// and makes sure properties required by API are set, but the set of arguments |
| 34 | +// will change when the set of required properties is changed. |
| 35 | +func NewRetentionFilterUpdateAttributes(enabled bool, filter SpansFilterCreate, filterType RetentionFilterAllType, name string, rate float64) *RetentionFilterUpdateAttributes { |
| 36 | + this := RetentionFilterUpdateAttributes{} |
| 37 | + this.Enabled = enabled |
| 38 | + this.Filter = filter |
| 39 | + this.FilterType = filterType |
| 40 | + this.Name = name |
| 41 | + this.Rate = rate |
| 42 | + return &this |
| 43 | +} |
| 44 | + |
| 45 | +// NewRetentionFilterUpdateAttributesWithDefaults instantiates a new RetentionFilterUpdateAttributes object. |
| 46 | +// This constructor will only assign default values to properties that have it defined, |
| 47 | +// but it doesn't guarantee that properties required by API are set. |
| 48 | +func NewRetentionFilterUpdateAttributesWithDefaults() *RetentionFilterUpdateAttributes { |
| 49 | + this := RetentionFilterUpdateAttributes{} |
| 50 | + var filterType RetentionFilterAllType = RETENTIONFILTERALLTYPE_SPANS_SAMPLING_PROCESSOR |
| 51 | + this.FilterType = filterType |
| 52 | + return &this |
| 53 | +} |
| 54 | + |
| 55 | +// GetEnabled returns the Enabled field value. |
| 56 | +func (o *RetentionFilterUpdateAttributes) GetEnabled() bool { |
| 57 | + if o == nil { |
| 58 | + var ret bool |
| 59 | + return ret |
| 60 | + } |
| 61 | + return o.Enabled |
| 62 | +} |
| 63 | + |
| 64 | +// GetEnabledOk returns a tuple with the Enabled field value |
| 65 | +// and a boolean to check if the value has been set. |
| 66 | +func (o *RetentionFilterUpdateAttributes) GetEnabledOk() (*bool, bool) { |
| 67 | + if o == nil { |
| 68 | + return nil, false |
| 69 | + } |
| 70 | + return &o.Enabled, true |
| 71 | +} |
| 72 | + |
| 73 | +// SetEnabled sets field value. |
| 74 | +func (o *RetentionFilterUpdateAttributes) SetEnabled(v bool) { |
| 75 | + o.Enabled = v |
| 76 | +} |
| 77 | + |
| 78 | +// GetFilter returns the Filter field value. |
| 79 | +func (o *RetentionFilterUpdateAttributes) GetFilter() SpansFilterCreate { |
| 80 | + if o == nil { |
| 81 | + var ret SpansFilterCreate |
| 82 | + return ret |
| 83 | + } |
| 84 | + return o.Filter |
| 85 | +} |
| 86 | + |
| 87 | +// GetFilterOk returns a tuple with the Filter field value |
| 88 | +// and a boolean to check if the value has been set. |
| 89 | +func (o *RetentionFilterUpdateAttributes) GetFilterOk() (*SpansFilterCreate, bool) { |
| 90 | + if o == nil { |
| 91 | + return nil, false |
| 92 | + } |
| 93 | + return &o.Filter, true |
| 94 | +} |
| 95 | + |
| 96 | +// SetFilter sets field value. |
| 97 | +func (o *RetentionFilterUpdateAttributes) SetFilter(v SpansFilterCreate) { |
| 98 | + o.Filter = v |
| 99 | +} |
| 100 | + |
| 101 | +// GetFilterType returns the FilterType field value. |
| 102 | +func (o *RetentionFilterUpdateAttributes) GetFilterType() RetentionFilterAllType { |
| 103 | + if o == nil { |
| 104 | + var ret RetentionFilterAllType |
| 105 | + return ret |
| 106 | + } |
| 107 | + return o.FilterType |
| 108 | +} |
| 109 | + |
| 110 | +// GetFilterTypeOk returns a tuple with the FilterType field value |
| 111 | +// and a boolean to check if the value has been set. |
| 112 | +func (o *RetentionFilterUpdateAttributes) GetFilterTypeOk() (*RetentionFilterAllType, bool) { |
| 113 | + if o == nil { |
| 114 | + return nil, false |
| 115 | + } |
| 116 | + return &o.FilterType, true |
| 117 | +} |
| 118 | + |
| 119 | +// SetFilterType sets field value. |
| 120 | +func (o *RetentionFilterUpdateAttributes) SetFilterType(v RetentionFilterAllType) { |
| 121 | + o.FilterType = v |
| 122 | +} |
| 123 | + |
| 124 | +// GetName returns the Name field value. |
| 125 | +func (o *RetentionFilterUpdateAttributes) GetName() string { |
| 126 | + if o == nil { |
| 127 | + var ret string |
| 128 | + return ret |
| 129 | + } |
| 130 | + return o.Name |
| 131 | +} |
| 132 | + |
| 133 | +// GetNameOk returns a tuple with the Name field value |
| 134 | +// and a boolean to check if the value has been set. |
| 135 | +func (o *RetentionFilterUpdateAttributes) GetNameOk() (*string, bool) { |
| 136 | + if o == nil { |
| 137 | + return nil, false |
| 138 | + } |
| 139 | + return &o.Name, true |
| 140 | +} |
| 141 | + |
| 142 | +// SetName sets field value. |
| 143 | +func (o *RetentionFilterUpdateAttributes) SetName(v string) { |
| 144 | + o.Name = v |
| 145 | +} |
| 146 | + |
| 147 | +// GetRate returns the Rate field value. |
| 148 | +func (o *RetentionFilterUpdateAttributes) GetRate() float64 { |
| 149 | + if o == nil { |
| 150 | + var ret float64 |
| 151 | + return ret |
| 152 | + } |
| 153 | + return o.Rate |
| 154 | +} |
| 155 | + |
| 156 | +// GetRateOk returns a tuple with the Rate field value |
| 157 | +// and a boolean to check if the value has been set. |
| 158 | +func (o *RetentionFilterUpdateAttributes) GetRateOk() (*float64, bool) { |
| 159 | + if o == nil { |
| 160 | + return nil, false |
| 161 | + } |
| 162 | + return &o.Rate, true |
| 163 | +} |
| 164 | + |
| 165 | +// SetRate sets field value. |
| 166 | +func (o *RetentionFilterUpdateAttributes) SetRate(v float64) { |
| 167 | + o.Rate = v |
| 168 | +} |
| 169 | + |
| 170 | +// MarshalJSON serializes the struct using spec logic. |
| 171 | +func (o RetentionFilterUpdateAttributes) MarshalJSON() ([]byte, error) { |
| 172 | + toSerialize := map[string]interface{}{} |
| 173 | + if o.UnparsedObject != nil { |
| 174 | + return datadog.Marshal(o.UnparsedObject) |
| 175 | + } |
| 176 | + toSerialize["enabled"] = o.Enabled |
| 177 | + toSerialize["filter"] = o.Filter |
| 178 | + toSerialize["filter_type"] = o.FilterType |
| 179 | + toSerialize["name"] = o.Name |
| 180 | + toSerialize["rate"] = o.Rate |
| 181 | + |
| 182 | + for key, value := range o.AdditionalProperties { |
| 183 | + toSerialize[key] = value |
| 184 | + } |
| 185 | + return datadog.Marshal(toSerialize) |
| 186 | +} |
| 187 | + |
| 188 | +// UnmarshalJSON deserializes the given payload. |
| 189 | +func (o *RetentionFilterUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { |
| 190 | + all := struct { |
| 191 | + Enabled *bool `json:"enabled"` |
| 192 | + Filter *SpansFilterCreate `json:"filter"` |
| 193 | + FilterType *RetentionFilterAllType `json:"filter_type"` |
| 194 | + Name *string `json:"name"` |
| 195 | + Rate *float64 `json:"rate"` |
| 196 | + }{} |
| 197 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 198 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 199 | + } |
| 200 | + if all.Enabled == nil { |
| 201 | + return fmt.Errorf("required field enabled missing") |
| 202 | + } |
| 203 | + if all.Filter == nil { |
| 204 | + return fmt.Errorf("required field filter missing") |
| 205 | + } |
| 206 | + if all.FilterType == nil { |
| 207 | + return fmt.Errorf("required field filter_type missing") |
| 208 | + } |
| 209 | + if all.Name == nil { |
| 210 | + return fmt.Errorf("required field name missing") |
| 211 | + } |
| 212 | + if all.Rate == nil { |
| 213 | + return fmt.Errorf("required field rate missing") |
| 214 | + } |
| 215 | + additionalProperties := make(map[string]interface{}) |
| 216 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 217 | + datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "filter", "filter_type", "name", "rate"}) |
| 218 | + } else { |
| 219 | + return err |
| 220 | + } |
| 221 | + |
| 222 | + hasInvalidField := false |
| 223 | + o.Enabled = *all.Enabled |
| 224 | + if all.Filter.UnparsedObject != nil && o.UnparsedObject == nil { |
| 225 | + hasInvalidField = true |
| 226 | + } |
| 227 | + o.Filter = *all.Filter |
| 228 | + if !all.FilterType.IsValid() { |
| 229 | + hasInvalidField = true |
| 230 | + } else { |
| 231 | + o.FilterType = *all.FilterType |
| 232 | + } |
| 233 | + o.Name = *all.Name |
| 234 | + o.Rate = *all.Rate |
| 235 | + |
| 236 | + if len(additionalProperties) > 0 { |
| 237 | + o.AdditionalProperties = additionalProperties |
| 238 | + } |
| 239 | + |
| 240 | + if hasInvalidField { |
| 241 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 242 | + } |
| 243 | + |
| 244 | + return nil |
| 245 | +} |
0 commit comments