# generated by datamodel-codegen:
#   filename:  media_buy/create_media_buy_request.json
#   timestamp: 2025-11-22T15:29:34+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated

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

from ..core import brand_manifest as brand_manifest_1
from ..core import context as context_1
from ..core import ext as ext_1
from ..core.push_notification_config import PushNotificationConfig
from . import package_request


class ReportingFrequency(Enum):
    hourly = 'hourly'
    daily = 'daily'
    monthly = 'monthly'


class RequestedMetric(Enum):
    impressions = 'impressions'
    spend = 'spend'
    clicks = 'clicks'
    ctr = 'ctr'
    video_completions = 'video_completions'
    completion_rate = 'completion_rate'
    conversions = 'conversions'
    viewability = 'viewability'
    engagement_rate = 'engagement_rate'


class ReportingWebhook(PushNotificationConfig):
    reporting_frequency: Annotated[
        ReportingFrequency,
        Field(
            description='Frequency for automated reporting delivery. Must be supported by all products in the media buy.'
        ),
    ]
    requested_metrics: Annotated[
        list[RequestedMetric] | None,
        Field(
            description="Optional list of metrics to include in webhook notifications. If omitted, all available metrics are included. Must be subset of product's available_metrics."
        ),
    ] = None


class CreateMediaBuyRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    brand_manifest: Annotated[
        brand_manifest_1.BrandManifest | AnyUrl,
        Field(
            description='Brand information manifest serving as the namespace and identity for this media buy. Provides brand context, assets, and product catalog. Can be provided inline or as a URL reference to a hosted manifest. Can be cached and reused across multiple requests.',
            examples=[
                {
                    'data': {
                        'colors': {'primary': '#FF6B35'},
                        'name': 'ACME Corporation',
                        'url': 'https://acmecorp.com',
                    },
                    'description': 'Inline brand manifest',
                },
                {
                    'data': 'https://cdn.acmecorp.com/brand-manifest.json',
                    'description': 'URL string reference to hosted manifest',
                },
            ],
            title='Brand Manifest Reference',
        ),
    ]
    buyer_ref: Annotated[str, Field(description="Buyer's reference identifier for this media buy")]
    context: context_1.ContextObject | None = None
    end_time: Annotated[
        AwareDatetime, Field(description='Campaign end date/time in ISO 8601 format')
    ]
    ext: ext_1.ExtensionObject | None = None
    packages: Annotated[
        list[package_request.PackageRequest], Field(description='Array of package configurations')
    ]
    po_number: Annotated[str | None, Field(description='Purchase order number for tracking')] = None
    reporting_webhook: ReportingWebhook | None = None
    start_time: Annotated[
        str | AwareDatetime,
        Field(
            description="Campaign start timing: 'asap' or ISO 8601 date-time", title='Start Timing'
        ),
    ]
