# 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 .auto_sync_info import AutoSyncInfo
from .document_usage_mode_enum import DocumentUsageModeEnum
from .external_file_sync_info import ExternalFileSyncInfo
from .external_folder_sync_info import ExternalFolderSyncInfo
from .get_knowledge_base_summary_file_response_model_dependent_agents_item import (
    GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem,
)
from .get_knowledge_base_summary_folder_response_model_dependent_agents_item import (
    GetKnowledgeBaseSummaryFolderResponseModelDependentAgentsItem,
)
from .get_knowledge_base_summary_text_response_model_dependent_agents_item import (
    GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem,
)
from .get_knowledge_base_summary_url_response_model_dependent_agents_item import (
    GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem,
)
from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel
from .knowledge_base_folder_path_segment_summary_response_model import (
    KnowledgeBaseFolderPathSegmentSummaryResponseModel,
)
from .resource_access_info import ResourceAccessInfo


class KnowledgeBaseContentSearchResultDocument_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[KnowledgeBaseFolderPathSegmentSummaryResponseModel]] = None
    dependent_agents: typing.List[GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem]
    external_sync_info: typing.Optional[ExternalFileSyncInfo] = 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 KnowledgeBaseContentSearchResultDocument_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[KnowledgeBaseFolderPathSegmentSummaryResponseModel]] = None
    dependent_agents: typing.List[GetKnowledgeBaseSummaryFolderResponseModelDependentAgentsItem]
    children_count: int
    auto_sync_info: typing.Optional[AutoSyncInfo] = None
    external_sync_info: typing.Optional[ExternalFolderSyncInfo] = 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 KnowledgeBaseContentSearchResultDocument_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[KnowledgeBaseFolderPathSegmentSummaryResponseModel]] = None
    dependent_agents: typing.List[GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem]

    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 KnowledgeBaseContentSearchResultDocument_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[KnowledgeBaseFolderPathSegmentSummaryResponseModel]] = None
    dependent_agents: typing.List[GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem]
    url: str
    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


KnowledgeBaseContentSearchResultDocument = typing_extensions.Annotated[
    typing.Union[
        KnowledgeBaseContentSearchResultDocument_File,
        KnowledgeBaseContentSearchResultDocument_Folder,
        KnowledgeBaseContentSearchResultDocument_Text,
        KnowledgeBaseContentSearchResultDocument_Url,
    ],
    UnionMetadata(discriminant="type"),
]
