Skip to content

Commit 1c51e04

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Flag IP case action (#3230)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3ad6a79 commit 1c51e04

9 files changed

Lines changed: 146 additions & 12 deletions

.generated-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"spec_repo_commit": "06ccc32",
3-
"generated": "2025-07-21 13:56:48.290"
2+
"spec_repo_commit": "8ca2883",
3+
"generated": "2025-07-22 07:16:27.623"
44
}

.generator/schemas/v2/openapi.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34296,9 +34296,22 @@ components:
3429634296
format: int64
3429734297
minimum: 0
3429834298
type: integer
34299+
flaggedIPType:
34300+
$ref: '#/components/schemas/SecurityMonitoringRuleCaseActionOptionsFlaggedIPType'
3429934301
userBehaviorName:
3430034302
$ref: '#/components/schemas/SecurityMonitoringRuleCaseActionOptionsUserBehaviorName'
3430134303
type: object
34304+
SecurityMonitoringRuleCaseActionOptionsFlaggedIPType:
34305+
description: Used with the case action of type 'flag_ip'. The value specified
34306+
in this field is applied as a flag to the IP addresses.
34307+
enum:
34308+
- SUSPICIOUS
34309+
- FLAGGED
34310+
example: FLAGGED
34311+
type: string
34312+
x-enum-varnames:
34313+
- SUSPICIOUS
34314+
- FLAGGED
3430234315
SecurityMonitoringRuleCaseActionOptionsUserBehaviorName:
3430334316
description: Used with the case action of type 'user_behavior'. The value specified
3430434317
in this field is applied as a risk tag to all users affected by the rule.
@@ -34309,11 +34322,13 @@ components:
3430934322
- block_ip
3431034323
- block_user
3431134324
- user_behavior
34325+
- flag_ip
3431234326
type: string
3431334327
x-enum-varnames:
3431434328
- BLOCK_IP
3431534329
- BLOCK_USER
3431634330
- USER_BEHAVIOR
34331+
- FLAG_IP
3431734332
SecurityMonitoringRuleCaseCreate:
3431834333
description: Case when signal is generated.
3431934334
properties:

