Skip to content

Commit 8931837

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

File tree

10 files changed

+279
-11
lines changed

10 files changed

+279
-11
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:57.613520",
8-
"spec_repo_commit": "3fb610b5"
7+
"regenerated": "2024-04-11 15:35:34.930029",
8+
"spec_repo_commit": "8ffb168c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-04-10 19:44:57.631078",
13-
"spec_repo_commit": "3fb610b5"
12+
"regenerated": "2024-04-11 15:35:34.947335",
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'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024-04-10T12:31:19.300Z

cassettes/features/v2/apm_retention_filters/Create-a-default-retention-filter-returns-Bad-Request-response.yml

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
body = DatadogAPIClient::V2::RetentionFilterUpdateRequest.new({
1010
data: DatadogAPIClient::V2::RetentionFilterUpdateData.new({
11-
attributes: DatadogAPIClient::V2::RetentionFilterCreateAttributes.new({
11+
attributes: DatadogAPIClient::V2::RetentionFilterUpdateAttributes.new({
1212
name: "test",
1313
rate: 0.9,
1414
filter: DatadogAPIClient::V2::SpansFilterCreate.new({
1515
query: "@_top_level:1 test:service-demo",
1616
}),
1717
enabled: true,
18-
filter_type: DatadogAPIClient::V2::RetentionFilterType::SPANS_SAMPLING_PROCESSOR,
18+
filter_type: DatadogAPIClient::V2::RetentionFilterAllType::SPANS_SAMPLING_PROCESSOR,
1919
}),
2020
id: "test-id",
2121
type: DatadogAPIClient::V2::ApmRetentionFilterType::APM_RETENTION_FILTER,

features/v2/apm_retention_filters.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Feature: APM Retention Filters
1212
And a valid "appKeyAuth" key in the system
1313
And an instance of "APMRetentionFilters" API
1414

15+
@team:DataDog/apm-trace-intake
16+
Scenario: Create a default retention filter returns "Bad Request" response
17+
Given new "CreateApmRetentionFilter" request
18+
And body with value {"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.0}, "type": "apm_retention_filter"}}
19+
When the request is sent
20+
Then the response status is 400 Bad Request
21+
1522
@team:DataDog/apm-trace-intake
1623
Scenario: Create a retention filter returns "Bad Request" response
1724
Given new "CreateApmRetentionFilter" request

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,7 @@ def overrides
18251825
"v2.retention_filter_response" => "RetentionFilterResponse",
18261826
"v2.retention_filters_response" => "RetentionFiltersResponse",
18271827
"v2.retention_filter_type" => "RetentionFilterType",
1828+
"v2.retention_filter_update_attributes" => "RetentionFilterUpdateAttributes",
18281829
"v2.retention_filter_update_data" => "RetentionFilterUpdateData",
18291830
"v2.retention_filter_update_request" => "RetentionFilterUpdateRequest",
18301831
"v2.retention_filter_without_attributes" => "RetentionFilterWithoutAttributes",

lib/datadog_api_client/v2/api/apm_retention_filters_api.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def create_apm_retention_filter(body, opts = {})
3636
# Create a retention filter to index spans in your organization.
3737
# Returns the retention filter definition when the request is successful.
3838
#
39+
# Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be created.
40+
#
3941
# @param body [RetentionFilterCreateRequest] The definition of the new retention filter.
4042
# @param opts [Hash] the optional parameters
4143
# @return [Array<(RetentionFilterResponse, Integer, Hash)>] RetentionFilterResponse data, response status code and response headers
@@ -103,6 +105,8 @@ def delete_apm_retention_filter(filter_id, opts = {})
103105
#
104106
# Delete a specific retention filter from your organization.
105107
#
108+
# Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be deleted.
109+
#
106110
# @param filter_id [String] The ID of the retention filter.
107111
# @param opts [Hash] the optional parameters
108112
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
@@ -360,6 +364,8 @@ def update_apm_retention_filter(filter_id, body, opts = {})
360364
#
361365
# Update a retention filter from your organization.
362366
#
367+
# Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor) cannot be renamed or removed.
368+
#
363369
# @param filter_id [String] The ID of the retention filter.
364370
# @param body [RetentionFilterUpdateRequest] The updated definition of the retention filter.
365371
# @param opts [Hash] the optional parameters
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V2
20+
# The object describing the configuration of the retention filter to create/update.
21+
class RetentionFilterUpdateAttributes
22+
include BaseGenericModel
23+
24+
# Enable/Disable the retention filter.
25+
attr_reader :enabled
26+
27+
# The spans filter. Spans matching this filter will be indexed and stored.
28+
attr_reader :filter
29+
30+
# The type of retention filter.
31+
attr_reader :filter_type
32+
33+
# The name of the retention filter.
34+
attr_reader :name
35+
36+
# Sample rate to apply to spans going through this retention filter,
37+
# a value of 1.0 keeps all spans matching the query.
38+
attr_reader :rate
39+
40+
# Attribute mapping from ruby-style variable name to JSON key.
41+
# @!visibility private
42+
def self.attribute_map
43+
{
44+
:'enabled' => :'enabled',
45+
:'filter' => :'filter',
46+
:'filter_type' => :'filter_type',
47+
:'name' => :'name',
48+
:'rate' => :'rate'
49+
}
50+
end
51+
52+
# Attribute type mapping.
53+
# @!visibility private
54+
def self.openapi_types
55+
{
56+
:'enabled' => :'Boolean',
57+
:'filter' => :'SpansFilterCreate',
58+
:'filter_type' => :'RetentionFilterAllType',
59+
:'name' => :'String',
60+
:'rate' => :'Float'
61+
}
62+
end
63+
64+
# Initializes the object
65+
# @param attributes [Hash] Model attributes in the form of hash
66+
# @!visibility private
67+
def initialize(attributes = {})
68+
if (!attributes.is_a?(Hash))
69+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::RetentionFilterUpdateAttributes` initialize method"
70+
end
71+
72+
# check to see if the attribute exists and convert string to symbol for hash key
73+
attributes = attributes.each_with_object({}) { |(k, v), h|
74+
if (!self.class.attribute_map.key?(k.to_sym))
75+
fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::RetentionFilterUpdateAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76+
end
77+
h[k.to_sym] = v
78+
}
79+
80+
if attributes.key?(:'enabled')
81+
self.enabled = attributes[:'enabled']
82+
end
83+
84+
if attributes.key?(:'filter')
85+
self.filter = attributes[:'filter']
86+
end
87+
88+
if attributes.key?(:'filter_type')
89+
self.filter_type = attributes[:'filter_type']
90+
end
91+
92+
if attributes.key?(:'name')
93+
self.name = attributes[:'name']
94+
end
95+
96+
if attributes.key?(:'rate')
97+
self.rate = attributes[:'rate']
98+
end
99+
end
100+
101+
# Check to see if the all the properties in the model are valid
102+
# @return true if the model is valid
103+
# @!visibility private
104+
def valid?
105+
return false if @enabled.nil?
106+
return false if @filter.nil?
107+
return false if @filter_type.nil?
108+
return false if @name.nil?
109+
return false if @rate.nil?
110+
true
111+
end
112+
113+
# Custom attribute writer method with validation
114+
# @param enabled [Object] Object to be assigned
115+
# @!visibility private
116+
def enabled=(enabled)
117+
if enabled.nil?
118+
fail ArgumentError, 'invalid value for "enabled", enabled cannot be nil.'
119+
end
120+
@enabled = enabled
121+
end
122+
123+
# Custom attribute writer method with validation
124+
# @param filter [Object] Object to be assigned
125+
# @!visibility private
126+
def filter=(filter)
127+
if filter.nil?
128+
fail ArgumentError, 'invalid value for "filter", filter cannot be nil.'
129+
end
130+
@filter = filter
131+
end
132+
133+
# Custom attribute writer method with validation
134+
# @param filter_type [Object] Object to be assigned
135+
# @!visibility private
136+
def filter_type=(filter_type)
137+
if filter_type.nil?
138+
fail ArgumentError, 'invalid value for "filter_type", filter_type cannot be nil.'
139+
end
140+
@filter_type = filter_type
141+
end
142+
143+
# Custom attribute writer method with validation
144+
# @param name [Object] Object to be assigned
145+
# @!visibility private
146+
def name=(name)
147+
if name.nil?
148+
fail ArgumentError, 'invalid value for "name", name cannot be nil.'
149+
end
150+
@name = name
151+
end
152+
153+
# Custom attribute writer method with validation
154+
# @param rate [Object] Object to be assigned
155+
# @!visibility private
156+
def rate=(rate)
157+
if rate.nil?
158+
fail ArgumentError, 'invalid value for "rate", rate cannot be nil.'
159+
end
160+
@rate = rate
161+
end
162+
163+
# Checks equality by comparing each attribute.
164+
# @param o [Object] Object to be compared
165+
# @!visibility private
166+
def ==(o)
167+
return true if self.equal?(o)
168+
self.class == o.class &&
169+
enabled == o.enabled &&
170+
filter == o.filter &&
171+
filter_type == o.filter_type &&
172+
name == o.name &&
173+
rate == o.rate
174+
end
175+
176+
# Calculates hash code according to all attributes.
177+
# @return [Integer] Hash code
178+
# @!visibility private
179+
def hash
180+
[enabled, filter, filter_type, name, rate].hash
181+
end
182+
end
183+
end

lib/datadog_api_client/v2/models/retention_filter_update_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def self.attribute_map
4444
# @!visibility private
4545
def self.openapi_types
4646
{
47-
:'attributes' => :'RetentionFilterCreateAttributes',
47+
:'attributes' => :'RetentionFilterUpdateAttributes',
4848
:'id' => :'String',
4949
:'type' => :'ApmRetentionFilterType'
5050
}

0 commit comments

Comments
 (0)