# generated by datamodel-codegen:
#   filename:  property/base_property_source.json
#   timestamp: 2026-02-23T01:56:40+00:00

from __future__ import annotations

from typing import Annotated, Literal

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

from ..core import identifier, property_id, property_tag


class BasePropertySource1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    publisher_domain: Annotated[
        str,
        Field(
            description="Domain where publisher's adagents.json is hosted (e.g., 'raptive.com')",
            pattern='^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$',
        ),
    ]
    selection_type: Annotated[
        Literal['publisher_tags'],
        Field(description='Discriminator indicating selection by property tags within a publisher'),
    ]
    tags: Annotated[
        list[property_tag.PropertyTag],
        Field(
            description="Property tags from the publisher's adagents.json. Selects all properties with these tags.",
            min_length=1,
        ),
    ]


class BasePropertySource2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    property_ids: Annotated[
        list[property_id.PropertyId],
        Field(description="Specific property IDs from the publisher's adagents.json", min_length=1),
    ]
    publisher_domain: Annotated[
        str,
        Field(
            description="Domain where publisher's adagents.json is hosted (e.g., 'raptive.com')",
            pattern='^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$',
        ),
    ]
    selection_type: Annotated[
        Literal['publisher_ids'],
        Field(
            description='Discriminator indicating selection by specific property IDs within a publisher'
        ),
    ]


class BasePropertySource3(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    identifiers: Annotated[
        list[identifier.Identifier],
        Field(description='Direct property identifiers (domains, app IDs, etc.)', min_length=1),
    ]
    selection_type: Annotated[
        Literal['identifiers'],
        Field(description='Discriminator indicating selection by direct identifiers'),
    ]


class BasePropertySource(
    RootModel[BasePropertySource1 | BasePropertySource2 | BasePropertySource3]
):
    root: Annotated[
        BasePropertySource1 | BasePropertySource2 | BasePropertySource3,
        Field(
            description='A source of properties for a property list. Supports three selection patterns: publisher with tags, publisher with property IDs, or direct identifiers.',
            discriminator='selection_type',
            title='Base Property Source',
        ),
    ]
