From ac173a4c2d9a0e044ac00eb52e3ace46998a83c3 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:19:06 +0000 Subject: [PATCH] Update retention filters public API (#1594) Co-authored-by: ci.datadog-api-spec Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 52 ++++++++++- .../frozen.json | 1 + .../recording.har | 67 +++++++++++++ features/v2/apm_retention_filters.feature | 7 ++ .../apis/APMRetentionFiltersApi.ts | 6 ++ packages/datadog-api-client-v2/index.ts | 1 + .../models/ObjectSerializer.ts | 2 + .../models/RetentionFilterUpdateAttributes.ts | 93 +++++++++++++++++++ .../models/RetentionFilterUpdateData.ts | 6 +- 10 files changed, 232 insertions(+), 11 deletions(-) create mode 100644 cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/frozen.json create mode 100644 cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/recording.har create mode 100644 packages/datadog-api-client-v2/models/RetentionFilterUpdateAttributes.ts diff --git a/.apigentools-info b/.apigentools-info index 13825f0559c..0a6eff3fa2f 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-10 19:44:51.330205", - "spec_repo_commit": "3fb610b5" + "regenerated": "2024-04-11 15:35:24.319441", + "spec_repo_commit": "8ffb168c" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-04-10 19:44:51.348296", - "spec_repo_commit": "3fb610b5" + "regenerated": "2024-04-11 15:35:24.337042", + "spec_repo_commit": "8ffb168c" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 90e25751f7f..5b5588fa263 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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 @@ -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 @@ -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: @@ -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' @@ -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' diff --git a/cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/frozen.json b/cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/frozen.json new file mode 100644 index 00000000000..93bea23041e --- /dev/null +++ b/cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/frozen.json @@ -0,0 +1 @@ +"2024-04-10T12:31:19.300Z" diff --git a/cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/recording.har b/cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/recording.har new file mode 100644 index 00000000000..7b3968e46d5 --- /dev/null +++ b/cassettes/v2/APM-Retention-Filters_3978335078/Create-a-default-retention-filter-returns-Bad-Request-response_652075659/recording.har @@ -0,0 +1,67 @@ +{ + "log": { + "_recordingName": "APM Retention Filters/Create a default retention filter returns \"Bad Request\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "23cb9ef503c91078cfb54a6f43add906", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 218, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 587, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"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},\"type\":\"apm_retention_filter\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/apm/config/retention-filters" + }, + "response": { + "bodySize": 91, + "content": { + "mimeType": "application/json", + "size": 91, + "text": "{\"errors\":[\"Field 'filter_type' is invalid, expected value is 'spans-sampling-processor'\"]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 516, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 400, + "statusText": "Bad Request" + }, + "startedDateTime": "2024-04-10T12:31:19.304Z", + "time": 436 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/features/v2/apm_retention_filters.feature b/features/v2/apm_retention_filters.feature index e88870c76da..e68470157dd 100644 --- a/features/v2/apm_retention_filters.feature +++ b/features/v2/apm_retention_filters.feature @@ -12,6 +12,13 @@ Feature: APM Retention Filters And a valid "appKeyAuth" key in the system And an instance of "APMRetentionFilters" API + @team:DataDog/apm-trace-intake + Scenario: Create a default retention filter returns "Bad Request" response + Given new "CreateApmRetentionFilter" request + 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"}} + When the request is sent + Then the response status is 400 Bad Request + @team:DataDog/apm-trace-intake Scenario: Create a retention filter returns "Bad Request" response Given new "CreateApmRetentionFilter" request diff --git a/packages/datadog-api-client-v2/apis/APMRetentionFiltersApi.ts b/packages/datadog-api-client-v2/apis/APMRetentionFiltersApi.ts index ebf16aa76c1..28cd860d7f7 100644 --- a/packages/datadog-api-client-v2/apis/APMRetentionFiltersApi.ts +++ b/packages/datadog-api-client-v2/apis/APMRetentionFiltersApi.ts @@ -679,6 +679,8 @@ export class APMRetentionFiltersApi { /** * 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. * @param param The request object */ public createApmRetentionFilter( @@ -702,6 +704,8 @@ export class APMRetentionFiltersApi { /** * Delete a specific retention filter from your organization. + * + * Default filters with types spans-errors-sampling-processor and spans-appsec-sampling-processor cannot be deleted. * @param param The request object */ public deleteApmRetentionFilter( @@ -787,6 +791,8 @@ export class APMRetentionFiltersApi { /** * 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. * @param param The request object */ public updateApmRetentionFilter( diff --git a/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index 35c3465717a..8595097cd32 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -1480,6 +1480,7 @@ export { RetentionFilterCreateRequest } from "./models/RetentionFilterCreateRequ export { RetentionFilterResponse } from "./models/RetentionFilterResponse"; export { RetentionFiltersResponse } from "./models/RetentionFiltersResponse"; export { RetentionFilterType } from "./models/RetentionFilterType"; +export { RetentionFilterUpdateAttributes } from "./models/RetentionFilterUpdateAttributes"; export { RetentionFilterUpdateData } from "./models/RetentionFilterUpdateData"; export { RetentionFilterUpdateRequest } from "./models/RetentionFilterUpdateRequest"; export { RetentionFilterWithoutAttributes } from "./models/RetentionFilterWithoutAttributes"; diff --git a/packages/datadog-api-client-v2/models/ObjectSerializer.ts b/packages/datadog-api-client-v2/models/ObjectSerializer.ts index bc75aef6304..72fafc33fa4 100644 --- a/packages/datadog-api-client-v2/models/ObjectSerializer.ts +++ b/packages/datadog-api-client-v2/models/ObjectSerializer.ts @@ -791,6 +791,7 @@ import { RetentionFilterCreateAttributes } from "./RetentionFilterCreateAttribut import { RetentionFilterCreateData } from "./RetentionFilterCreateData"; import { RetentionFilterCreateRequest } from "./RetentionFilterCreateRequest"; import { RetentionFilterResponse } from "./RetentionFilterResponse"; +import { RetentionFilterUpdateAttributes } from "./RetentionFilterUpdateAttributes"; import { RetentionFilterUpdateData } from "./RetentionFilterUpdateData"; import { RetentionFilterUpdateRequest } from "./RetentionFilterUpdateRequest"; import { RetentionFilterWithoutAttributes } from "./RetentionFilterWithoutAttributes"; @@ -2584,6 +2585,7 @@ const typeMap: { [index: string]: any } = { RetentionFilterCreateData: RetentionFilterCreateData, RetentionFilterCreateRequest: RetentionFilterCreateRequest, RetentionFilterResponse: RetentionFilterResponse, + RetentionFilterUpdateAttributes: RetentionFilterUpdateAttributes, RetentionFilterUpdateData: RetentionFilterUpdateData, RetentionFilterUpdateRequest: RetentionFilterUpdateRequest, RetentionFilterWithoutAttributes: RetentionFilterWithoutAttributes, diff --git a/packages/datadog-api-client-v2/models/RetentionFilterUpdateAttributes.ts b/packages/datadog-api-client-v2/models/RetentionFilterUpdateAttributes.ts new file mode 100644 index 00000000000..2a4bcc2e489 --- /dev/null +++ b/packages/datadog-api-client-v2/models/RetentionFilterUpdateAttributes.ts @@ -0,0 +1,93 @@ +/** + * 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 2020-Present Datadog, Inc. + */ +import { RetentionFilterAllType } from "./RetentionFilterAllType"; +import { SpansFilterCreate } from "./SpansFilterCreate"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * The object describing the configuration of the retention filter to create/update. + */ +export class RetentionFilterUpdateAttributes { + /** + * Enable/Disable the retention filter. + */ + "enabled": boolean; + /** + * The spans filter. Spans matching this filter will be indexed and stored. + */ + "filter": SpansFilterCreate; + /** + * The type of retention filter. + */ + "filterType": RetentionFilterAllType; + /** + * The name of the retention filter. + */ + "name": string; + /** + * Sample rate to apply to spans going through this retention filter, + * a value of 1.0 keeps all spans matching the query. + */ + "rate": number; + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + enabled: { + baseName: "enabled", + type: "boolean", + required: true, + }, + filter: { + baseName: "filter", + type: "SpansFilterCreate", + required: true, + }, + filterType: { + baseName: "filter_type", + type: "RetentionFilterAllType", + required: true, + }, + name: { + baseName: "name", + type: "string", + required: true, + }, + rate: { + baseName: "rate", + type: "number", + required: true, + format: "double", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "any", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return RetentionFilterUpdateAttributes.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v2/models/RetentionFilterUpdateData.ts b/packages/datadog-api-client-v2/models/RetentionFilterUpdateData.ts index 950ecf4425c..c6f4ab5eea0 100644 --- a/packages/datadog-api-client-v2/models/RetentionFilterUpdateData.ts +++ b/packages/datadog-api-client-v2/models/RetentionFilterUpdateData.ts @@ -4,7 +4,7 @@ * Copyright 2020-Present Datadog, Inc. */ import { ApmRetentionFilterType } from "./ApmRetentionFilterType"; -import { RetentionFilterCreateAttributes } from "./RetentionFilterCreateAttributes"; +import { RetentionFilterUpdateAttributes } from "./RetentionFilterUpdateAttributes"; import { AttributeTypeMap } from "../../datadog-api-client-common/util"; @@ -15,7 +15,7 @@ export class RetentionFilterUpdateData { /** * The object describing the configuration of the retention filter to create/update. */ - "attributes": RetentionFilterCreateAttributes; + "attributes": RetentionFilterUpdateAttributes; /** * The ID of the retention filter. */ @@ -43,7 +43,7 @@ export class RetentionFilterUpdateData { static readonly attributeTypeMap: AttributeTypeMap = { attributes: { baseName: "attributes", - type: "RetentionFilterCreateAttributes", + type: "RetentionFilterUpdateAttributes", required: true, }, id: {