"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 81919086e371

from __future__ import annotations
from .filepurpose import FilePurpose
from .filevisibility import FileVisibility
from .sampletype import SampleType
from .source import Source
from mistralai.client.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing_extensions import Annotated, NotRequired, TypedDict


class GetFileResponseTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the file."""
    object: str
    r"""The object type, which is always \"file\"."""
    size_bytes: int
    r"""The size of the file, in bytes."""
    created_at: int
    r"""The UNIX timestamp (in seconds) of the event."""
    filename: str
    r"""The name of the uploaded file."""
    purpose: FilePurpose
    sample_type: SampleType
    source: Source
    deleted: bool
    num_lines: NotRequired[Nullable[int]]
    mimetype: NotRequired[Nullable[str]]
    signature: NotRequired[Nullable[str]]
    expires_at: NotRequired[Nullable[int]]
    visibility: NotRequired[Nullable[FileVisibility]]


class GetFileResponse(BaseModel):
    id: str
    r"""The unique identifier of the file."""

    object: str
    r"""The object type, which is always \"file\"."""

    size_bytes: Annotated[int, pydantic.Field(alias="bytes")]
    r"""The size of the file, in bytes."""

    created_at: int
    r"""The UNIX timestamp (in seconds) of the event."""

    filename: str
    r"""The name of the uploaded file."""

    purpose: FilePurpose

    sample_type: SampleType

    source: Source

    deleted: bool

    num_lines: OptionalNullable[int] = UNSET

    mimetype: OptionalNullable[str] = UNSET

    signature: OptionalNullable[str] = UNSET

    expires_at: OptionalNullable[int] = UNSET

    visibility: OptionalNullable[FileVisibility] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["num_lines", "mimetype", "signature", "expires_at", "visibility"]
        )
        nullable_fields = set(
            ["num_lines", "mimetype", "signature", "expires_at", "visibility"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


try:
    GetFileResponse.model_rebuild()
except NameError:
    pass
