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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from .....core.pydantic_utilities import IS_PYDANTIC_V2
from .....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata
from .....types.auto_sync_info import AutoSyncInfo
from .....types.content_format import ContentFormat
from .....types.document_usage_mode_enum import DocumentUsageModeEnum
from .....types.external_file_sync_info import ExternalFileSyncInfo
from .....types.external_folder_sync_info import ExternalFolderSyncInfo
from .....types.file_refresh_status import FileRefreshStatus
from .....types.kb_external_sync_job import KbExternalSyncJob
from .....types.knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel
from .....types.knowledge_base_folder_path_segment_response_model import KnowledgeBaseFolderPathSegmentResponseModel
from .....types.resource_access_info import ResourceAccessInfo


class DocumentsGetResponse_Url(UncheckedBaseModel):
    type: typing.Literal["url"] = "url"
    id: str
    name: str
    metadata: KnowledgeBaseDocumentMetadataResponseModel
    supported_usages: typing.List[DocumentUsageModeEnum]
    access_info: ResourceAccessInfo
    folder_parent_id: typing.Optional[str] = None
    folder_path: typing.Optional[typing.List[KnowledgeBaseFolderPathSegmentResponseModel]] = None
    url: str
    extracted_inner_html: str
    content_format: typing.Optional[ContentFormat] = None
    auto_sync_info: typing.Optional[AutoSyncInfo] = 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


class DocumentsGetResponse_File(UncheckedBaseModel):
    type: typing.Literal["file"] = "file"
    id: str
    name: str
    metadata: KnowledgeBaseDocumentMetadataResponseModel
    supported_usages: typing.List[DocumentUsageModeEnum]
    access_info: ResourceAccessInfo
    folder_parent_id: typing.Optional[str] = None
    folder_path: typing.Optional[typing.List[KnowledgeBaseFolderPathSegmentResponseModel]] = None
    extracted_inner_html: str
    content_format: typing.Optional[ContentFormat] = None
    filename: str
    external_sync_info: typing.Optional[ExternalFileSyncInfo] = None
    auto_sync_info: typing.Optional[AutoSyncInfo] = None
    refresh_status: typing.Optional[FileRefreshStatus] = None
    is_frozen: typing.Optional[bool] = 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


class DocumentsGetResponse_Text(UncheckedBaseModel):
    type: typing.Literal["text"] = "text"
    id: str
    name: str
    metadata: KnowledgeBaseDocumentMetadataResponseModel
    supported_usages: typing.List[DocumentUsageModeEnum]
    access_info: ResourceAccessInfo
    folder_parent_id: typing.Optional[str] = None
    folder_path: typing.Optional[typing.List[KnowledgeBaseFolderPathSegmentResponseModel]] = None
    extracted_inner_html: str
    content_format: typing.Optional[ContentFormat] = 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


class DocumentsGetResponse_Folder(UncheckedBaseModel):
    type: typing.Literal["folder"] = "folder"
    id: str
    name: str
    metadata: KnowledgeBaseDocumentMetadataResponseModel
    supported_usages: typing.List[DocumentUsageModeEnum]
    access_info: ResourceAccessInfo
    folder_parent_id: typing.Optional[str] = None
    folder_path: typing.Optional[typing.List[KnowledgeBaseFolderPathSegmentResponseModel]] = None
    children_count: int
    document_count: int
    auto_sync_info: typing.Optional[AutoSyncInfo] = None
    external_sync_info: typing.Optional[ExternalFolderSyncInfo] = None
    is_frozen: typing.Optional[bool] = None
    active_sync_job: typing.Optional[KbExternalSyncJob] = 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


DocumentsGetResponse = typing_extensions.Annotated[
    typing.Union[
        DocumentsGetResponse_Url, DocumentsGetResponse_File, DocumentsGetResponse_Text, DocumentsGetResponse_Folder
    ],
    UnionMetadata(discriminant="type"),
]
