Skip to content

Commit 6b5d64b

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 149f595 of spec repo
1 parent 990d73a commit 6b5d64b

File tree

5 files changed

+197
-1
lines changed

5 files changed

+197
-1
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50893,6 +50893,8 @@ components:
5089350893
maximum: 5
5089450894
minimum: 1
5089550895
type: integer
50896+
suppressions:
50897+
$ref: '#/components/schemas/SensitiveDataScannerSuppressions'
5089650898
tags:
5089750899
description: List of tags.
5089850900
items:
@@ -51114,6 +51116,32 @@ components:
5111451116
type:
5111551117
$ref: '#/components/schemas/SensitiveDataScannerStandardPatternType'
5111651118
type: object
51119+
SensitiveDataScannerSuppressions:
51120+
description: 'Object describing the suppressions for a rule. There are three
51121+
types of suppressions, `starts_with`, `ends_with`, and `exact_match`.
51122+
51123+
Suppressed matches are not obfuscated, counted in metrics, or displayed in
51124+
the Findings page.'
51125+
properties:
51126+
ends_with:
51127+
description: List of strings to use for suppression of matches ending with
51128+
these strings.
51129+
items:
51130+
type: string
51131+
type: array
51132+
exact_match:
51133+
description: List of strings to use for suppression of matches exactly matching
51134+
these strings.
51135+
items:
51136+
type: string
51137+
type: array
51138+
starts_with:
51139+
description: List of strings to use for suppression of matches starting
51140+
with these strings.
51141+
items:
51142+
type: string
51143+
type: array
51144+
type: object
5111751145
SensitiveDataScannerTextReplacement:
5111851146
description: Object describing how the scanned event will be replaced.
5111951147
properties:

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6352,6 +6352,8 @@ pub mod model_sensitive_data_scanner_rule_attributes;
63526352
pub use self::model_sensitive_data_scanner_rule_attributes::SensitiveDataScannerRuleAttributes;
63536353
pub mod model_sensitive_data_scanner_included_keyword_configuration;
63546354
pub use self::model_sensitive_data_scanner_included_keyword_configuration::SensitiveDataScannerIncludedKeywordConfiguration;
6355+
pub mod model_sensitive_data_scanner_suppressions;
6356+
pub use self::model_sensitive_data_scanner_suppressions::SensitiveDataScannerSuppressions;
63556357
pub mod model_sensitive_data_scanner_text_replacement;
63566358
pub use self::model_sensitive_data_scanner_text_replacement::SensitiveDataScannerTextReplacement;
63576359
pub mod model_sensitive_data_scanner_text_replacement_type;

