Skip to content

Commit 489771f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add anomaly detection options to security monitoring rules (DataDog#3531)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 17c8998 commit 489771f

11 files changed

Lines changed: 739 additions & 2 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47320,6 +47320,86 @@ components:
4732047320
description: The name of the reference table.
4732147321
type: string
4732247322
type: object
47323+
SecurityMonitoringRuleAnomalyDetectionOptions:
47324+
additionalProperties: {}
47325+
description: Options on anomaly detection method.
47326+
properties:
47327+
bucketDuration:
47328+
$ref: '#/components/schemas/SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration'
47329+
detectionTolerance:
47330+
$ref: '#/components/schemas/SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance'
47331+
learningDuration:
47332+
$ref: '#/components/schemas/SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration'
47333+
learningPeriodBaseline:
47334+
description: An optional override baseline to apply while the rule is in
47335+
the learning period. Must be greater than or equal to 0.
47336+
format: int64
47337+
minimum: 0
47338+
type: integer
47339+
type: object
47340+
SecurityMonitoringRuleAnomalyDetectionOptionsBucketDuration:
47341+
description: 'Duration in seconds of the time buckets used to aggregate events
47342+
matched by the rule.
47343+
47344+
Must be greater than or equal to 300.'
47345+
enum:
47346+
- 300
47347+
- 600
47348+
- 900
47349+
- 1800
47350+
- 3600
47351+
- 10800
47352+
example: 300
47353+
format: int32
47354+
type: integer
47355+
x-enum-varnames:
47356+
- FIVE_MINUTES
47357+
- TEN_MINUTES
47358+
- FIFTEEN_MINUTES
47359+
- THIRTY_MINUTES
47360+
- ONE_HOUR
47361+
- THREE_HOURS
47362+
SecurityMonitoringRuleAnomalyDetectionOptionsDetectionTolerance:
47363+
description: 'An optional parameter that sets how permissive anomaly detection
47364+
is.
47365+
47366+
Higher values require higher deviations before triggering a signal.'
47367+
enum:
47368+
- 1
47369+
- 2
47370+
- 3
47371+
- 4
47372+
- 5
47373+
example: 5
47374+
format: int32
47375+
type: integer
47376+
x-enum-varnames:
47377+
- ONE
47378+
- TWO
47379+
- THREE
47380+
- FOUR
47381+
- FIVE
47382+
SecurityMonitoringRuleAnomalyDetectionOptionsLearningDuration:
47383+
description: Learning duration in hours. Anomaly detection waits for at least
47384+
this amount of historical data before it starts evaluating.
47385+
enum:
47386+
- 1
47387+
- 6
47388+
- 12
47389+
- 24
47390+
- 48
47391+
- 168
47392+
- 336
47393+
format: int32
47394+
type: integer
47395+
x-enum-varnames:
47396+
- ONE_HOUR
47397+
- SIX_HOURS
47398+
- TWELVE_HOURS
47399+
- ONE_DAY
47400+
- TWO_DAYS
47401+
- ONE_WEEK
47402+
- TWO_WEEKS
4732347403
SecurityMonitoringRuleCase:
4732447404
description: Case when signal is generated.
4732547405
properties:
@@ -47685,6 +47765,8 @@ components:
4768547765
SecurityMonitoringRuleOptions:
4768647766
description: Options.
4768747767
properties:
47768+
anomalyDetectionOptions:
47769+
$ref: '#/components/schemas/SecurityMonitoringRuleAnomalyDetectionOptions'
4768847770
complianceRuleOptions:
4768947771
$ref: '#/components/schemas/CloudConfigurationComplianceRuleOptions'
4769047772
decreaseCriticalityBasedOnEnv:
@@ -55124,6 +55206,8 @@ components:
5512455206
ThreatHuntingJobOptions:
5512555207
description: Job options.
5512655208
properties:
55209+
anomalyDetectionOptions:
55210+
$ref: '#/components/schemas/SecurityMonitoringRuleAnomalyDetectionOptions'
5512755211
detectionMethod:
5512855212
$ref: '#/components/schemas/SecurityMonitoringRuleDetectionMethod'
5512955213
evaluationWindow:
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
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

Comments
 (0)