# generated by datamodel-codegen:
#   filename:  list-authorized-properties-response.json
#   timestamp: 2025-11-15T22:03:55+00:00

from __future__ import annotations

from typing import Annotated, Any

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

from . import channels, error


class PrimaryCountry(RootModel[str]):
    root: Annotated[str, Field(pattern="^[A-Z]{2}$")]


class PublisherDomain(RootModel[str]):
    root: Annotated[
        str,
        Field(
            description="Domain where publisher's adagents.json is hosted (e.g., 'cnn.com')",
            pattern="^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$",
        ),
    ]


class ListAuthorizedPropertiesResponse(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    advertising_policies: Annotated[
        str | None,
        Field(
            description="Publisher's advertising content policies, restrictions, and guidelines in natural language. May include prohibited categories, blocked advertisers, restricted tactics, brand safety requirements, or links to full policy documentation.",
            max_length=10000,
            min_length=1,
        ),
    ] = None
    context: Annotated[
        dict[str, Any] | None,
        Field(
            description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers."
        ),
    ] = None
    errors: Annotated[
        list[error.Error] | None,
        Field(description="Task-specific errors and warnings (e.g., property availability issues)"),
    ] = None
    last_updated: Annotated[
        AwareDatetime | None,
        Field(
            description="ISO 8601 timestamp of when the agent's publisher authorization list was last updated. Buyers can use this to determine if their cached publisher adagents.json files might be stale."
        ),
    ] = None
    portfolio_description: Annotated[
        str | None,
        Field(
            description="Markdown-formatted description of the property portfolio, including inventory types, audience characteristics, and special features.",
            max_length=5000,
            min_length=1,
        ),
    ] = None
    primary_channels: Annotated[
        list[channels.AdvertisingChannels] | None,
        Field(
            description="Primary advertising channels represented in this property portfolio. Helps buying agents quickly filter relevance.",
            min_length=1,
        ),
    ] = None
    primary_countries: Annotated[
        list[PrimaryCountry] | None,
        Field(
            description="Primary countries (ISO 3166-1 alpha-2 codes) where properties are concentrated. Helps buying agents quickly filter relevance.",
            min_length=1,
        ),
    ] = None
    publisher_domains: Annotated[
        list[PublisherDomain],
        Field(
            description="Publisher domains this agent is authorized to represent. Buyers should fetch each publisher's adagents.json to see property definitions and verify this agent is in their authorized_agents list with authorization scope.",
            min_length=1,
        ),
    ]
