# generated by datamodel-codegen:
#   filename:  tasks-list-request.json
#   timestamp: 2025-11-18T03:35:10+00:00

from __future__ import annotations

from enum import Enum
from typing import Annotated, Any

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

from . import task_status
from . import task_type as task_type_1


class Domain(Enum):
    media_buy = 'media-buy'
    signals = 'signals'


class Filters(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    context_contains: Annotated[
        str | None,
        Field(
            description='Filter tasks where context contains this text (searches buyer_ref, media_buy_id, signal_id, etc.)'
        ),
    ] = None
    created_after: Annotated[
        AwareDatetime | None, Field(description='Filter tasks created after this date (ISO 8601)')
    ] = None
    created_before: Annotated[
        AwareDatetime | None, Field(description='Filter tasks created before this date (ISO 8601)')
    ] = None
    domain: Annotated[Domain | None, Field(description='Filter by single AdCP domain')] = None
    domains: Annotated[
        list[Domain] | None, Field(description='Filter by multiple AdCP domains')
    ] = None
    has_webhook: Annotated[
        bool | None, Field(description='Filter tasks that have webhook configuration when true')
    ] = None
    status: Annotated[
        task_status.TaskStatus | None, Field(description='Filter by single task status')
    ] = None
    statuses: Annotated[
        list[task_status.TaskStatus] | None, Field(description='Filter by multiple task statuses')
    ] = None
    task_ids: Annotated[
        list[str] | None, Field(description='Filter by specific task IDs', max_length=100)
    ] = None
    task_type: Annotated[
        task_type_1.TaskType | None, Field(description='Filter by single task type')
    ] = None
    task_types: Annotated[
        list[task_type_1.TaskType] | None, Field(description='Filter by multiple task types')
    ] = None
    updated_after: Annotated[
        AwareDatetime | None,
        Field(description='Filter tasks last updated after this date (ISO 8601)'),
    ] = None
    updated_before: Annotated[
        AwareDatetime | None,
        Field(description='Filter tasks last updated before this date (ISO 8601)'),
    ] = None


class Pagination(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    limit: Annotated[
        int | None, Field(description='Maximum number of tasks to return', ge=1, le=100)
    ] = 50
    offset: Annotated[int | None, Field(description='Number of tasks to skip', ge=0)] = 0


class Direction(Enum):
    asc = 'asc'
    desc = 'desc'


class Field1(Enum):
    created_at = 'created_at'
    updated_at = 'updated_at'
    status = 'status'
    task_type = 'task_type'
    domain = 'domain'


class Sort(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    direction: Annotated[Direction | None, Field(description='Sort direction')] = Direction.desc
    field: Annotated[Field1 | None, Field(description='Field to sort by')] = Field1.created_at


class TasksListRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    context: Annotated[
        dict[str, Any] | None,
        Field(
            description='Initiator-provided context included in the request payload. Agents must echo this value back unchanged in responses and webhooks. Use for UI/session hints, correlation tokens, or tracking metadata.'
        ),
    ] = None
    filters: Annotated[Filters | None, Field(description='Filter criteria for querying tasks')] = (
        None
    )
    include_history: Annotated[
        bool | None,
        Field(
            description='Include full conversation history for each task (may significantly increase response size)'
        ),
    ] = False
    pagination: Annotated[Pagination | None, Field(description='Pagination parameters')] = None
    sort: Annotated[Sort | None, Field(description='Sorting parameters')] = None
