# generated by datamodel-codegen:
#   filename:  content_standards/create_content_standards_request.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

from ..core import context as context_1
from ..core import ext as ext_1
from ..enums import channels
from . import artifact


class Fail(AdCPBaseModel):
    language: Annotated[
        str | None, Field(description='BCP 47 language tag for content at this URL')
    ] = None
    type: Annotated[Literal['url'], Field(description='Indicates this is a URL reference')]
    value: Annotated[
        AnyUrl,
        Field(
            description="Full URL to a specific page (e.g., 'https://news.example.com/controversial-article')"
        ),
    ]


class Pass(AdCPBaseModel):
    language: Annotated[
        str | None, Field(description='BCP 47 language tag for content at this URL')
    ] = None
    type: Annotated[Literal['url'], Field(description='Indicates this is a URL reference')]
    value: Annotated[
        AnyUrl,
        Field(
            description="Full URL to a specific page (e.g., 'https://espn.com/nba/story/_/id/12345/lakers-win')"
        ),
    ]


class Scope(AdCPBaseModel):
    channels_any: Annotated[
        list[channels.MediaChannel] | None,
        Field(
            description='Advertising channels. Standards apply to ANY of the listed channels (OR logic).',
            min_length=1,
        ),
    ] = None
    countries_all: Annotated[
        list[str] | None,
        Field(
            description='ISO 3166-1 alpha-2 country codes. Standards apply in ALL listed countries (AND logic).',
            min_length=1,
        ),
    ] = None
    description: Annotated[
        str | None, Field(description='Human-readable description of this scope')
    ] = None
    languages_any: Annotated[
        list[str],
        Field(
            description="BCP 47 language tags (e.g., 'en', 'de', 'fr'). Standards apply to content in ANY of these languages (OR logic). Content in unlisted languages is not covered by these standards.",
            min_length=1,
        ),
    ]


class CalibrationExemplars(AdCPBaseModel):
    fail: Annotated[
        list[Fail | artifact.Artifact] | None, Field(description='Content that fails the standards')
    ] = None
    pass_: Annotated[
        list[Pass | artifact.Artifact] | None,
        Field(alias='pass', description='Content that passes the standards'),
    ] = None


class CreateContentStandardsRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    calibration_exemplars: Annotated[
        CalibrationExemplars | None,
        Field(
            description='Training/test set to calibrate policy interpretation. Use URL references for pages to be fetched and analyzed, or full artifacts for pre-extracted content.'
        ),
    ] = None
    context: context_1.ContextObject | None = None
    ext: ext_1.ExtensionObject | None = None
    policy: Annotated[
        str,
        Field(
            description='Natural language policy describing acceptable and unacceptable content contexts. Used by LLMs and human reviewers to make judgments.'
        ),
    ]
    scope: Annotated[Scope, Field(description='Where this standards configuration applies')]
