Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new options for new value detection type on security monitoring rules #1537

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.2",
"regenerated": "2022-06-17 19:27:08.019214",
"spec_repo_commit": "ba61a429"
"regenerated": "2022-06-20 06:54:31.141550",
"spec_repo_commit": "17f09b79"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-06-17 19:27:08.034297",
"spec_repo_commit": "ba61a429"
"regenerated": "2022-06-20 06:54:31.154165",
"spec_repo_commit": "17f09b79"
}
}
}
28 changes: 28 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6469,6 +6469,10 @@ components:
$ref: '#/components/schemas/SecurityMonitoringRuleNewValueOptionsForgetAfter'
learningDuration:
$ref: '#/components/schemas/SecurityMonitoringRuleNewValueOptionsLearningDuration'
learningMethod:
$ref: '#/components/schemas/SecurityMonitoringRuleNewValueOptionsLearningMethod'
learningThreshold:
$ref: '#/components/schemas/SecurityMonitoringRuleNewValueOptionsLearningThreshold'
type: object
SecurityMonitoringRuleNewValueOptionsForgetAfter:
description: The duration in days after which a learned value is forgotten.
Expand All @@ -6489,6 +6493,7 @@ components:
- THREE_WEEKS
- FOUR_WEEKS
SecurityMonitoringRuleNewValueOptionsLearningDuration:
default: 0
description: 'The duration in days during which values are learned, and after
which signals will be generated for values that

Expand All @@ -6504,6 +6509,29 @@ components:
- ZERO_DAYS
- ONE_DAY
- SEVEN_DAYS
SecurityMonitoringRuleNewValueOptionsLearningMethod:
default: duration
description: The learning method used to determine when signals should be generated
for values that weren't learned.
enum:
- duration
- threshold
type: string
x-enum-varnames:
- DURATION
- THRESHOLD
SecurityMonitoringRuleNewValueOptionsLearningThreshold:
default: 0
description: A number of occurrences after which signals will be generated for
values that weren't learned.
enum:
- 0
- 1
format: int32
type: integer
x-enum-varnames:
- ZERO_OCCURRENCES
- ONE_OCCURRENCE
SecurityMonitoringRuleOptions:
description: Options on rules.
properties:
Expand Down
110 changes: 108 additions & 2 deletions api/v2/datadog/model_security_monitoring_rule_new_value_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ type SecurityMonitoringRuleNewValueOptions struct {
// The duration in days during which values are learned, and after which signals will be generated for values that
// weren't learned. If set to 0, a signal will be generated for all new values after the first value is learned.
LearningDuration *SecurityMonitoringRuleNewValueOptionsLearningDuration `json:"learningDuration,omitempty"`
// The learning method used to determine when signals should be generated for values that weren't learned.
LearningMethod *SecurityMonitoringRuleNewValueOptionsLearningMethod `json:"learningMethod,omitempty"`
// A number of occurrences after which signals will be generated for values that weren't learned.
LearningThreshold *SecurityMonitoringRuleNewValueOptionsLearningThreshold `json:"learningThreshold,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:-`
AdditionalProperties map[string]interface{}
Expand All @@ -26,6 +30,12 @@ type SecurityMonitoringRuleNewValueOptions struct {
// will change when the set of required properties is changed.
func NewSecurityMonitoringRuleNewValueOptions() *SecurityMonitoringRuleNewValueOptions {
this := SecurityMonitoringRuleNewValueOptions{}
var learningDuration SecurityMonitoringRuleNewValueOptionsLearningDuration = SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGDURATION_ZERO_DAYS
this.LearningDuration = &learningDuration
var learningMethod SecurityMonitoringRuleNewValueOptionsLearningMethod = SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGMETHOD_DURATION
this.LearningMethod = &learningMethod
var learningThreshold SecurityMonitoringRuleNewValueOptionsLearningThreshold = SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGTHRESHOLD_ZERO_OCCURRENCES
this.LearningThreshold = &learningThreshold
return &this
}

Expand All @@ -34,6 +44,12 @@ func NewSecurityMonitoringRuleNewValueOptions() *SecurityMonitoringRuleNewValueO
// but it doesn't guarantee that properties required by API are set.
func NewSecurityMonitoringRuleNewValueOptionsWithDefaults() *SecurityMonitoringRuleNewValueOptions {
this := SecurityMonitoringRuleNewValueOptions{}
var learningDuration SecurityMonitoringRuleNewValueOptionsLearningDuration = SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGDURATION_ZERO_DAYS
this.LearningDuration = &learningDuration
var learningMethod SecurityMonitoringRuleNewValueOptionsLearningMethod = SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGMETHOD_DURATION
this.LearningMethod = &learningMethod
var learningThreshold SecurityMonitoringRuleNewValueOptionsLearningThreshold = SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGTHRESHOLD_ZERO_OCCURRENCES
this.LearningThreshold = &learningThreshold
return &this
}

Expand Down Expand Up @@ -101,6 +117,70 @@ func (o *SecurityMonitoringRuleNewValueOptions) SetLearningDuration(v SecurityMo
o.LearningDuration = &v
}

// GetLearningMethod returns the LearningMethod field value if set, zero value otherwise.
func (o *SecurityMonitoringRuleNewValueOptions) GetLearningMethod() SecurityMonitoringRuleNewValueOptionsLearningMethod {
if o == nil || o.LearningMethod == nil {
var ret SecurityMonitoringRuleNewValueOptionsLearningMethod
return ret
}
return *o.LearningMethod
}

// GetLearningMethodOk returns a tuple with the LearningMethod field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SecurityMonitoringRuleNewValueOptions) GetLearningMethodOk() (*SecurityMonitoringRuleNewValueOptionsLearningMethod, bool) {
if o == nil || o.LearningMethod == nil {
return nil, false
}
return o.LearningMethod, true
}

// HasLearningMethod returns a boolean if a field has been set.
func (o *SecurityMonitoringRuleNewValueOptions) HasLearningMethod() bool {
if o != nil && o.LearningMethod != nil {
return true
}

return false
}

// SetLearningMethod gets a reference to the given SecurityMonitoringRuleNewValueOptionsLearningMethod and assigns it to the LearningMethod field.
func (o *SecurityMonitoringRuleNewValueOptions) SetLearningMethod(v SecurityMonitoringRuleNewValueOptionsLearningMethod) {
o.LearningMethod = &v
}

// GetLearningThreshold returns the LearningThreshold field value if set, zero value otherwise.
func (o *SecurityMonitoringRuleNewValueOptions) GetLearningThreshold() SecurityMonitoringRuleNewValueOptionsLearningThreshold {
if o == nil || o.LearningThreshold == nil {
var ret SecurityMonitoringRuleNewValueOptionsLearningThreshold
return ret
}
return *o.LearningThreshold
}

// GetLearningThresholdOk returns a tuple with the LearningThreshold field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SecurityMonitoringRuleNewValueOptions) GetLearningThresholdOk() (*SecurityMonitoringRuleNewValueOptionsLearningThreshold, bool) {
if o == nil || o.LearningThreshold == nil {
return nil, false
}
return o.LearningThreshold, true
}

