# generated by datamodel-codegen:
#   filename:  core/signal_id.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 AnyUrl, ConfigDict, Field, RootModel


class SignalId2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    data_provider_domain: Annotated[
        str,
        Field(
            description="Domain of the data provider that owns this signal (e.g., 'polk.com', 'experian.com'). The signal definition is published at this domain's /.well-known/adagents.json",
            pattern='^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$',
        ),
    ]
    id: Annotated[
        str,
        Field(
            description="Signal identifier within the data provider's catalog (e.g., 'likely_tesla_buyers', 'income_100k_plus')",
            pattern='^[a-zA-Z0-9_-]+$',
        ),
    ]
    source: Annotated[
        Literal['catalog'],
        Field(
            description="Discriminator indicating this signal is from a data provider's published catalog"
        ),
    ]


class SignalId3(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    agent_url: Annotated[
        AnyUrl,
        Field(
            description="URL of the signals agent that provides this signal (e.g., 'https://liveramp.com/.well-known/adcp/signals')"
        ),
    ]
    id: Annotated[
        str,
        Field(
            description="Signal identifier within the agent's signal set (e.g., 'custom_auto_intenders')",
            pattern='^[a-zA-Z0-9_-]+$',
        ),
    ]
    source: Annotated[
        Literal['agent'],
        Field(
            description='Discriminator indicating this signal is native to the agent (not from a data provider catalog)'
        ),
    ]


class SignalId(RootModel[SignalId2 | SignalId3]):
    root: Annotated[
        SignalId2 | SignalId3,
        Field(
            description="Universal signal identifier. Uses 'source' as discriminator: 'catalog' for signals from a data provider's published catalog (verifiable), 'agent' for agent-native signals (not externally verifiable).",
            discriminator='source',
            title='Signal ID',
        ),
    ]