src/datadogV2/model/model_sensitive_data_scanner_rule_attributes.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ pub struct SensitiveDataScannerRuleAttributes {
4040
/// Integer from 1 (high) to 5 (low) indicating rule issue severity.
4141
#[serde(rename = "priority")]
4242
pub priority: Option<i64>,
43+
/// Object describing the suppressions for a rule. There are three types of suppressions, `starts_with`, `ends_with`, and `exact_match`.
44+
/// Suppressed matches are not obfuscated, counted in metrics, or displayed in the Findings page.
45+
#[serde(rename = "suppressions")]
46+
pub suppressions: Option<crate::datadogV2::model::SensitiveDataScannerSuppressions>,
4347
/// List of tags.
4448
#[serde(rename = "tags")]
4549
pub tags: Option<Vec<String>>,
@@ -64,6 +68,7 @@ impl SensitiveDataScannerRuleAttributes {
6468
namespaces: None,
6569
pattern: None,
6670
priority: None,
71+
suppressions: None,
6772
tags: None,
6873
text_replacement: None,
6974
additional_properties: std::collections::BTreeMap::new(),
@@ -114,6 +119,14 @@ impl SensitiveDataScannerRuleAttributes {
114119
self
115120
}
116121

122+
pub fn suppressions(
123+
mut self,
124+
value: crate::datadogV2::model::SensitiveDataScannerSuppressions,
125+
) -> Self {
126+
self.suppressions = Some(value);
127+
self
128+
}
129+
117130
pub fn tags(mut self, value: Vec<String>) -> Self {
118131
self.tags = Some(value);
119132
self
@@ -169,6 +182,9 @@ impl<'de> Deserialize<'de> for SensitiveDataScannerRuleAttributes {
169182
let mut namespaces: Option<Vec<String>> = None;
170183
let mut pattern: Option<String> = None;
171184
let mut priority: Option<i64> = None;
185+
let mut suppressions: Option<
186+
crate::datadogV2::model::SensitiveDataScannerSuppressions,
187+
> = None;
172188
let mut tags: Option<Vec<String>> = None;
173189
let mut text_replacement: Option<
174190
crate::datadogV2::model::SensitiveDataScannerTextReplacement,
@@ -232,6 +248,13 @@ impl<'de> Deserialize<'de> for SensitiveDataScannerRuleAttributes {
232248
}
233249
priority = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
234250
}
251+
"suppressions" => {
252+
if v.is_null() {
253+
continue;
254+
}
255+
suppressions =
256+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
257+
}
235258
"tags" => {
236259
if v.is_null() {
237260
continue;
@@ -262,6 +285,7 @@ impl<'de> Deserialize<'de> for SensitiveDataScannerRuleAttributes {
262285
namespaces,
263286
pattern,
264287
priority,
288+
suppressions,
265289
tags,
266290
text_replacement,
267291
additional_properties,
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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+
/// Object describing the suppressions for a rule. There are three types of suppressions, `starts_with`, `ends_with`, and `exact_match`.
10+
/// Suppressed matches are not obfuscated, counted in metrics, or displayed in the Findings page.
11+
#[non_exhaustive]
12+
#[skip_serializing_none]
13+
#[derive(Clone, Debug, PartialEq, Serialize)]
14+
pub struct SensitiveDataScannerSuppressions {
15+
/// List of strings to use for suppression of matches ending with these strings.
16+
#[serde(rename = "ends_with")]
17+
pub ends_with: Option<Vec<String>>,
18+
/// List of strings to use for suppression of matches exactly matching these strings.
19+
#[serde(rename = "exact_match")]
20+
pub exact_match: Option<Vec<String>>,
21+
/// List of strings to use for suppression of matches starting with these strings.
22+
#[serde(rename = "starts_with")]
23+
pub starts_with: Option<Vec<String>>,
24+
#[serde(flatten)]
25+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
26+
#[serde(skip)]
27+
#[serde(default)]
28+
pub(crate) _unparsed: bool,
29+
}
30+
31+
impl SensitiveDataScannerSuppressions {
32+
pub fn new() -> SensitiveDataScannerSuppressions {
33+
SensitiveDataScannerSuppressions {
34+
ends_with: None,
35+
exact_match: None,
36+
starts_with: None,
37+
additional_properties: std::collections::BTreeMap::new(),
38+
_unparsed: false,
39+
}
40+
}
41+
42+
pub fn ends_with(mut self, value: Vec<String>) -> Self {
43+
self.ends_with = Some(value);
44+
self
45+
}
46+
47+
pub fn exact_match(mut self, value: Vec<String>) -> Self {
48+
self.exact_match = Some(value);
49+
self
50+
}
51+
52+
pub fn starts_with(mut self, value: Vec<String>) -> Self {
53+
self.starts_with = Some(value);
54+
self
55+
}
56+
57+
pub fn additional_properties(
58+
mut self,
59+
value: std::collections::BTreeMap<String, serde_json::Value>,
60+
) -> Self {
61+
self.additional_properties = value;
62+
self
63+
}
64+
}
65+
66+
impl Default for SensitiveDataScannerSuppressions {
67+
fn default() -> Self {
68+
Self::new()
69+
}
70+
}
71+
72+
impl<'de> Deserialize<'de> for SensitiveDataScannerSuppressions {
73+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
74+
where
75+
D: Deserializer<'de>,
76+
{
77+
struct SensitiveDataScannerSuppressionsVisitor;
78+
impl<'a> Visitor<'a> for SensitiveDataScannerSuppressionsVisitor {
79+
type Value = SensitiveDataScannerSuppressions;
80+
81+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
82+
f.write_str("a mapping")
83+
}
84+
85+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
86+
where
87+
M: MapAccess<'a>,
88+
{
89+
let mut ends_with: Option<Vec<String>> = None;
90+
let mut exact_match: Option<Vec<String>> = None;
91+
let mut starts_with: Option<Vec<String>> = None;
92+
let mut additional_properties: std::collections::BTreeMap<
93+
String,
94+
serde_json::Value,
95+
> = std::collections::BTreeMap::new();
96+
let mut _unparsed = false;
97+
98+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
99+
match k.as_str() {
100+
"ends_with" => {
101+
if v.is_null() {
102+
continue;
103+
}
104+
ends_with = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
105+
}
106+
"exact_match" => {
107+
if v.is_null() {
108+
continue;
109+
}
110+
exact_match =
111+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
112+
}
113+
"starts_with" => {
114+
if v.is_null() {
115+
continue;
116+
}
117+
starts_with =
118+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
119+
}
120+
&_ => {
121+
if let Ok(value) = serde_json::from_value(v.clone()) {
122+
additional_properties.insert(k, value);
123+
}
124+
}
125+
}
126+
}
127+
128+
let content = SensitiveDataScannerSuppressions {
129+
ends_with,
130+
exact_match,
131+
starts_with,
132+
additional_properties,
133+
_unparsed,
134+
};
135+
136+
Ok(content)
137+
}
138+
}
139+
140+
deserializer.deserialize_any(SensitiveDataScannerSuppressionsVisitor)
141+
}
142+
}

tests/scenarios/features/v2/sensitive_data_scanner.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Feature: Sensitive Data Scanner
200200
Scenario: Update Scanning Rule returns "Not Found" response
201201
Given new "UpdateScanningRule" request
202202
And request contains "rule_id" parameter from "REPLACE.ME"
203-
And body with value {"data": {"attributes": {"excluded_namespaces": ["admin.name"], "included_keyword_configuration": {"character_count": 30, "keywords": ["credit card", "cc"]}, "namespaces": ["admin"], "tags": [], "text_replacement": {"type": "none"}}, "relationships": {"group": {"data": {"type": "sensitive_data_scanner_group"}}, "standard_pattern": {"data": {"type": "sensitive_data_scanner_standard_pattern"}}}, "type": "sensitive_data_scanner_rule"}, "meta": {"version": 0}}
203+
And body with value {"data": {"attributes": {"excluded_namespaces": ["admin.name"], "included_keyword_configuration": {"character_count": 30, "keywords": ["credit card", "cc"]}, "namespaces": ["admin"], "suppressions": {"ends_with": [], "exact_match": [], "starts_with": []}, "tags": [], "text_replacement": {"type": "none"}}, "relationships": {"group": {"data": {"type": "sensitive_data_scanner_group"}}, "standard_pattern": {"data": {"type": "sensitive_data_scanner_standard_pattern"}}}, "type": "sensitive_data_scanner_rule"}, "meta": {"version": 0}}
204204
When the request is sent
205205
Then the response status is 404 Not Found
206206

0 commit comments

Comments
 (0)