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

import datetime as dt
import typing

from ..commons.types.entity_id import EntityId
from ..commons.types.entity_id_base import EntityIdBase
from ..commons.types.entity_id_without_agent import EntityIdWithoutAgent
from ..commons.types.precondition import Precondition
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawKnowledgeClient, RawKnowledgeClient
from .types.knowledge_base_response import KnowledgeBaseResponse
from .types.knowledge_base_version import KnowledgeBaseVersion
from .types.knowledge_base_version_finalize_status import KnowledgeBaseVersionFinalizeStatus
from .types.knowledge_base_version_status import KnowledgeBaseVersionStatus
from .types.knowledge_base_version_type import KnowledgeBaseVersionType
from .types.knowledge_document_content_type import KnowledgeDocumentContentType
from .types.knowledge_document_response import KnowledgeDocumentResponse

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class KnowledgeClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawKnowledgeClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawKnowledgeClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawKnowledgeClient
        """
        return self._raw_client

    def create_or_update_knowledge_base(
        self,
        *,
        knowledge_base_id: EntityIdBase,
        name: str,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        precondition: typing.Optional[Precondition] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseResponse:
        """
        Update a knowledge base or create it if it doesn't exist.

        Parameters
        ----------
        knowledge_base_id : EntityIdBase
            ID that uniquely identifies this knowledge base

        name : str
            The name of the knowledge base

        metadata : typing.Optional[typing.Dict[str, str]]
            Metadata for the knowledge base.

        precondition : typing.Optional[Precondition]
            (Beta) The preconditions that must be met for knowledge base be relevant to a conversation. Can be used to limit knowledge to certain types of users.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseResponse

        Examples
        --------
        from mavenagi import MavenAGI
        from mavenagi.commons import EntityIdBase

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.create_or_update_knowledge_base(
            knowledge_base_id=EntityIdBase(
                reference_id="help-center",
            ),
            name="Help center",
        )
        """
        _response = self._raw_client.create_or_update_knowledge_base(
            knowledge_base_id=knowledge_base_id,
            name=name,
            metadata=metadata,
            precondition=precondition,
            request_options=request_options,
        )
        return _response.data

    def get_knowledge_base(
        self, knowledge_base_reference_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeBaseResponse:
        """
        Get an existing knowledge base by its supplied ID

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to get. All other entity ID fields are inferred from the request.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseResponse

        Examples
        --------
        from mavenagi import MavenAGI

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.get_knowledge_base(
            knowledge_base_reference_id="help-center",
        )
        """
        _response = self._raw_client.get_knowledge_base(knowledge_base_reference_id, request_options=request_options)
        return _response.data

    def create_knowledge_base_version(
        self,
        knowledge_base_reference_id: str,
        *,
        version_id: EntityId,
        type: KnowledgeBaseVersionType,
        status: KnowledgeBaseVersionStatus,
        error_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseVersion:
        """
        Create a new knowledge base version.

        If an existing version is in progress, then that version will be finalized in an error state.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to create a version for. All other entity ID fields are inferred from the request.

        version_id : EntityId
            The unique ID of the knowledge base version.

        type : KnowledgeBaseVersionType
            Indicates whether the completed version constitutes a full or partial refresh of the knowledge base. Deleting and updating documents is only supported for partial refreshes.

        status : KnowledgeBaseVersionStatus
            The status of the knowledge base version

        error_message : typing.Optional[str]
            A user-facing error message that provides more details about a version failure.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseVersion

        Examples
        --------
        from mavenagi import MavenAGI
        from mavenagi.commons import EntityId

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.create_knowledge_base_version(
            knowledge_base_reference_id="help-center",
            version_id=EntityId(
                type="KNOWLEDGE_BASE_VERSION",
                reference_id="versionId",
                app_id="maven",
                organization_id="acme",
                agent_id="support",
            ),
            type="FULL",
            status="IN_PROGRESS",
        )
        """
        _response = self._raw_client.create_knowledge_base_version(
            knowledge_base_reference_id,
            version_id=version_id,
            type=type,
            status=status,
            error_message=error_message,
            request_options=request_options,
        )
        return _response.data

    def finalize_knowledge_base_version(
        self,
        knowledge_base_reference_id: str,
        *,
        version_id: typing.Optional[EntityIdWithoutAgent] = OMIT,
        status: typing.Optional[KnowledgeBaseVersionFinalizeStatus] = OMIT,
        error_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseVersion:
        """
        Finalize the latest knowledge base version. Required to indicate the version is complete. Will throw an exception if the latest version is not in progress.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to finalize a version for. All other entity ID fields are inferred from the request.

        version_id : typing.Optional[EntityIdWithoutAgent]
            ID that uniquely identifies which knowledge base version to finalize. If not provided will use the most recent version of the knowledge base.

        status : typing.Optional[KnowledgeBaseVersionFinalizeStatus]
            Whether the knowledge base version processing was successful or not.

        error_message : typing.Optional[str]
            A user-facing error message that provides more details about a version failure.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseVersion

        Examples
        --------
        from mavenagi import MavenAGI
        from mavenagi.commons import EntityIdWithoutAgent

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.finalize_knowledge_base_version(
            knowledge_base_reference_id="help-center",
            version_id=EntityIdWithoutAgent(
                type="KNOWLEDGE_BASE_VERSION",
                reference_id="versionId",
                app_id="maven",
            ),
            status="SUCCEEDED",
        )
        """
        _response = self._raw_client.finalize_knowledge_base_version(
            knowledge_base_reference_id,
            version_id=version_id,
            status=status,
            error_message=error_message,
            request_options=request_options,
        )
        return _response.data

    def create_knowledge_document(
        self,
        knowledge_base_reference_id: str,
        *,
        knowledge_document_id: EntityIdBase,
        content_type: KnowledgeDocumentContentType,
        content: str,
        title: str,
        version_id: typing.Optional[EntityIdWithoutAgent] = OMIT,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        url: typing.Optional[str] = OMIT,
        language: typing.Optional[str] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        author: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeDocumentResponse:
        """
        Create knowledge document. Requires an existing knowledge base with an in progress version. Will throw an exception if the latest version is not in progress.

        <Tip>
        This API maintains document version history. If for the same reference ID neither the `title` nor `text` fields
        have changed, a new document version will not be created. The existing version will be reused.
        </Tip>

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to create a document for. All other entity ID fields are inferred from the request.

        knowledge_document_id : EntityIdBase
            ID that uniquely identifies this knowledge document within its knowledge base

        content_type : KnowledgeDocumentContentType

        content : str
            The content of the document. Not shown directly to users. May be provided in HTML or markdown. HTML will be converted to markdown automatically. Images are not currently supported and will be ignored.

        title : str
            The title of the document. Will be shown as part of answers.

        version_id : typing.Optional[EntityIdWithoutAgent]
            ID that uniquely identifies which knowledge base version to create the document in. If not provided will use the most recent version of the knowledge base.

        metadata : typing.Optional[typing.Dict[str, str]]
            Metadata for the knowledge document.

        url : typing.Optional[str]
            The URL of the document. Should be visible to end users. Will be shown as part of answers. Not used for crawling.

        language : typing.Optional[str]
            The document language. Must be a valid ISO 639-1 language code.

        created_at : typing.Optional[dt.datetime]
            The time at which this document was created.

        updated_at : typing.Optional[dt.datetime]
            The time at which this document was last modified.

        author : typing.Optional[str]
            The name of the author who created this document.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeDocumentResponse

        Examples
        --------
        from mavenagi import MavenAGI
        from mavenagi.commons import EntityIdBase, EntityIdWithoutAgent

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.create_knowledge_document(
            knowledge_base_reference_id="help-center",
            knowledge_document_id=EntityIdBase(
                reference_id="getting-started",
            ),
            version_id=EntityIdWithoutAgent(
                type="KNOWLEDGE_BASE_VERSION",
                reference_id="versionId",
                app_id="maven",
            ),
            content_type="MARKDOWN",
            content="## Getting started\\nThis is a getting started guide for the help center.",
            title="Getting started",
            metadata={"category": "getting-started"},
        )
        """
        _response = self._raw_client.create_knowledge_document(
            knowledge_base_reference_id,
            knowledge_document_id=knowledge_document_id,
            content_type=content_type,
            content=content,
            title=title,
            version_id=version_id,
            metadata=metadata,
            url=url,
            language=language,
            created_at=created_at,
            updated_at=updated_at,
            author=author,
            request_options=request_options,
        )
        return _response.data

    def update_knowledge_document(
        self,
        knowledge_base_reference_id: str,
        *,
        knowledge_document_id: EntityIdBase,
        content_type: KnowledgeDocumentContentType,
        content: str,
        title: str,
        version_id: typing.Optional[EntityIdWithoutAgent] = OMIT,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        url: typing.Optional[str] = OMIT,
        language: typing.Optional[str] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        author: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeDocumentResponse:
        """
        Not yet implemented. Update knowledge document. Requires an existing knowledge base with an in progress version of type PARTIAL. Will throw an exception if the latest version is not in progress.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base that contains the document to update. All other entity ID fields are inferred from the request.

        knowledge_document_id : EntityIdBase
            ID that uniquely identifies this knowledge document within its knowledge base

        content_type : KnowledgeDocumentContentType

        content : str
            The content of the document. Not shown directly to users. May be provided in HTML or markdown. HTML will be converted to markdown automatically. Images are not currently supported and will be ignored.

        title : str
            The title of the document. Will be shown as part of answers.

        version_id : typing.Optional[EntityIdWithoutAgent]
            ID that uniquely identifies which knowledge base version to create the document in. If not provided will use the most recent version of the knowledge base.

        metadata : typing.Optional[typing.Dict[str, str]]
            Metadata for the knowledge document.

        url : typing.Optional[str]
            The URL of the document. Should be visible to end users. Will be shown as part of answers. Not used for crawling.

        language : typing.Optional[str]
            The document language. Must be a valid ISO 639-1 language code.

        created_at : typing.Optional[dt.datetime]
            The time at which this document was created.

        updated_at : typing.Optional[dt.datetime]
            The time at which this document was last modified.

        author : typing.Optional[str]
            The name of the author who created this document.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeDocumentResponse

        Examples
        --------
        from mavenagi import MavenAGI
        from mavenagi.commons import EntityIdBase, EntityIdWithoutAgent

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.update_knowledge_document(
            knowledge_base_reference_id="help-center",
            knowledge_document_id=EntityIdBase(
                reference_id="getting-started",
            ),
            version_id=EntityIdWithoutAgent(
                type="KNOWLEDGE_BASE_VERSION",
                reference_id="versionId",
                app_id="maven",
            ),
            content_type="MARKDOWN",
            content="## Getting started\\nThis is a getting started guide for the help center.",
            title="Getting started",
            metadata={"category": "getting-started"},
        )
        """
        _response = self._raw_client.update_knowledge_document(
            knowledge_base_reference_id,
            knowledge_document_id=knowledge_document_id,
            content_type=content_type,
            content=content,
            title=title,
            version_id=version_id,
            metadata=metadata,
            url=url,
            language=language,
            created_at=created_at,
            updated_at=updated_at,
            author=author,
            request_options=request_options,
        )
        return _response.data

    def delete_knowledge_document(
        self,
        knowledge_base_reference_id: str,
        knowledge_document_reference_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Not yet implemented. Delete knowledge document. Requires an existing knowledge base with an in progress version of type PARTIAL. Will throw an exception if the latest version is not in progress.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base that contains the document to delete. All other entity ID fields are inferred from the request

        knowledge_document_reference_id : str
            The reference ID of the knowledge document to delete. All other entity ID fields are inferred from the request.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from mavenagi import MavenAGI

        client = MavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )
        client.knowledge.delete_knowledge_document(
            knowledge_base_reference_id="help-center",
            knowledge_document_reference_id="getting-started",
        )
        """
        _response = self._raw_client.delete_knowledge_document(
            knowledge_base_reference_id, knowledge_document_reference_id, request_options=request_options
        )
        return _response.data


class AsyncKnowledgeClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawKnowledgeClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawKnowledgeClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawKnowledgeClient
        """
        return self._raw_client

    async def create_or_update_knowledge_base(
        self,
        *,
        knowledge_base_id: EntityIdBase,
        name: str,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        precondition: typing.Optional[Precondition] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseResponse:
        """
        Update a knowledge base or create it if it doesn't exist.

        Parameters
        ----------
        knowledge_base_id : EntityIdBase
            ID that uniquely identifies this knowledge base

        name : str
            The name of the knowledge base

        metadata : typing.Optional[typing.Dict[str, str]]
            Metadata for the knowledge base.

        precondition : typing.Optional[Precondition]
            (Beta) The preconditions that must be met for knowledge base be relevant to a conversation. Can be used to limit knowledge to certain types of users.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseResponse

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI
        from mavenagi.commons import EntityIdBase

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.create_or_update_knowledge_base(
                knowledge_base_id=EntityIdBase(
                    reference_id="help-center",
                ),
                name="Help center",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_or_update_knowledge_base(
            knowledge_base_id=knowledge_base_id,
            name=name,
            metadata=metadata,
            precondition=precondition,
            request_options=request_options,
        )
        return _response.data

    async def get_knowledge_base(
        self, knowledge_base_reference_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeBaseResponse:
        """
        Get an existing knowledge base by its supplied ID

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to get. All other entity ID fields are inferred from the request.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseResponse

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.get_knowledge_base(
                knowledge_base_reference_id="help-center",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_knowledge_base(
            knowledge_base_reference_id, request_options=request_options
        )
        return _response.data

    async def create_knowledge_base_version(
        self,
        knowledge_base_reference_id: str,
        *,
        version_id: EntityId,
        type: KnowledgeBaseVersionType,
        status: KnowledgeBaseVersionStatus,
        error_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseVersion:
        """
        Create a new knowledge base version.

        If an existing version is in progress, then that version will be finalized in an error state.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to create a version for. All other entity ID fields are inferred from the request.

        version_id : EntityId
            The unique ID of the knowledge base version.

        type : KnowledgeBaseVersionType
            Indicates whether the completed version constitutes a full or partial refresh of the knowledge base. Deleting and updating documents is only supported for partial refreshes.

        status : KnowledgeBaseVersionStatus
            The status of the knowledge base version

        error_message : typing.Optional[str]
            A user-facing error message that provides more details about a version failure.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseVersion

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI
        from mavenagi.commons import EntityId

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.create_knowledge_base_version(
                knowledge_base_reference_id="help-center",
                version_id=EntityId(
                    type="KNOWLEDGE_BASE_VERSION",
                    reference_id="versionId",
                    app_id="maven",
                    organization_id="acme",
                    agent_id="support",
                ),
                type="FULL",
                status="IN_PROGRESS",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_knowledge_base_version(
            knowledge_base_reference_id,
            version_id=version_id,
            type=type,
            status=status,
            error_message=error_message,
            request_options=request_options,
        )
        return _response.data

    async def finalize_knowledge_base_version(
        self,
        knowledge_base_reference_id: str,
        *,
        version_id: typing.Optional[EntityIdWithoutAgent] = OMIT,
        status: typing.Optional[KnowledgeBaseVersionFinalizeStatus] = OMIT,
        error_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseVersion:
        """
        Finalize the latest knowledge base version. Required to indicate the version is complete. Will throw an exception if the latest version is not in progress.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to finalize a version for. All other entity ID fields are inferred from the request.

        version_id : typing.Optional[EntityIdWithoutAgent]
            ID that uniquely identifies which knowledge base version to finalize. If not provided will use the most recent version of the knowledge base.

        status : typing.Optional[KnowledgeBaseVersionFinalizeStatus]
            Whether the knowledge base version processing was successful or not.

        error_message : typing.Optional[str]
            A user-facing error message that provides more details about a version failure.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeBaseVersion

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI
        from mavenagi.commons import EntityIdWithoutAgent

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.finalize_knowledge_base_version(
                knowledge_base_reference_id="help-center",
                version_id=EntityIdWithoutAgent(
                    type="KNOWLEDGE_BASE_VERSION",
                    reference_id="versionId",
                    app_id="maven",
                ),
                status="SUCCEEDED",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.finalize_knowledge_base_version(
            knowledge_base_reference_id,
            version_id=version_id,
            status=status,
            error_message=error_message,
            request_options=request_options,
        )
        return _response.data

    async def create_knowledge_document(
        self,
        knowledge_base_reference_id: str,
        *,
        knowledge_document_id: EntityIdBase,
        content_type: KnowledgeDocumentContentType,
        content: str,
        title: str,
        version_id: typing.Optional[EntityIdWithoutAgent] = OMIT,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        url: typing.Optional[str] = OMIT,
        language: typing.Optional[str] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        author: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeDocumentResponse:
        """
        Create knowledge document. Requires an existing knowledge base with an in progress version. Will throw an exception if the latest version is not in progress.

        <Tip>
        This API maintains document version history. If for the same reference ID neither the `title` nor `text` fields
        have changed, a new document version will not be created. The existing version will be reused.
        </Tip>

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base to create a document for. All other entity ID fields are inferred from the request.

        knowledge_document_id : EntityIdBase
            ID that uniquely identifies this knowledge document within its knowledge base

        content_type : KnowledgeDocumentContentType

        content : str
            The content of the document. Not shown directly to users. May be provided in HTML or markdown. HTML will be converted to markdown automatically. Images are not currently supported and will be ignored.

        title : str
            The title of the document. Will be shown as part of answers.

        version_id : typing.Optional[EntityIdWithoutAgent]
            ID that uniquely identifies which knowledge base version to create the document in. If not provided will use the most recent version of the knowledge base.

        metadata : typing.Optional[typing.Dict[str, str]]
            Metadata for the knowledge document.

        url : typing.Optional[str]
            The URL of the document. Should be visible to end users. Will be shown as part of answers. Not used for crawling.

        language : typing.Optional[str]
            The document language. Must be a valid ISO 639-1 language code.

        created_at : typing.Optional[dt.datetime]
            The time at which this document was created.

        updated_at : typing.Optional[dt.datetime]
            The time at which this document was last modified.

        author : typing.Optional[str]
            The name of the author who created this document.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeDocumentResponse

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI
        from mavenagi.commons import EntityIdBase, EntityIdWithoutAgent

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.create_knowledge_document(
                knowledge_base_reference_id="help-center",
                knowledge_document_id=EntityIdBase(
                    reference_id="getting-started",
                ),
                version_id=EntityIdWithoutAgent(
                    type="KNOWLEDGE_BASE_VERSION",
                    reference_id="versionId",
                    app_id="maven",
                ),
                content_type="MARKDOWN",
                content="## Getting started\\nThis is a getting started guide for the help center.",
                title="Getting started",
                metadata={"category": "getting-started"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_knowledge_document(
            knowledge_base_reference_id,
            knowledge_document_id=knowledge_document_id,
            content_type=content_type,
            content=content,
            title=title,
            version_id=version_id,
            metadata=metadata,
            url=url,
            language=language,
            created_at=created_at,
            updated_at=updated_at,
            author=author,
            request_options=request_options,
        )
        return _response.data

    async def update_knowledge_document(
        self,
        knowledge_base_reference_id: str,
        *,
        knowledge_document_id: EntityIdBase,
        content_type: KnowledgeDocumentContentType,
        content: str,
        title: str,
        version_id: typing.Optional[EntityIdWithoutAgent] = OMIT,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        url: typing.Optional[str] = OMIT,
        language: typing.Optional[str] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        author: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeDocumentResponse:
        """
        Not yet implemented. Update knowledge document. Requires an existing knowledge base with an in progress version of type PARTIAL. Will throw an exception if the latest version is not in progress.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base that contains the document to update. All other entity ID fields are inferred from the request.

        knowledge_document_id : EntityIdBase
            ID that uniquely identifies this knowledge document within its knowledge base

        content_type : KnowledgeDocumentContentType

        content : str
            The content of the document. Not shown directly to users. May be provided in HTML or markdown. HTML will be converted to markdown automatically. Images are not currently supported and will be ignored.

        title : str
            The title of the document. Will be shown as part of answers.

        version_id : typing.Optional[EntityIdWithoutAgent]
            ID that uniquely identifies which knowledge base version to create the document in. If not provided will use the most recent version of the knowledge base.

        metadata : typing.Optional[typing.Dict[str, str]]
            Metadata for the knowledge document.

        url : typing.Optional[str]
            The URL of the document. Should be visible to end users. Will be shown as part of answers. Not used for crawling.

        language : typing.Optional[str]
            The document language. Must be a valid ISO 639-1 language code.

        created_at : typing.Optional[dt.datetime]
            The time at which this document was created.

        updated_at : typing.Optional[dt.datetime]
            The time at which this document was last modified.

        author : typing.Optional[str]
            The name of the author who created this document.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        KnowledgeDocumentResponse

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI
        from mavenagi.commons import EntityIdBase, EntityIdWithoutAgent

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.update_knowledge_document(
                knowledge_base_reference_id="help-center",
                knowledge_document_id=EntityIdBase(
                    reference_id="getting-started",
                ),
                version_id=EntityIdWithoutAgent(
                    type="KNOWLEDGE_BASE_VERSION",
                    reference_id="versionId",
                    app_id="maven",
                ),
                content_type="MARKDOWN",
                content="## Getting started\\nThis is a getting started guide for the help center.",
                title="Getting started",
                metadata={"category": "getting-started"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_knowledge_document(
            knowledge_base_reference_id,
            knowledge_document_id=knowledge_document_id,
            content_type=content_type,
            content=content,
            title=title,
            version_id=version_id,
            metadata=metadata,
            url=url,
            language=language,
            created_at=created_at,
            updated_at=updated_at,
            author=author,
            request_options=request_options,
        )
        return _response.data

    async def delete_knowledge_document(
        self,
        knowledge_base_reference_id: str,
        knowledge_document_reference_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Not yet implemented. Delete knowledge document. Requires an existing knowledge base with an in progress version of type PARTIAL. Will throw an exception if the latest version is not in progress.

        Parameters
        ----------
        knowledge_base_reference_id : str
            The reference ID of the knowledge base that contains the document to delete. All other entity ID fields are inferred from the request

        knowledge_document_reference_id : str
            The reference ID of the knowledge document to delete. All other entity ID fields are inferred from the request.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from mavenagi import AsyncMavenAGI

        client = AsyncMavenAGI(
            organization_id="YOUR_ORGANIZATION_ID",
            agent_id="YOUR_AGENT_ID",
            app_id="YOUR_APP_ID",
            app_secret="YOUR_APP_SECRET",
        )


        async def main() -> None:
            await client.knowledge.delete_knowledge_document(
                knowledge_base_reference_id="help-center",
                knowledge_document_reference_id="getting-started",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_knowledge_document(
            knowledge_base_reference_id, knowledge_document_reference_id, request_options=request_options
        )
        return _response.data
