# generated by datamodel-codegen:
#   filename:  media_buy/update_media_buy_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 AwareDatetime, ConfigDict, Field, RootModel

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


class UpdateMediaBuyResponse2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    errors: Annotated[
        list[error.Error],
        Field(description='Array of errors explaining why the operation failed', min_length=1),
    ]
    ext: ext_1.ExtensionObject | None = None


class UpdateMediaBuyResponse1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    affected_packages: Annotated[
        list[package.Package] | None,
        Field(description='Array of packages that were modified with complete state information'),
    ] = None
    buyer_ref: Annotated[str, Field(description="Buyer's reference identifier for the media buy")]
    context: context_1.ContextObject | None = None
    ext: ext_1.ExtensionObject | None = None
    implementation_date: Annotated[
        AwareDatetime | None,
        Field(description='ISO 8601 timestamp when changes take effect (null if pending approval)'),
    ] = None
    media_buy_id: Annotated[str, Field(description="Publisher's identifier for the media buy")]
    sandbox: Annotated[
        bool | None,
        Field(description='When true, this response contains simulated data from sandbox mode.'),
    ] = None


class UpdateMediaBuyResponse(RootModel[UpdateMediaBuyResponse1 | UpdateMediaBuyResponse2]):
    root: Annotated[
        UpdateMediaBuyResponse1 | UpdateMediaBuyResponse2,
        Field(
            description='Response payload for update_media_buy task. Returns either complete success data OR error information, never both. This enforces atomic operation semantics - updates are either fully applied or not applied at all.',
            title='Update Media Buy Response',
        ),
    ]
