diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 2ba4dbf6d6..683c28d9d2 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -6182,6 +6182,190 @@ components: type: string x-enum-varnames: - ARITHMETIC_PROCESSOR + LogsArrayMapArithmeticSubProcessor: + description: |- + An arithmetic sub-processor for use inside an array-map processor. + Unlike the top-level arithmetic processor, `is_enabled` is not supported. + properties: + expression: + description: Arithmetic operation to perform. + example: $sourceElem.count * 2 + type: string + is_replace_missing: + default: false + description: Replace missing attribute values with 0. + type: boolean + name: + description: Name of the sub-processor. + type: string + target: + description: Target attribute path for the result. + example: $targetElem.doubled + type: string + type: + $ref: "#/components/schemas/LogsArithmeticProcessorType" + required: + - expression + - target + - type + type: object + LogsArrayMapAttributeRemapper: + description: |- + An attribute remapper sub-processor for use inside an array-map processor. + Unlike the top-level attribute remapper, `is_enabled`, `source_type`, and + `target_type` are not supported. + properties: + name: + description: Name of the sub-processor. + type: string + override_on_conflict: + default: false + description: Override the target element if already set. + type: boolean + preserve_source: + default: false + description: Remove or preserve the remapped source element. + type: boolean + sources: + description: Array of source attribute paths. + example: + - $sourceElem.id + items: + type: string + type: array + target: + description: Target attribute path. + example: $targetElem.uid + type: string + target_format: + $ref: "#/components/schemas/TargetFormatType" + type: + $ref: "#/components/schemas/LogsAttributeRemapperType" + required: + - sources + - target + - type + type: object + LogsArrayMapCategorySubProcessor: + description: |- + A category sub-processor for use inside an array-map processor. + Unlike the top-level category processor, `is_enabled` is not supported. + properties: + categories: + description: Array of filters to match against a log and the corresponding value to assign. + items: + $ref: "#/components/schemas/LogsCategoryProcessorCategory" + type: array + name: + description: Name of the sub-processor. + type: string + target: + description: Target attribute path for the category value. + example: $targetElem.level + type: string + type: + $ref: "#/components/schemas/LogsCategoryProcessorType" + required: + - categories + - target + - type + type: object + LogsArrayMapProcessor: + description: |- + The array-map processor transforms each element of a source array by applying + sub-processors in order and collecting the results into a target array. + Results can be written to a new array, to the source array (in-place), or to + an existing target array. Sub-processors can read from `$sourceElem.` + (object element field), bare `$sourceElem` (primitive element), or any parent + log attribute path. Sub-processors write to `$targetElem.` (object + output field) or bare `$targetElem` (primitive output). + 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 + LogsArrayMapStringBuilderSubProcessor: + description: |- + A string builder sub-processor for use inside an array-map processor. + Unlike the top-level string builder processor, `is_enabled` is not supported. + properties: + is_replace_missing: + default: false + description: Replace missing attribute values with an empty string. + type: boolean + name: + description: Name of the sub-processor. + type: string + target: + description: Target attribute path for the result. + example: $targetElem.label + type: string + template: + description: Formula with one or more attributes and raw text. + example: item-%{$sourceElem.id} + type: string + type: + $ref: "#/components/schemas/LogsStringBuilderProcessorType" + required: + - template + - target + - type + type: object + 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/LogsArrayMapAttributeRemapper" + - $ref: "#/components/schemas/LogsArrayMapArithmeticSubProcessor" + - $ref: "#/components/schemas/LogsArrayMapStringBuilderSubProcessor" + - $ref: "#/components/schemas/LogsArrayMapCategorySubProcessor" LogsArrayProcessor: description: |- A processor for extracting, aggregating, or transforming values from JSON arrays within your logs. @@ -7237,6 +7421,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/docs/datadog_api_client.v1.model.rst b/docs/datadog_api_client.v1.model.rst index 1b6e3313f9..4a3f774b9d 100644 --- a/docs/datadog_api_client.v1.model.rst +++ b/docs/datadog_api_client.v1.model.rst @@ -1957,6 +1957,55 @@ datadog\_api\_client.v1.model.logs\_arithmetic\_processor\_type module :members: :show-inheritance: +datadog\_api\_client.v1.model.logs\_array\_map\_arithmetic\_sub\_processor module +--------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_arithmetic_sub_processor + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.logs\_array\_map\_attribute\_remapper module +-------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_attribute_remapper + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.logs\_array\_map\_category\_sub\_processor module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_category_sub_processor + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.logs\_array\_map\_processor module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_processor + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.logs\_array\_map\_processor\_type module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_processor_type + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.logs\_array\_map\_string\_builder\_sub\_processor module +-------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_string_builder_sub_processor + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.logs\_array\_map\_sub\_processor module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v1.model.logs_array_map_sub_processor + :members: + :show-inheritance: + datadog\_api\_client.v1.model.logs\_array\_processor module ----------------------------------------------------------- diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.py b/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.py new file mode 100644 index 0000000000..5127ea2a90 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_104735144.py @@ -0,0 +1,46 @@ +""" +Create a pipeline with Array Map Processor with preserve_source false returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.logs_pipelines_api import LogsPipelinesApi +from datadog_api_client.v1.model.logs_array_map_attribute_remapper import LogsArrayMapAttributeRemapper +from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor +from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType +from datadog_api_client.v1.model.logs_attribute_remapper_type import LogsAttributeRemapperType +from datadog_api_client.v1.model.logs_filter import LogsFilter +from datadog_api_client.v1.model.logs_pipeline import LogsPipeline + +body = LogsPipeline( + filter=LogsFilter( + query="source:python", + ), + name="testPipelineArrayMapNoPreserve", + processors=[ + LogsArrayMapProcessor( + type=LogsArrayMapProcessorType.ARRAY_MAP_PROCESSOR, + is_enabled=True, + name="map and remove source", + source="items", + target="out", + preserve_source=False, + processors=[ + LogsArrayMapAttributeRemapper( + type=LogsAttributeRemapperType.ATTRIBUTE_REMAPPER, + sources=[ + "$sourceElem.id", + ], + target="$targetElem.uid", + ), + ], + ), + ], + tags=[], +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsPipelinesApi(api_client) + response = api_instance.create_logs_pipeline(body=body) + + print(response) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.py b/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.py new file mode 100644 index 0000000000..6c981d5891 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_1185292896.py @@ -0,0 +1,57 @@ +""" +Create a pipeline with Array Map Processor using category sub-processor returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.logs_pipelines_api import LogsPipelinesApi +from datadog_api_client.v1.model.logs_array_map_category_sub_processor import LogsArrayMapCategorySubProcessor +from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor +from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType +from datadog_api_client.v1.model.logs_category_processor_category import LogsCategoryProcessorCategory +from datadog_api_client.v1.model.logs_category_processor_type import LogsCategoryProcessorType +from datadog_api_client.v1.model.logs_filter import LogsFilter +from datadog_api_client.v1.model.logs_pipeline import LogsPipeline + +body = LogsPipeline( + filter=LogsFilter( + query="source:python", + ), + name="testPipelineArrayMapCategory", + processors=[ + LogsArrayMapProcessor( + type=LogsArrayMapProcessorType.ARRAY_MAP_PROCESSOR, + is_enabled=True, + name="categorize items", + source="items", + target="out", + processors=[ + LogsArrayMapCategorySubProcessor( + type=LogsCategoryProcessorType.CATEGORY_PROCESSOR, + target="$targetElem.level", + categories=[ + LogsCategoryProcessorCategory( + filter=LogsFilter( + query="@$sourceElem.status:error", + ), + name="error", + ), + LogsCategoryProcessorCategory( + filter=LogsFilter( + query="*", + ), + name="info", + ), + ], + ), + ], + ), + ], + tags=[], +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsPipelinesApi(api_client) + response = api_instance.create_logs_pipeline(body=body) + + print(response) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.py b/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.py new file mode 100644 index 0000000000..de003bd93a --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_2402034476.py @@ -0,0 +1,43 @@ +""" +Create a pipeline with Array Map Processor using arithmetic sub-processor returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.logs_pipelines_api import LogsPipelinesApi +from datadog_api_client.v1.model.logs_arithmetic_processor_type import LogsArithmeticProcessorType +from datadog_api_client.v1.model.logs_array_map_arithmetic_sub_processor import LogsArrayMapArithmeticSubProcessor +from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor +from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType +from datadog_api_client.v1.model.logs_filter import LogsFilter +from datadog_api_client.v1.model.logs_pipeline import LogsPipeline + +body = LogsPipeline( + filter=LogsFilter( + query="source:python", + ), + name="testPipelineArrayMapArithmetic", + processors=[ + LogsArrayMapProcessor( + type=LogsArrayMapProcessorType.ARRAY_MAP_PROCESSOR, + is_enabled=True, + name="double counts", + source="items", + target="out", + processors=[ + LogsArrayMapArithmeticSubProcessor( + type=LogsArithmeticProcessorType.ARITHMETIC_PROCESSOR, + expression="$sourceElem.count * 2", + target="$targetElem.doubled", + ), + ], + ), + ], + tags=[], +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsPipelinesApi(api_client) + response = api_instance.create_logs_pipeline(body=body) + + print(response) diff --git a/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.py b/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.py new file mode 100644 index 0000000000..cc23a6b1a3 --- /dev/null +++ b/examples/v1/logs-pipelines/CreateLogsPipeline_3996915493.py @@ -0,0 +1,56 @@ +""" +Create a pipeline with Array Map Processor returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.logs_pipelines_api import LogsPipelinesApi +from datadog_api_client.v1.model.logs_array_map_attribute_remapper import LogsArrayMapAttributeRemapper +from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor +from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType +from datadog_api_client.v1.model.logs_array_map_string_builder_sub_processor import ( + LogsArrayMapStringBuilderSubProcessor, +) +from datadog_api_client.v1.model.logs_attribute_remapper_type import LogsAttributeRemapperType +from datadog_api_client.v1.model.logs_filter import LogsFilter +from datadog_api_client.v1.model.logs_pipeline import LogsPipeline +from datadog_api_client.v1.model.logs_string_builder_processor_type import LogsStringBuilderProcessorType + +body = LogsPipeline( + filter=LogsFilter( + query="source:python", + ), + name="testPipelineArrayMap", + processors=[ + LogsArrayMapProcessor( + type=LogsArrayMapProcessorType.ARRAY_MAP_PROCESSOR, + is_enabled=True, + name="map items", + source="items", + target="out", + preserve_source=True, + processors=[ + LogsArrayMapAttributeRemapper( + type=LogsAttributeRemapperType.ATTRIBUTE_REMAPPER, + sources=[ + "$sourceElem.id", + ], + target="$targetElem.uid", + preserve_source=True, + ), + LogsArrayMapStringBuilderSubProcessor( + type=LogsStringBuilderProcessorType.STRING_BUILDER_PROCESSOR, + template="item-%{$sourceElem.id}", + target="$targetElem.label", + ), + ], + ), + ], + tags=[], +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = LogsPipelinesApi(api_client) + response = api_instance.create_logs_pipeline(body=body) + + print(response) diff --git a/src/datadog_api_client/v1/model/logs_array_map_arithmetic_sub_processor.py b/src/datadog_api_client/v1/model/logs_array_map_arithmetic_sub_processor.py new file mode 100644 index 0000000000..0f67471e1e --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_arithmetic_sub_processor.py @@ -0,0 +1,77 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.logs_arithmetic_processor_type import LogsArithmeticProcessorType + + +class LogsArrayMapArithmeticSubProcessor(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.logs_arithmetic_processor_type import LogsArithmeticProcessorType + + return { + "expression": (str,), + "is_replace_missing": (bool,), + "name": (str,), + "target": (str,), + "type": (LogsArithmeticProcessorType,), + } + + attribute_map = { + "expression": "expression", + "is_replace_missing": "is_replace_missing", + "name": "name", + "target": "target", + "type": "type", + } + + def __init__( + self_, + expression: str, + target: str, + type: LogsArithmeticProcessorType, + is_replace_missing: Union[bool, UnsetType] = unset, + name: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + An arithmetic sub-processor for use inside an array-map processor. + Unlike the top-level arithmetic processor, ``is_enabled`` is not supported. + + :param expression: Arithmetic operation to perform. + :type expression: str + + :param is_replace_missing: Replace missing attribute values with 0. + :type is_replace_missing: bool, optional + + :param name: Name of the sub-processor. + :type name: str, optional + + :param target: Target attribute path for the result. + :type target: str + + :param type: Type of logs arithmetic processor. + :type type: LogsArithmeticProcessorType + """ + if is_replace_missing is not unset: + kwargs["is_replace_missing"] = is_replace_missing + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) + + self_.expression = expression + self_.target = target + self_.type = type diff --git a/src/datadog_api_client/v1/model/logs_array_map_attribute_remapper.py b/src/datadog_api_client/v1/model/logs_array_map_attribute_remapper.py new file mode 100644 index 0000000000..1e21f2e755 --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_attribute_remapper.py @@ -0,0 +1,98 @@ +# 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. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.target_format_type import TargetFormatType + from datadog_api_client.v1.model.logs_attribute_remapper_type import LogsAttributeRemapperType + + +class LogsArrayMapAttributeRemapper(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.target_format_type import TargetFormatType + from datadog_api_client.v1.model.logs_attribute_remapper_type import LogsAttributeRemapperType + + return { + "name": (str,), + "override_on_conflict": (bool,), + "preserve_source": (bool,), + "sources": ([str],), + "target": (str,), + "target_format": (TargetFormatType,), + "type": (LogsAttributeRemapperType,), + } + + attribute_map = { + "name": "name", + "override_on_conflict": "override_on_conflict", + "preserve_source": "preserve_source", + "sources": "sources", + "target": "target", + "target_format": "target_format", + "type": "type", + } + + def __init__( + self_, + sources: List[str], + target: str, + type: LogsAttributeRemapperType, + name: Union[str, UnsetType] = unset, + override_on_conflict: Union[bool, UnsetType] = unset, + preserve_source: Union[bool, UnsetType] = unset, + target_format: Union[TargetFormatType, UnsetType] = unset, + **kwargs, + ): + """ + An attribute remapper sub-processor for use inside an array-map processor. + Unlike the top-level attribute remapper, ``is_enabled`` , ``source_type`` , and + ``target_type`` are not supported. + + :param name: Name of the sub-processor. + :type name: str, optional + + :param override_on_conflict: Override the target element if already set. + :type override_on_conflict: bool, optional + + :param preserve_source: Remove or preserve the remapped source element. + :type preserve_source: bool, optional + + :param sources: Array of source attribute paths. + :type sources: [str] + + :param target: Target attribute path. + :type target: str + + :param target_format: If the ``target_type`` of the remapper is ``attribute`` , try to cast the value to a new specific type. + If the cast is not possible, the original type is kept. ``string`` , ``integer`` , or ``double`` are the possible types. + If the ``target_type`` is ``tag`` , this parameter may not be specified. + :type target_format: TargetFormatType, optional + + :param type: Type of logs attribute remapper. + :type type: LogsAttributeRemapperType + """ + if name is not unset: + kwargs["name"] = name + if override_on_conflict is not unset: + kwargs["override_on_conflict"] = override_on_conflict + if preserve_source is not unset: + kwargs["preserve_source"] = preserve_source + if target_format is not unset: + kwargs["target_format"] = target_format + super().__init__(kwargs) + + self_.sources = sources + self_.target = target + self_.type = type diff --git a/src/datadog_api_client/v1/model/logs_array_map_category_sub_processor.py b/src/datadog_api_client/v1/model/logs_array_map_category_sub_processor.py new file mode 100644 index 0000000000..3ac3fb7ecb --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_category_sub_processor.py @@ -0,0 +1,71 @@ +# 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. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.logs_category_processor_category import LogsCategoryProcessorCategory + from datadog_api_client.v1.model.logs_category_processor_type import LogsCategoryProcessorType + + +class LogsArrayMapCategorySubProcessor(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.logs_category_processor_category import LogsCategoryProcessorCategory + from datadog_api_client.v1.model.logs_category_processor_type import LogsCategoryProcessorType + + return { + "categories": ([LogsCategoryProcessorCategory],), + "name": (str,), + "target": (str,), + "type": (LogsCategoryProcessorType,), + } + + attribute_map = { + "categories": "categories", + "name": "name", + "target": "target", + "type": "type", + } + + def __init__( + self_, + categories: List[LogsCategoryProcessorCategory], + target: str, + type: LogsCategoryProcessorType, + name: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A category sub-processor for use inside an array-map processor. + Unlike the top-level category processor, ``is_enabled`` is not supported. + + :param categories: Array of filters to match against a log and the corresponding value to assign. + :type categories: [LogsCategoryProcessorCategory] + + :param name: Name of the sub-processor. + :type name: str, optional + + :param target: Target attribute path for the category value. + :type target: str + + :param type: Type of logs category processor. + :type type: LogsCategoryProcessorType + """ + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) + + self_.categories = categories + self_.target = target + self_.type = type diff --git a/src/datadog_api_client/v1/model/logs_array_map_processor.py b/src/datadog_api_client/v1/model/logs_array_map_processor.py new file mode 100644 index 0000000000..b575e4ec1e --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_processor.py @@ -0,0 +1,117 @@ +# 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. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.logs_array_map_sub_processor import LogsArrayMapSubProcessor + from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType + from datadog_api_client.v1.model.logs_array_map_attribute_remapper import LogsArrayMapAttributeRemapper + from datadog_api_client.v1.model.logs_array_map_arithmetic_sub_processor import LogsArrayMapArithmeticSubProcessor + from datadog_api_client.v1.model.logs_array_map_string_builder_sub_processor import ( + LogsArrayMapStringBuilderSubProcessor, + ) + from datadog_api_client.v1.model.logs_array_map_category_sub_processor import LogsArrayMapCategorySubProcessor + + +class LogsArrayMapProcessor(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.logs_array_map_sub_processor import LogsArrayMapSubProcessor + from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType + + return { + "is_enabled": (bool,), + "name": (str,), + "preserve_source": (bool,), + "processors": ([LogsArrayMapSubProcessor],), + "source": (str,), + "target": (str,), + "type": (LogsArrayMapProcessorType,), + } + + attribute_map = { + "is_enabled": "is_enabled", + "name": "name", + "preserve_source": "preserve_source", + "processors": "processors", + "source": "source", + "target": "target", + "type": "type", + } + + def __init__( + self_, + processors: List[ + Union[ + LogsArrayMapSubProcessor, + LogsArrayMapAttributeRemapper, + LogsArrayMapArithmeticSubProcessor, + LogsArrayMapStringBuilderSubProcessor, + LogsArrayMapCategorySubProcessor, + ] + ], + source: str, + target: str, + type: LogsArrayMapProcessorType, + is_enabled: Union[bool, UnsetType] = unset, + name: Union[str, UnsetType] = unset, + preserve_source: Union[bool, UnsetType] = unset, + **kwargs, + ): + """ + The array-map processor transforms each element of a source array by applying + sub-processors in order and collecting the results into a target array. + Results can be written to a new array, to the source array (in-place), or to + an existing target array. Sub-processors can read from ``$sourceElem.`` + (object element field), bare ``$sourceElem`` (primitive element), or any parent + log attribute path. Sub-processors write to ``$targetElem.`` (object + output field) or bare ``$targetElem`` (primitive output). + + :param is_enabled: Whether or not the processor is enabled. + :type is_enabled: bool, optional + + :param name: Name of the processor. + :type name: str, optional + + :param preserve_source: When ``false`` and ``source != target`` , the source attribute is removed after + processing. Cannot be ``false`` when ``source == target``. + :type preserve_source: bool, optional + + :param processors: Sub-processors applied to each element. Allowed types: ``attribute-remapper`` , + ``string-builder-processor`` , ``arithmetic-processor`` , ``category-processor``. + :type processors: [LogsArrayMapSubProcessor] + + :param source: Attribute path of the source array. Elements are read-only via ``$sourceElem`` + inside sub-processors. + :type source: str + + :param target: Attribute path of the output array. Sub-processors write to ``$targetElem`` + (or ``$targetElem.`` ) to build each output element. + :type target: str + + :param type: Type of logs array-map processor. + :type type: LogsArrayMapProcessorType + """ + if is_enabled is not unset: + kwargs["is_enabled"] = is_enabled + if name is not unset: + kwargs["name"] = name + if preserve_source is not unset: + kwargs["preserve_source"] = preserve_source + super().__init__(kwargs) + + self_.processors = processors + self_.source = source + self_.target = target + self_.type = type diff --git a/src/datadog_api_client/v1/model/logs_array_map_processor_type.py b/src/datadog_api_client/v1/model/logs_array_map_processor_type.py new file mode 100644 index 0000000000..0c4efc5478 --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_processor_type.py @@ -0,0 +1,35 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class LogsArrayMapProcessorType(ModelSimple): + """ + Type of logs array-map processor. + + :param value: If omitted defaults to "array-map-processor". Must be one of ["array-map-processor"]. + :type value: str + """ + + allowed_values = { + "array-map-processor", + } + ARRAY_MAP_PROCESSOR: ClassVar["LogsArrayMapProcessorType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +LogsArrayMapProcessorType.ARRAY_MAP_PROCESSOR = LogsArrayMapProcessorType("array-map-processor") diff --git a/src/datadog_api_client/v1/model/logs_array_map_string_builder_sub_processor.py b/src/datadog_api_client/v1/model/logs_array_map_string_builder_sub_processor.py new file mode 100644 index 0000000000..8799ca3dac --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_string_builder_sub_processor.py @@ -0,0 +1,77 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v1.model.logs_string_builder_processor_type import LogsStringBuilderProcessorType + + +class LogsArrayMapStringBuilderSubProcessor(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v1.model.logs_string_builder_processor_type import LogsStringBuilderProcessorType + + return { + "is_replace_missing": (bool,), + "name": (str,), + "target": (str,), + "template": (str,), + "type": (LogsStringBuilderProcessorType,), + } + + attribute_map = { + "is_replace_missing": "is_replace_missing", + "name": "name", + "target": "target", + "template": "template", + "type": "type", + } + + def __init__( + self_, + target: str, + template: str, + type: LogsStringBuilderProcessorType, + is_replace_missing: Union[bool, UnsetType] = unset, + name: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A string builder sub-processor for use inside an array-map processor. + Unlike the top-level string builder processor, ``is_enabled`` is not supported. + + :param is_replace_missing: Replace missing attribute values with an empty string. + :type is_replace_missing: bool, optional + + :param name: Name of the sub-processor. + :type name: str, optional + + :param target: Target attribute path for the result. + :type target: str + + :param template: Formula with one or more attributes and raw text. + :type template: str + + :param type: Type of logs string builder processor. + :type type: LogsStringBuilderProcessorType + """ + if is_replace_missing is not unset: + kwargs["is_replace_missing"] = is_replace_missing + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) + + self_.target = target + self_.template = template + self_.type = type diff --git a/src/datadog_api_client/v1/model/logs_array_map_sub_processor.py b/src/datadog_api_client/v1/model/logs_array_map_sub_processor.py new file mode 100644 index 0000000000..0273ad8ba4 --- /dev/null +++ b/src/datadog_api_client/v1/model/logs_array_map_sub_processor.py @@ -0,0 +1,82 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class LogsArrayMapSubProcessor(ModelComposed): + def __init__(self, **kwargs): + """ + A sub-processor used inside an array-map processor. + Allowed types: ``attribute-remapper`` , ``string-builder-processor`` , + ``arithmetic-processor`` , ``category-processor``. + + :param name: Name of the sub-processor. + :type name: str, optional + + :param override_on_conflict: Override the target element if already set. + :type override_on_conflict: bool, optional + + :param preserve_source: Remove or preserve the remapped source element. + :type preserve_source: bool, optional + + :param sources: Array of source attribute paths. + :type sources: [str] + + :param target: Target attribute path. + :type target: str + + :param target_format: If the `target_type` of the remapper is `attribute`, try to cast the value to a new specific type. + If the cast is not possible, the original type is kept. `string`, `integer`, or `double` are the possible types. + If the `target_type` is `tag`, this parameter may not be specified. + :type target_format: TargetFormatType, optional + + :param type: Type of logs attribute remapper. + :type type: LogsAttributeRemapperType + + :param expression: Arithmetic operation to perform. + :type expression: str + + :param is_replace_missing: Replace missing attribute values with 0. + :type is_replace_missing: bool, optional + + :param template: Formula with one or more attributes and raw text. + :type template: str + + :param categories: Array of filters to match against a log and the corresponding value to assign. + :type categories: [LogsCategoryProcessorCategory] + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v1.model.logs_array_map_attribute_remapper import LogsArrayMapAttributeRemapper + from datadog_api_client.v1.model.logs_array_map_arithmetic_sub_processor import ( + LogsArrayMapArithmeticSubProcessor, + ) + from datadog_api_client.v1.model.logs_array_map_string_builder_sub_processor import ( + LogsArrayMapStringBuilderSubProcessor, + ) + from datadog_api_client.v1.model.logs_array_map_category_sub_processor import LogsArrayMapCategorySubProcessor + + return { + "oneOf": [ + LogsArrayMapAttributeRemapper, + LogsArrayMapArithmeticSubProcessor, + LogsArrayMapStringBuilderSubProcessor, + LogsArrayMapCategorySubProcessor, + ], + } diff --git a/src/datadog_api_client/v1/model/logs_pipeline.py b/src/datadog_api_client/v1/model/logs_pipeline.py index 75aa50d693..2f2c0bc430 100644 --- a/src/datadog_api_client/v1/model/logs_pipeline.py +++ b/src/datadog_api_client/v1/model/logs_pipeline.py @@ -37,6 +37,7 @@ from datadog_api_client.v1.model.logs_decoder_processor import LogsDecoderProcessor from datadog_api_client.v1.model.logs_schema_processor import LogsSchemaProcessor from datadog_api_client.v1.model.logs_exclude_attribute_processor import LogsExcludeAttributeProcessor + from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor class LogsPipeline(ModelNormal): @@ -107,6 +108,7 @@ def __init__( LogsDecoderProcessor, LogsSchemaProcessor, LogsExcludeAttributeProcessor, + LogsArrayMapProcessor, ] ], UnsetType, diff --git a/src/datadog_api_client/v1/model/logs_pipeline_processor.py b/src/datadog_api_client/v1/model/logs_pipeline_processor.py index 07d59fd9f7..955a688ea9 100644 --- a/src/datadog_api_client/v1/model/logs_pipeline_processor.py +++ b/src/datadog_api_client/v1/model/logs_pipeline_processor.py @@ -37,6 +37,7 @@ from datadog_api_client.v1.model.logs_decoder_processor import LogsDecoderProcessor from datadog_api_client.v1.model.logs_schema_processor import LogsSchemaProcessor from datadog_api_client.v1.model.logs_exclude_attribute_processor import LogsExcludeAttributeProcessor + from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor class LogsPipelineProcessor(ModelNormal): @@ -98,6 +99,7 @@ def __init__( LogsDecoderProcessor, LogsSchemaProcessor, LogsExcludeAttributeProcessor, + LogsArrayMapProcessor, ] ], UnsetType, diff --git a/src/datadog_api_client/v1/model/logs_processor.py b/src/datadog_api_client/v1/model/logs_processor.py index 07498773fc..884f31651e 100644 --- a/src/datadog_api_client/v1/model/logs_processor.py +++ b/src/datadog_api_client/v1/model/logs_processor.py @@ -148,6 +148,7 @@ def _composed_schemas(_): from datadog_api_client.v1.model.logs_decoder_processor import LogsDecoderProcessor from datadog_api_client.v1.model.logs_schema_processor import LogsSchemaProcessor from datadog_api_client.v1.model.logs_exclude_attribute_processor import LogsExcludeAttributeProcessor + from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor return { "oneOf": [ @@ -172,5 +173,6 @@ def _composed_schemas(_): LogsDecoderProcessor, LogsSchemaProcessor, LogsExcludeAttributeProcessor, + LogsArrayMapProcessor, ], } diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 85c9757ab5..8736815702 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -333,6 +333,15 @@ from datadog_api_client.v1.model.logs_api_limit_reached_response import LogsAPILimitReachedResponse from datadog_api_client.v1.model.logs_arithmetic_processor import LogsArithmeticProcessor from datadog_api_client.v1.model.logs_arithmetic_processor_type import LogsArithmeticProcessorType +from datadog_api_client.v1.model.logs_array_map_arithmetic_sub_processor import LogsArrayMapArithmeticSubProcessor +from datadog_api_client.v1.model.logs_array_map_attribute_remapper import LogsArrayMapAttributeRemapper +from datadog_api_client.v1.model.logs_array_map_category_sub_processor import LogsArrayMapCategorySubProcessor +from datadog_api_client.v1.model.logs_array_map_processor import LogsArrayMapProcessor +from datadog_api_client.v1.model.logs_array_map_processor_type import LogsArrayMapProcessorType +from datadog_api_client.v1.model.logs_array_map_string_builder_sub_processor import ( + LogsArrayMapStringBuilderSubProcessor, +) +from datadog_api_client.v1.model.logs_array_map_sub_processor import LogsArrayMapSubProcessor from datadog_api_client.v1.model.logs_array_processor import LogsArrayProcessor from datadog_api_client.v1.model.logs_array_processor_operation import LogsArrayProcessorOperation from datadog_api_client.v1.model.logs_array_processor_operation_append import LogsArrayProcessorOperationAppend @@ -1674,6 +1683,13 @@ "LogsAPILimitReachedResponse", "LogsArithmeticProcessor", "LogsArithmeticProcessorType", + "LogsArrayMapArithmeticSubProcessor", + "LogsArrayMapAttributeRemapper", + "LogsArrayMapCategorySubProcessor", + "LogsArrayMapProcessor", + "LogsArrayMapProcessorType", + "LogsArrayMapStringBuilderSubProcessor", + "LogsArrayMapSubProcessor", "LogsArrayProcessor", "LogsArrayProcessorOperation", "LogsArrayProcessorOperationAppend", diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_returns_ok_response.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_returns_ok_response.frozen new file mode 100644 index 0000000000..6324009397 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-06-23T13:26:57.908Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_returns_ok_response.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_returns_ok_response.yaml new file mode 100644 index 0000000000..d7de66b7f3 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_returns_ok_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '{"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: + string: '{"id":"9R-fEK0LRyWg0HzDbM-gOg","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":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","preserve_source":true,"override_on_conflict":false,"type":"attribute-remapper"},{"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 +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/9R-fEK0LRyWg0HzDbM-gOg + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_arithmetic_subprocessor_returns_ok_response.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_arithmetic_subprocessor_returns_ok_response.frozen new file mode 100644 index 0000000000..56e4aef1ac --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_arithmetic_subprocessor_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-06-23T13:27:34.721Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_arithmetic_subprocessor_returns_ok_response.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_arithmetic_subprocessor_returns_ok_response.yaml new file mode 100644 index 0000000000..f43e541467 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_arithmetic_subprocessor_returns_ok_response.yaml @@ -0,0 +1,43 @@ +interactions: +- request: + body: '{"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: + string: '{"id":"PxfujWHYRaGCWVqVCVrBAg","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":[{"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 +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/PxfujWHYRaGCWVqVCVrBAg + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_category_subprocessor_returns_ok_response.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_category_subprocessor_returns_ok_response.frozen new file mode 100644 index 0000000000..bc38a40a89 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_category_subprocessor_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-06-23T13:27:55.552Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_category_subprocessor_returns_ok_response.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_category_subprocessor_returns_ok_response.yaml new file mode 100644 index 0000000000..62bbfd978f --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_using_category_subprocessor_returns_ok_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '{"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: + string: '{"id":"NW1Ws0rnRwWbxKdNUlBFOQ","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":[{"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 +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/NW1Ws0rnRwWbxKdNUlBFOQ + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_with_preserve_source_false_returns_ok_response.frozen b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_with_preserve_source_false_returns_ok_response.frozen new file mode 100644 index 0000000000..4f838f02df --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_with_preserve_source_false_returns_ok_response.frozen @@ -0,0 +1 @@ +2026-06-23T13:28:15.444Z \ No newline at end of file diff --git a/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_with_preserve_source_false_returns_ok_response.yaml b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_with_preserve_source_false_returns_ok_response.yaml new file mode 100644 index 0000000000..48867b6fe8 --- /dev/null +++ b/tests/v1/cassettes/test_scenarios/test_create_a_pipeline_with_array_map_processor_with_preserve_source_false_returns_ok_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: '{"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: + string: '{"id":"hJXlpnp0RD68QPplvOMAcQ","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":[{"sources":["$sourceElem.id"],"target":"$targetElem.uid","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 +- request: + body: null + headers: + accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v1/logs/config/pipelines/hJXlpnp0RD68QPplvOMAcQ + response: + body: + string: '{} + + ' + headers: + content-type: + - application/json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v1/features/logs_pipelines.feature b/tests/v1/features/logs_pipelines.feature index 1ab4401b0f..ac28f05261 100644 --- a/tests/v1/features/logs_pipelines.feature +++ b/tests/v1/features/logs_pipelines.feature @@ -35,6 +35,34 @@ 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 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 Processor Append Operation returns "OK" response Given new "CreateLogsPipeline" request