|
| 1 | +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +# This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +# Copyright 2019-Present Datadog, Inc. |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +from typing import Union, TYPE_CHECKING |
| 7 | + |
| 8 | +from datadog_api_client.model_utils import ( |
| 9 | + ModelNormal, |
| 10 | + cached_property, |
| 11 | + unset, |
| 12 | + UnsetType, |
| 13 | +) |
| 14 | + |
| 15 | + |
| 16 | +if TYPE_CHECKING: |
| 17 | + from datadog_api_client.v1.model.logs_array_processor_operation_extract_key_value_type import ( |
| 18 | + LogsArrayProcessorOperationExtractKeyValueType, |
| 19 | + ) |
| 20 | + |
| 21 | + |
| 22 | +class LogsArrayProcessorOperationExtractKeyValue(ModelNormal): |
| 23 | + @cached_property |
| 24 | + def openapi_types(_): |
| 25 | + from datadog_api_client.v1.model.logs_array_processor_operation_extract_key_value_type import ( |
| 26 | + LogsArrayProcessorOperationExtractKeyValueType, |
| 27 | + ) |
| 28 | + |
| 29 | + return { |
| 30 | + "key_to_extract": (str,), |
| 31 | + "override_on_conflict": (bool,), |
| 32 | + "source": (str,), |
| 33 | + "target": (str,), |
| 34 | + "type": (LogsArrayProcessorOperationExtractKeyValueType,), |
| 35 | + "value_to_extract": (str,), |
| 36 | + } |
| 37 | + |
| 38 | + attribute_map = { |
| 39 | + "key_to_extract": "key_to_extract", |
| 40 | + "override_on_conflict": "override_on_conflict", |
| 41 | + "source": "source", |
| 42 | + "target": "target", |
| 43 | + "type": "type", |
| 44 | + "value_to_extract": "value_to_extract", |
| 45 | + } |
| 46 | + |
| 47 | + def __init__( |
| 48 | + self_, |
| 49 | + key_to_extract: str, |
| 50 | + source: str, |
| 51 | + type: LogsArrayProcessorOperationExtractKeyValueType, |
| 52 | + value_to_extract: str, |
| 53 | + override_on_conflict: Union[bool, UnsetType] = unset, |
| 54 | + target: Union[str, UnsetType] = unset, |
| 55 | + **kwargs, |
| 56 | + ): |
| 57 | + """ |
| 58 | + Operation that extracts key-value pairs from a ``source`` array and stores the result in the ``target`` attribute. |
| 59 | +
|
| 60 | + :param key_to_extract: Key of the attribute in each array element that holds the name to use for the extracted attribute. |
| 61 | + :type key_to_extract: str |
| 62 | +
|
| 63 | + :param override_on_conflict: Whether to override the target element if it's already set. |
| 64 | + :type override_on_conflict: bool, optional |
| 65 | +
|
| 66 | + :param source: Attribute path of the array to extract key-value pairs from. |
| 67 | + :type source: str |
| 68 | +
|
| 69 | + :param target: Attribute that receives the extracted key-value pairs. If not specified, the extracted attributes are added at the root level of the log. |
| 70 | + :type target: str, optional |
| 71 | +
|
| 72 | + :param type: Operation type. |
| 73 | + :type type: LogsArrayProcessorOperationExtractKeyValueType |
| 74 | +
|
| 75 | + :param value_to_extract: Key of the attribute in each array element that holds the value to use for the extracted attribute. |
| 76 | + :type value_to_extract: str |
| 77 | + """ |
| 78 | + if override_on_conflict is not unset: |
| 79 | + kwargs["override_on_conflict"] = override_on_conflict |
| 80 | + if target is not unset: |
| 81 | + kwargs["target"] = target |
| 82 | + super().__init__(kwargs) |
| 83 | + |
| 84 | + self_.key_to_extract = key_to_extract |
| 85 | + self_.source = source |
| 86 | + self_.type = type |
| 87 | + self_.value_to_extract = value_to_extract |
0 commit comments