# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata


class OtlpAttributeValue(UniversalBaseModel):
    """
    OTLP attribute value supporting multiple types.

    Per OTLP JSON spec, intValue is transmitted as a string to avoid JSON number
    precision issues with int64 values. We validate that the string represents
    a valid integer and provide a helper property to get the actual int value.

    String values are limited to MAX_ATTRIBUTE_VALUE_LENGTH (4KB) to prevent
    memory exhaustion and ClickHouse insert failures.
    """

    array_value: typing_extensions.Annotated[
        typing.Optional[typing.Dict[str, typing.Any]], FieldMetadata(alias="arrayValue")
    ] = pydantic.Field(alias="arrayValue", default=None)
    bool_value: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="boolValue")] = pydantic.Field(
        alias="boolValue", default=None
    )
    bytes_value: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="bytesValue")] = pydantic.Field(
        alias="bytesValue", default=None
    )
    double_value: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="doubleValue")] = (
        pydantic.Field(alias="doubleValue", default=None)
    )
    int_value: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="intValue")] = pydantic.Field(
        alias="intValue", default=None
    )
    string_value: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="stringValue")] = (
        pydantic.Field(alias="stringValue", default=None)
    )

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
