# generated by datamodel-codegen:
#   filename:  media_buy/log_event_response.json
#   timestamp: 2026-02-23T01:56:40+00:00

from __future__ import annotations

from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import ConfigDict, Field, RootModel

from ..core import context as context_1
from ..core import error
from ..core import ext as ext_1


class PartialFailure(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    code: Annotated[str, Field(description='Error code')]
    event_id: Annotated[str, Field(description='ID of the failed event')]
    message: Annotated[str, Field(description='Human-readable error message')]


class LogEventResponse1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    events_processed: Annotated[
        int, Field(description='Number of events successfully queued for processing', ge=0)
    ]
    events_received: Annotated[int, Field(description='Number of events received', ge=0)]
    ext: ext_1.ExtensionObject | None = None
    match_quality: Annotated[
        float | None,
        Field(
            description='Overall match quality score for the batch (0.0 = no matches, 1.0 = all matched)',
            ge=0.0,
            le=1.0,
        ),
    ] = None
    partial_failures: Annotated[
        list[PartialFailure] | None, Field(description='Events that failed validation')
    ] = None
    sandbox: Annotated[
        bool | None,
        Field(description='When true, this response contains simulated data from sandbox mode.'),
    ] = None
    warnings: Annotated[
        list[str] | None,
        Field(
            description='Non-fatal issues (low match quality, missing recommended fields, deprecation notices)'
        ),
    ] = None


class LogEventResponse2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    errors: Annotated[list[error.Error], Field(description='Operation-level errors', min_length=1)]
    ext: ext_1.ExtensionObject | None = None


class LogEventResponse(RootModel[LogEventResponse1 | LogEventResponse2]):
    root: Annotated[
        LogEventResponse1 | LogEventResponse2,
        Field(
            description='Response from event logging operation. Returns either event processing results OR operation-level errors.',
            title='Log Event Response',
        ),
    ]
