# 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
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .created_at import CreatedAt
from .file_contents import FileContents
from .file_metadata import FileMetadata
from .file_type import FileType
from .updated_at import UpdatedAt


class File(UncheckedBaseModel):
    object: typing.Literal["file"] = pydantic.Field(default="file")
    """
    The type of object. Will always be `"file"`.
    """

    id: str = pydantic.Field()
    """
    ID for the file.
    
    Example: `"file_xK9mLPqRtN3vS8wF5hB2cQ"`
    """

    name: str = pydantic.Field()
    """
    The name of the file
    
    Example: `"Invoices.pdf"`
    """

    type: typing.Optional[FileType] = pydantic.Field(default=None)
    """
    The type of the file.
    
    **Availability:** Present when the file type could be determined.
    """

    presigned_url: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="presignedUrl")] = (
        pydantic.Field(alias="presignedUrl", default=None)
    )
    """
    A presigned URL to download the file. Expires after 15 minutes.
    
    **Availability:** Present on `GET /files/{id}`. Not present on `POST /files/upload` or when the file is embedded in other resources (e.g., in run responses).
    """

    parent_file_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="parentFileId")] = (
        pydantic.Field(alias="parentFileId", default=None)
    )
    """
    ID of the parent file.
    
    **Availability:** Present for files created via a Splitter in a workflow.
    """

    contents: typing.Optional[FileContents] = pydantic.Field(default=None)
    """
    **Deprecated:** Use the `POST /parse_runs` endpoint instead to parse and retrieve file contents. The parse runs endpoint provides more control over parsing configuration and better performance.
    
    The parsed content of the file. This field will only contain data after the file has been parsed via a parse run, extract run, classify run, split run, edit run, or workflow run.
    
    **Availability:** Only present and populated on `GET /files/{id}` when the file has been previously parsed and the corresponding query parameters are set to true. Will be `null` on `POST /files/upload` and for files that haven't been parsed. The structure varies based on file type.
    """

    metadata: FileMetadata
    created_at: typing_extensions.Annotated[CreatedAt, FieldMetadata(alias="createdAt")] = pydantic.Field(
        alias="createdAt"
    )
    updated_at: typing_extensions.Annotated[UpdatedAt, FieldMetadata(alias="updatedAt")] = pydantic.Field(
        alias="updatedAt"
    )

    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
