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

import datetime as dt
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 .knowledge_base_item_item_type import KnowledgeBaseItemItemType
from .knowledge_base_item_processing_status import KnowledgeBaseItemProcessingStatus


class KnowledgeBaseItem(UncheckedBaseModel):
    id: typing_extensions.Annotated[
        str,
        FieldMetadata(alias="_id"),
        pydantic.Field(alias="_id", description="The unique identifier for the knowledge base item"),
    ]
    item_type: typing_extensions.Annotated[
        KnowledgeBaseItemItemType,
        FieldMetadata(alias="itemType"),
        pydantic.Field(alias="itemType", description="The type of the knowledge base item"),
    ]
    metadata: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Additional metadata for the item
    """

    knowledge_base_id: typing_extensions.Annotated[
        str,
        FieldMetadata(alias="knowledgeBaseId"),
        pydantic.Field(alias="knowledgeBaseId", description="The ID of the knowledge base this item belongs to"),
    ]
    processing_status: typing_extensions.Annotated[
        KnowledgeBaseItemProcessingStatus,
        FieldMetadata(alias="processingStatus"),
        pydantic.Field(alias="processingStatus", description="The processing status of the item"),
    ]
    file_name: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="fileName"),
        pydantic.Field(alias="fileName", description="The name of the file (for file type items)"),
    ] = None
    content_type: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="contentType"),
        pydantic.Field(alias="contentType", description="The MIME type of the content"),
    ] = None
    size: typing.Optional[float] = pydantic.Field(default=None)
    """
    The size of the file in bytes
    """

    key: typing.Optional[str] = pydantic.Field(default=None)
    """
    The storage key for the file
    """

    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    The title of the item
    """

    content: typing.Optional[str] = pydantic.Field(default=None)
    """
    The content of the item (for text type items)
    """

    created_at: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="createdAt"),
        pydantic.Field(alias="createdAt", description="The date and time when the item was created"),
    ]
    updated_at: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="updatedAt"),
        pydantic.Field(alias="updatedAt", description="The date and time when the item was last updated"),
    ]

    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
