Skip to content

Commit

Permalink
Update retention filters public API (#2466)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Apr 11, 2024
1 parent a24a0bb commit 6d2a7be
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-04-10 19:45:03.769689",
"spec_repo_commit": "3fb610b5"
"regenerated": "2024-04-11 15:35:22.269841",
"spec_repo_commit": "8ffb168c"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-04-10 19:45:03.787823",
"spec_repo_commit": "3fb610b5"
"regenerated": "2024-04-11 15:35:22.287485",
"spec_repo_commit": "8ffb168c"
}
}
}
52 changes: 48 additions & 4 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16072,6 +16072,7 @@ components:
- spans-sampling-processor
- spans-errors-sampling-processor
- spans-appsec-sampling-processor
example: spans-sampling-processor
type: string
x-enum-varnames:
- SPANS_SAMPLING_PROCESSOR
Expand Down Expand Up @@ -16188,11 +16189,42 @@ components:
type: string
x-enum-varnames:
- SPANS_SAMPLING_PROCESSOR
RetentionFilterUpdateAttributes:
description: The object describing the configuration of the retention filter
to create/update.
properties:
enabled:
description: Enable/Disable the retention filter.
example: true
type: boolean
filter:
$ref: '#/components/schemas/SpansFilterCreate'
filter_type:
$ref: '#/components/schemas/RetentionFilterAllType'
name:
description: The name of the retention filter.
example: my retention filter
type: string
rate:
description: 'Sample rate to apply to spans going through this retention
filter,

a value of 1.0 keeps all spans matching the query.'
example: 1.0
format: double
type: number
required:
- name
- filter
- enabled
- filter_type
- rate
type: object
RetentionFilterUpdateData:
description: The body of the retention filter to be updated.
properties:
attributes:
$ref: '#/components/schemas/RetentionFilterCreateAttributes'
$ref: '#/components/schemas/RetentionFilterUpdateAttributes'
id:
description: The ID of the retention filter.
example: retention-filter-id
Expand Down Expand Up @@ -23271,7 +23303,11 @@ paths:
post:
description: 'Create a retention filter to index spans in your organization.

