Skip to content

Commit 76a4aba

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 789a1f8 of spec repo
1 parent f06c589 commit 76a4aba

7 files changed

+136
-5
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,6 +4338,10 @@ components:
43384338
- ip_match
43394339
- "!ip_match"
43404340
- capture_data
4341+
- exists
4342+
- "!exists"
4343+
- equals
4344+
- "!equals"
43414345
example: "match_regex"
43424346
type: string
43434347
x-enum-varnames:
@@ -4352,6 +4356,10 @@ components:
43524356
- IP_MATCH
43534357
- NOT_IP_MATCH
43544358
- CAPTURE_DATA
4359+
- EXISTS
4360+
- NOT_EXISTS
4361+
- EQUALS
4362+
- NOT_EQUALS
43554363
ApplicationSecurityWafCustomRuleConditionOptions:
43564364
description: Options for the operator of this condition.
43574365
properties:
@@ -4392,6 +4400,8 @@ components:
43924400
description: "Regex to use with the condition. Only used with match_regex and !match_regex operator."
43934401
example: "path.*"
43944402
type: string
4403+
type:
4404+
$ref: "#/components/schemas/ApplicationSecurityWafCustomRuleConditionParametersType"
43954405
value:
43964406
description: |-
43974407
Store the captured value in the specified tag name. Only used with the capture_data operator.
@@ -4400,6 +4410,22 @@ components:
44004410
required:
44014411
- inputs
44024412
type: object
4413+
ApplicationSecurityWafCustomRuleConditionParametersType:
4414+
description: The type of the value to compare against. Only used with the equals and !equals operator.
4415+
enum:
4416+
- boolean
4417+
- signed
4418+
- unsigned
4419+
- float
4420+
- string
4421+
example: "string"
4422+
type: string
4423+
x-enum-varnames:
4424+
- BOOLEAN
4425+
- SIGNED
4426+
- UNSIGNED
4427+
- FLOAT
4428+
- STRING
44034429
ApplicationSecurityWafCustomRuleCreateAttributes:
44044430
description: "Create a new WAF custom rule."
44054431
properties:

examples/v2_application-security_CreateApplicationSecurityWafCustomRule.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCondit
1010
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionOperator;
1111
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionOptions;
1212
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParameters;
13+
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParametersType;
1314
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCreateAttributes;
1415
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCreateData;
1516
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCreateRequest;
@@ -44,6 +45,7 @@ async fn main() {
4445
.min_length(0),
4546
)
4647
.regex("path.*".to_string())
48+
.type_(ApplicationSecurityWafCustomRuleConditionParametersType::STRING)
4749
.value("custom_tag".to_string()),
4850
)
4951
],

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6550,6 +6550,8 @@ pub mod model_application_security_waf_custom_rule_condition_input_address;
65506550
pub use self::model_application_security_waf_custom_rule_condition_input_address::ApplicationSecurityWafCustomRuleConditionInputAddress;
65516551
pub mod model_application_security_waf_custom_rule_condition_options;
65526552
pub use self::model_application_security_waf_custom_rule_condition_options::ApplicationSecurityWafCustomRuleConditionOptions;
6553+
pub mod model_application_security_waf_custom_rule_condition_parameters_type;
6554+
pub use self::model_application_security_waf_custom_rule_condition_parameters_type::ApplicationSecurityWafCustomRuleConditionParametersType;
65536555
pub mod model_application_security_waf_custom_rule_metadata;
65546556
pub use self::model_application_security_waf_custom_rule_metadata::ApplicationSecurityWafCustomRuleMetadata;
65556557
pub mod model_application_security_waf_custom_rule_scope;

src/datadogV2/model/model_application_security_waf_custom_rule_condition_operator.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub enum ApplicationSecurityWafCustomRuleConditionOperator {
1818
IP_MATCH,
1919
NOT_IP_MATCH,
2020
CAPTURE_DATA,
21+
EXISTS,
22+
NOT_EXISTS,
23+
EQUALS,
24+
NOT_EQUALS,
2125
UnparsedObject(crate::datadog::UnparsedObject),
2226
}
2327

