Skip to content

Commit ca4faf7

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update retention filters public API (#1941)
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 ab4253e commit ca4faf7

11 files changed

+181
-17
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:53.239946",
8-
"spec_repo_commit": "3fb610b5"
7+
"regenerated": "2024-04-11 15:35:31.200778",
8+
"spec_repo_commit": "8ffb168c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-04-10 19:44:53.257718",
13-
"spec_repo_commit": "3fb610b5"
12+
"regenerated": "2024-04-11 15:35:31.217642",
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'

docs/datadog_api_client.v2.model.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6952,6 +6952,13 @@ retention\_filter\_type
69526952
:members:
69536953
:show-inheritance:
69546954

6955+
retention\_filter\_update\_attributes
6956+
-------------------------------------
6957+
6958+
.. automodule:: datadog_api_client.v2.model.retention_filter_update_attributes
6959+
:members:
6960+
:show-inheritance:
6961+
69556962
retention\_filter\_update\_data
69566963
-------------------------------
69576964

examples/v2/apm-retention-filters/UpdateApmRetentionFilter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from datadog_api_client import ApiClient, Configuration
77
from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi
88
from datadog_api_client.v2.model.apm_retention_filter_type import ApmRetentionFilterType
9-
from datadog_api_client.v2.model.retention_filter_create_attributes import RetentionFilterCreateAttributes
10-
from datadog_api_client.v2.model.retention_filter_type import RetentionFilterType
9+
from datadog_api_client.v2.model.retention_filter_all_type import RetentionFilterAllType
10+
from datadog_api_client.v2.model.retention_filter_update_attributes import RetentionFilterUpdateAttributes
1111
from datadog_api_client.v2.model.retention_filter_update_data import RetentionFilterUpdateData
1212
from datadog_api_client.v2.model.retention_filter_update_request import RetentionFilterUpdateRequest
1313
from datadog_api_client.v2.model.spans_filter_create import SpansFilterCreate
@@ -17,14 +17,14 @@
1717

1818
body = RetentionFilterUpdateRequest(
1919
data=RetentionFilterUpdateData(
20-
attributes=RetentionFilterCreateAttributes(
20+
attributes=RetentionFilterUpdateAttributes(
2121
name="test",
2222
rate=0.9,
2323
filter=SpansFilterCreate(
2424
query="@_top_level:1 test:service-demo",
2525
),
2626
enabled=True,
27-
filter_type=RetentionFilterType.SPANS_SAMPLING_PROCESSOR,
27+
filter_type=RetentionFilterAllType.SPANS_SAMPLING_PROCESSOR,
2828
),
2929
id="test-id",
3030
type=ApmRetentionFilterType.apm_retention_filter,

src/datadog_api_client/v2/api/apm_retention_filters_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ def create_apm_retention_filter(
161161
Create a retention filter to index spans in your organization.
162162
Returns the retention filter definition when the request is successful.
163163
164+
Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be created.
165+
164166
:param body: The definition of the new retention filter.
165167
:type body: RetentionFilterCreateRequest
166168
:rtype: RetentionFilterResponse
@@ -178,6 +180,8 @@ def delete_apm_retention_filter(
178180
179181
Delete a specific retention filter from your organization.
180182
183+
Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be deleted.
184+
181185
:param filter_id: The ID of the retention filter.
182186
:type filter_id: str
183187
:rtype: None
@@ -242,6 +246,8 @@ def update_apm_retention_filter(
242246
243247
Update a retention filter from your organization.
244248
249+
Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor) cannot be renamed or removed.
250+
245251
:param filter_id: The ID of the retention filter.
246252
:type filter_id: str
247253
:param body: The updated definition of the retention filter.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
from __future__ import annotations
5+
6+
from typing import TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
)
12+
13+
14+
if TYPE_CHECKING:
15+
from datadog_api_client.v2.model.spans_filter_create import SpansFilterCreate
16+
from datadog_api_client.v2.model.retention_filter_all_type import RetentionFilterAllType
17+
18+
19+
class RetentionFilterUpdateAttributes(ModelNormal):
20+
@cached_property
21+
def openapi_types(_):
22+
from datadog_api_client.v2.model.spans_filter_create import SpansFilterCreate
23+
from datadog_api_client.v2.model.retention_filter_all_type import RetentionFilterAllType
24+
25+
return {
26+
"enabled": (bool,),
27+
"filter": (SpansFilterCreate,),
28+
"filter_type": (RetentionFilterAllType,),
29+
"name": (str,),
30+
"rate": (float,),
31+
}
32+
33+
attribute_map = {
34+
"enabled": "enabled",
35+
"filter": "filter",
36+
"filter_type": "filter_type",
37+
"name": "name",
38+
"rate": "rate",
39+
}
40+
41+
def __init__(
42+
self_,
43+
enabled: bool,
44+
filter: SpansFilterCreate,
45+
filter_type: RetentionFilterAllType,
46+
name: str,
47+
rate: float,
48+
**kwargs,
49+
):
50+
"""
51+
The object describing the configuration of the retention filter to create/update.
52+
53+
:param enabled: Enable/Disable the retention filter.
54+
:type enabled: bool
55+
56+
:param filter: The spans filter. Spans matching this filter will be indexed and stored.
57+
:type filter: SpansFilterCreate
58+
59+
:param filter_type: The type of retention filter.
60+
:type filter_type: RetentionFilterAllType
61+
62+
:param name: The name of the retention filter.
63+
:type name: str
64+
65+
:param rate: Sample rate to apply to spans going through this retention filter,
66+
a value of 1.0 keeps all spans matching the query.
67+
:type rate: float
68+
"""
69+
super().__init__(kwargs)
70+
71+
self_.enabled = enabled
72+
self_.filter = filter
73+
self_.filter_type = filter_type
74+
self_.name = name
75+
self_.rate = rate

src/datadog_api_client/v2/model/retention_filter_update_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313

1414
if TYPE_CHECKING:
15-
from datadog_api_client.v2.model.retention_filter_create_attributes import RetentionFilterCreateAttributes
15+
from datadog_api_client.v2.model.retention_filter_update_attributes import RetentionFilterUpdateAttributes
1616
from datadog_api_client.v2.model.apm_retention_filter_type import ApmRetentionFilterType
1717

1818

1919
class RetentionFilterUpdateData(ModelNormal):
2020
@cached_property
2121
def openapi_types(_):
22-
from datadog_api_client.v2.model.retention_filter_create_attributes import RetentionFilterCreateAttributes
22+
from datadog_api_client.v2.model.retention_filter_update_attributes import RetentionFilterUpdateAttributes
2323
from datadog_api_client.v2.model.apm_retention_filter_type import ApmRetentionFilterType
2424

2525
return {
26-
"attributes": (RetentionFilterCreateAttributes,),
26+
"attributes": (RetentionFilterUpdateAttributes,),
2727
"id": (str,),
2828
"type": (ApmRetentionFilterType,),
2929
}
@@ -34,12 +34,12 @@ def openapi_types(_):
3434
"type": "type",
3535
}
3636

37-
def __init__(self_, attributes: RetentionFilterCreateAttributes, id: str, type: ApmRetentionFilterType, **kwargs):
37+
def __init__(self_, attributes: RetentionFilterUpdateAttributes, id: str, type: ApmRetentionFilterType, **kwargs):
3838
"""
3939
The body of the retention filter to be updated.
4040
4141
:param attributes: The object describing the configuration of the retention filter to create/update.
42-
:type attributes: RetentionFilterCreateAttributes
42+
:type attributes: RetentionFilterUpdateAttributes
4343
4444
:param id: The ID of the retention filter.
4545
:type id: str

src/datadog_api_client/v2/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@
12221222
from datadog_api_client.v2.model.retention_filter_create_request import RetentionFilterCreateRequest
12231223
from datadog_api_client.v2.model.retention_filter_response import RetentionFilterResponse
12241224
from datadog_api_client.v2.model.retention_filter_type import RetentionFilterType
1225+
from datadog_api_client.v2.model.retention_filter_update_attributes import RetentionFilterUpdateAttributes
12251226
from datadog_api_client.v2.model.retention_filter_update_data import RetentionFilterUpdateData
12261227
from datadog_api_client.v2.model.retention_filter_update_request import RetentionFilterUpdateRequest
12271228
from datadog_api_client.v2.model.retention_filter_without_attributes import RetentionFilterWithoutAttributes
@@ -2832,6 +2833,7 @@
28322833
"RetentionFilterCreateRequest",
28332834
"RetentionFilterResponse",
28342835
"RetentionFilterType",
2836+
"RetentionFilterUpdateAttributes",
28352837
"RetentionFilterUpdateData",
28362838
"RetentionFilterUpdateRequest",
28372839
"RetentionFilterWithoutAttributes",
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,22 @@
1+
interactions:
2+
- request:
3+
body: '{"data":{"attributes":{"enabled":true,"filter":{"query":"@http.status_code:200
4+
service:my-service"},"filter_type":"spans-errors-sampling-processor","name":"my
5+
retention filter","rate":1},"type":"apm_retention_filter"}}'
6+
headers:
7+
accept:
8+
- application/json
9+
content-type:
10+
- application/json
11+
method: POST
12+
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters
13+
response:
14+
body:
15+
string: '{"errors":["Field ''filter_type'' is invalid, expected value is ''spans-sampling-processor''"]}'
16+
headers:
17+
content-type:
18+
- application/json
19+
status:
20+
code: 400
21+
message: Bad Request
22+
version: 1

0 commit comments

Comments
 (0)