diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e922a2a26ab0..07b01b423475 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -6182,6 +6182,76 @@ components: type: string x-enum-varnames: - ARITHMETIC_PROCESSOR + LogsArrayMapProcessor: + description: |- + The array-map processor transforms each element of a source array by running + sub-processors against it and writing results to a target array. + Sub-processors reference the current element via `$sourceElem` (read) and + `$targetElem` (write). Parent log attributes are read via plain paths as usual. + Supported sub-processor types: `attribute-remapper`, `string-builder-processor`, + `arithmetic-processor`, `category-processor`. + `is_enabled` on sub-processors is ignored; sub-processor execution is gated + entirely by the parent array-map's `is_enabled` flag. + properties: + is_enabled: + default: false + description: Whether or not the processor is enabled. + type: boolean + name: + description: Name of the processor. + type: string + preserve_source: + default: true + description: |- + When `false` and `source != target`, the source attribute is removed after + processing. Cannot be `false` when `source == target`. + type: boolean + processors: + description: |- + Sub-processors applied to each element. Allowed types: `attribute-remapper`, + `string-builder-processor`, `arithmetic-processor`, `category-processor`. + items: + $ref: "#/components/schemas/LogsArrayMapSubProcessor" + type: array + source: + description: |- + Attribute path of the source array. Elements are read-only via `$sourceElem` + inside sub-processors. + example: detail.resource.s3BucketDetails + type: string + target: + description: |- + Attribute path of the output array. Sub-processors write to `$targetElem` + (or `$targetElem.`) to build each output element. + example: ocsf.resources + type: string + type: + $ref: "#/components/schemas/LogsArrayMapProcessorType" + required: + - source + - target + - processors + - type + type: object + LogsArrayMapProcessorType: + default: array-map-processor + description: Type of logs array-map processor. + enum: + - array-map-processor + example: array-map-processor + type: string + x-enum-varnames: + - ARRAY_MAP_PROCESSOR + LogsArrayMapSubProcessor: + description: |- + A sub-processor used inside an array-map processor. + Allowed types: `attribute-remapper`, `string-builder-processor`, + `arithmetic-processor`, `category-processor`. + oneOf: + - $ref: "#/components/schemas/LogsAttributeRemapper" + - $ref: "#/components/schemas/LogsStringBuilderProcessor" + - $ref: "#/components/schemas/LogsArithmeticProcessor" + - $ref: "#/components/schemas/LogsCategoryProcessor" LogsArrayProcessor: description: |- A processor for extracting, aggregating, or transforming values from JSON arrays within your logs. @@ -7237,6 +7307,7 @@ components: - $ref: "#/components/schemas/LogsDecoderProcessor" - $ref: "#/components/schemas/LogsSchemaProcessor" - $ref: "#/components/schemas/LogsExcludeAttributeProcessor" + - $ref: "#/components/schemas/LogsArrayMapProcessor" LogsQueryCompute: description: Define computation for a log query. properties: diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen new file mode 100644 index 000000000000..4919e2c81ab6 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-11T11:21:14.898Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml new file mode 100644 index 000000000000..8f15230ee020 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-returns-OK-response.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Thu, 11 Jun 2026 11:21:14 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMap","processors":[{"is_enabled":true,"name":"map + items","preserve_source":true,"processors":[{"preserve_source":true,"sources":["$sourceElem.id"],"target":"$targetElem.uid","type":"attribute-remapper"},{"target":"$targetElem.label","template":"item-%{$sourceElem.id}","type":"string-builder-processor"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"hZIWv906QoyQIWpVKqb6pw","type":"pipeline","name":"testPipelineArrayMap","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"map + items","is_enabled":true,"source":"items","target":"out","processors":[{"is_enabled":true,"sources":["$sourceElem.id"],"target":"$targetElem.uid","target_type":"attribute","preserve_source":true,"override_on_conflict":false,"type":"attribute-remapper"},{"is_enabled":true,"template":"item-%{$sourceElem.id}","target":"$targetElem.label","is_replace_missing":false,"type":"string-builder-processor"}],"preserve_source":true,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Thu, 11 Jun 2026 11:21:14 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/hZIWv906QoyQIWpVKqb6pw + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen new file mode 100644 index 000000000000..ff1b67db842f --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-11T11:21:29.886Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml new file mode 100644 index 000000000000..4cf38b6fa1b0 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-arithmetic-sub-processor-returns-OK-response.yml @@ -0,0 +1,49 @@ +http_interactions: +- recorded_at: Thu, 11 Jun 2026 11:21:29 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapArithmetic","processors":[{"is_enabled":true,"name":"double + counts","processors":[{"expression":"$sourceElem.count * 2","target":"$targetElem.doubled","type":"arithmetic-processor"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"oqjvoc0pSh6ZgjsHgiDQCg","type":"pipeline","name":"testPipelineArrayMapArithmetic","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"double + counts","is_enabled":true,"source":"items","target":"out","processors":[{"is_enabled":true,"expression":"$sourceElem.count + * 2","target":"$targetElem.doubled","is_replace_missing":false,"type":"arithmetic-processor"}],"preserve_source":true,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Thu, 11 Jun 2026 11:21:29 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/oqjvoc0pSh6ZgjsHgiDQCg + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen new file mode 100644 index 000000000000..44f040139a0c --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-11T11:21:45.245Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml new file mode 100644 index 000000000000..1b8c68e757e1 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-using-category-sub-processor-returns-OK-response.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Thu, 11 Jun 2026 11:21:45 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapCategory","processors":[{"is_enabled":true,"name":"categorize + items","processors":[{"categories":[{"filter":{"query":"@$sourceElem.status:error"},"name":"error"},{"filter":{"query":"*"},"name":"info"}],"target":"$targetElem.level","type":"category-processor"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"m9rsoJZvRyekemX5ED_r9g","type":"pipeline","name":"testPipelineArrayMapCategory","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"categorize + items","is_enabled":true,"source":"items","target":"out","processors":[{"is_enabled":true,"categories":[{"filter":{"query":"@$sourceElem.status:error"},"name":"error"},{"filter":{"query":"*"},"name":"info"}],"target":"$targetElem.level","type":"category-processor"}],"preserve_source":true,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Thu, 11 Jun 2026 11:21:45 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/m9rsoJZvRyekemX5ED_r9g + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-and-same-source-and-target-returns-Bad-Request-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-and-same-source-and-target-returns-Bad-Request-response.frozen new file mode 100644 index 000000000000..3defeadb30ec --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-and-same-source-and-target-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2026-06-11T11:22:00.340Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-and-same-source-and-target-returns-Bad-Request-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-and-same-source-and-target-returns-Bad-Request-response.yml new file mode 100644 index 000000000000..1b369820207f --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-and-same-source-and-target-returns-Bad-Request-response.yml @@ -0,0 +1,28 @@ +http_interactions: +- recorded_at: Thu, 11 Jun 2026 11:22:00 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapInvalid","processors":[{"is_enabled":true,"name":"invalid + preserve_source","preserve_source":false,"processors":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","type":"attribute-remapper"}],"source":"items","target":"items","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"error":{"code":"InvalidArgument","message":"Invalid Pipeline","details":[{"code":"InvalidArgument","message":"preserve_source:false + is not allowed when source equals target"}]}} + + ' + headers: + Content-Type: + - application/json + status: + code: 400 + message: Bad Request +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen new file mode 100644 index 000000000000..fa046304a137 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-11T11:22:14.718Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml new file mode 100644 index 000000000000..b7850e10cab6 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-preserve-source-false-returns-OK-response.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Thu, 11 Jun 2026 11:22:14 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapNoPreserve","processors":[{"is_enabled":true,"name":"map + and remove source","preserve_source":false,"processors":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","type":"attribute-remapper"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"id":"ltWiUpfFRCaNE9L65g2VvQ","type":"pipeline","name":"testPipelineArrayMapNoPreserve","is_enabled":false,"is_read_only":false,"filter":{"query":"source:python"},"processors":[{"name":"map + and remove source","is_enabled":true,"source":"items","target":"out","processors":[{"is_enabled":true,"sources":["$sourceElem.id"],"target":"$targetElem.uid","target_type":"attribute","preserve_source":false,"override_on_conflict":false,"type":"attribute-remapper"}],"preserve_source":false,"type":"array-map-processor"}],"tags":[]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Thu, 11 Jun 2026 11:22:14 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/ltWiUpfFRCaNE9L65g2VvQ + response: + body: + encoding: UTF-8 + string: '{} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-targetElem-used-as-source-returns-Bad-Request-response.frozen b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-targetElem-used-as-source-returns-Bad-Request-response.frozen new file mode 100644 index 000000000000..0ea55a724af4 --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-targetElem-used-as-source-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2026-06-11T11:22:30.099Z \ No newline at end of file diff --git a/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-targetElem-used-as-source-returns-Bad-Request-response.yml b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-targetElem-used-as-source-returns-Bad-Request-response.yml new file mode 100644 index 000000000000..c42301f553db --- /dev/null +++ b/cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Array-Map-Processor-with-targetElem-used-as-source-returns-Bad-Request-response.yml @@ -0,0 +1,28 @@ +http_interactions: +- recorded_at: Thu, 11 Jun 2026 11:22:30 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"query":"source:python"},"name":"testPipelineArrayMapTargetElemSource","processors":[{"is_enabled":true,"name":"invalid + targetElem source","processors":[{"sources":["$targetElem.uid"],"target":"$targetElem.label","type":"attribute-remapper"}],"source":"items","target":"out","type":"array-map-processor"}],"tags":[]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines + response: + body: + encoding: UTF-8 + string: '{"error":{"code":"InvalidArgument","message":"Invalid Pipeline","details":[{"code":"InvalidArgument","message":"$targetElem + cannot be used as a source, got: $targetElem.uid"}]}} + + ' + headers: + Content-Type: + - application/json + status: + code: 400 + message: Bad Request +recorded_with: VCR 6.0.0 diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb new file mode 100644 index 000000000000..64f71a732419 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.rb @@ -0,0 +1,32 @@ +# Create a pipeline with Array Map Processor with preserve_source false returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMapNoPreserve", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "map and remove source", + source: "items", + target: "out", + preserve_source: false, + processors: [ + DatadogAPIClient::V1::LogsAttributeRemapper.new({ + type: DatadogAPIClient::V1::LogsAttributeRemapperType::ATTRIBUTE_REMAPPER, + sources: [ + "$sourceElem.id", + ], + target: "$targetElem.uid", + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb new file mode 100644 index 000000000000..693ca67c8b80 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.rb @@ -0,0 +1,42 @@ +# Create a pipeline with Array Map Processor using category sub-processor returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMapCategory", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "categorize items", + source: "items", + target: "out", + processors: [ + DatadogAPIClient::V1::LogsCategoryProcessor.new({ + type: DatadogAPIClient::V1::LogsCategoryProcessorType::CATEGORY_PROCESSOR, + target: "$targetElem.level", + categories: [ + DatadogAPIClient::V1::LogsCategoryProcessorCategory.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "@$sourceElem.status:error", + }), + name: "error", + }), + DatadogAPIClient::V1::LogsCategoryProcessorCategory.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "*", + }), + name: "info", + }), + ], + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb new file mode 100644 index 000000000000..4c9e7ad771a3 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.rb @@ -0,0 +1,29 @@ +# Create a pipeline with Array Map Processor using arithmetic sub-processor returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMapArithmetic", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "double counts", + source: "items", + target: "out", + processors: [ + DatadogAPIClient::V1::LogsArithmeticProcessor.new({ + type: DatadogAPIClient::V1::LogsArithmeticProcessorType::ARITHMETIC_PROCESSOR, + expression: "$sourceElem.count * 2", + target: "$targetElem.doubled", + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb b/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb new file mode 100644 index 000000000000..b4a0bf1e4365 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.rb @@ -0,0 +1,38 @@ +# Create a pipeline with Array Map Processor returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new + +body = DatadogAPIClient::V1::LogsPipeline.new({ + filter: DatadogAPIClient::V1::LogsFilter.new({ + query: "source:python", + }), + name: "testPipelineArrayMap", + processors: [ + DatadogAPIClient::V1::LogsArrayMapProcessor.new({ + type: DatadogAPIClient::V1::LogsArrayMapProcessorType::ARRAY_MAP_PROCESSOR, + is_enabled: true, + name: "map items", + source: "items", + target: "out", + preserve_source: true, + processors: [ + DatadogAPIClient::V1::LogsAttributeRemapper.new({ + type: DatadogAPIClient::V1::LogsAttributeRemapperType::ATTRIBUTE_REMAPPER, + sources: [ + "$sourceElem.id", + ], + target: "$targetElem.uid", + preserve_source: true, + }), + DatadogAPIClient::V1::LogsStringBuilderProcessor.new({ + type: DatadogAPIClient::V1::LogsStringBuilderProcessorType::STRING_BUILDER_PROCESSOR, + template: "item-%{$sourceElem.id}", + target: "$targetElem.label", + }), + ], + }), + ], + tags: [], +}) +p api_instance.create_logs_pipeline(body) diff --git a/features/v1/logs_pipelines.feature b/features/v1/logs_pipelines.feature index 1ab4401b0fdc..c2f21622a3ad 100644 --- a/features/v1/logs_pipelines.feature +++ b/features/v1/logs_pipelines.feature @@ -35,6 +35,48 @@ Feature: Logs Pipelines When the request is sent Then the response status is 200 OK + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMap", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "map items", "source": "items", "target": "out", "preserve_source": true, "processors": [{"type": "attribute-remapper", "sources": ["$sourceElem.id"], "target": "$targetElem.uid", "preserve_source": true}, {"type": "string-builder-processor", "template": "item-%{$sourceElem.id}", "target": "$targetElem.label"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor using arithmetic sub-processor returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapArithmetic", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "double counts", "source": "items", "target": "out", "processors": [{"type": "arithmetic-processor", "expression": "$sourceElem.count * 2", "target": "$targetElem.doubled"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor using category sub-processor returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapCategory", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "categorize items", "source": "items", "target": "out", "processors": [{"type": "category-processor", "target": "$targetElem.level", "categories": [{"filter": {"query": "@$sourceElem.status:error"}, "name": "error"}, {"filter": {"query": "*"}, "name": "info"}]}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor with preserve_source false and same source and target returns "Bad Request" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapInvalid", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "invalid preserve_source", "source": "items", "target": "items", "preserve_source": false, "processors": [{"type": "attribute-remapper", "sources": ["$sourceElem.id"], "target": "$targetElem.uid"}]}], "tags": []} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor with preserve_source false returns "OK" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapNoPreserve", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "map and remove source", "source": "items", "target": "out", "preserve_source": false, "processors": [{"type": "attribute-remapper", "sources": ["$sourceElem.id"], "target": "$targetElem.uid"}]}], "tags": []} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-onboarding + Scenario: Create a pipeline with Array Map Processor with targetElem used as source returns "Bad Request" response + Given new "CreateLogsPipeline" request + And body with value {"filter": {"query": "source:python"}, "name": "testPipelineArrayMapTargetElemSource", "processors": [{"type": "array-map-processor", "is_enabled": true, "name": "invalid targetElem source", "source": "items", "target": "out", "processors": [{"type": "attribute-remapper", "sources": ["$targetElem.uid"], "target": "$targetElem.label"}]}], "tags": []} + When the request is sent + Then the response status is 400 Bad Request + @team:DataDog/logs-onboarding Scenario: Create a pipeline with Array Processor Append Operation returns "OK" response Given new "CreateLogsPipeline" request diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 0f0830cc8eb9..2689d2109d5f 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -282,6 +282,9 @@ def overrides "v1.logs_api_limit_reached_response" => "LogsAPILimitReachedResponse", "v1.logs_arithmetic_processor" => "LogsArithmeticProcessor", "v1.logs_arithmetic_processor_type" => "LogsArithmeticProcessorType", + "v1.logs_array_map_processor" => "LogsArrayMapProcessor", + "v1.logs_array_map_processor_type" => "LogsArrayMapProcessorType", + "v1.logs_array_map_sub_processor" => "LogsArrayMapSubProcessor", "v1.logs_array_processor" => "LogsArrayProcessor", "v1.logs_array_processor_operation" => "LogsArrayProcessorOperation", "v1.logs_array_processor_operation_append" => "LogsArrayProcessorOperationAppend", diff --git a/lib/datadog_api_client/v1/models/logs_array_map_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_processor.rb new file mode 100644 index 000000000000..21f5bcdb0cae --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_processor.rb @@ -0,0 +1,229 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # The array-map processor transforms each element of a source array by running + # sub-processors against it and writing results to a target array. + # Sub-processors reference the current element via `$sourceElem` (read) and + # `$targetElem` (write). Parent log attributes are read via plain paths as usual. + # Supported sub-processor types: `attribute-remapper`, `string-builder-processor`, + # `arithmetic-processor`, `category-processor`. + # `is_enabled` on sub-processors is ignored; sub-processor execution is gated + # entirely by the parent array-map's `is_enabled` flag. + class LogsArrayMapProcessor + include BaseGenericModel + + # Whether or not the processor is enabled. + attr_accessor :is_enabled + + # Name of the processor. + attr_accessor :name + + # When `false` and `source != target`, the source attribute is removed after + # processing. Cannot be `false` when `source == target`. + attr_accessor :preserve_source + + # Sub-processors applied to each element. Allowed types: `attribute-remapper`, + # `string-builder-processor`, `arithmetic-processor`, `category-processor`. + attr_reader :processors + + # Attribute path of the source array. Elements are read-only via `$sourceElem` + # inside sub-processors. + attr_reader :source + + # Attribute path of the output array. Sub-processors write to `$targetElem` + # (or `$targetElem.`) to build each output element. + attr_reader :target + + # Type of logs array-map processor. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'is_enabled' => :'is_enabled', + :'name' => :'name', + :'preserve_source' => :'preserve_source', + :'processors' => :'processors', + :'source' => :'source', + :'target' => :'target', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'is_enabled' => :'Boolean', + :'name' => :'String', + :'preserve_source' => :'Boolean', + :'processors' => :'Array', + :'source' => :'String', + :'target' => :'String', + :'type' => :'LogsArrayMapProcessorType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsArrayMapProcessor` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'is_enabled') + self.is_enabled = attributes[:'is_enabled'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'preserve_source') + self.preserve_source = attributes[:'preserve_source'] + end + + if attributes.key?(:'processors') + if (value = attributes[:'processors']).is_a?(Array) + self.processors = value + end + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'target') + self.target = attributes[:'target'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @processors.nil? + return false if @source.nil? + return false if @target.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param processors [Object] Object to be assigned + # @!visibility private + def processors=(processors) + if processors.nil? + fail ArgumentError, 'invalid value for "processors", processors cannot be nil.' + end + @processors = processors + end + + # Custom attribute writer method with validation + # @param source [Object] Object to be assigned + # @!visibility private + def source=(source) + if source.nil? + fail ArgumentError, 'invalid value for "source", source cannot be nil.' + end + @source = source + end + + # Custom attribute writer method with validation + # @param target [Object] Object to be assigned + # @!visibility private + def target=(target) + if target.nil? + fail ArgumentError, 'invalid value for "target", target cannot be nil.' + end + @target = target + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + is_enabled == o.is_enabled && + name == o.name && + preserve_source == o.preserve_source && + processors == o.processors && + source == o.source && + target == o.target && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [is_enabled, name, preserve_source, processors, source, target, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb b/lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb new file mode 100644 index 000000000000..76c00d0cca19 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_processor_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Type of logs array-map processor. + class LogsArrayMapProcessorType + include BaseEnumModel + + ARRAY_MAP_PROCESSOR = "array-map-processor".freeze + end +end diff --git a/lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb b/lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb new file mode 100644 index 000000000000..511c309bf011 --- /dev/null +++ b/lib/datadog_api_client/v1/models/logs_array_map_sub_processor.rb @@ -0,0 +1,67 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # A sub-processor used inside an array-map processor. + # Allowed types: `attribute-remapper`, `string-builder-processor`, + # `arithmetic-processor`, `category-processor`. + module LogsArrayMapSubProcessor + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'LogsAttributeRemapper', + :'LogsStringBuilderProcessor', + :'LogsArithmeticProcessor', + :'LogsCategoryProcessor' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v1/models/logs_processor.rb b/lib/datadog_api_client/v1/models/logs_processor.rb index 156f2eae4d94..fc216834c911 100644 --- a/lib/datadog_api_client/v1/models/logs_processor.rb +++ b/lib/datadog_api_client/v1/models/logs_processor.rb @@ -46,7 +46,8 @@ def openapi_one_of :'LogsArrayProcessor', :'LogsDecoderProcessor', :'LogsSchemaProcessor', - :'LogsExcludeAttributeProcessor' + :'LogsExcludeAttributeProcessor', + :'LogsArrayMapProcessor' ] end # Builds the object