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

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .ifta_detail_job_args_response_body import IftaDetailJobArgsResponseBody
from .ifta_detail_job_output_response_body import IftaDetailJobOutputResponseBody
from .ifta_detail_job_response_body_job_status import IftaDetailJobResponseBodyJobStatus


class IftaDetailJobResponseBody(UniversalBaseModel):
    """
    A job representing the async generation of IFTA mileage segments. The job should be polled until the state is terminal.
    """

    args: IftaDetailJobArgsResponseBody
    completed_at_time: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="completedAtTime"),
        pydantic.Field(alias="completedAtTime", description=" The time this job completed successfully."),
    ] = None
    details: typing.Optional[str] = pydantic.Field(default=None)
    """
    A message containing additional details about the job, if available.
    """

    failed_at_time: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="failedAtTime"),
        pydantic.Field(alias="failedAtTime", description=" The time this job failed."),
    ] = None
    files: typing.Optional[typing.List[IftaDetailJobOutputResponseBody]] = pydantic.Field(default=None)
    """
    A list of files generated by this job. This field will be omitted when the job status is "Failed" or no data exists with the provided job arguments. Read about the file structure [here](https://developers.samsara.com/docs/ifta-detail-csv).
    """

    job_id: typing_extensions.Annotated[
        str,
        FieldMetadata(alias="jobId"),
        pydantic.Field(alias="jobId", description=" The ID used to retrieve this job."),
    ]
    job_status: typing_extensions.Annotated[
        IftaDetailJobResponseBodyJobStatus,
        FieldMetadata(alias="jobStatus"),
        pydantic.Field(
            alias="jobStatus",
            description=" The status of this job. `jobStatus` can be one of Requested, Processing, Completed, or Failed.  Valid values: `Requested`, `Processing`, `Completed`, `Failed`",
        ),
    ]
    requested_at_time: typing_extensions.Annotated[
        str,
        FieldMetadata(alias="requestedAtTime"),
        pydantic.Field(alias="requestedAtTime", description=" The time this job was requested for creation."),
    ]
    started_at_time: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="startedAtTime"),
        pydantic.Field(alias="startedAtTime", description=" The time this job started processing."),
    ] = None

    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
