Skip to content

Commit ece77e0

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add referenceTables field to security monitoring endpoints (#301)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 4a7cce8 commit ece77e0

13 files changed

+357
-11
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-09-30 14:37:40.714287",
8-
"spec_repo_commit": "60bc9127"
7+
"regenerated": "2024-09-30 19:44:30.949374",
8+
"spec_repo_commit": "909e369c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-30 14:37:40.728525",
13-
"spec_repo_commit": "60bc9127"
12+
"regenerated": "2024-09-30 19:44:30.963864",
13+
"spec_repo_commit": "909e369c"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19089,6 +19089,25 @@ components:
1908919089
meta:
1909019090
$ref: '#/components/schemas/ResponseMetaAttributes'
1909119091
type: object
19092+
SecurityMonitoringReferenceTable:
19093+
description: Reference table for the rule.
19094+
properties:
19095+
checkPresence:
19096+
description: Whether to include or exclude the matched values.
19097+
type: boolean
19098+
columnName:
19099+
description: The name of the column in the reference table.
19100+
type: string
19101+
logFieldPath:
19102+
description: The field in the log to match against the reference table.
19103+
type: string
19104+
ruleQueryName:
19105+
description: The name of the rule query to apply the reference table to.
19106+
type: string
19107+
tableName:
19108+
description: The name of the reference table.
19109+
type: string
19110+
type: object
1909219111
SecurityMonitoringRuleCase:
1909319112
description: Case when signal is generated.
1909419113
properties:
@@ -19594,6 +19613,11 @@ components:
1959419613
items:
1959519614
$ref: '#/components/schemas/SecurityMonitoringRuleQuery'
1959619615
type: array
19616+
referenceTables:
19617+
description: Reference tables for the rule.
19618+
items:
19619+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
19620+
type: array
1959719621
tags:
1959819622
description: Tags for generated signals.
1959919623
items:
@@ -20298,6 +20322,11 @@ components:
2029820322
items:
2029920323
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2030020324
type: array
20325+
referenceTables:
20326+
description: Reference tables for the rule.
20327+
items:
20328+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20329+
type: array
2030120330
tags:
2030220331
description: Tags for generated signals.
2030320332
example:
@@ -20365,6 +20394,11 @@ components:
2036520394
items:
2036620395
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2036720396
type: array
20397+
referenceTables:
20398+
description: Reference tables for the rule.
20399+
items:
20400+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20401+
type: array
2036820402
tags:
2036920403
description: Tags for generated signals.
2037020404
example:
@@ -20505,6 +20539,11 @@ components:
2050520539
items:
2050620540
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2050720541
type: array
20542+
referenceTables:
20543+
description: Reference tables for the rule.
20544+
items:
20545+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20546+
type: array
2050820547
tags:
2050920548
description: Tags for generated signals.
2051020549
items:
@@ -20569,6 +20608,11 @@ components:
2056920608
items:
2057020609
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
2057120610
type: array
20611+
referenceTables:
20612+
description: Reference tables for the rule.
20613+
items:
20614+
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
20615+
type: array
2057220616
tags:
2057320617
description: Tags for generated signals.
2057420618
example:

examples/v2_security-monitoring_CreateSecurityMonitoringRule.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Create a detection rule returns "OK" response
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI;
4+
use datadog_api_client::datadogV2::model::SecurityMonitoringReferenceTable;
45
use datadog_api_client::datadogV2::model::SecurityMonitoringRuleCaseCreate;
56
use datadog_api_client::datadogV2::model::SecurityMonitoringRuleCreatePayload;
67
use datadog_api_client::datadogV2::model::SecurityMonitoringRuleEvaluationWindow;
@@ -39,6 +40,12 @@ async fn main() {
3940
.query("@test:true".to_string())],
4041
)
4142
.filters(vec![])
43+
.reference_tables(vec![SecurityMonitoringReferenceTable::new()
44+
.check_presence(true)
45+
.column_name("value".to_string())
46+
.log_field_path("testtag".to_string())
47+
.rule_query_name("a".to_string())
48+
.table_name("synthetics_test_reference_table_dont_delete".to_string())])
4249
.tags(vec![])
4350
.type_(SecurityMonitoringRuleTypeCreate::LOG_DETECTION),
4451
));

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,8 @@ pub mod model_security_monitoring_standard_rule_query;
24402440
pub use self::model_security_monitoring_standard_rule_query::SecurityMonitoringStandardRuleQuery;
24412441
pub mod model_security_monitoring_rule_query_aggregation;
24422442
pub use self::model_security_monitoring_rule_query_aggregation::SecurityMonitoringRuleQueryAggregation;
2443+
pub mod model_security_monitoring_reference_table;
2444+
pub use self::model_security_monitoring_reference_table::SecurityMonitoringReferenceTable;
24432445
pub mod model_security_monitoring_third_party_rule_case;
24442446
pub use self::model_security_monitoring_third_party_rule_case::SecurityMonitoringThirdPartyRuleCase;
24452447
pub mod model_security_monitoring_rule_type_read;
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Reference table for the rule.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct SecurityMonitoringReferenceTable {
14+
/// Whether to include or exclude the matched values.
15+
#[serde(rename = "checkPresence")]
16+
pub check_presence: Option<bool>,
17+
/// The name of the column in the reference table.
18+
#[serde(rename = "columnName")]
19+
pub column_name: Option<String>,
20+
/// The field in the log to match against the reference table.
21+
#[serde(rename = "logFieldPath")]
22+
pub log_field_path: Option<String>,
23+
/// The name of the rule query to apply the reference table to.
24+
#[serde(rename = "ruleQueryName")]
25+
pub rule_query_name: Option<String>,
26+
/// The name of the reference table.
27+
#[serde(rename = "tableName")]
28+
pub table_name: Option<String>,
29+
#[serde(flatten)]
30+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
31+
#[serde(skip)]
32+
#[serde(default)]
33+
pub(crate) _unparsed: bool,
34+
}
35+
36+
impl SecurityMonitoringReferenceTable {
37+
pub fn new() -> SecurityMonitoringReferenceTable {
38+
SecurityMonitoringReferenceTable {
39+
check_presence: None,
40+
column_name: None,
41+
log_field_path: None,
42+
rule_query_name: None,
43+
table_name: None,
44+
additional_properties: std::collections::BTreeMap::new(),
45+
_unparsed: false,
46+
}
47+
}
48+
49+
pub fn check_presence(mut self, value: bool) -> Self {
50+
self.check_presence = Some(value);
51+
self
52+
}
53+
54+
pub fn column_name(mut self, value: String) -> Self {
55+
self.column_name = Some(value);
56+
self
57+
}
58+
59+
pub fn log_field_path(mut self, value: String) -> Self {
60+
self.log_field_path = Some(value);
61+
self
62+
}
63+
64+
pub fn rule_query_name(mut self, value: String) -> Self {
65+
self.rule_query_name = Some(value);
66+
self
67+
}
68+
69+
pub fn table_name(mut self, value: String) -> Self {
70+
self.table_name = Some(value);
71+
self
72+
}
73+
74+
pub fn additional_properties(
75+
mut self,
76+
value: std::collections::BTreeMap<String, serde_json::Value>,
77+
) -> Self {
78+
self.additional_properties = value;
79+
self
80+
}
81+
}
82+
83+
impl Default for SecurityMonitoringReferenceTable {
84+
fn default() -> Self {
85+
Self::new()
86+
}
87+
}
88+
89+
impl<'de> Deserialize<'de> for SecurityMonitoringReferenceTable {
90+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
91+
where
92+
D: Deserializer<'de>,
93+
{
94+
struct SecurityMonitoringReferenceTableVisitor;
95+
impl<'a> Visitor<'a> for SecurityMonitoringReferenceTableVisitor {
96+
type Value = SecurityMonitoringReferenceTable;
97+
98+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
99+
f.write_str("a mapping")
100+
}
101+
102+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
103+
where
104+
M: MapAccess<'a>,
105+
{
106+
let mut check_presence: Option<bool> = None;
107+
let mut column_name: Option<String> = None;
108+
let mut log_field_path: Option<String> = None;
109+
let mut rule_query_name: Option<String> = None;
110+
let mut table_name: Option<String> = None;
111+
let mut additional_properties: std::collections::BTreeMap<
112+
String,
113+
serde_json::Value,
114+
> = std::collections::BTreeMap::new();
115+
let mut _unparsed = false;
116+
117+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
118+
match k.as_str() {
119+
"checkPresence" => {
120+
if v.is_null() {
121+
continue;
122+
}
123+
check_presence =
124+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
125+
}
126+
"columnName" => {
127+
if v.is_null() {
128+
continue;
129+
}
130+
column_name =
131+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
132+
}
133+
"logFieldPath" => {
134+
if v.is_null() {
135+
continue;
136+
}
137+
log_field_path =
138+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
139+
}
140+
"ruleQueryName" => {
141+
if v.is_null() {
142+
continue;
143+
}
144+
rule_query_name =
145+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
146+
}
147+
"tableName" => {
148+
if v.is_null() {
149+
continue;
150+
}
151+
table_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
152+
}
153+
&_ => {
154+
if let Ok(value) = serde_json::from_value(v.clone()) {
155+
additional_properties.insert(k, value);
156+
}
157+
}
158+
}
159+
}
160+
161+
let content = SecurityMonitoringReferenceTable {
162+
check_presence,
163+
column_name,
164+
log_field_path,
165+
rule_query_name,
166+
table_name,
167+
additional_properties,
168+
_unparsed,
169+
};
170+
171+
Ok(content)
172+
}
173+
}
174+
175+
deserializer.deserialize_any(SecurityMonitoringReferenceTableVisitor)
176+
}
177+
}

