Skip to content

Commit 2d4253c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add get APM retention filter endpoint (#1692)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent cca77de commit 2d4253c

10 files changed

+193
-4
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": "2023-09-28 14:17:26.300170",
8-
"spec_repo_commit": "3f45eb23"
7+
"regenerated": "2023-09-28 19:18:56.822567",
8+
"spec_repo_commit": "4b2bab38"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2023-09-28 14:17:26.313410",
13-
"spec_repo_commit": "3f45eb23"
12+
"regenerated": "2023-09-28 19:18:56.909324",
13+
"spec_repo_commit": "4b2bab38"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17987,6 +17987,31 @@ paths:
1798717987
summary: Delete a retention filter
1798817988
tags:
1798917989
- APM Retention Filters
17990+
get:
17991+
description: Get an APM retention filter.
17992+
operationId: GetApmRetentionFilter
17993+
parameters:
17994+
- $ref: '#/components/parameters/RetentionFilterIdParam'
17995+
responses:
17996+
'200':
17997+
content:
17998+
application/json:
17999+
schema:
18000+
$ref: '#/components/schemas/RetentionFilterResponse'
18001+
description: OK
18002+
'403':
18003+
$ref: '#/components/responses/NotAuthorizedResponse'
18004+
'404':
18005+
$ref: '#/components/responses/NotFoundResponse'
18006+
'429':
18007+
$ref: '#/components/responses/TooManyRequestsResponse'
18008+
security:
18009+
- apiKeyAuth: []
18010+
appKeyAuth: []
18011+
- AuthZ: []
18012+
summary: Get a given APM retention filter
18013+
tags:
18014+
- APM Retention Filters
1799018015
put:
1799118016
description: Update a retention filter from your organization.
1799218017
operationId: UpdateApmRetentionFilter
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Get a given APM retention filter returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi
8+
9+
# there is a valid "retention_filter" in the system
10+
RETENTION_FILTER_DATA_ID = environ["RETENTION_FILTER_DATA_ID"]
11+
12+
configuration = Configuration()
13+
with ApiClient(configuration) as api_client:
14+
api_instance = APMRetentionFiltersApi(api_client)
15+
response = api_instance.get_apm_retention_filter(
16+
filter_id=RETENTION_FILTER_DATA_ID,
17+
)
18+
19+
print(response)

src/datadog_api_client/v2/api/apm_retention_filters_api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ def __init__(self, api_client=None):
6767
api_client=api_client,
6868
)
6969