@@ -35,6 +39,10 @@ impl ToString for ApplicationSecurityWafCustomRuleConditionOperator {
3539
Self::IP_MATCH => String::from("ip_match"),
3640
Self::NOT_IP_MATCH => String::from("!ip_match"),
3741
Self::CAPTURE_DATA => String::from("capture_data"),
42+
Self::EXISTS => String::from("exists"),
43+
Self::NOT_EXISTS => String::from("!exists"),
44+
Self::EQUALS => String::from("equals"),
45+
Self::NOT_EQUALS => String::from("!equals"),
3846
Self::UnparsedObject(v) => v.value.to_string(),
3947
}
4048
}
@@ -70,6 +78,10 @@ impl<'de> Deserialize<'de> for ApplicationSecurityWafCustomRuleConditionOperator
7078
"ip_match" => Self::IP_MATCH,
7179
"!ip_match" => Self::NOT_IP_MATCH,
7280
"capture_data" => Self::CAPTURE_DATA,
81+
"exists" => Self::EXISTS,
82+
"!exists" => Self::NOT_EXISTS,
83+
"equals" => Self::EQUALS,
84+
"!equals" => Self::NOT_EQUALS,
7385
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
7486
value: serde_json::Value::String(s.into()),
7587
}),

src/datadogV2/model/model_application_security_waf_custom_rule_condition_parameters.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ pub struct ApplicationSecurityWafCustomRuleConditionParameters {
2727
/// Regex to use with the condition. Only used with match_regex and !match_regex operator.
2828
#[serde(rename = "regex")]
2929
pub regex: Option<String>,
30+
/// The type of the value to compare against. Only used with the equals and !equals operator.
31+
#[serde(rename = "type")]
32+
pub type_:
33+
Option<crate::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParametersType>,
3034
/// Store the captured value in the specified tag name. Only used with the capture_data operator.
3135
#[serde(rename = "value")]
3236
pub value: Option<String>,
@@ -47,6 +51,7 @@ impl ApplicationSecurityWafCustomRuleConditionParameters {
4751
list: None,
4852
options: None,
4953
regex: None,
54+
type_: None,
5055
value: None,
5156
additional_properties: std::collections::BTreeMap::new(),
5257
_unparsed: false,
@@ -76,6 +81,14 @@ impl ApplicationSecurityWafCustomRuleConditionParameters {
7681
self
7782
}
7883

84+
pub fn type_(
85+
mut self,
86+
value: crate::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParametersType,
87+
) -> Self {
88+
self.type_ = Some(value);
89+
self
90+
}
91+
7992
pub fn value(mut self, value: String) -> Self {
8093
self.value = Some(value);
8194
self
@@ -116,6 +129,7 @@ impl<'de> Deserialize<'de> for ApplicationSecurityWafCustomRuleConditionParamete
116129
crate::datadogV2::model::ApplicationSecurityWafCustomRuleConditionOptions,
117130
> = None;
118131
let mut regex: Option<String> = None;
132+
let mut type_: Option<crate::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParametersType> = None;
119133
let mut value: Option<String> = None;
120134
let mut additional_properties: std::collections::BTreeMap<
121135
String,
@@ -152,6 +166,20 @@ impl<'de> Deserialize<'de> for ApplicationSecurityWafCustomRuleConditionParamete
152166
}
153167
regex = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
154168
}
169+
"type" => {
170+
if v.is_null() {
171+
continue;
172+
}
173+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
174+
if let Some(ref _type_) = type_ {
175+
match _type_ {
176+
crate::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParametersType::UnparsedObject(_type_) => {
177+
_unparsed = true;
178+
},
179+
_ => {}
180+
}
181+
}
182+
}
155183
"value" => {
156184
if v.is_null() {
157185
continue;
@@ -173,6 +201,7 @@ impl<'de> Deserialize<'de> for ApplicationSecurityWafCustomRuleConditionParamete
173201
list,
174202
options,
175203
regex,
204+
type_,
176205
value,
177206
additional_properties,
178207
_unparsed,
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, Eq, PartialEq)]
9+
pub enum ApplicationSecurityWafCustomRuleConditionParametersType {
10+
BOOLEAN,
11+
SIGNED,
12+
UNSIGNED,
13+
FLOAT,
14+
STRING,
15+
UnparsedObject(crate::datadog::UnparsedObject),
16+
}
17+
18+
impl ToString for ApplicationSecurityWafCustomRuleConditionParametersType {
19+
fn to_string(&self) -> String {
20+
match self {
21+
Self::BOOLEAN => String::from("boolean"),
22+
Self::SIGNED => String::from("signed"),
23+
Self::UNSIGNED => String::from("unsigned"),
24+
Self::FLOAT => String::from("float"),
25+
Self::STRING => String::from("string"),
26+
Self::UnparsedObject(v) => v.value.to_string(),
27+
}
28+
}
29+
}
30+
31+
impl Serialize for ApplicationSecurityWafCustomRuleConditionParametersType {
32+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
33+
where
34+
S: Serializer,
35+
{
36+
match self {
37+
Self::UnparsedObject(v) => v.serialize(serializer),
38+
_ => serializer.serialize_str(self.to_string().as_str()),
39+
}
40+
}
41+
}
42+
43+
impl<'de> Deserialize<'de> for ApplicationSecurityWafCustomRuleConditionParametersType {
44+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
45+
where
46+
D: Deserializer<'de>,
47+
{
48+
let s: String = String::deserialize(deserializer)?;
49+
Ok(match s.as_str() {
50+
"boolean" => Self::BOOLEAN,
51+
"signed" => Self::SIGNED,
52+
"unsigned" => Self::UNSIGNED,
53+
"float" => Self::FLOAT,
54+
"string" => Self::STRING,
55+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
56+
value: serde_json::Value::String(s.into()),
57+
}),
58+
})
59+
}
60+
}

