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

from __future__ import annotations

from typing import Annotated

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

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


class UsageItem(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    account: Annotated[
        account_ref.AccountReference, Field(description='Account for this usage record.')
    ]
    buyer_campaign_ref: Annotated[
        str | None,
        Field(
            description="The buyer's campaign reference (e.g., a media_buy_id). Used to group records by campaign."
        ),
    ] = None
    currency: Annotated[str, Field(description='ISO 4217 currency code.', pattern='^[A-Z]{3}$')]
    impressions: Annotated[
        int | None, Field(description='Impressions delivered using this vendor service.', ge=0)
    ] = None
    media_spend: Annotated[
        float | None,
        Field(
            description='Media spend in currency for the period. Required when a percent_of_media pricing model was used, so the vendor can verify the applied rate.',
            ge=0.0,
        ),
    ] = None
    pricing_option_id: Annotated[
        str | None,
        Field(
            description="Pricing option identifier from the vendor's discovery response (e.g., get_signals, list_content_standards). The vendor uses this to verify the correct rate was applied."
        ),
    ] = None
    signal_agent_segment_id: Annotated[
        str | None,
        Field(description='Signal identifier from get_signals. Required for signals agents.'),
    ] = None
    standards_id: Annotated[
        str | None,
        Field(
            description='Content standards configuration identifier. Required for governance agents.'
        ),
    ] = None
    vendor_cost: Annotated[
        float,
        Field(
            description='Amount owed to the vendor for this record, denominated in currency.',
            ge=0.0,
        ),
    ]


class ReportUsageRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    context: context_1.ContextObject | None = None
    ext: ext_1.ExtensionObject | None = None
    idempotency_key: Annotated[
        str | None,
        Field(
            description='Client-generated unique key for this request. If a request with the same key has already been accepted, the server returns the original response without re-processing. Use a UUID or other unique identifier. Prevents duplicate billing on retries.'
        ),
    ] = None
    reporting_period: Annotated[
        datetime_range.DatetimeRange,
        Field(
            description='The time range covered by this usage report. Applies to all records in the request.'
        ),
    ]
    usage: Annotated[
        list[UsageItem],
        Field(
            description='One or more usage records. Each record is self-contained: it carries its own account and buyer_campaign_ref, allowing a single request to span multiple accounts and campaigns.',
            min_length=1,
        ),
    ]
