Skip to content

Commit 636a2e7

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update retention filters public API (#74)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 5a6373a commit 636a2e7

10 files changed

+249
-15
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-04-10 19:44:58.186735",
8-
"spec_repo_commit": "3fb610b5"
7+
"regenerated": "2024-04-11 15:35:27.700324",
8+
"spec_repo_commit": "8ffb168c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-04-10 19:44:58.204246",
13-
"spec_repo_commit": "3fb610b5"
12+
"regenerated": "2024-04-11 15:35:27.721018",
13+
"spec_repo_commit": "8ffb168c"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16072,6 +16072,7 @@ components:
1607216072
- spans-sampling-processor
1607316073
- spans-errors-sampling-processor
1607416074
- spans-appsec-sampling-processor
16075+
example: spans-sampling-processor
1607516076
type: string
1607616077
x-enum-varnames:
1607716078
- SPANS_SAMPLING_PROCESSOR
@@ -16188,11 +16189,42 @@ components:
1618816189
type: string
1618916190
x-enum-varnames:
1619016191
- SPANS_SAMPLING_PROCESSOR
16192+
RetentionFilterUpdateAttributes:
16193+
description: The object describing the configuration of the retention filter
16194+
to create/update.
16195+
properties:
16196+
enabled:
16197+
description: Enable/Disable the retention filter.
16198+
example: true
16199+
type: boolean
16200+
filter:
16201+
$ref: '#/components/schemas/SpansFilterCreate'
16202+
filter_type:
16203+
$ref: '#/components/schemas/RetentionFilterAllType'
16204+
name:
16205+
description: The name of the retention filter.
16206+
example: my retention filter
16207+
type: string
16208+
rate:
16209+
description: 'Sample rate to apply to spans going through this retention
16210+
filter,
16211+
16212+
a value of 1.0 keeps all spans matching the query.'
16213+
example: 1.0
16214+
format: double
16215+
type: number
16216+
required:
16217+
- name
16218+
- filter
16219+
- enabled
16220+
- filter_type
16221+
- rate
16222+
type: object
1619116223
RetentionFilterUpdateData:
1619216224
description: The body of the retention filter to be updated.
1619316225
properties:
1619416226
attributes:
16195-
$ref: '#/components/schemas/RetentionFilterCreateAttributes'
16227+
$ref: '#/components/schemas/RetentionFilterUpdateAttributes'
1619616228
id:
1619716229
description: The ID of the retention filter.
1619816230
example: retention-filter-id
@@ -23271,7 +23303,11 @@ paths:
2327123303
post:
2327223304
description: 'Create a retention filter to index spans in your organization.
2327323305

23274-
Returns the retention filter definition when the request is successful.'
23306+
Returns the retention filter definition when the request is successful.
23307+
23308+
23309+
Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor
23310+
cannot be created.'
2327523311
operationId: CreateApmRetentionFilter
2327623312
requestBody:
2327723313
content:
@@ -23325,7 +23361,11 @@ paths:
2332523361
x-codegen-request-body-name: body
2332623362
/api/v2/apm/config/retention-filters/{filter_id}:
2332723363
delete:
23328-
description: Delete a specific retention filter from your organization.
23364+
description: 'Delete a specific retention filter from your organization.
23365+
23366+
23367+
Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor
23368+
cannot be deleted.'
2332923369
operationId: DeleteApmRetentionFilter
2333023370
parameters:
2333123371
- $ref: '#/components/parameters/RetentionFilterIdParam'
@@ -23363,7 +23403,11 @@ paths:
2336323403
tags:
2336423404
- APM Retention Filters
2336523405
put:
23366-
description: Update a retention filter from your organization.
23406+
description: 'Update a retention filter from your organization.
23407+
23408+
23409+
Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor)
23410+
cannot be renamed or removed.'
2336723411
operationId: UpdateApmRetentionFilter
2336823412
parameters:
2336923413
- $ref: '#/components/parameters/RetentionFilterIdParam'

