|
| 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 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 9 | +) |
| 10 | + |
| 11 | +// RumCrossProductSampling Configuration for additional APM trace data retention for sessions that match this retention filter. |
| 12 | +// When a session matches the filter and is retained (based on `sample_rate`), you can configure |
| 13 | +// the percentage of retained sessions with ingested traces whose traces are indexed. |
| 14 | +type RumCrossProductSampling struct { |
| 15 | + // Indicates whether trace cross-product sampling is enabled. If `false`, no traces are indexed regardless of `trace_sample_rate`. |
| 16 | + TraceEnabled *bool `json:"trace_enabled,omitempty"` |
| 17 | + // The percentage (0-100) of retained sessions with ingested traces whose traces are indexed. |
| 18 | + // For example, 25.0 means 25% of retained sessions with ingested traces have their traces indexed. |
| 19 | + TraceSampleRate *float64 `json:"trace_sample_rate,omitempty"` |
| 20 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 21 | + UnparsedObject map[string]interface{} `json:"-"` |
| 22 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 23 | +} |
| 24 | + |
| 25 | +// NewRumCrossProductSampling instantiates a new RumCrossProductSampling object. |
| 26 | +// This constructor will assign default values to properties that have it defined, |
| 27 | +// and makes sure properties required by API are set, but the set of arguments |
| 28 | +// will change when the set of required properties is changed. |
| 29 | +func NewRumCrossProductSampling() *RumCrossProductSampling { |
| 30 | + this := RumCrossProductSampling{} |
| 31 | + return &this |
| 32 | +} |
| 33 | + |
| 34 | +// NewRumCrossProductSamplingWithDefaults instantiates a new RumCrossProductSampling object. |
| 35 | +// This constructor will only assign default values to properties that have it defined, |
| 36 | +// but it doesn't guarantee that properties required by API are set. |
| 37 | +func NewRumCrossProductSamplingWithDefaults() *RumCrossProductSampling { |
| 38 | + this := RumCrossProductSampling{} |
| 39 | + return &this |
| 40 | +} |
| 41 | + |
| 42 | +// GetTraceEnabled returns the TraceEnabled field value if set, zero value otherwise. |
| 43 | +func (o *RumCrossProductSampling) GetTraceEnabled() bool { |
| 44 | + if o == nil || o.TraceEnabled == nil { |
| 45 | + var ret bool |
| 46 | + return ret |
| 47 | + } |
| 48 | + return *o.TraceEnabled |
| 49 | +} |
| 50 | + |
| 51 | +// GetTraceEnabledOk returns a tuple with the TraceEnabled field value if set, nil otherwise |
| 52 | +// and a boolean to check if the value has been set. |
| 53 | +func (o *RumCrossProductSampling) GetTraceEnabledOk() (*bool, bool) { |
| 54 | + if o == nil || o.TraceEnabled == nil { |
| 55 | + return nil, false |
| 56 | + } |
| 57 | + return o.TraceEnabled, true |
| 58 | +} |
| 59 | + |
| 60 | +// HasTraceEnabled returns a boolean if a field has been set. |
| 61 | +func (o *RumCrossProductSampling) HasTraceEnabled() bool { |
| 62 | + return o != nil && o.TraceEnabled != nil |
| 63 | +} |
| 64 | + |
| 65 | +// SetTraceEnabled gets a reference to the given bool and assigns it to the TraceEnabled field. |
| 66 | +func (o *RumCrossProductSampling) SetTraceEnabled(v bool) { |
| 67 | + o.TraceEnabled = &v |
| 68 | +} |
| 69 | + |
| 70 | +// GetTraceSampleRate returns the TraceSampleRate field value if set, zero value otherwise. |
| 71 | +func (o *RumCrossProductSampling) GetTraceSampleRate() float64 { |
| 72 | + if o == nil || o.TraceSampleRate == nil { |
| 73 | + var ret float64 |
| 74 | + return ret |
| 75 | + } |
| 76 | + return *o.TraceSampleRate |
| 77 | +} |
| 78 | + |
| 79 | +// GetTraceSampleRateOk returns a tuple with the TraceSampleRate field value if set, nil otherwise |
| 80 | +// and a boolean to check if the value has been set. |
| 81 | +func (o *RumCrossProductSampling) GetTraceSampleRateOk() (*float64, bool) { |
| 82 | + if o == nil || o.TraceSampleRate == nil { |
| 83 | + return nil, false |
| 84 | + } |
| 85 | + return o.TraceSampleRate, true |
| 86 | +} |
| 87 | + |
| 88 | +// HasTraceSampleRate returns a boolean if a field has been set. |
| 89 | +func (o *RumCrossProductSampling) HasTraceSampleRate() bool { |
| 90 | + return o != nil && o.TraceSampleRate != nil |
| 91 | +} |
| 92 | + |
| 93 | +// SetTraceSampleRate gets a reference to the given float64 and assigns it to the TraceSampleRate field. |
| 94 | +func (o *RumCrossProductSampling) SetTraceSampleRate(v float64) { |
| 95 | + o.TraceSampleRate = &v |
| 96 | +} |
| 97 | + |
| 98 | +// MarshalJSON serializes the struct using spec logic. |
| 99 | +func (o RumCrossProductSampling) MarshalJSON() ([]byte, error) { |
| 100 | + toSerialize := map[string]interface{}{} |
| 101 | + if o.UnparsedObject != nil { |
| 102 | + return datadog.Marshal(o.UnparsedObject) |
| 103 | + } |
| 104 | + if o.TraceEnabled != nil { |
| 105 | + toSerialize["trace_enabled"] = o.TraceEnabled |
| 106 | + } |
| 107 | + if o.TraceSampleRate != nil { |
| 108 | + toSerialize["trace_sample_rate"] = o.TraceSampleRate |
| 109 | + } |
| 110 | + |
| 111 | + for key, value := range o.AdditionalProperties { |
| 112 | + toSerialize[key] = value |
| 113 | + } |
| 114 | + return datadog.Marshal(toSerialize) |
| 115 | +} |
| 116 | + |
| 117 | +// UnmarshalJSON deserializes the given payload. |
| 118 | +func (o *RumCrossProductSampling) UnmarshalJSON(bytes []byte) (err error) { |
| 119 | + all := struct { |
| 120 | + TraceEnabled *bool `json:"trace_enabled,omitempty"` |
| 121 | + TraceSampleRate *float64 `json:"trace_sample_rate,omitempty"` |
| 122 | + }{} |
| 123 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 124 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 125 | + } |
| 126 | + additionalProperties := make(map[string]interface{}) |
| 127 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 128 | + datadog.DeleteKeys(additionalProperties, &[]string{"trace_enabled", "trace_sample_rate"}) |
| 129 | + } else { |
| 130 | + return err |
| 131 | + } |
| 132 | + o.TraceEnabled = all.TraceEnabled |
| 133 | + o.TraceSampleRate = all.TraceSampleRate |
| 134 | + |
| 135 | + if len(additionalProperties) > 0 { |
| 136 | + o.AdditionalProperties = additionalProperties |
| 137 | + } |
| 138 | + |
| 139 | + return nil |
| 140 | +} |
0 commit comments