|
| 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 | +// SecurityMonitoringRuleAnomalyDetectionOptions Options on anomaly detection method. |
| 12 | +type SecurityMonitoringRuleAnomalyDetectionOptions struct { |
| 13 | + // Duration in seconds of the time buckets used to aggregate events matched by the rule. |
| 14 | + // Must be greater than or equal to 300. |
| 15 | + BucketDuration *SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration `json:"bucketDuration,omitempty"` |
| 16 | + // An optional parameter that sets how permissive anomaly detection is. |
| 17 | + // Higher values require higher deviations before triggering a signal. |
| 18 | + DetectionTolerance *SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance `json:"detectionTolerance,omitempty"` |
| 19 | + // Learning duration in hours. Anomaly detection waits for at least this amount of historical data before it starts evaluating. |
| 20 | + LearningDuration *SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration `json:"learningDuration,omitempty"` |
| 21 | + // An optional override baseline to apply while the rule is in the learning period. Must be greater than or equal to 0. |
| 22 | + LearningPeriodBaseline *int64 `json:"learningPeriodBaseline,omitempty"` |
| 23 | + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct |
| 24 | + UnparsedObject map[string]interface{} `json:"-"` |
| 25 | + AdditionalProperties map[string]interface{} `json:"-"` |
| 26 | +} |
| 27 | + |
| 28 | +// NewSecurityMonitoringRuleAnomalyDetectionOptions instantiates a new SecurityMonitoringRuleAnomalyDetectionOptions object. |
| 29 | +// This constructor will assign default values to properties that have it defined, |
| 30 | +// and makes sure properties required by API are set, but the set of arguments |
| 31 | +// will change when the set of required properties is changed. |
| 32 | +func NewSecurityMonitoringRuleAnomalyDetectionOptions() *SecurityMonitoringRuleAnomalyDetectionOptions { |
| 33 | + this := SecurityMonitoringRuleAnomalyDetectionOptions{} |
| 34 | + return &this |
| 35 | +} |
| 36 | + |
| 37 | +// NewSecurityMonitoringRuleAnomalyDetectionOptionsWithDefaults instantiates a new SecurityMonitoringRuleAnomalyDetectionOptions object. |
| 38 | +// This constructor will only assign default values to properties that have it defined, |
| 39 | +// but it doesn't guarantee that properties required by API are set. |
| 40 | +func NewSecurityMonitoringRuleAnomalyDetectionOptionsWithDefaults() *SecurityMonitoringRuleAnomalyDetectionOptions { |
| 41 | + this := SecurityMonitoringRuleAnomalyDetectionOptions{} |
| 42 | + return &this |
| 43 | +} |
| 44 | + |
| 45 | +// GetBucketDuration returns the BucketDuration field value if set, zero value otherwise. |
| 46 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetBucketDuration() SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration { |
| 47 | + if o == nil || o.BucketDuration == nil { |
| 48 | + var ret SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration |
| 49 | + return ret |
| 50 | + } |
| 51 | + return *o.BucketDuration |
| 52 | +} |
| 53 | + |
| 54 | +// GetBucketDurationOk returns a tuple with the BucketDuration field value if set, nil otherwise |
| 55 | +// and a boolean to check if the value has been set. |
| 56 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetBucketDurationOk() (*SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration, bool) { |
| 57 | + if o == nil || o.BucketDuration == nil { |
| 58 | + return nil, false |
| 59 | + } |
| 60 | + return o.BucketDuration, true |
| 61 | +} |
| 62 | + |
| 63 | +// HasBucketDuration returns a boolean if a field has been set. |
| 64 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) HasBucketDuration() bool { |
| 65 | + return o != nil && o.BucketDuration != nil |
| 66 | +} |
| 67 | + |
| 68 | +// SetBucketDuration gets a reference to the given SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration and assigns it to the BucketDuration field. |
| 69 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) SetBucketDuration(v SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration) { |
| 70 | + o.BucketDuration = &v |
| 71 | +} |
| 72 | + |
| 73 | +// GetDetectionTolerance returns the DetectionTolerance field value if set, zero value otherwise. |
| 74 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetDetectionTolerance() SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance { |
| 75 | + if o == nil || o.DetectionTolerance == nil { |
| 76 | + var ret SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance |
| 77 | + return ret |
| 78 | + } |
| 79 | + return *o.DetectionTolerance |
| 80 | +} |
| 81 | + |
| 82 | +// GetDetectionToleranceOk returns a tuple with the DetectionTolerance field value if set, nil otherwise |
| 83 | +// and a boolean to check if the value has been set. |
| 84 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetDetectionToleranceOk() (*SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance, bool) { |
| 85 | + if o == nil || o.DetectionTolerance == nil { |
| 86 | + return nil, false |
| 87 | + } |
| 88 | + return o.DetectionTolerance, true |
| 89 | +} |
| 90 | + |
| 91 | +// HasDetectionTolerance returns a boolean if a field has been set. |
| 92 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) HasDetectionTolerance() bool { |
| 93 | + return o != nil && o.DetectionTolerance != nil |
| 94 | +} |
| 95 | + |
| 96 | +// SetDetectionTolerance gets a reference to the given SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance and assigns it to the DetectionTolerance field. |
| 97 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) SetDetectionTolerance(v SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance) { |
| 98 | + o.DetectionTolerance = &v |
| 99 | +} |
| 100 | + |
| 101 | +// GetLearningDuration returns the LearningDuration field value if set, zero value otherwise. |
| 102 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetLearningDuration() SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration { |
| 103 | + if o == nil || o.LearningDuration == nil { |
| 104 | + var ret SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration |
| 105 | + return ret |
| 106 | + } |
| 107 | + return *o.LearningDuration |
| 108 | +} |
| 109 | + |
| 110 | +// GetLearningDurationOk returns a tuple with the LearningDuration field value if set, nil otherwise |
| 111 | +// and a boolean to check if the value has been set. |
| 112 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetLearningDurationOk() (*SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration, bool) { |
| 113 | + if o == nil || o.LearningDuration == nil { |
| 114 | + return nil, false |
| 115 | + } |
| 116 | + return o.LearningDuration, true |
| 117 | +} |
| 118 | + |
| 119 | +// HasLearningDuration returns a boolean if a field has been set. |
| 120 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) HasLearningDuration() bool { |
| 121 | + return o != nil && o.LearningDuration != nil |
| 122 | +} |
| 123 | + |
| 124 | +// SetLearningDuration gets a reference to the given SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration and assigns it to the LearningDuration field. |
| 125 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) SetLearningDuration(v SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration) { |
| 126 | + o.LearningDuration = &v |
| 127 | +} |
| 128 | + |
| 129 | +// GetLearningPeriodBaseline returns the LearningPeriodBaseline field value if set, zero value otherwise. |
| 130 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetLearningPeriodBaseline() int64 { |
| 131 | + if o == nil || o.LearningPeriodBaseline == nil { |
| 132 | + var ret int64 |
| 133 | + return ret |
| 134 | + } |
| 135 | + return *o.LearningPeriodBaseline |
| 136 | +} |
| 137 | + |
| 138 | +// GetLearningPeriodBaselineOk returns a tuple with the LearningPeriodBaseline field value if set, nil otherwise |
| 139 | +// and a boolean to check if the value has been set. |
| 140 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) GetLearningPeriodBaselineOk() (*int64, bool) { |
| 141 | + if o == nil || o.LearningPeriodBaseline == nil { |
| 142 | + return nil, false |
| 143 | + } |
| 144 | + return o.LearningPeriodBaseline, true |
| 145 | +} |
| 146 | + |
| 147 | +// HasLearningPeriodBaseline returns a boolean if a field has been set. |
| 148 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) HasLearningPeriodBaseline() bool { |
| 149 | + return o != nil && o.LearningPeriodBaseline != nil |
| 150 | +} |
| 151 | + |
| 152 | +// SetLearningPeriodBaseline gets a reference to the given int64 and assigns it to the LearningPeriodBaseline field. |
| 153 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) SetLearningPeriodBaseline(v int64) { |
| 154 | + o.LearningPeriodBaseline = &v |
| 155 | +} |
| 156 | + |
| 157 | +// MarshalJSON serializes the struct using spec logic. |
| 158 | +func (o SecurityMonitoringRuleAnomalyDetectionOptions) MarshalJSON() ([]byte, error) { |
| 159 | + toSerialize := map[string]interface{}{} |
| 160 | + if o.UnparsedObject != nil { |
| 161 | + return datadog.Marshal(o.UnparsedObject) |
| 162 | + } |
| 163 | + if o.BucketDuration != nil { |
| 164 | + toSerialize["bucketDuration"] = o.BucketDuration |
| 165 | + } |
| 166 | + if o.DetectionTolerance != nil { |
| 167 | + toSerialize["detectionTolerance"] = o.DetectionTolerance |
| 168 | + } |
| 169 | + if o.LearningDuration != nil { |
| 170 | + toSerialize["learningDuration"] = o.LearningDuration |
| 171 | + } |
| 172 | + if o.LearningPeriodBaseline != nil { |
| 173 | + toSerialize["learningPeriodBaseline"] = o.LearningPeriodBaseline |
| 174 | + } |
| 175 | + |
| 176 | + for key, value := range o.AdditionalProperties { |
| 177 | + toSerialize[key] = value |
| 178 | + } |
| 179 | + return datadog.Marshal(toSerialize) |
| 180 | +} |
| 181 | + |
| 182 | +// UnmarshalJSON deserializes the given payload. |
| 183 | +func (o *SecurityMonitoringRuleAnomalyDetectionOptions) UnmarshalJSON(bytes []byte) (err error) { |
| 184 | + all := struct { |
| 185 | + BucketDuration *SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration `json:"bucketDuration,omitempty"` |
| 186 | + DetectionTolerance *SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance `json:"detectionTolerance,omitempty"` |
| 187 | + LearningDuration *SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration `json:"learningDuration,omitempty"` |
| 188 | + LearningPeriodBaseline *int64 `json:"learningPeriodBaseline,omitempty"` |
| 189 | + }{} |
| 190 | + if err = datadog.Unmarshal(bytes, &all); err != nil { |
| 191 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 192 | + } |
| 193 | + additionalProperties := make(map[string]interface{}) |
| 194 | + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { |
| 195 | + datadog.DeleteKeys(additionalProperties, &[]string{"bucketDuration", "detectionTolerance", "learningDuration", "learningPeriodBaseline"}) |
| 196 | + } else { |
| 197 | + return err |
| 198 | + } |
| 199 | + |
| 200 | + hasInvalidField := false |
| 201 | + if all.BucketDuration != nil && !all.BucketDuration.IsValid() { |
| 202 | + hasInvalidField = true |
| 203 | + } else { |
| 204 | + o.BucketDuration = all.BucketDuration |
| 205 | + } |
| 206 | + if all.DetectionTolerance != nil && !all.DetectionTolerance.IsValid() { |
| 207 | + hasInvalidField = true |
| 208 | + } else { |
| 209 | + o.DetectionTolerance = all.DetectionTolerance |
| 210 | + } |
| 211 | + if all.LearningDuration != nil && !all.LearningDuration.IsValid() { |
| 212 | + hasInvalidField = true |
| 213 | + } else { |
| 214 | + o.LearningDuration = all.LearningDuration |
| 215 | + } |
| 216 | + o.LearningPeriodBaseline = all.LearningPeriodBaseline |
| 217 | + |
| 218 | + if len(additionalProperties) > 0 { |
| 219 | + o.AdditionalProperties = additionalProperties |
| 220 | + } |
| 221 | + |
| 222 | + if hasInvalidField { |
| 223 | + return datadog.Unmarshal(bytes, &o.UnparsedObject) |
| 224 | + } |
| 225 | + |
| 226 | + return nil |
| 227 | +} |
0 commit comments