70+
self._get_apm_retention_filter_endpoint = _Endpoint(
71+
settings={
72+
"response_type": (RetentionFilterResponse,),
73+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
74+
"endpoint_path": "/api/v2/apm/config/retention-filters/{filter_id}",
75+
"operation_id": "get_apm_retention_filter",
76+
"http_method": "GET",
77+
"version": "v2",
78+
},
79+
params_map={
80+
"filter_id": {
81+
"required": True,
82+
"openapi_types": (str,),
83+
"attribute": "filter_id",
84+
"location": "path",
85+
},
86+
},
87+
headers_map={
88+
"accept": ["application/json"],
89+
},
90+
api_client=api_client,
91+
)
92+
7093
self._list_apm_retention_filters_endpoint = _Endpoint(
7194
settings={
7295
"response_type": (RetentionFiltersResponse,),
@@ -164,6 +187,23 @@ def delete_apm_retention_filter(
164187

165188
return self._delete_apm_retention_filter_endpoint.call_with_http_info(**kwargs)
166189

190+
def get_apm_retention_filter(
191+
self,
192+
filter_id: str,
193+
) -> RetentionFilterResponse:
194+
"""Get a given APM retention filter.
195+
196+
Get an APM retention filter.
197+
198+
:param filter_id: The ID of the retention filter.
199+
:type filter_id: str
200+
:rtype: RetentionFilterResponse
201+
"""
202+
kwargs: Dict[str, Any] = {}
203+
kwargs["filter_id"] = filter_id
204+
205+
return self._get_apm_retention_filter_endpoint.call_with_http_info(**kwargs)
206+
167207
def list_apm_retention_filters(
168208
self,
169209
) -> RetentionFiltersResponse:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-09-28T08:19:42.753Z
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
accept:
6+
- application/json
7+
method: GET
8+
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters/REPLACE.ME
9+
response:
10+
body:
11+
string: '{"errors":["retention filter with id: ''REPLACE.ME'' not found"]}'
12+
headers:
13+
content-type:
14+
- application/json
15+
status:
16+
code: 404
17+
message: Not Found
18+
version: 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-09-28T08:19:43.496Z
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
interactions:
2+
- request:
3+
body: '{"data":{"attributes":{"enabled":true,"filter":{"query":"@_top_level:1
4+
test:service-demo"},"filter_type":"spans-sampling-processor","name":"demo retention
5+
filter","rate":0.9},"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: '{"data":{"id":"FaVuDNMERS25j8w4QWTwzg","attributes":{"name":"demo retention
16+
filter","rate":0.9,"enabled":true,"filter_type":"spans-sampling-processor","filter":{"query":"@_top_level:1
17+
test:service-demo"},"editable":true,"modified_by":"[email protected]","modified_at":1695889183,"created_by":"[email protected]","created_at":1695889183},"type":"apm_retention_filter"}}
18+
19+
'
20+
headers:
21+
content-type:
22+
- application/json
23+
status:
24+
code: 200
25+
message: OK
26+
- request:
27+
body: null
28+
headers:
29+
accept:
30+
- application/json
31+
method: GET
32+
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters/FaVuDNMERS25j8w4QWTwzg
33+
response:
34+
body:
35+
string: '{"data":{"id":"FaVuDNMERS25j8w4QWTwzg","attributes":{"name":"demo retention
36+
filter","rate":0.9,"enabled":true,"filter_type":"spans-sampling-processor","filter":{"query":"@_top_level:1
37+
test:service-demo"},"editable":true,"modified_by":"[email protected]","modified_at":1695889183,"created_by":"[email protected]","created_at":1695889183},"type":"apm_retention_filter"}}
38+
39+
'
40+
headers:
41+
content-type:
42+
- application/json
43+
status:
44+
code: 200
45+
message: OK
46+
- request:
47+
body: null
48+
headers:
49+
accept:
50+
- '*/*'
51+
method: DELETE
52+
uri: https://api.datadoghq.com/api/v2/apm/config/retention-filters/FaVuDNMERS25j8w4QWTwzg
53+
response:
54+
body:
55+
string: '{}
56+
57+
'
58+
headers:
59+
content-type:
60+
- application/json
61+
status:
62+
code: 200
63+
message: OK
64+
version: 1

tests/v2/features/apm_retention_filters.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ Feature: APM Retention Filters
4646
When the request is sent
4747
Then the response status is 200 OK
4848

49+
@team:DataDog/apm-trace-intake
50+
Scenario: Get a given APM retention filter returns "Not Found" response
51+
Given new "GetApmRetentionFilter" request
52+
And request contains "filter_id" parameter with value "REPLACE.ME"
53+
When the request is sent
54+
Then the response status is 404 Not Found
55+
56+
@team:DataDog/apm-trace-intake
57+
Scenario: Get a given APM retention filter returns "OK" response
58+
Given there is a valid "retention_filter" in the system
59+
And new "GetApmRetentionFilter" request
60+
And request contains "filter_id" parameter from "retention_filter.data.id"
61+
When the request is sent
62+
Then the response status is 200 OK
63+
4964
@team:DataDog/apm-trace-intake
5065
Scenario: List all APM retention filters returns "OK" response
5166
Given there is a valid "retention_filter" in the system

tests/v2/features/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@
104104
"type": "idempotent"
105105
}
106106
},
107+
"GetApmRetentionFilter": {
108+
"tag": "APM Retention Filters",
109+
"undo": {
110+
"type": "safe"
111+
}
112+
},
107113
"UpdateApmRetentionFilter": {
108114
"tag": "APM Retention Filters",
109115
"undo": {

0 commit comments

Comments
 (0)