Skip to content

Commit b8d8432

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add sampling fields to SDS spec (#693)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 096a46d commit b8d8432

27 files changed

+321
-148
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": "2025-06-17 14:56:00.539225",
8-
"spec_repo_commit": "b359fdcc"
7+
"regenerated": "2025-06-17 18:21:57.470118",
8+
"spec_repo_commit": "b1a1c000"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-06-17 14:56:00.555372",
13-
"spec_repo_commit": "b359fdcc"
12+
"regenerated": "2025-06-17 18:21:57.486359",
13+
"spec_repo_commit": "b1a1c000"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35002,6 +35002,11 @@ components:
3500235002
items:
3500335003
$ref: '#/components/schemas/SensitiveDataScannerProduct'
3500435004
type: array
35005+
samplings:
35006+
description: List of sampling rates per product type.
35007+
items:
35008+
$ref: '#/components/schemas/SensitiveDataScannerSamplings'
35009+
type: array
3500535010
type: object
3500635011
SensitiveDataScannerGroupCreate:
3500735012
description: Data related to the creation of a group.
@@ -35433,6 +35438,19 @@ components:
3543335438
meta:
3543435439
$ref: '#/components/schemas/SensitiveDataScannerMetaVersionOnly'
3543535440
type: object
35441+
SensitiveDataScannerSamplings:
35442+
description: Sampling configurations for the Scanning Group.
35443+
properties:
35444+
product:
35445+
$ref: '#/components/schemas/SensitiveDataScannerProduct'
35446+
rate:
35447+
description: Rate at which data in product type will be scanned, as a percentage.
35448+
example: 100.0
35449+
format: double
35450+
maximum: 100.0
35451+
minimum: 0.0
35452+
type: number
35453+
type: object
3543635454
SensitiveDataScannerStandardPattern:
3543735455
description: Data containing the standard pattern id.
3543835456
properties:

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4332,6 +4332,8 @@ pub mod model_sensitive_data_scanner_filter;
43324332
pub use self::model_sensitive_data_scanner_filter::SensitiveDataScannerFilter;
43334333
pub mod model_sensitive_data_scanner_product;
43344334
pub use self::model_sensitive_data_scanner_product::SensitiveDataScannerProduct;
4335+
pub mod model_sensitive_data_scanner_samplings;
4336+
pub use self::model_sensitive_data_scanner_samplings::SensitiveDataScannerSamplings;
43354337
pub mod model_sensitive_data_scanner_group_relationships;
43364338
pub use self::model_sensitive_data_scanner_group_relationships::SensitiveDataScannerGroupRelationships;
43374339
pub mod model_sensitive_data_scanner_configuration_data;

src/datadogV2/model/model_sensitive_data_scanner_group_attributes.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ pub struct SensitiveDataScannerGroupAttributes {
2626
/// List of products the scanning group applies.
2727
#[serde(rename = "product_list")]
2828
pub product_list: Option<Vec<crate::datadogV2::model::SensitiveDataScannerProduct>>,
29+
/// List of sampling rates per product type.
30+
#[serde(rename = "samplings")]
31+
pub samplings: Option<Vec<crate::datadogV2::model::SensitiveDataScannerSamplings>>,
2932
#[serde(flatten)]
3033
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
3134
#[serde(skip)]
@@ -41,6 +44,7 @@ impl SensitiveDataScannerGroupAttributes {
4144
is_enabled: None,
4245
name: None,
4346
product_list: None,
47+
samplings: None,
4448
additional_properties: std::collections::BTreeMap::new(),
4549
_unparsed: false,
4650
}
@@ -74,6 +78,14 @@ impl SensitiveDataScannerGroupAttributes {
7478
self
7579
}
7680

81+
pub fn samplings(
82+
mut self,
83+
value: Vec<crate::datadogV2::model::SensitiveDataScannerSamplings>,
84+
) -> Self {
85+
self.samplings = Some(value);
86+
self
87+
}
88+
7789
pub fn additional_properties(
7890
mut self,
7991
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -113,6 +125,9 @@ impl<'de> Deserialize<'de> for SensitiveDataScannerGroupAttributes {
113125
let mut product_list: Option<
114126
Vec<crate::datadogV2::model::SensitiveDataScannerProduct>,
115127
> = None;
128+
let mut samplings: Option<
129+
Vec<crate::datadogV2::model::SensitiveDataScannerSamplings>,
130+
> = None;
116131
let mut additional_properties: std::collections::BTreeMap<
117132
String,
118133
serde_json::Value,
@@ -153,6 +168,12 @@ impl<'de> Deserialize<'de> for SensitiveDataScannerGroupAttributes {
153168
product_list =
154169
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
155170
}
171+
"samplings" => {
172+
if v.is_null() {
173+
continue;
174+
}
175+
samplings = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
176+
}
156177
&_ => {
157178
if let Ok(value) = serde_json::from_value(v.clone()) {
158179
additional_properties.insert(k, value);
@@ -167,6 +188,7 @@ impl<'de> Deserialize<'de> for SensitiveDataScannerGroupAttributes {
167188
is_enabled,
168189
name,
169190
product_list,
191+
samplings,
170192
additional_properties,
171193
_unparsed,
172194
};
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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+
/// Sampling configurations for the Scanning Group.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct SensitiveDataScannerSamplings {
14+
/// Datadog product onto which Sensitive Data Scanner can be activated.
15+
#[serde(rename = "product")]
16+
pub product: Option<crate::datadogV2::model::SensitiveDataScannerProduct>,
17+
/// Rate at which data in product type will be scanned, as a percentage.
18+
#[serde(rename = "rate")]
19+
pub rate: Option<f64>,
20+
#[serde(flatten)]
21+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
22+
#[serde(skip)]
23+
#[serde(default)]
24+
pub(crate) _unparsed: bool,
25+
}
26+
27+
impl SensitiveDataScannerSamplings {
28+
pub fn new() -> SensitiveDataScannerSamplings {
29+
SensitiveDataScannerSamplings {
30+
product: None,
31+
rate: None,
32+
additional_properties: std::collections::BTreeMap::new(),
33+
_unparsed: false,
34+
}
35+
}
36+
37+
pub fn product(mut self, value: crate::datadogV2::model::SensitiveDataScannerProduct) -> Self {
38+
self.product = Some(value);
39+
self
40+
}
41+
42+
pub fn rate(mut self, value: f64) -> Self {
43+
self.rate = Some(value);
44+
self
45+
}
46+
47+
pub fn additional_properties(
48+
mut self,
49+
value: std::collections::BTreeMap<String, serde_json::Value>,
50+
) -> Self {
51+
self.additional_properties = value;
52+
self
53+
}
54+
}
55+
56+
impl Default for SensitiveDataScannerSamplings {
57+
fn default() -> Self {
58+
Self::new()
59+
}
60+
}
61+
62+
impl<'de> Deserialize<'de> for SensitiveDataScannerSamplings {
63+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
64+
where
65+
D: Deserializer<'de>,
66+
{
67+
struct SensitiveDataScannerSamplingsVisitor;
68+
impl<'a> Visitor<'a> for SensitiveDataScannerSamplingsVisitor {
69+
type Value = SensitiveDataScannerSamplings;
70+
71+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
72+
f.write_str("a mapping")
73+
}
74+
75+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
76+
where
77+
M: MapAccess<'a>,
78+
{
79+
let mut product: Option<crate::datadogV2::model::SensitiveDataScannerProduct> =
80+
None;
81+
let mut rate: Option<f64> = None;
82+
let mut additional_properties: std::collections::BTreeMap<
83+
String,
84+
serde_json::Value,
85+
> = std::collections::BTreeMap::new();
86+
let mut _unparsed = false;
87+
88+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
89+
match k.as_str() {
90+
"product" => {
91+
if v.is_null() {
92+
continue;
93+
}
94+
product = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
95+
if let Some(ref _product) = product {
96+
match _product {
97+
crate::datadogV2::model::SensitiveDataScannerProduct::UnparsedObject(_product) => {
98+
_unparsed = true;
99+
},
100+
_ => {}
101+
}
102+
}
103+
}
104+
"rate" => {
105+
if v.is_null() {
106+
continue;
107+
}
108+
rate = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
109+
}
110+
&_ => {
111+
if let Ok(value) = serde_json::from_value(v.clone()) {
112+
additional_properties.insert(k, value);
113+
}
114+
}
115+
}
116+
}
117+
118+
let content = SensitiveDataScannerSamplings {
119+
product,
120+
rate,
121+
additional_properties,
122+
_unparsed,
123+
};
124+
125+
Ok(content)
126+
}
127+
}
128+
129+
deserializer.deserialize_any(SensitiveDataScannerSamplingsVisitor)
130+
}
131+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-12-15T14:50:52.745Z
1+
2025-05-30T17:17:05.785Z

tests/scenarios/cassettes/v2/sensitive_data_scanner/Create-Scanning-Rule-returns-Bad-Request-response.json

Lines changed: 10 additions & 10 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-01-04T13:51:03.802Z
1+
2025-05-30T17:17:07.743Z

tests/scenarios/cassettes/v2/sensitive_data_scanner/Create-Scanning-Rule-returns-OK-response.json

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-12-09T09:52:52.562Z
1+
2025-05-30T17:17:09.412Z

0 commit comments

Comments
 (0)