api/datadogV2/model_security_monitoring_rule_case_action_options.go

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
type SecurityMonitoringRuleCaseActionOptions struct {
1313
// Duration of the action in seconds. 0 indicates no expiration.
1414
Duration *int64 `json:"duration,omitempty"`
15+
// Used with the case action of type 'flag_ip'. The value specified in this field is applied as a flag to the IP addresses.
16+
FlaggedIpType *SecurityMonitoringRuleCaseActionOptionsFlaggedIPType `json:"flaggedIPType,omitempty"`
1517
// Used with the case action of type 'user_behavior'. The value specified in this field is applied as a risk tag to all users affected by the rule.
1618
UserBehaviorName *string `json:"userBehaviorName,omitempty"`
1719
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
@@ -64,6 +66,34 @@ func (o *SecurityMonitoringRuleCaseActionOptions) SetDuration(v int64) {
6466
o.Duration = &v
6567
}
6668

69+
// GetFlaggedIpType returns the FlaggedIpType field value if set, zero value otherwise.
70+
func (o *SecurityMonitoringRuleCaseActionOptions) GetFlaggedIpType() SecurityMonitoringRuleCaseActionOptionsFlaggedIPType {
71+
if o == nil || o.FlaggedIpType == nil {
72+
var ret SecurityMonitoringRuleCaseActionOptionsFlaggedIPType
73+
return ret
74+
}
75+
return *o.FlaggedIpType
76+
}
77+
78+
// GetFlaggedIpTypeOk returns a tuple with the FlaggedIpType field value if set, nil otherwise
79+
// and a boolean to check if the value has been set.
80+
func (o *SecurityMonitoringRuleCaseActionOptions) GetFlaggedIpTypeOk() (*SecurityMonitoringRuleCaseActionOptionsFlaggedIPType, bool) {
81+
if o == nil || o.FlaggedIpType == nil {
82+
return nil, false
83+
}
84+
return o.FlaggedIpType, true
85+
}
86+
87+
// HasFlaggedIpType returns a boolean if a field has been set.
88+
func (o *SecurityMonitoringRuleCaseActionOptions) HasFlaggedIpType() bool {
89+
return o != nil && o.FlaggedIpType != nil
90+
}
91+
92+
// SetFlaggedIpType gets a reference to the given SecurityMonitoringRuleCaseActionOptionsFlaggedIPType and assigns it to the FlaggedIpType field.
93+
func (o *SecurityMonitoringRuleCaseActionOptions) SetFlaggedIpType(v SecurityMonitoringRuleCaseActionOptionsFlaggedIPType) {
94+
o.FlaggedIpType = &v
95+
}
96+
6797
// GetUserBehaviorName returns the UserBehaviorName field value if set, zero value otherwise.
6898
func (o *SecurityMonitoringRuleCaseActionOptions) GetUserBehaviorName() string {
6999
if o == nil || o.UserBehaviorName == nil {
@@ -101,6 +131,9 @@ func (o SecurityMonitoringRuleCaseActionOptions) MarshalJSON() ([]byte, error) {
101131
if o.Duration != nil {
102132
toSerialize["duration"] = o.Duration
103133
}
134+
if o.FlaggedIpType != nil {
135+
toSerialize["flaggedIPType"] = o.FlaggedIpType
136+
}
104137
if o.UserBehaviorName != nil {
105138
toSerialize["userBehaviorName"] = o.UserBehaviorName
106139
}
@@ -114,24 +147,36 @@ func (o SecurityMonitoringRuleCaseActionOptions) MarshalJSON() ([]byte, error) {
114147
// UnmarshalJSON deserializes the given payload.
115148
func (o *SecurityMonitoringRuleCaseActionOptions) UnmarshalJSON(bytes []byte) (err error) {
116149
all := struct {
117-
Duration *int64 `json:"duration,omitempty"`
118-
UserBehaviorName *string `json:"userBehaviorName,omitempty"`
150+
Duration *int64 `json:"duration,omitempty"`
151+
FlaggedIpType *SecurityMonitoringRuleCaseActionOptionsFlaggedIPType `json:"flaggedIPType,omitempty"`
152+
UserBehaviorName *string `json:"userBehaviorName,omitempty"`
119153
}{}
120154
if err = datadog.Unmarshal(bytes, &all); err != nil {
121155
return datadog.Unmarshal(bytes, &o.UnparsedObject)
122156
}
123157
additionalProperties := make(map[string]interface{})
124158
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
125-
datadog.DeleteKeys(additionalProperties, &[]string{"duration", "userBehaviorName"})
159+
datadog.DeleteKeys(additionalProperties, &[]string{"duration", "flaggedIPType", "userBehaviorName"})
126160
} else {
127161
return err
128162
}
163+
164+
hasInvalidField := false
129165
o.Duration = all.Duration
166+
if all.FlaggedIpType != nil && !all.FlaggedIpType.IsValid() {
167+
hasInvalidField = true
168+
} else {
169+
o.FlaggedIpType = all.FlaggedIpType
170+
}
130171
o.UserBehaviorName = all.UserBehaviorName
131172

132173
if len(additionalProperties) > 0 {
133174
o.AdditionalProperties = additionalProperties
134175
}
135176

177+
if hasInvalidField {
178+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
179+
}
180+
136181
return nil
137182
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
// SecurityMonitoringRuleCaseActionOptionsFlaggedIPType Used with the case action of type 'flag_ip'. The value specified in this field is applied as a flag to the IP addresses.
14+
type SecurityMonitoringRuleCaseActionOptionsFlaggedIPType string
15+
16+
// List of SecurityMonitoringRuleCaseActionOptionsFlaggedIPType.
17+
const (
18+
SECURITYMONITORINGRULECASEACTIONOPTIONSFLAGGEDIPTYPE_SUSPICIOUS SecurityMonitoringRuleCaseActionOptionsFlaggedIPType = "SUSPICIOUS"
19+
SECURITYMONITORINGRULECASEACTIONOPTIONSFLAGGEDIPTYPE_FLAGGED SecurityMonitoringRuleCaseActionOptionsFlaggedIPType = "FLAGGED"
20+
)
21+
22+
var allowedSecurityMonitoringRuleCaseActionOptionsFlaggedIPTypeEnumValues = []SecurityMonitoringRuleCaseActionOptionsFlaggedIPType{
23+
SECURITYMONITORINGRULECASEACTIONOPTIONSFLAGGEDIPTYPE_SUSPICIOUS,
24+
SECURITYMONITORINGRULECASEACTIONOPTIONSFLAGGEDIPTYPE_FLAGGED,
25+
}
26+
27+
// GetAllowedValues reeturns the list of possible values.
28+
func (v *SecurityMonitoringRuleCaseActionOptionsFlaggedIPType) GetAllowedValues() []SecurityMonitoringRuleCaseActionOptionsFlaggedIPType {
29+
return allowedSecurityMonitoringRuleCaseActionOptionsFlaggedIPTypeEnumValues
30+
}
31+
32+
// UnmarshalJSON deserializes the given payload.
33+
func (v *SecurityMonitoringRuleCaseActionOptionsFlaggedIPType) UnmarshalJSON(src []byte) error {
34+
var value string
35+
err := datadog.Unmarshal(src, &value)
36+
if err != nil {
37+
return err
38+
}
39+
*v = SecurityMonitoringRuleCaseActionOptionsFlaggedIPType(value)
40+
return nil
41+
}
42+
43+
// NewSecurityMonitoringRuleCaseActionOptionsFlaggedIPTypeFromValue returns a pointer to a valid SecurityMonitoringRuleCaseActionOptionsFlaggedIPType
44+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
45+
func NewSecurityMonitoringRuleCaseActionOptionsFlaggedIPTypeFromValue(v string) (*SecurityMonitoringRuleCaseActionOptionsFlaggedIPType, error) {
46+
ev := SecurityMonitoringRuleCaseActionOptionsFlaggedIPType(v)
47+
if ev.IsValid() {
48+
return &ev, nil
49+
}
50+
return nil, fmt.Errorf("invalid value '%v' for SecurityMonitoringRuleCaseActionOptionsFlaggedIPType: valid values are %v", v, allowedSecurityMonitoringRuleCaseActionOptionsFlaggedIPTypeEnumValues)
51+
}
52+
53+
// IsValid return true if the value is valid for the enum, false otherwise.
54+
func (v SecurityMonitoringRuleCaseActionOptionsFlaggedIPType) IsValid() bool {
55+
for _, existing := range allowedSecurityMonitoringRuleCaseActionOptionsFlaggedIPTypeEnumValues {
56+
if existing == v {
57+
return true
58+
}
59+
}
60+
return false
61+
}
62+
63+
// Ptr returns reference to SecurityMonitoringRuleCaseActionOptionsFlaggedIPType value.
64+
func (v SecurityMonitoringRuleCaseActionOptionsFlaggedIPType) Ptr() *SecurityMonitoringRuleCaseActionOptionsFlaggedIPType {
65+
return &v
66+
}

api/datadogV2/model_security_monitoring_rule_case_action_type.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ const (
1818
SECURITYMONITORINGRULECASEACTIONTYPE_BLOCK_IP SecurityMonitoringRuleCaseActionType = "block_ip"
1919
SECURITYMONITORINGRULECASEACTIONTYPE_BLOCK_USER SecurityMonitoringRuleCaseActionType = "block_user"
2020
SECURITYMONITORINGRULECASEACTIONTYPE_USER_BEHAVIOR SecurityMonitoringRuleCaseActionType = "user_behavior"
21+
SECURITYMONITORINGRULECASEACTIONTYPE_FLAG_IP SecurityMonitoringRuleCaseActionType = "flag_ip"
2122
)
2223

2324
var allowedSecurityMonitoringRuleCaseActionTypeEnumValues = []SecurityMonitoringRuleCaseActionType{
2425
SECURITYMONITORINGRULECASEACTIONTYPE_BLOCK_IP,
2526
SECURITYMONITORINGRULECASEACTIONTYPE_BLOCK_USER,
2627
SECURITYMONITORINGRULECASEACTIONTYPE_USER_BEHAVIOR,
28+
SECURITYMONITORINGRULECASEACTIONTYPE_FLAG_IP,
2729
}
2830

2931
// GetAllowedValues reeturns the list of possible values.

examples/v2/security-monitoring/CreateSecurityMonitoringRule_1965169892.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ func main() {
4848
UserBehaviorName: datadog.PtrString("behavior"),
4949
},
5050
},
51+
{
52+
Type: datadogV2.SECURITYMONITORINGRULECASEACTIONTYPE_FLAG_IP.Ptr(),
53+
Options: &datadogV2.SecurityMonitoringRuleCaseActionOptions{
54+
FlaggedIpType: datadogV2.SECURITYMONITORINGRULECASEACTIONOPTIONSFLAGGEDIPTYPE_FLAGGED.Ptr(),
55+
},
56+
},
5157
},
5258
},
5359
},
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-04-09T15:02:05.047Z
1+
2025-07-17T10:35:24.061Z

tests/scenarios/cassettes/TestScenarios/v2/Feature_Security_Monitoring/Scenario_Create_a_detection_rule_with_type_application_security_returns_OK_response.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interactions:
22
- request:
33
body: |
4-
{"cases":[{"actions":[{"options":{"duration":900},"type":"block_ip"},{"options":{"userBehaviorName":"behavior"},"type":"user_behavior"}],"condition":"a \u003e 100000","name":"","notifications":[],"status":"info"}],"filters":[],"groupSignalsBy":["service"],"isEnabled":true,"message":"Test rule","name":"Test-Create_a_detection_rule_with_type_application_security_returns_OK_response-1744210925_appsec_rule","options":{"detectionMethod":"threshold","evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":["service","@http.client_ip"],"query":"@appsec.security_activity:business_logic.users.login.failure"}],"tags":[],"type":"application_security"}
4+
{"cases":[{"actions":[{"options":{"duration":900},"type":"block_ip"},{"options":{"userBehaviorName":"behavior"},"type":"user_behavior"},{"options":{"flaggedIPType":"FLAGGED"},"type":"flag_ip"}],"condition":"a \u003e 100000","name":"","notifications":[],"status":"info"}],"filters":[],"groupSignalsBy":["service"],"isEnabled":true,"message":"Test rule","name":"Test-Create_a_detection_rule_with_type_application_security_returns_OK_response-1752748524_appsec_rule","options":{"detectionMethod":"threshold","evaluationWindow":900,"keepAlive":3600,"maxSignalDuration":86400},"queries":[{"aggregation":"count","distinctFields":[],"groupByFields":["service","@http.client_ip"],"query":"@appsec.security_activity:business_logic.users.login.failure"}],"tags":[],"type":"application_security"}
55
form: {}
66
headers:
77
Accept:
@@ -12,9 +12,9 @@ interactions:
1212
method: POST
1313
url: https://api.datadoghq.com/api/v2/security_monitoring/rules
1414
response:
15-
body: '{"name":"Test-Create_a_detection_rule_with_type_application_security_returns_OK_response-1744210925_appsec_rule","createdAt":1744210925675,"isDefault":false,"isPartner":false,"isEnabled":true,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"@appsec.security_activity:business_logic.users.login.failure","groupByFields":["service","@http.client_ip"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"","dataSource":"app_sec_spans"}],"options":{"evaluationWindow":900,"detectionMethod":"threshold","maxSignalDuration":86400,"keepAlive":3600},"cases":[{"name":"","status":"info","notifications":[],"condition":"a
16-
\u003e 100000","actions":[{"type":"block_ip","options":{"duration":900}},{"type":"user_behavior","options":{"userBehaviorName":"behavior"}}]}],"message":"Test
17-
rule","tags":[],"hasExtendedTitle":false,"type":"application_security","filters":[],"version":1,"id":"lfr-zxg-fyc","blocking":true,"groupSignalsBy":["service"],"dependencies":["business_logic.users.login.failure"],"metadata":{"entities":null,"sources":null},"creationAuthorId":2320499,"creator":{"handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
15+
body: '{"name":"Test-Create_a_detection_rule_with_type_application_security_returns_OK_response-1752748524_appsec_rule","createdAt":1752748524806,"isDefault":false,"isPartner":false,"isEnabled":true,"isBeta":false,"isDeleted":false,"isDeprecated":false,"queries":[{"query":"@appsec.security_activity:business_logic.users.login.failure","groupByFields":["service","@http.client_ip"],"hasOptionalGroupByFields":false,"distinctFields":[],"aggregation":"count","name":"","dataSource":"app_sec_spans"}],"options":{"evaluationWindow":900,"detectionMethod":"threshold","maxSignalDuration":86400,"keepAlive":3600},"cases":[{"name":"","status":"info","notifications":[],"condition":"a
16+
\u003e 100000","actions":[{"type":"block_ip","options":{"duration":900}},{"type":"user_behavior","options":{"userBehaviorName":"behavior"}},{"type":"flag_ip","options":{"flaggedIPType":"FLAGGED"}}]}],"message":"Test
17+
rule","tags":[],"hasExtendedTitle":false,"type":"application_security","filters":[],"version":1,"id":"wgo-lgy-ajy","blocking":true,"groupSignalsBy":["service"],"dependencies":["business_logic.users.login.failure"],"metadata":{"entities":null,"sources":null},"creationAuthorId":2320499,"creator":{"handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
1818
Account"},"updater":{"handle":"","name":""}}'
1919
code: 200
2020
duration: 0ms
@@ -30,7 +30,7 @@ interactions:
3030
- '*/*'
3131
id: 1
3232
method: DELETE
33-
url: https://api.datadoghq.com/api/v2/security_monitoring/rules/lfr-zxg-fyc
33+
url: https://api.datadoghq.com/api/v2/security_monitoring/rules/wgo-lgy-ajy
3434
response:
3535
body: ''
3636
code: 204