examples/v2_apm-retention-filters_update_apm_retention_filter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_apm_retention_filters::APMRetentionFiltersAPI;
44
use datadog_api_client::datadogV2::model::ApmRetentionFilterType;
5-
use datadog_api_client::datadogV2::model::RetentionFilterCreateAttributes;
6-
use datadog_api_client::datadogV2::model::RetentionFilterType;
5+
use datadog_api_client::datadogV2::model::RetentionFilterAllType;
6+
use datadog_api_client::datadogV2::model::RetentionFilterUpdateAttributes;
77
use datadog_api_client::datadogV2::model::RetentionFilterUpdateData;
88
use datadog_api_client::datadogV2::model::RetentionFilterUpdateRequest;
99
use datadog_api_client::datadogV2::model::SpansFilterCreate;
@@ -13,10 +13,10 @@ async fn main() {
1313
// there is a valid "retention_filter" in the system
1414
let retention_filter_data_id = std::env::var("RETENTION_FILTER_DATA_ID").unwrap();
1515
let body = RetentionFilterUpdateRequest::new(RetentionFilterUpdateData::new(
16-
RetentionFilterCreateAttributes::new(
16+
RetentionFilterUpdateAttributes::new(
1717
true,
1818
SpansFilterCreate::new("@_top_level:1 test:service-demo".to_string()),
19-
RetentionFilterType::SPANS_SAMPLING_PROCESSOR,
19+
RetentionFilterAllType::SPANS_SAMPLING_PROCESSOR,
2020
"test".to_string(),
2121
0.9,
2222
),

src/datadogV2/api/api_apm_retention_filters.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ impl APMRetentionFiltersAPI {
138138

139139
/// Create a retention filter to index spans in your organization.
140140
/// Returns the retention filter definition when the request is successful.
141+
///
142+
/// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be created.
141143
pub async fn create_apm_retention_filter(
142144
&self,
143145
body: crate::datadogV2::model::RetentionFilterCreateRequest,
@@ -161,6 +163,8 @@ impl APMRetentionFiltersAPI {
161163

162164
/// Create a retention filter to index spans in your organization.
163165
/// Returns the retention filter definition when the request is successful.
166+
///
167+
/// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be created.
164168
pub async fn create_apm_retention_filter_with_http_info(
165169
&self,
166170
body: crate::datadogV2::model::RetentionFilterCreateRequest,
@@ -291,6 +295,8 @@ impl APMRetentionFiltersAPI {
291295
}
292296

293297
/// Delete a specific retention filter from your organization.
298+
///
299+
/// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be deleted.
294300
pub async fn delete_apm_retention_filter(
295301
&self,
296302
filter_id: String,
@@ -305,6 +311,8 @@ impl APMRetentionFiltersAPI {
305311
}
306312

307313
/// Delete a specific retention filter from your organization.
314+
///
315+
/// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be deleted.
308316
pub async fn delete_apm_retention_filter_with_http_info(
309317
&self,
310318
filter_id: String,
@@ -728,6 +736,8 @@ impl APMRetentionFiltersAPI {
728736
}
729737

730738
/// Update a retention filter from your organization.
739+
///
740+
/// Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor) cannot be renamed or removed.
731741
pub async fn update_apm_retention_filter(
732742
&self,
733743
filter_id: String,
@@ -754,6 +764,8 @@ impl APMRetentionFiltersAPI {
754764
}
755765

756766
/// Update a retention filter from your organization.
767+
///
768+
/// Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor) cannot be renamed or removed.
757769
pub async fn update_apm_retention_filter_with_http_info(
758770
&self,
759771
filter_id: String,

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ pub mod model_retention_filter_update_request;
162162
pub use self::model_retention_filter_update_request::RetentionFilterUpdateRequest;
163163
pub mod model_retention_filter_update_data;
164164
pub use self::model_retention_filter_update_data::RetentionFilterUpdateData;
165+
pub mod model_retention_filter_update_attributes;
166+
pub use self::model_retention_filter_update_attributes::RetentionFilterUpdateAttributes;
165167
pub mod model_application_keys_sort;
166168
pub use self::model_application_keys_sort::ApplicationKeysSort;
167169
pub mod model_list_application_keys_response;
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
/// The object describing the configuration of the retention filter to create/update.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct RetentionFilterUpdateAttributes {
14+
/// Enable/Disable the retention filter.
15+
#[serde(rename = "enabled")]
16+
pub enabled: bool,
17+
/// The spans filter. Spans matching this filter will be indexed and stored.
18+
#[serde(rename = "filter")]
19+
pub filter: crate::datadogV2::model::SpansFilterCreate,
20+
/// The type of retention filter.
21+
#[serde(rename = "filter_type")]
22+
pub filter_type: crate::datadogV2::model::RetentionFilterAllType,
23+
/// The name of the retention filter.
24+
#[serde(rename = "name")]
25+
pub name: String,
26+
/// Sample rate to apply to spans going through this retention filter,
27+
/// a value of 1.0 keeps all spans matching the query.
28+
#[serde(rename = "rate")]
29+
pub rate: f64,
30+
#[serde(skip)]
31+
#[serde(default)]
32+
pub(crate) _unparsed: bool,
33+
}
34+
35+
impl RetentionFilterUpdateAttributes {
36+
pub fn new(
37+
enabled: bool,
38+
filter: crate::datadogV2::model::SpansFilterCreate,
39+
filter_type: crate::datadogV2::model::RetentionFilterAllType,
40+
name: String,
41+
rate: f64,
42+
) -> RetentionFilterUpdateAttributes {
43+
RetentionFilterUpdateAttributes {
44+
enabled,
45+
filter,
46+
filter_type,
47+
name,
48+
rate,
49+
_unparsed: false,
50+
}
51+
}
52+
}
53+
54+
impl<'de> Deserialize<'de> for RetentionFilterUpdateAttributes {
55+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
56+
where
57+
D: Deserializer<'de>,
58+
{
59+
struct RetentionFilterUpdateAttributesVisitor;
60+
impl<'a> Visitor<'a> for RetentionFilterUpdateAttributesVisitor {
61+
type Value = RetentionFilterUpdateAttributes;
62+
63+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
64+
f.write_str("a mapping")
65+
}
66+
67+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
68+
where
69+
M: MapAccess<'a>,
70+
{
71+
let mut enabled: Option<bool> = None;
72+
let mut filter: Option<crate::datadogV2::model::SpansFilterCreate> = None;
73+
let mut filter_type: Option<crate::datadogV2::model::RetentionFilterAllType> = None;
74+
let mut name: Option<String> = None;
75+
let mut rate: Option<f64> = None;
76+
let mut _unparsed = false;
77+
78+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
79+
match k.as_str() {
80+
"enabled" => {
81+
enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
82+
}
83+
"filter" => {
84+
filter = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
85+
}
86+
"filter_type" => {
87+
filter_type =
88+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
89+
if let Some(ref _filter_type) = filter_type {
90+
match _filter_type {
91+
crate::datadogV2::model::RetentionFilterAllType::UnparsedObject(_filter_type) => {
92+
_unparsed = true;
93+
},
94+
_ => {}
95+
}
96+
}
97+
}
98+
"name" => {
99+
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
100+
}
101+
"rate" => {
102+
rate = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
103+
}
104+
&_ => {}
105+
}
106+
}
107+
let enabled = enabled.ok_or_else(|| M::Error::missing_field("enabled"))?;
108+
let filter = filter.ok_or_else(|| M::Error::missing_field("filter"))?;
109+
let filter_type =
110+
filter_type.ok_or_else(|| M::Error::missing_field("filter_type"))?;
111+
let name = name.ok_or_else(|| M::Error::missing_field("name"))?;
112+
let rate = rate.ok_or_else(|| M::Error::missing_field("rate"))?;
113+
114+
let content = RetentionFilterUpdateAttributes {
115+
enabled,
116+
filter,
117+
filter_type,
118+
name,
119+
rate,
120+
_unparsed,
121+
};
122+
123+
Ok(content)
124+
}
125+
}
126+
127+
deserializer.deserialize_any(RetentionFilterUpdateAttributesVisitor)
128+
}
129+
}

src/datadogV2/model/model_retention_filter_update_data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt::{self, Formatter};
1313
pub struct RetentionFilterUpdateData {
1414
/// The object describing the configuration of the retention filter to create/update.
1515
#[serde(rename = "attributes")]
16-
pub attributes: crate::datadogV2::model::RetentionFilterCreateAttributes,
16+
pub attributes: crate::datadogV2::model::RetentionFilterUpdateAttributes,
1717
/// The ID of the retention filter.
1818
#[serde(rename = "id")]
1919
pub id: String,
@@ -27,7 +27,7 @@ pub struct RetentionFilterUpdateData {
2727

2828
impl RetentionFilterUpdateData {
2929
pub fn new(
30-
attributes: crate::datadogV2::model::RetentionFilterCreateAttributes,
30+
attributes: crate::datadogV2::model::RetentionFilterUpdateAttributes,
3131
id: String,
3232
type_: crate::datadogV2::model::ApmRetentionFilterType,
3333
) -> RetentionFilterUpdateData {
@@ -58,7 +58,7 @@ impl<'de> Deserialize<'de> for RetentionFilterUpdateData {
5858
M: MapAccess<'a>,
5959
{
6060
let mut attributes: Option<
61-
crate::datadogV2::model::RetentionFilterCreateAttributes,
61+
crate::datadogV2::model::RetentionFilterUpdateAttributes,
6262
> = None;
6363
let mut id: Option<String> = None;
6464
let mut type_: Option<crate::datadogV2::model::ApmRetentionFilterType> = None;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024-04-10T12:31:19.300Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": {
6+
"string": "{\"data\":{\"attributes\":{\"enabled\":true,\"filter\":{\"query\":\"@http.status_code:200 service:my-service\"},\"filter_type\":\"spans-errors-sampling-processor\",\"name\":\"my retention filter\",\"rate\":1},\"type\":\"apm_retention_filter\"}}",
7+
"encoding": null
8+
},
9+
"headers": {
10+
"Accept": [
11+
"application/json"
12+
],
13+
"Content-Type": [
14+
"application/json"
15+
]
16+
},
17+
"method": "post",
18+
"uri": "https://api.datadoghq.com/api/v2/apm/config/retention-filters"
19+
},
20+
"response": {
21+
"body": {
22+
"string": "{\"errors\":[\"Field 'filter_type' is invalid, expected value is 'spans-sampling-processor'\"]}",
23+
"encoding": null
24+
},
25+
"headers": {
26+
"Content-Type": [
27+
"application/json"
28+
]
29+
},
30+
"status": {
31+
"code": 400,
32+
"message": "Bad Request"
33+
}
34+
},
35+
"recorded_at": "Wed, 10 Apr 2024 12:31:19 GMT"
36+
}
37+
],
38+
"recorded_with": "VCR 6.0.0"
39+
}

0 commit comments

Comments
 (0)