# generated by datamodel-codegen:
#   filename:  media_buy/get_media_buys_request.json
#   timestamp: 2026-02-27T02:10:10+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 account_ref
from ..core import context as context_1
from ..core import ext as ext_1
from ..core import pagination_request
from ..enums import media_buy_status


class StatusFilter(RootModel[list[media_buy_status.MediaBuyStatus]]):
    root: Annotated[
        list[media_buy_status.MediaBuyStatus],
        Field(
            description='Filter by status. Can be a single status or array of statuses. Defaults to ["active"] only when media_buy_ids and buyer_refs are both omitted. When media_buy_ids or buyer_refs are provided, no implicit status filter is applied.',
            min_length=1,
        ),
    ]


class GetMediaBuysRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    account: Annotated[
        account_ref.AccountReference, Field(description='Account to retrieve media buys for.')
    ]
    buyer_refs: Annotated[
        list[str] | None,
        Field(description='Array of buyer reference IDs to retrieve', min_length=1),
    ] = None
    context: context_1.ContextObject | None = None
    ext: ext_1.ExtensionObject | None = None
    include_snapshot: Annotated[
        bool | None,
        Field(
            description='When true, include a near-real-time delivery snapshot for each package. Snapshots reflect the latest available entity-level stats from the platform (e.g., updated every ~15 minutes on GAM, ~1 hour on batch-only platforms). The staleness_seconds field on each snapshot indicates data freshness. If a snapshot cannot be returned, package.snapshot_unavailable_reason explains why. Defaults to false.'
        ),
    ] = False
    media_buy_ids: Annotated[
        list[str] | None,
        Field(
            description='Array of publisher media buy IDs to retrieve. When omitted along with buyer_refs, returns a paginated set of accessible media buys matching status_filter.',
            min_length=1,
        ),
    ] = None
    pagination: Annotated[
        pagination_request.PaginationRequest | None,
        Field(
            description='Cursor-based pagination controls. Strongly recommended when querying broad scopes (for example, all active media buys in an account).'
        ),
    ] = None
    status_filter: Annotated[
        media_buy_status.MediaBuyStatus | StatusFilter | None,
        Field(
            description='Filter by status. Can be a single status or array of statuses. Defaults to ["active"] only when media_buy_ids and buyer_refs are both omitted. When media_buy_ids or buyer_refs are provided, no implicit status filter is applied.'
        ),
    ] = None