// HasLearningThreshold returns a boolean if a field has been set.
func (o *SecurityMonitoringRuleNewValueOptions) HasLearningThreshold() bool {
if o != nil && o.LearningThreshold != nil {
return true
}

return false
}

// SetLearningThreshold gets a reference to the given SecurityMonitoringRuleNewValueOptionsLearningThreshold and assigns it to the LearningThreshold field.
func (o *SecurityMonitoringRuleNewValueOptions) SetLearningThreshold(v SecurityMonitoringRuleNewValueOptionsLearningThreshold) {
o.LearningThreshold = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o SecurityMonitoringRuleNewValueOptions) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -113,6 +193,12 @@ func (o SecurityMonitoringRuleNewValueOptions) MarshalJSON() ([]byte, error) {
if o.LearningDuration != nil {
toSerialize["learningDuration"] = o.LearningDuration
}
if o.LearningMethod != nil {
toSerialize["learningMethod"] = o.LearningMethod
}
if o.LearningThreshold != nil {
toSerialize["learningThreshold"] = o.LearningThreshold
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -124,8 +210,10 @@ func (o SecurityMonitoringRuleNewValueOptions) MarshalJSON() ([]byte, error) {
func (o *SecurityMonitoringRuleNewValueOptions) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
all := struct {
ForgetAfter *SecurityMonitoringRuleNewValueOptionsForgetAfter `json:"forgetAfter,omitempty"`
LearningDuration *SecurityMonitoringRuleNewValueOptionsLearningDuration `json:"learningDuration,omitempty"`
ForgetAfter *SecurityMonitoringRuleNewValueOptionsForgetAfter `json:"forgetAfter,omitempty"`
LearningDuration *SecurityMonitoringRuleNewValueOptionsLearningDuration `json:"learningDuration,omitempty"`
LearningMethod *SecurityMonitoringRuleNewValueOptionsLearningMethod `json:"learningMethod,omitempty"`
LearningThreshold *SecurityMonitoringRuleNewValueOptionsLearningThreshold `json:"learningThreshold,omitempty"`
}{}
err = json.Unmarshal(bytes, &all)
if err != nil {
Expand All @@ -152,7 +240,25 @@ func (o *SecurityMonitoringRuleNewValueOptions) UnmarshalJSON(bytes []byte) (err
o.UnparsedObject = raw
return nil
}
if v := all.LearningMethod; v != nil && !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
if v := all.LearningThreshold; v != nil && !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
o.ForgetAfter = all.ForgetAfter
o.LearningDuration = all.LearningDuration
o.LearningMethod = all.LearningMethod
o.LearningThreshold = all.LearningThreshold
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

package datadog

import (
"encoding/json"
"fmt"
)

// SecurityMonitoringRuleNewValueOptionsLearningMethod The learning method used to determine when signals should be generated for values that weren't learned.
type SecurityMonitoringRuleNewValueOptionsLearningMethod string

// List of SecurityMonitoringRuleNewValueOptionsLearningMethod.
const (
SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGMETHOD_DURATION SecurityMonitoringRuleNewValueOptionsLearningMethod = "duration"
SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGMETHOD_THRESHOLD SecurityMonitoringRuleNewValueOptionsLearningMethod = "threshold"
)

var allowedSecurityMonitoringRuleNewValueOptionsLearningMethodEnumValues = []SecurityMonitoringRuleNewValueOptionsLearningMethod{
SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGMETHOD_DURATION,
SECURITYMONITORINGRULENEWVALUEOPTIONSLEARNINGMETHOD_THRESHOLD,
}

// GetAllowedValues reeturns the list of possible values.
func (v *SecurityMonitoringRuleNewValueOptionsLearningMethod) GetAllowedValues() []SecurityMonitoringRuleNewValueOptionsLearningMethod {
return allowedSecurityMonitoringRuleNewValueOptionsLearningMethodEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *SecurityMonitoringRuleNewValueOptionsLearningMethod) UnmarshalJSON(src []byte) error {
var value string
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
*v = SecurityMonitoringRuleNewValueOptionsLearningMethod(value)
return nil
}

// NewSecurityMonitoringRuleNewValueOptionsLearningMethodFromValue returns a pointer to a valid SecurityMonitoringRuleNewValueOptionsLearningMethod
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewSecurityMonitoringRuleNewValueOptionsLearningMethodFromValue(v string) (*SecurityMonitoringRuleNewValueOptionsLearningMethod, error) {
ev := SecurityMonitoringRuleNewValueOptionsLearningMethod(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for SecurityMonitoringRuleNewValueOptionsLearningMethod: valid values are %v", v, allowedSecurityMonitoringRuleNewValueOptionsLearningMethodEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v SecurityMonitoringRuleNewValueOptionsLearningMethod) IsValid() bool {
for _, existing := range allowedSecurityMonitoringRuleNewValueOptionsLearningMethodEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to SecurityMonitoringRuleNewValueOptionsLearningMethod value.
func (v SecurityMonitoringRuleNewValueOptionsLearningMethod) Ptr() *SecurityMonitoringRuleNewValueOptionsLearningMethod {
return &v
}

// NullableSecurityMonitoringRuleNewValueOptionsLearningMethod handles when a null is used for SecurityMonitoringRuleNewValueOptionsLearningMethod.
type NullableSecurityMonitoringRuleNewValueOptionsLearningMethod struct {
value *SecurityMonitoringRuleNewValueOptionsLearningMethod
isSet bool
}

// Get returns the associated value.
func (v NullableSecurityMonitoringRuleNewValueOptionsLearningMethod) Get() *SecurityMonitoringRuleNewValueOptionsLearningMethod {
return v.value
}

// Set changes the value and indicates it's been called.
func (v *NullableSecurityMonitoringRuleNewValueOptionsLearningMethod) Set(val *SecurityMonitoringRuleNewValueOptionsLearningMethod) {
v.value = val
v.isSet = true
}

// IsSet returns whether Set has been called.
func (v NullableSecurityMonitoringRuleNewValueOptionsLearningMethod) IsSet() bool {
return v.isSet
}

// Unset sets the value to nil and resets the set flag.
func (v *NullableSecurityMonitoringRuleNewValueOptionsLearningMethod) Unset() {
v.value = nil
v.isSet = false
}

// NewNullableSecurityMonitoringRuleNewValueOptionsLearningMethod initializes the struct as if Set has been called.
func NewNullableSecurityMonitoringRuleNewValueOptionsLearningMethod(val *SecurityMonitoringRuleNewValueOptionsLearningMethod) *NullableSecurityMonitoringRuleNewValueOptionsLearningMethod {
return &NullableSecurityMonitoringRuleNewValueOptionsLearningMethod{value: val, isSet: true}
}

// MarshalJSON serializes the associated value.
func (v NullableSecurityMonitoringRuleNewValueOptionsLearningMethod) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}

// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called.
func (v *NullableSecurityMonitoringRuleNewValueOptionsLearningMethod) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}
Loading