# generated by datamodel-codegen:
#   filename:  core/signal_pricing_option.json
#   timestamp: 2026-02-28T17:39:50+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated, Literal

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

from . import ext as ext_1


class SignalPricingOption1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    cpm: Annotated[float, Field(description='Cost per thousand impressions', ge=0.0)]
    currency: Annotated[str, Field(description='ISO 4217 currency code', pattern='^[A-Z]{3}$')]
    ext: ext_1.ExtensionObject | None = None
    model: Literal['cpm']


class SignalPricingOption2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    currency: Annotated[
        str,
        Field(description='ISO 4217 currency code for the resulting charge', pattern='^[A-Z]{3}$'),
    ]
    ext: ext_1.ExtensionObject | None = None
    max_cpm: Annotated[
        float | None,
        Field(
            description='Optional CPM cap. When set, the effective charge is min(percent × media_spend_per_mille, max_cpm).',
            ge=0.0,
        ),
    ] = None
    model: Literal['percent_of_media']
    percent: Annotated[
        float, Field(description='Percentage of media spend, e.g. 15 = 15%', ge=0.0, le=100.0)
    ]


class Period(Enum):
    monthly = 'monthly'
    quarterly = 'quarterly'
    annual = 'annual'
    campaign = 'campaign'


class SignalPricingOption3(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    amount: Annotated[float, Field(description='Fixed charge for the billing period', ge=0.0)]
    currency: Annotated[str, Field(description='ISO 4217 currency code', pattern='^[A-Z]{3}$')]
    ext: ext_1.ExtensionObject | None = None
    model: Literal['flat_fee']
    period: Annotated[Period, Field(description='Billing period for the flat fee.')]


class SignalPricingOption4(AdCPBaseModel):
    pricing_option_id: Annotated[
        str,
        Field(
            description='Opaque identifier for this pricing option, unique within the signals agent. Pass this in report_usage to identify which pricing option was applied.'
        ),
    ]


class SignalPricingOption5(SignalPricingOption1, SignalPricingOption4):
    pass


class SignalPricingOption6(SignalPricingOption2, SignalPricingOption4):
    pass


class SignalPricingOption7(SignalPricingOption3, SignalPricingOption4):
    pass


class SignalPricingOption(
    RootModel[SignalPricingOption5 | SignalPricingOption6 | SignalPricingOption7]
):
    root: Annotated[
        SignalPricingOption5 | SignalPricingOption6 | SignalPricingOption7,
        Field(
            description='A pricing option offered by a signals agent. Combines pricing_option_id with the signal pricing model fields at the same level — pass pricing_option_id in report_usage for billing verification.',
            title='Signal Pricing Option',
        ),
    ]