src/datadogV2/model/model_security_monitoring_rule_update_payload.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ pub struct SecurityMonitoringRuleUpdatePayload {
3939
/// Queries for selecting logs which are part of the rule.
4040
#[serde(rename = "queries")]
4141
pub queries: Option<Vec<crate::datadogV2::model::SecurityMonitoringRuleQuery>>,
42+
/// Reference tables for the rule.
43+
#[serde(rename = "referenceTables")]
44+
pub reference_tables: Option<Vec<crate::datadogV2::model::SecurityMonitoringReferenceTable>>,
4245
/// Tags for generated signals.
4346
#[serde(rename = "tags")]
4447
pub tags: Option<Vec<String>>,
@@ -68,6 +71,7 @@ impl SecurityMonitoringRuleUpdatePayload {
6871
name: None,
6972
options: None,
7073
queries: None,
74+
reference_tables: None,
7175
tags: None,
7276
third_party_cases: None,
7377
version: None,
@@ -136,6 +140,14 @@ impl SecurityMonitoringRuleUpdatePayload {
136140
self
137141
}
138142

143+
pub fn reference_tables(
144+
mut self,
145+
value: Vec<crate::datadogV2::model::SecurityMonitoringReferenceTable>,
146+
) -> Self {
147+
self.reference_tables = Some(value);
148+
self
149+
}
150+
139151
pub fn tags(mut self, value: Vec<String>) -> Self {
140152
self.tags = Some(value);
141153
self
@@ -201,6 +213,9 @@ impl<'de> Deserialize<'de> for SecurityMonitoringRuleUpdatePayload {
201213
None;
202214
let mut queries: Option<Vec<crate::datadogV2::model::SecurityMonitoringRuleQuery>> =
203215
None;
216+
let mut reference_tables: Option<
217+
Vec<crate::datadogV2::model::SecurityMonitoringReferenceTable>,
218+
> = None;
204219
let mut tags: Option<Vec<String>> = None;
205220
let mut third_party_cases: Option<
206221
Vec<crate::datadogV2::model::SecurityMonitoringThirdPartyRuleCase>,
@@ -270,6 +285,13 @@ impl<'de> Deserialize<'de> for SecurityMonitoringRuleUpdatePayload {
270285
}
271286
queries = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
272287
}
288+
"referenceTables" => {
289+
if v.is_null() {
290+
continue;
291+
}
292+
reference_tables =
293+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
294+
}
273295
"tags" => {
274296
if v.is_null() {
275297
continue;
@@ -307,6 +329,7 @@ impl<'de> Deserialize<'de> for SecurityMonitoringRuleUpdatePayload {
307329
name,
308330
options,
309331
queries,
332+
reference_tables,
310333
tags,
311334
third_party_cases,
312335
version,

0 commit comments

Comments
 (0)