# 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 .chunk_info_status import ChunkInfoStatus
from .updated_at import UpdatedAt


class ChunkInfo(UniversalBaseModel):
    index: typing.Optional[int] = pydantic.Field(default=None)
    """
    The index of the chunk. The platform uses 1-based indexing, and this value matches the value of the [`chunk_index`](/v1.3/api-reference/upload-content/multipart-uploads/create#response.body.upload_urls.chunk_index) field in the list of upload URLs.
    """

    status: typing.Optional[ChunkInfoStatus] = pydantic.Field(default=None)
    """
    The current status of this chunk. This field can take one of the following values:
    - `completed`: Successfully uploaded and reported.
    - `pending`: Not yet reported. A chunk may be in this status if it has been uploaded but not yet reported.
    - `failed`: The upload process failed; you must retry uploading this chunk.
    """

    uploaded_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The date and time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when this chunk was successfully reported as uploaded. The value of this field is `null` for pending or failed chunks.
    """

    updated_at: typing.Optional[UpdatedAt] = None
    error: typing.Optional[str] = pydantic.Field(default=None)
    """
    A detailed error message explaining why this chunk failed. The platform returns this field only when the status is failed.
    """

    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