Returns the retention filter definition when the request is successful.'
Returns the retention filter definition when the request is successful.


Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor
cannot be created.'
operationId: CreateApmRetentionFilter
requestBody:
content:
Expand Down Expand Up @@ -23325,7 +23361,11 @@ paths:
x-codegen-request-body-name: body
/api/v2/apm/config/retention-filters/{filter_id}:
delete:
description: Delete a specific retention filter from your organization.
description: 'Delete a specific retention filter from your organization.


Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor
cannot be deleted.'
operationId: DeleteApmRetentionFilter
parameters:
- $ref: '#/components/parameters/RetentionFilterIdParam'
Expand Down Expand Up @@ -23363,7 +23403,11 @@ paths:
tags:
- APM Retention Filters
put:
description: Update a retention filter from your organization.
description: 'Update a retention filter from your organization.


Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor)
cannot be renamed or removed.'
operationId: UpdateApmRetentionFilter
parameters:
- $ref: '#/components/parameters/RetentionFilterIdParam'
Expand Down
6 changes: 6 additions & 0 deletions api/datadogV2/api_apm_retention_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type APMRetentionFiltersApi datadog.Service
// CreateApmRetentionFilter Create a retention filter.
// Create a retention filter to index spans in your organization.
// Returns the retention filter definition when the request is successful.
//
// Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be created.
func (a *APMRetentionFiltersApi) CreateApmRetentionFilter(ctx _context.Context, body RetentionFilterCreateRequest) (RetentionFilterResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
Expand Down Expand Up @@ -92,6 +94,8 @@ func (a *APMRetentionFiltersApi) CreateApmRetentionFilter(ctx _context.Context,

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

// UpdateApmRetentionFilter Update a retention filter.
// Update a retention filter from your organization.
//
// Default filters (filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor) cannot be renamed or removed.
func (a *APMRetentionFiltersApi) UpdateApmRetentionFilter(ctx _context.Context, filterId string, body RetentionFilterUpdateRequest) (RetentionFilterResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPut
Expand Down
245 changes: 245 additions & 0 deletions api/datadogV2/model_retention_filter_update_attributes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

package datadogV2

import (
"fmt"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// RetentionFilterUpdateAttributes The object describing the configuration of the retention filter to create/update.
type RetentionFilterUpdateAttributes struct {
// Enable/Disable the retention filter.
Enabled bool `json:"enabled"`
// The spans filter. Spans matching this filter will be indexed and stored.
Filter SpansFilterCreate `json:"filter"`
// The type of retention filter.
FilterType RetentionFilterAllType `json:"filter_type"`
// The name of the retention filter.
Name string `json:"name"`
// Sample rate to apply to spans going through this retention filter,
// a value of 1.0 keeps all spans matching the query.
Rate float64 `json:"rate"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{}
}

// NewRetentionFilterUpdateAttributes instantiates a new RetentionFilterUpdateAttributes object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewRetentionFilterUpdateAttributes(enabled bool, filter SpansFilterCreate, filterType RetentionFilterAllType, name string, rate float64) *RetentionFilterUpdateAttributes {
this := RetentionFilterUpdateAttributes{}
this.Enabled = enabled
this.Filter = filter
this.FilterType = filterType
this.Name = name
this.Rate = rate
return &this
}

// NewRetentionFilterUpdateAttributesWithDefaults instantiates a new RetentionFilterUpdateAttributes object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewRetentionFilterUpdateAttributesWithDefaults() *RetentionFilterUpdateAttributes {
this := RetentionFilterUpdateAttributes{}
var filterType RetentionFilterAllType = RETENTIONFILTERALLTYPE_SPANS_SAMPLING_PROCESSOR
this.FilterType = filterType
return &this
}

// GetEnabled returns the Enabled field value.
func (o *RetentionFilterUpdateAttributes) GetEnabled() bool {
if o == nil {
var ret bool
return ret
}
return o.Enabled
}

// GetEnabledOk returns a tuple with the Enabled field value
// and a boolean to check if the value has been set.
func (o *RetentionFilterUpdateAttributes) GetEnabledOk() (*bool, bool) {
if o == nil {
return nil, false
}
return &o.Enabled, true
}

// SetEnabled sets field value.
func (o *RetentionFilterUpdateAttributes) SetEnabled(v bool) {
o.Enabled = v
}

// GetFilter returns the Filter field value.
func (o *RetentionFilterUpdateAttributes) GetFilter() SpansFilterCreate {
if o == nil {
var ret SpansFilterCreate
return ret
}
return o.Filter
}

// GetFilterOk returns a tuple with the Filter field value
// and a boolean to check if the value has been set.
func (o *RetentionFilterUpdateAttributes) GetFilterOk() (*SpansFilterCreate, bool) {
if o == nil {
return nil, false
}
return &o.Filter, true
}

// SetFilter sets field value.
func (o *RetentionFilterUpdateAttributes) SetFilter(v SpansFilterCreate) {
o.Filter = v
}

// GetFilterType returns the FilterType field value.
func (o *RetentionFilterUpdateAttributes) GetFilterType() RetentionFilterAllType {
if o == nil {
var ret RetentionFilterAllType
return ret
}
return o.FilterType
}

// GetFilterTypeOk returns a tuple with the FilterType field value
// and a boolean to check if the value has been set.
func (o *RetentionFilterUpdateAttributes) GetFilterTypeOk() (*RetentionFilterAllType, bool) {
if o == nil {
return nil, false
}
return &o.FilterType, true
}

// SetFilterType sets field value.
func (o *RetentionFilterUpdateAttributes) SetFilterType(v RetentionFilterAllType) {
o.FilterType = v
}

// GetName returns the Name field value.
func (o *RetentionFilterUpdateAttributes) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}

// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *RetentionFilterUpdateAttributes) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}

// SetName sets field value.
func (o *RetentionFilterUpdateAttributes) SetName(v string) {
o.Name = v
}

// GetRate returns the Rate field value.
func (o *RetentionFilterUpdateAttributes) GetRate() float64 {
if o == nil {
var ret float64
return ret
}
return o.Rate
}

// GetRateOk returns a tuple with the Rate field value
// and a boolean to check if the value has been set.
func (o *RetentionFilterUpdateAttributes) GetRateOk() (*float64, bool) {
if o == nil {
return nil, false
}
return &o.Rate, true
}

// SetRate sets field value.
func (o *RetentionFilterUpdateAttributes) SetRate(v float64) {
o.Rate = v
}

// MarshalJSON serializes the struct using spec logic.
func (o RetentionFilterUpdateAttributes) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["enabled"] = o.Enabled
toSerialize["filter"] = o.Filter
toSerialize["filter_type"] = o.FilterType
toSerialize["name"] = o.Name
toSerialize["rate"] = o.Rate

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *RetentionFilterUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Enabled *bool `json:"enabled"`
Filter *SpansFilterCreate `json:"filter"`
FilterType *RetentionFilterAllType `json:"filter_type"`
Name *string `json:"name"`
Rate *float64 `json:"rate"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Enabled == nil {
return fmt.Errorf("required field enabled missing")
}
if all.Filter == nil {
return fmt.Errorf("required field filter missing")
}
if all.FilterType == nil {
return fmt.Errorf("required field filter_type missing")
}
if all.Name == nil {
return fmt.Errorf("required field name missing")
}
if all.Rate == nil {
return fmt.Errorf("required field rate missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "filter", "filter_type", "name", "rate"})
} else {
return err
}

hasInvalidField := false
o.Enabled = *all.Enabled
if all.Filter.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
o.Filter = *all.Filter
if !all.FilterType.IsValid() {
hasInvalidField = true
} else {
o.FilterType = *all.FilterType
}
o.Name = *all.Name
o.Rate = *all.Rate

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

if hasInvalidField {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}

return nil
}
Loading

0 comments on commit 6d2a7be

Please sign in to comment.