# generated by datamodel-codegen:
#   filename:  content_standards/get_media_buy_artifacts_request.json
#   timestamp: 2026-02-27T02:10:10+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated

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

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


class Pagination(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    cursor: Annotated[
        str | None,
        Field(description='Opaque cursor from a previous response to fetch the next page'),
    ] = None
    max_results: Annotated[
        int | None,
        Field(description='Maximum number of artifacts to return per page', ge=1, le=10000),
    ] = 1000


class Method(Enum):
    random = 'random'
    stratified = 'stratified'
    recent = 'recent'
    failures_only = 'failures_only'


class Sampling(AdCPBaseModel):
    method: Annotated[Method | None, Field(description='How to select the sample')] = None
    rate: Annotated[
        float | None,
        Field(
            description='Sampling rate (0-1). 1.0 = all deliveries, 0.25 = 25% sample.',
            ge=0.0,
            le=1.0,
        ),
    ] = None


class TimeRange(AdCPBaseModel):
    end: Annotated[AwareDatetime | None, Field(description='End of time range (exclusive)')] = None
    start: Annotated[AwareDatetime | None, Field(description='Start of time range (inclusive)')] = (
        None
    )


class GetMediaBuyArtifactsRequest(AdCPBaseModel):
    account: Annotated[
        account_ref.AccountReference | None,
        Field(
            description='Filter artifacts to a specific account. When omitted, returns artifacts across all accessible accounts.'
        ),
    ] = None
    context: context_1.ContextObject | None = None
    ext: ext_1.ExtensionObject | None = None
    media_buy_id: Annotated[str, Field(description='Media buy to get artifacts from')]
    package_ids: Annotated[
        list[str] | None,
        Field(description='Filter to specific packages within the media buy', min_length=1),
    ] = None
    pagination: Annotated[
        Pagination | None,
        Field(
            description='Pagination parameters. Uses higher limits than standard pagination because artifact result sets can be very large.'
        ),
    ] = None
    sampling: Annotated[
        Sampling | None,
        Field(
            description='Sampling parameters. Defaults to the sampling rate agreed in the media buy.'
        ),
    ] = None
    time_range: Annotated[TimeRange | None, Field(description='Filter to specific time period')] = (
        None
    )
