Skip to content

Commit 6d2a7be

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

File tree

9 files changed

+342
-17
lines changed

9 files changed

+342
-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:45:03.769689",
8-
"spec_repo_commit": "3fb610b5"
7+
"regenerated": "2024-04-11 15:35:22.269841",
8+
"spec_repo_commit": "8ffb168c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-04-10 19:45:03.787823",
13-
"spec_repo_commit": "3fb610b5"
12+
"regenerated": "2024-04-11 15:35:22.287485",
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'

api/datadogV2/api_apm_retention_filters.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type APMRetentionFiltersApi datadog.Service
1919
// CreateApmRetentionFilter Create a retention filter.
2020
// Create a retention filter to index spans in your organization.
2121
// Returns the retention filter definition when the request is successful.
22+
//
23+
// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be created.
2224
func (a *APMRetentionFiltersApi) CreateApmRetentionFilter(ctx _context.Context, body RetentionFilterCreateRequest) (RetentionFilterResponse, *_nethttp.Response, error) {
2325
var (
2426
localVarHTTPMethod = _nethttp.MethodPost
@@ -92,6 +94,8 @@ func (a *APMRetentionFiltersApi) CreateApmRetentionFilter(ctx _context.Context,
9294

9395
// DeleteApmRetentionFilter Delete a retention filter.
9496
// Delete a specific retention filter from your organization.
97+
//
98+
// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be deleted.
9599
func (a *APMRetentionFiltersApi) DeleteApmRetentionFilter(ctx _context.Context, filterId string) (*_nethttp.Response, error) {
96100
var (
97101
localVarHTTPMethod = _nethttp.MethodDelete
@@ -357,6 +361,8 @@ func (a *APMRetentionFiltersApi) ReorderApmRetentionFilters(ctx _context.Context
357361

358362
// UpdateApmRetentionFilter Update a retention filter.
359363
// Update a retention filter from your organization.
364+
//
365+
// Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor) cannot be renamed or removed.
360366
func (a *APMRetentionFiltersApi) UpdateApmRetentionFilter(ctx _context.Context, filterId string, body RetentionFilterUpdateRequest) (RetentionFilterResponse, *_nethttp.Response, error) {
361367
var (
362368
localVarHTTPMethod = _nethttp.MethodPut
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
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+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// RetentionFilterUpdateAttributes The object describing the configuration of the retention filter to create/update.
14+
type RetentionFilterUpdateAttributes struct {
15+
// Enable/Disable the retention filter.
16+
Enabled bool `json:"enabled"`
17+
// The spans filter. Spans matching this filter will be indexed and stored.
18+
Filter SpansFilterCreate `json:"filter"`
19+
// The type of retention filter.
20+
FilterType RetentionFilterAllType `json:"filter_type"`
21+
// The name of the retention filter.
22+
Name string `json:"name"`
23+
// Sample rate to apply to spans going through this retention filter,
24+
// a value of 1.0 keeps all spans matching the query.
25+
Rate float64 `json:"rate"`
26+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
27+
UnparsedObject map[string]interface{} `json:"-"`
28+
AdditionalProperties map[string]interface{}
29+
}
30+
31+
// NewRetentionFilterUpdateAttributes instantiates a new RetentionFilterUpdateAttributes object.
32+
// This constructor will assign default values to properties that have it defined,
33+
// and makes sure properties required by API are set, but the set of arguments
34+
// will change when the set of required properties is changed.
35+
func NewRetentionFilterUpdateAttributes(enabled bool, filter SpansFilterCreate, filterType RetentionFilterAllType, name string, rate float64) *RetentionFilterUpdateAttributes {
36+
this := RetentionFilterUpdateAttributes{}
37+
this.Enabled = enabled
38+
this.Filter = filter
39+
this.FilterType = filterType
40+
this.Name = name
41+
this.Rate = rate
42+
return &this
43+
}
44+
45+
// NewRetentionFilterUpdateAttributesWithDefaults instantiates a new RetentionFilterUpdateAttributes object.
46+
// This constructor will only assign default values to properties that have it defined,
47+
// but it doesn't guarantee that properties required by API are set.
48+
func NewRetentionFilterUpdateAttributesWithDefaults() *RetentionFilterUpdateAttributes {
49+
this := RetentionFilterUpdateAttributes{}
50+
var filterType RetentionFilterAllType = RETENTIONFILTERALLTYPE_SPANS_SAMPLING_PROCESSOR
51+
this.FilterType = filterType
52+
return &this
53+
}
54+
55+
// GetEnabled returns the Enabled field value.
56+
func (o *RetentionFilterUpdateAttributes) GetEnabled() bool {
57+
if o == nil {
58+
var ret bool
59+
return ret
60+
}
61+
return o.Enabled
62+
}
63+
64+
// GetEnabledOk returns a tuple with the Enabled field value
65+
// and a boolean to check if the value has been set.
66+
func (o *RetentionFilterUpdateAttributes) GetEnabledOk() (*bool, bool) {
67+
if o == nil {
68+
return nil, false
69+
}
70+
return &o.Enabled, true
71+
}
72+
73+
// SetEnabled sets field value.
74+
func (o *RetentionFilterUpdateAttributes) SetEnabled(v bool) {
75+
o.Enabled = v
76+
}
77+
78+
// GetFilter returns the Filter field value.
79+
func (o *RetentionFilterUpdateAttributes) GetFilter() SpansFilterCreate {
80+
if o == nil {
81+
var ret SpansFilterCreate
82+
return ret
83+
}
84+
return o.Filter
85+
}
86+
87+
// GetFilterOk returns a tuple with the Filter field value
88+
// and a boolean to check if the value has been set.
89+
func (o *RetentionFilterUpdateAttributes) GetFilterOk() (*SpansFilterCreate, bool) {
90+
if o == nil {
91+
return nil, false
92+
}
93+
return &o.Filter, true
94+
}
95+
96+
// SetFilter sets field value.
97+
func (o *RetentionFilterUpdateAttributes) SetFilter(v SpansFilterCreate) {
98+
o.Filter = v
99+
}
100+
101+
// GetFilterType returns the FilterType field value.
102+
func (o *RetentionFilterUpdateAttributes) GetFilterType() RetentionFilterAllType {
103+
if o == nil {
104+
var ret RetentionFilterAllType
105+
return ret
106+
}
107+
return o.FilterType
108+
}
109+
110+
// GetFilterTypeOk returns a tuple with the FilterType field value
111+
// and a boolean to check if the value has been set.
112+
func (o *RetentionFilterUpdateAttributes) GetFilterTypeOk() (*RetentionFilterAllType, bool) {
113+
if o == nil {
114+
return nil, false
115+
}
116+
return &o.FilterType, true
117+
}
118+
119+
// SetFilterType sets field value.
120+
func (o *RetentionFilterUpdateAttributes) SetFilterType(v RetentionFilterAllType) {
121+
o.FilterType = v
122+
}
123+
124+
// GetName returns the Name field value.
125+
func (o *RetentionFilterUpdateAttributes) GetName() string {
126+
if o == nil {
127+
var ret string
128+
return ret
129+
}
130+
return o.Name
131+
}
132+
133+
// GetNameOk returns a tuple with the Name field value
134+
// and a boolean to check if the value has been set.
135+
func (o *RetentionFilterUpdateAttributes) GetNameOk() (*string, bool) {
136+
if o == nil {
137+
return nil, false
138+
}
139+
return &o.Name, true
140+
}
141+
142+
// SetName sets field value.
143+
func (o *RetentionFilterUpdateAttributes) SetName(v string) {
144+
o.Name = v
145+
}
146+
147+
// GetRate returns the Rate field value.
148+
func (o *RetentionFilterUpdateAttributes) GetRate() float64 {
149+
if o == nil {
150+
var ret float64
151+
return ret
152+
}
153+
return o.Rate
154+
}
155+
156+
// GetRateOk returns a tuple with the Rate field value
157+
// and a boolean to check if the value has been set.
158+
func (o *RetentionFilterUpdateAttributes) GetRateOk() (*float64, bool) {
159+
if o == nil {
160+
return nil, false
161+
}
162+
return &o.Rate, true
163+
}
164+
165+
// SetRate sets field value.
166+
func (o *RetentionFilterUpdateAttributes) SetRate(v float64) {
167+
o.Rate = v
168+
}
169+
170+
// MarshalJSON serializes the struct using spec logic.
171+
func (o RetentionFilterUpdateAttributes) MarshalJSON() ([]byte, error) {
172+
toSerialize := map[string]interface{}{}
173+
if o.UnparsedObject != nil {
174+
return datadog.Marshal(o.UnparsedObject)
175+
}
176+
toSerialize["enabled"] = o.Enabled
177+
toSerialize["filter"] = o.Filter
178+
toSerialize["filter_type"] = o.FilterType
179+
toSerialize["name"] = o.Name
180+
toSerialize["rate"] = o.Rate
181+
182+
for key, value := range o.AdditionalProperties {
183+
toSerialize[key] = value
184+
}
185+
return datadog.Marshal(toSerialize)
186+
}
187+
188+
// UnmarshalJSON deserializes the given payload.
189+
func (o *RetentionFilterUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) {
190+
all := struct {
191+
Enabled *bool `json:"enabled"`
192+
Filter *SpansFilterCreate `json:"filter"`
193+
FilterType *RetentionFilterAllType `json:"filter_type"`
194+
Name *string `json:"name"`
195+
Rate *float64 `json:"rate"`
196+
}{}
197+
if err = datadog.Unmarshal(bytes, &all); err != nil {
198+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
199+
}
200+
if all.Enabled == nil {
201+
return fmt.Errorf("required field enabled missing")
202+
}
203+
if all.Filter == nil {
204+
return fmt.Errorf("required field filter missing")
205+
}
206+
if all.FilterType == nil {
207+
return fmt.Errorf("required field filter_type missing")
208+
}
209+
if all.Name == nil {
210+
return fmt.Errorf("required field name missing")
211+
}
212+
if all.Rate == nil {
213+
return fmt.Errorf("required field rate missing")
214+
}
215+
additionalProperties := make(map[string]interface{})
216+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
217+
datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "filter", "filter_type", "name", "rate"})
218+
} else {
219+
return err
220+
}
221+
222+
hasInvalidField := false
223+
o.Enabled = *all.Enabled
224+
if all.Filter.UnparsedObject != nil && o.UnparsedObject == nil {
225+
hasInvalidField = true
226+
}
227+
o.Filter = *all.Filter
228+
if !all.FilterType.IsValid() {
229+
hasInvalidField = true
230+
} else {
231+
o.FilterType = *all.FilterType
232+
}
233+
o.Name = *all.Name
234+
o.Rate = *all.Rate
235+
236+
if len(additionalProperties) > 0 {
237+
o.AdditionalProperties = additionalProperties
238+
}
239+
240+
if hasInvalidField {
241+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
242+
}
243+
244+
return nil
245+
}

0 commit comments

Comments
 (0)