tests/scenarios/features/v2/application_security.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ Feature: Application Security
1616
@generated @skip @team:DataDog/asm-backend
1717
Scenario: Create a WAF custom rule returns "Bad Request" response
1818
Given new "CreateApplicationSecurityWafCustomRule" request
19-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
19+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
2020
When the request is sent
2121
Then the response status is 400 Bad Request
2222

2323
@generated @skip @team:DataDog/asm-backend
2424
Scenario: Create a WAF custom rule returns "Concurrent Modification" response
2525
Given new "CreateApplicationSecurityWafCustomRule" request
26-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
26+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
2727
When the request is sent
2828
Then the response status is 409 Concurrent Modification
2929

3030
@generated @skip @team:DataDog/asm-backend
3131
Scenario: Create a WAF custom rule returns "Created" response
3232
Given new "CreateApplicationSecurityWafCustomRule" request
33-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
33+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
3434
When the request is sent
3535
Then the response status is 201 Created
3636

@@ -153,15 +153,15 @@ Feature: Application Security
153153
Scenario: Update a WAF Custom Rule returns "Concurrent Modification" response
154154
Given new "UpdateApplicationSecurityWafCustomRule" request
155155
And request contains "custom_rule_id" parameter from "REPLACE.ME"
156-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
156+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
157157
When the request is sent
158158
Then the response status is 409 Concurrent Modification
159159

160160
@generated @skip @team:DataDog/asm-backend
161161
Scenario: Update a WAF Custom Rule returns "Not Found" response
162162
Given new "UpdateApplicationSecurityWafCustomRule" request
163163
And request contains "custom_rule_id" parameter from "REPLACE.ME"
164-
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
164+
And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "type": "string", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}}
165165
When the request is sent
166166
Then the response status is 404 Not Found
167167

0 commit comments

Comments
 (0)