tests/scenarios/features/v2/security_monitoring.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Feature: Security Monitoring
225225
@skip-validation @team:DataDog/k9-cloud-security-platform
226226
Scenario: Create a detection rule with type 'application_security 'returns "OK" response
227227
Given new "CreateSecurityMonitoringRule" request
228-
And body with value {"type":"application_security","name":"{{unique}}_appsec_rule","queries":[{"query":"@appsec.security_activity:business_logic.users.login.failure","aggregation":"count","groupByFields":["service","@http.client_ip"],"distinctFields":[]}],"filters":[],"cases":[{"name":"","status":"info","notifications":[],"condition":"a > 100000","actions":[{"type":"block_ip","options":{"duration":900}}, {"type":"user_behavior","options":{"userBehaviorName":"behavior"}}]}],"options":{"keepAlive":3600,"maxSignalDuration":86400,"evaluationWindow":900,"detectionMethod":"threshold"},"isEnabled":true,"message":"Test rule","tags":[],"groupSignalsBy":["service"]}
228+
And body with value {"type":"application_security","name":"{{unique}}_appsec_rule","queries":[{"query":"@appsec.security_activity:business_logic.users.login.failure","aggregation":"count","groupByFields":["service","@http.client_ip"],"distinctFields":[]}],"filters":[],"cases":[{"name":"","status":"info","notifications":[],"condition":"a > 100000","actions":[{"type":"block_ip","options":{"duration":900}}, {"type":"user_behavior","options":{"userBehaviorName":"behavior"}}, {"type":"flag_ip","options":{"flaggedIPType":"FLAGGED"}}]}],"options":{"keepAlive":3600,"maxSignalDuration":86400,"evaluationWindow":900,"detectionMethod":"threshold"},"isEnabled":true,"message":"Test rule","tags":[],"groupSignalsBy":["service"]}
229229
When the request is sent
230230
Then the response status is 200 OK
231231
And the response "name" is equal to "{{ unique }}_appsec_rule"

0 commit comments

Comments
 (0)