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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.knowledge_slice_list_response import KnowledgeSliceListResponse
from ..types.knowledge_slice_response import KnowledgeSliceResponse
from ..types.knowledge_vector_store_list_response import KnowledgeVectorStoreListResponse
from ..types.knowledge_vector_store_response import KnowledgeVectorStoreResponse
from .raw_client import AsyncRawKnowledgeClient, RawKnowledgeClient

# 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 list_slices(
        self,
        organization_id: str,
        *,
        status: typing.Optional[str] = None,
        type: typing.Optional[str] = None,
        search: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceListResponse:
        """
        Retrieves all knowledge slices in the organization, with optional filtering by status, type, and search term. Returns paginated results ordered by creation date. Use the 'search' parameter for case-insensitive name matching.

        Parameters
        ----------
        organization_id : str

        status : typing.Optional[str]

        type : typing.Optional[str]

        search : typing.Optional[str]
            Filter by name (case-insensitive)

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        KnowledgeSliceListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.list_slices(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_slices(
            organization_id,
            status=status,
            type=type,
            search=search,
            skip=skip,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    def create_slice(
        self,
        organization_id: str,
        *,
        name: str,
        owner_type: str,
        owner_id: str,
        description: typing.Optional[str] = OMIT,
        type: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Creates a new knowledge slice in the organization. Specify owner type and ID to control access scope. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        name : str
            Display name for the knowledge slice

        owner_type : str
            Owner entity type: 'organization', 'department', or 'user'

        owner_id : str
            ID of the owning entity (organization, department, or user)

        description : typing.Optional[str]
            Optional description of the knowledge slice's purpose or contents

        type : typing.Optional[str]
            Slice type: 'standard', 'personal', or 'chat_space'

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.create_slice(
            organization_id="organization_id",
            name="name",
            owner_type="owner_type",
            owner_id="owner_id",
        )
        """
        _response = self._raw_client.create_slice(
            organization_id,
            name=name,
            owner_type=owner_type,
            owner_id=owner_id,
            description=description,
            type=type,
            request_options=request_options,
        )
        return _response.data

    def get_slice(
        self, organization_id: str, slice_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeSliceResponse:
        """
        Retrieves a single knowledge slice by its ID. Returns full slice metadata including owner, status, and member slice IDs for composites. Requires access to the slice via ownership, department membership, or access grants.

        Parameters
        ----------
        organization_id : str

        slice_id : str

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.get_slice(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.get_slice(organization_id, slice_id, request_options=request_options)
        return _response.data

    def update_slice(
        self,
        organization_id: str,
        slice_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Updates the name or description of an existing knowledge slice. Requires access to the slice and the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        name : typing.Optional[str]
            Updated display name for the knowledge slice

        description : typing.Optional[str]
            Updated description of the knowledge slice

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.update_slice(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.update_slice(
            organization_id, slice_id, name=name, description=description, request_options=request_options
        )
        return _response.data

    def archive_slice(
        self, organization_id: str, slice_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeSliceResponse:
        """
        Archives a knowledge slice, making it inactive but preserving its data and stores. Archived slices can be restored with the unarchive endpoint. Requires the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.archive_slice(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.archive_slice(organization_id, slice_id, request_options=request_options)
        return _response.data

    def unarchive_slice(
        self, organization_id: str, slice_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeSliceResponse:
        """
        Restores a previously archived knowledge slice to active status. All associated stores and data remain intact. Requires the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.unarchive_slice(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.unarchive_slice(organization_id, slice_id, request_options=request_options)
        return _response.data

    def list_composites(
        self,
        organization_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceListResponse:
        """
        Retrieves all composite knowledge slices in the organization. Composite slices aggregate multiple member slices into a single queryable unit. Returns paginated results with member slice IDs included.

        Parameters
        ----------
        organization_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        KnowledgeSliceListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.list_composites(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_composites(
            organization_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    def create_composite(
        self,
        organization_id: str,
        *,
        name: str,
        member_slice_ids: typing.Sequence[str],
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Creates a composite slice that aggregates multiple member slices. The composite inherits access to all vector stores in its member slices. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        name : str
            Display name for the composite slice

        member_slice_ids : typing.Sequence[str]
            List of slice IDs to include as members of this composite

        description : typing.Optional[str]
            Optional description of the composite slice

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.create_composite(
            organization_id="organization_id",
            name="name",
            member_slice_ids=["member_slice_ids"],
        )
        """
        _response = self._raw_client.create_composite(
            organization_id,
            name=name,
            member_slice_ids=member_slice_ids,
            description=description,
            request_options=request_options,
        )
        return _response.data

    def update_composite(
        self,
        organization_id: str,
        slice_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        member_slice_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Updates a composite slice's name, description, or member slices. Replacing member slices updates which stores the composite aggregates. Requires access to the composite and the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        name : typing.Optional[str]
            Updated display name for the composite slice

        description : typing.Optional[str]
            Updated description of the composite slice

        member_slice_ids : typing.Optional[typing.Sequence[str]]
            Updated list of member slice IDs

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.update_composite(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.update_composite(
            organization_id,
            slice_id,
            name=name,
            description=description,
            member_slice_ids=member_slice_ids,
            request_options=request_options,
        )
        return _response.data

    def list_stores_by_slice(
        self,
        organization_id: str,
        slice_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreListResponse:
        """
        Lists all vector stores associated with a specific knowledge slice. Only returns stores the current user has access to based on access mode and grants. Use pagination parameters for large result sets.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        KnowledgeVectorStoreListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.list_stores_by_slice(
            organization_id="organization_id",
            slice_id="slice_id",
        )
        """
        _response = self._raw_client.list_stores_by_slice(
            organization_id, slice_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    def create_store_in_slice(
        self,
        organization_id: str,
        slice_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_target_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreResponse:
        """
        Creates a new vector store and assigns it to the specified knowledge slice. The user must have access to the parent slice. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        name : str
            Display name for the vector store

        description : typing.Optional[str]
            Optional description of the vector store's purpose or contents

        access_mode : typing.Optional[str]
            Access control mode. One of: 'organization', 'department', 'private', 'public', 'inherit'. 'inherit' copies access settings from the parent slice and is only available at creation time.

        access_target_id : typing.Optional[str]
            Target ID for department/user/group access modes

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.create_store_in_slice(
            organization_id="organization_id",
            slice_id="slice_id",
            name="name",
        )
        """
        _response = self._raw_client.create_store_in_slice(
            organization_id,
            slice_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_target_id=access_target_id,
            request_options=request_options,
        )
        return _response.data

    def list_stores_for_org(
        self,
        organization_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        sort: typing.Optional[str] = None,
        order: typing.Optional[str] = None,
        slice_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreListResponse:
        """
        Lists all vector stores accessible by the current user across the organization. Supports filtering by name search and slice, with configurable sort order. Results are scoped by the user's access permissions.

        Parameters
        ----------
        organization_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

        search : typing.Optional[str]
            Filter by name (case-insensitive)

        sort : typing.Optional[str]
            Sort column (name, created_at, data_size)

        order : typing.Optional[str]
            Sort direction (asc, desc)

        slice_id : typing.Optional[str]
            Filter by slice

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

        Returns
        -------
        KnowledgeVectorStoreListResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.list_stores_for_org(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_stores_for_org(
            organization_id,
            skip=skip,
            limit=limit,
            search=search,
            sort=sort,
            order=order,
            slice_id=slice_id,
            request_options=request_options,
        )
        return _response.data

    def create_store(
        self,
        organization_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_target_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreResponse:
        """
        Creates a new vector store without assigning it to any knowledge slice. The store can later be assigned to a slice via the update endpoint. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        name : str
            Display name for the vector store

        description : typing.Optional[str]
            Optional description of the vector store's purpose or contents

        access_mode : typing.Optional[str]
            Access control mode. One of: 'organization', 'department', 'private', 'public', 'inherit'. 'inherit' copies access settings from the parent slice and is only available at creation time.

        access_target_id : typing.Optional[str]
            Target ID for department/user/group access modes

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.create_store(
            organization_id="organization_id",
            name="name",
        )
        """
        _response = self._raw_client.create_store(
            organization_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_target_id=access_target_id,
            request_options=request_options,
        )
        return _response.data

    def get_store(
        self, organization_id: str, store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeVectorStoreResponse:
        """
        Retrieves a specific vector store by ID, including its slice assignments. Requires access to the store via ownership, access mode, or access grants.

        Parameters
        ----------
        organization_id : str

        store_id : str

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.get_store(
            organization_id="organization_id",
            store_id="store_id",
        )
        """
        _response = self._raw_client.get_store(organization_id, store_id, request_options=request_options)
        return _response.data

    def delete_store(
        self, organization_id: str, store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Permanently deletes a vector store and all its associated files and embeddings. This action cannot be undone. Requires access to the store and the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        store_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.delete_store(
            organization_id="organization_id",
            store_id="store_id",
        )
        """
        _response = self._raw_client.delete_store(organization_id, store_id, request_options=request_options)
        return _response.data

    def update_store(
        self,
        organization_id: str,
        store_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        slice_id: typing.Optional[str] = OMIT,
        slice_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreResponse:
        """
        Updates a vector store's name, description, access mode, or slice assignments. When assigning to a slice, the user must also have access to the target slice. Requires the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        store_id : str

        name : typing.Optional[str]
            Updated display name for the vector store

        description : typing.Optional[str]
            Updated description of the vector store

        access_mode : typing.Optional[str]
            Access control mode. One of: 'organization', 'department', 'private', 'public'. Note: 'inherit' is only available at creation time.

        slice_id : typing.Optional[str]
            ID of the slice to associate this vector store with

        slice_ids : typing.Optional[typing.Sequence[str]]
            Set multiple slice associations by providing a list of slice IDs

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.knowledge.update_store(
            organization_id="organization_id",
            store_id="store_id",
        )
        """
        _response = self._raw_client.update_store(
            organization_id,
            store_id,
            name=name,
            description=description,
            access_mode=access_mode,
            slice_id=slice_id,
            slice_ids=slice_ids,
            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 list_slices(
        self,
        organization_id: str,
        *,
        status: typing.Optional[str] = None,
        type: typing.Optional[str] = None,
        search: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceListResponse:
        """
        Retrieves all knowledge slices in the organization, with optional filtering by status, type, and search term. Returns paginated results ordered by creation date. Use the 'search' parameter for case-insensitive name matching.

        Parameters
        ----------
        organization_id : str

        status : typing.Optional[str]

        type : typing.Optional[str]

        search : typing.Optional[str]
            Filter by name (case-insensitive)

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        KnowledgeSliceListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.list_slices(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_slices(
            organization_id,
            status=status,
            type=type,
            search=search,
            skip=skip,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    async def create_slice(
        self,
        organization_id: str,
        *,
        name: str,
        owner_type: str,
        owner_id: str,
        description: typing.Optional[str] = OMIT,
        type: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Creates a new knowledge slice in the organization. Specify owner type and ID to control access scope. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        name : str
            Display name for the knowledge slice

        owner_type : str
            Owner entity type: 'organization', 'department', or 'user'

        owner_id : str
            ID of the owning entity (organization, department, or user)

        description : typing.Optional[str]
            Optional description of the knowledge slice's purpose or contents

        type : typing.Optional[str]
            Slice type: 'standard', 'personal', or 'chat_space'

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.create_slice(
                organization_id="organization_id",
                name="name",
                owner_type="owner_type",
                owner_id="owner_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_slice(
            organization_id,
            name=name,
            owner_type=owner_type,
            owner_id=owner_id,
            description=description,
            type=type,
            request_options=request_options,
        )
        return _response.data

    async def get_slice(
        self, organization_id: str, slice_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeSliceResponse:
        """
        Retrieves a single knowledge slice by its ID. Returns full slice metadata including owner, status, and member slice IDs for composites. Requires access to the slice via ownership, department membership, or access grants.

        Parameters
        ----------
        organization_id : str

        slice_id : str

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.get_slice(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_slice(organization_id, slice_id, request_options=request_options)
        return _response.data

    async def update_slice(
        self,
        organization_id: str,
        slice_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Updates the name or description of an existing knowledge slice. Requires access to the slice and the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        name : typing.Optional[str]
            Updated display name for the knowledge slice

        description : typing.Optional[str]
            Updated description of the knowledge slice

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.update_slice(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_slice(
            organization_id, slice_id, name=name, description=description, request_options=request_options
        )
        return _response.data

    async def archive_slice(
        self, organization_id: str, slice_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeSliceResponse:
        """
        Archives a knowledge slice, making it inactive but preserving its data and stores. Archived slices can be restored with the unarchive endpoint. Requires the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.archive_slice(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.archive_slice(organization_id, slice_id, request_options=request_options)
        return _response.data

    async def unarchive_slice(
        self, organization_id: str, slice_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeSliceResponse:
        """
        Restores a previously archived knowledge slice to active status. All associated stores and data remain intact. Requires the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.unarchive_slice(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.unarchive_slice(organization_id, slice_id, request_options=request_options)
        return _response.data

    async def list_composites(
        self,
        organization_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceListResponse:
        """
        Retrieves all composite knowledge slices in the organization. Composite slices aggregate multiple member slices into a single queryable unit. Returns paginated results with member slice IDs included.

        Parameters
        ----------
        organization_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        KnowledgeSliceListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.list_composites(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_composites(
            organization_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    async def create_composite(
        self,
        organization_id: str,
        *,
        name: str,
        member_slice_ids: typing.Sequence[str],
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Creates a composite slice that aggregates multiple member slices. The composite inherits access to all vector stores in its member slices. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        name : str
            Display name for the composite slice

        member_slice_ids : typing.Sequence[str]
            List of slice IDs to include as members of this composite

        description : typing.Optional[str]
            Optional description of the composite slice

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.create_composite(
                organization_id="organization_id",
                name="name",
                member_slice_ids=["member_slice_ids"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_composite(
            organization_id,
            name=name,
            member_slice_ids=member_slice_ids,
            description=description,
            request_options=request_options,
        )
        return _response.data

    async def update_composite(
        self,
        organization_id: str,
        slice_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        member_slice_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeSliceResponse:
        """
        Updates a composite slice's name, description, or member slices. Replacing member slices updates which stores the composite aggregates. Requires access to the composite and the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        name : typing.Optional[str]
            Updated display name for the composite slice

        description : typing.Optional[str]
            Updated description of the composite slice

        member_slice_ids : typing.Optional[typing.Sequence[str]]
            Updated list of member slice IDs

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

        Returns
        -------
        KnowledgeSliceResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.update_composite(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_composite(
            organization_id,
            slice_id,
            name=name,
            description=description,
            member_slice_ids=member_slice_ids,
            request_options=request_options,
        )
        return _response.data

    async def list_stores_by_slice(
        self,
        organization_id: str,
        slice_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreListResponse:
        """
        Lists all vector stores associated with a specific knowledge slice. Only returns stores the current user has access to based on access mode and grants. Use pagination parameters for large result sets.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

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

        Returns
        -------
        KnowledgeVectorStoreListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.list_stores_by_slice(
                organization_id="organization_id",
                slice_id="slice_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_stores_by_slice(
            organization_id, slice_id, skip=skip, limit=limit, request_options=request_options
        )
        return _response.data

    async def create_store_in_slice(
        self,
        organization_id: str,
        slice_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_target_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreResponse:
        """
        Creates a new vector store and assigns it to the specified knowledge slice. The user must have access to the parent slice. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        slice_id : str

        name : str
            Display name for the vector store

        description : typing.Optional[str]
            Optional description of the vector store's purpose or contents

        access_mode : typing.Optional[str]
            Access control mode. One of: 'organization', 'department', 'private', 'public', 'inherit'. 'inherit' copies access settings from the parent slice and is only available at creation time.

        access_target_id : typing.Optional[str]
            Target ID for department/user/group access modes

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.create_store_in_slice(
                organization_id="organization_id",
                slice_id="slice_id",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_store_in_slice(
            organization_id,
            slice_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_target_id=access_target_id,
            request_options=request_options,
        )
        return _response.data

    async def list_stores_for_org(
        self,
        organization_id: str,
        *,
        skip: typing.Optional[int] = None,
        limit: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        sort: typing.Optional[str] = None,
        order: typing.Optional[str] = None,
        slice_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreListResponse:
        """
        Lists all vector stores accessible by the current user across the organization. Supports filtering by name search and slice, with configurable sort order. Results are scoped by the user's access permissions.

        Parameters
        ----------
        organization_id : str

        skip : typing.Optional[int]

        limit : typing.Optional[int]

        search : typing.Optional[str]
            Filter by name (case-insensitive)

        sort : typing.Optional[str]
            Sort column (name, created_at, data_size)

        order : typing.Optional[str]
            Sort direction (asc, desc)

        slice_id : typing.Optional[str]
            Filter by slice

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

        Returns
        -------
        KnowledgeVectorStoreListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.list_stores_for_org(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_stores_for_org(
            organization_id,
            skip=skip,
            limit=limit,
            search=search,
            sort=sort,
            order=order,
            slice_id=slice_id,
            request_options=request_options,
        )
        return _response.data

    async def create_store(
        self,
        organization_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_target_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreResponse:
        """
        Creates a new vector store without assigning it to any knowledge slice. The store can later be assigned to a slice via the update endpoint. Requires the CREATE_KNOWLEDGE capability.

        Parameters
        ----------
        organization_id : str

        name : str
            Display name for the vector store

        description : typing.Optional[str]
            Optional description of the vector store's purpose or contents

        access_mode : typing.Optional[str]
            Access control mode. One of: 'organization', 'department', 'private', 'public', 'inherit'. 'inherit' copies access settings from the parent slice and is only available at creation time.

        access_target_id : typing.Optional[str]
            Target ID for department/user/group access modes

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.create_store(
                organization_id="organization_id",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_store(
            organization_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_target_id=access_target_id,
            request_options=request_options,
        )
        return _response.data

    async def get_store(
        self, organization_id: str, store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> KnowledgeVectorStoreResponse:
        """
        Retrieves a specific vector store by ID, including its slice assignments. Requires access to the store via ownership, access mode, or access grants.

        Parameters
        ----------
        organization_id : str

        store_id : str

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.get_store(
                organization_id="organization_id",
                store_id="store_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_store(organization_id, store_id, request_options=request_options)
        return _response.data

    async def delete_store(
        self, organization_id: str, store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Permanently deletes a vector store and all its associated files and embeddings. This action cannot be undone. Requires access to the store and the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        store_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.delete_store(
                organization_id="organization_id",
                store_id="store_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_store(organization_id, store_id, request_options=request_options)
        return _response.data

    async def update_store(
        self,
        organization_id: str,
        store_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        slice_id: typing.Optional[str] = OMIT,
        slice_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeVectorStoreResponse:
        """
        Updates a vector store's name, description, access mode, or slice assignments. When assigning to a slice, the user must also have access to the target slice. Requires the MANAGE_KNOWLEDGE_SLICES capability.

        Parameters
        ----------
        organization_id : str

        store_id : str

        name : typing.Optional[str]
            Updated display name for the vector store

        description : typing.Optional[str]
            Updated description of the vector store

        access_mode : typing.Optional[str]
            Access control mode. One of: 'organization', 'department', 'private', 'public'. Note: 'inherit' is only available at creation time.

        slice_id : typing.Optional[str]
            ID of the slice to associate this vector store with

        slice_ids : typing.Optional[typing.Sequence[str]]
            Set multiple slice associations by providing a list of slice IDs

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

        Returns
        -------
        KnowledgeVectorStoreResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.knowledge.update_store(
                organization_id="organization_id",
                store_id="store_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_store(
            organization_id,
            store_id,
            name=name,
            description=description,
            access_mode=access_mode,
            slice_id=slice_id,
            slice_ids=slice_ids,
            request_options=request_options,
        )
        return _response.data
