# generated by datamodel-codegen:
#   filename:  media_buy/create_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 account as account_1
from ..core import context as context_1
from ..core import error
from ..core import ext as ext_1
from ..core import package


class CreateMediaBuyResponse2(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 CreateMediaBuyResponse1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    account: Annotated[
        account_1.Account | None,
        Field(
            description='Account billed for this media buy. Includes advertiser, billing proxy (if any), and rate card applied.'
        ),
    ] = None
    buyer_campaign_ref: Annotated[
        str | None, Field(description="Buyer's campaign reference label, echoed from the request")
    ] = None
    buyer_ref: Annotated[str, Field(description="Buyer's reference identifier for this media buy")]
    context: context_1.ContextObject | None = None
    creative_deadline: Annotated[
        AwareDatetime | None, Field(description='ISO 8601 timestamp for creative upload deadline')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    media_buy_id: Annotated[
        str, Field(description="Publisher's unique identifier for the created media buy")
    ]
    packages: Annotated[
        list[package.Package],
        Field(description='Array of created packages with complete state information'),
    ]
    sandbox: Annotated[
        bool | None,
        Field(description='When true, this response contains simulated data from sandbox mode.'),
    ] = None


class CreateMediaBuyResponse(RootModel[CreateMediaBuyResponse1 | CreateMediaBuyResponse2]):
    root: Annotated[
        CreateMediaBuyResponse1 | CreateMediaBuyResponse2,
        Field(
            description='Response payload for create_media_buy task. Returns either complete success data OR error information, never both. This enforces atomic operation semantics - the media buy is either fully created or not created at all.',
            title='Create Media Buy Response',
        ),
    ]
