# This file was auto-generated by Fern from our API Definition.

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .analyze_task_error import AnalyzeTaskError
from .analyze_task_result import AnalyzeTaskResult
from .analyze_task_status import AnalyzeTaskStatus
from .analyze_task_webhook_info import AnalyzeTaskWebhookInfo


class AnalyzeTaskResponse(UniversalBaseModel):
    """
    Represents the status and results of an analysis task.
    """

    task_id: str = pydantic.Field()
    """
    The unique identifier of the analysis task.
    """

    status: AnalyzeTaskStatus
    created_at: dt.datetime = pydantic.Field()
    """
    A string representing the date and time, in RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the analysis task was created.
    """

    completed_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    A string representing the date and time, in RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the analysis task was completed or failed. The platform returns this field only if `status` is `ready` or `failed`.
    """

    result: typing.Optional[AnalyzeTaskResult] = pydantic.Field(default=None)
    """
    An object that contains the generated text and additional information. The platform returns this object only when `status` is `ready`.
    """

    error: typing.Optional[AnalyzeTaskError] = pydantic.Field(default=None)
    """
    Details about why the task failed. The platform returns this object only when `status` is `failed`.
    """

    webhooks: typing.Optional[typing.List[AnalyzeTaskWebhookInfo]] = pydantic.Field(default=None)
    """
    The delivery status of each webhook endpoint. The platform omits this field when no webhooks are configured. You can register webhooks through the Playground. See the [Webhooks](/v1.3/docs/advanced/webhooks) page for details.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
