# generated by datamodel-codegen:
#   filename:  property.json
#   timestamp: 2025-11-15T22:03:55+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated

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

from . import identifier_types


class Identifier(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    type: Annotated[
        identifier_types.PropertyIdentifierTypes,
        Field(description="Type of identifier for this property"),
    ]
    value: Annotated[
        str,
        Field(
            description="The identifier value. For domain type: 'example.com' matches base domain plus www and m subdomains; 'edition.example.com' matches that specific subdomain; '*.example.com' matches ALL subdomains but NOT base domain"
        ),
    ]


class PropertyType(Enum):
    website = "website"
    mobile_app = "mobile_app"
    ctv_app = "ctv_app"
    dooh = "dooh"
    podcast = "podcast"
    radio = "radio"
    streaming_audio = "streaming_audio"


class Tag(RootModel[str]):
    root: Annotated[
        str,
        Field(
            description="Lowercase tag with underscores (e.g., 'conde_nast_network', 'premium_content')",
            pattern="^[a-z0-9_]+$",
        ),
    ]


class Property(AdCPBaseModel):
    model_config = ConfigDict(
        extra="forbid",
    )
    identifiers: Annotated[
        list[Identifier], Field(description="Array of identifiers for this property", min_length=1)
    ]
    name: Annotated[str, Field(description="Human-readable property name")]
    property_id: Annotated[
        str | None,
        Field(
            description="Unique identifier for this property (optional). Enables referencing properties by ID instead of repeating full objects. Recommended format: lowercase with underscores (e.g., 'cnn_ctv_app', 'instagram_mobile')",
            pattern="^[a-z0-9_]+$",
        ),
    ] = None
    property_type: Annotated[PropertyType, Field(description="Type of advertising property")]
    publisher_domain: Annotated[
        str | None,
        Field(
            description="Domain where adagents.json should be checked for authorization validation. Required for list_authorized_properties response. Optional in adagents.json (file location implies domain)."
        ),
    ] = None
    tags: Annotated[
        list[Tag] | None,
        Field(
            description="Tags for categorization and grouping (e.g., network membership, content categories)"
        ),
    ] = None
