# 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.success_response_list_vector_store_response import SuccessResponseListVectorStoreResponse
from ..types.success_response_vector_store_response import SuccessResponseVectorStoreResponse
from ..types.success_response_vector_store_usage_response import SuccessResponseVectorStoreUsageResponse
from .raw_client import AsyncRawVectorStoresClient, RawVectorStoresClient

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


class VectorStoresClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVectorStoresClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawVectorStoresClient
        """
        return self._raw_client

    def list_vector_stores(
        self,
        organization_id: str,
        *,
        search: typing.Optional[str] = None,
        access_mode: typing.Optional[str] = None,
        flowplate_project_id: typing.Optional[str] = None,
        flow_id: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        take: typing.Optional[int] = None,
        sort: typing.Optional[str] = None,
        order: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseListVectorStoreResponse:
        """
        Retrieve a list of all vector stores in an organization that the user has access to. Supports filtering and search.

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

        search : typing.Optional[str]
            Search by vector store name

        access_mode : typing.Optional[str]
            Filter by access mode (public, organization, department, private)

        flowplate_project_id : typing.Optional[str]
            Filter by Flow-plate project ID

        flow_id : typing.Optional[str]
            Filter by Flow-plate flow ID

        skip : typing.Optional[int]
            Number of records to skip

        take : typing.Optional[int]
            Number of records to return

        sort : typing.Optional[str]
            Field to sort by

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

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

        Returns
        -------
        SuccessResponseListVectorStoreResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_stores.list_vector_stores(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.list_vector_stores(
            organization_id,
            search=search,
            access_mode=access_mode,
            flowplate_project_id=flowplate_project_id,
            flow_id=flow_id,
            skip=skip,
            take=take,
            sort=sort,
            order=order,
            request_options=request_options,
        )
        return _response.data

    def create_vector_store(
        self,
        organization_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_departments: typing.Optional[typing.Sequence[str]] = OMIT,
        access_users: typing.Optional[typing.Sequence[str]] = OMIT,
        flowplate_project_id: typing.Optional[str] = OMIT,
        flow_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreResponse:
        """
        Create a new vector store for semantic search and RAG

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

        name : str
            Name of the vector store

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

        access_mode : typing.Optional[str]
            Access control level: public, organization, department, private

        access_departments : typing.Optional[typing.Sequence[str]]
            Department IDs that can access (when access_mode is department)

        access_users : typing.Optional[typing.Sequence[str]]
            User IDs that can access (when access_mode is private)

        flowplate_project_id : typing.Optional[str]
            Flow-plate project ID for organizational scoping

        flow_id : typing.Optional[str]
            Flow-plate flow ID for flow-level scoping

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

        Returns
        -------
        SuccessResponseVectorStoreResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_stores.create_vector_store(
            organization_id="organization_id",
            name="name",
        )
        """
        _response = self._raw_client.create_vector_store(
            organization_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_departments=access_departments,
            access_users=access_users,
            flowplate_project_id=flowplate_project_id,
            flow_id=flow_id,
            request_options=request_options,
        )
        return _response.data

    def get_vector_store_usage(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SuccessResponseVectorStoreUsageResponse:
        """
        Get storage usage breakdown by vector store for the organization

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

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

        Returns
        -------
        SuccessResponseVectorStoreUsageResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_stores.get_vector_store_usage(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.get_vector_store_usage(organization_id, request_options=request_options)
        return _response.data

    def get_vector_store(
        self, organization_id: str, vector_store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SuccessResponseVectorStoreResponse:
        """
        Get details about a specific vector store by its ID

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

        vector_store_id : str

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

        Returns
        -------
        SuccessResponseVectorStoreResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_stores.get_vector_store(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
        )
        """
        _response = self._raw_client.get_vector_store(organization_id, vector_store_id, request_options=request_options)
        return _response.data

    def delete_vector_store(
        self, organization_id: str, vector_store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Permanently delete a vector store and remove all associated files

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

        vector_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.vector_stores.delete_vector_store(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
        )
        """
        _response = self._raw_client.delete_vector_store(
            organization_id, vector_store_id, request_options=request_options
        )
        return _response.data

    def update_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_departments: typing.Optional[typing.Sequence[str]] = OMIT,
        access_users: typing.Optional[typing.Sequence[str]] = OMIT,
        flowplate_project_id: typing.Optional[str] = OMIT,
        flow_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreResponse:
        """
        Modify the name, description, or access settings of a vector store

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

        vector_store_id : str

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

        description : typing.Optional[str]
            New description for the vector store

        access_mode : typing.Optional[str]
            New access control level: public, organization, department, private

        access_departments : typing.Optional[typing.Sequence[str]]
            Updated list of department IDs with access

        access_users : typing.Optional[typing.Sequence[str]]
            Updated list of user IDs with access

        flowplate_project_id : typing.Optional[str]
            Flow-plate project ID for organizational scoping

        flow_id : typing.Optional[str]
            Flow-plate flow ID for flow-level scoping

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

        Returns
        -------
        SuccessResponseVectorStoreResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_stores.update_vector_store(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
        )
        """
        _response = self._raw_client.update_vector_store(
            organization_id,
            vector_store_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_departments=access_departments,
            access_users=access_users,
            flowplate_project_id=flowplate_project_id,
            flow_id=flow_id,
            request_options=request_options,
        )
        return _response.data


class AsyncVectorStoresClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVectorStoresClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawVectorStoresClient
        """
        return self._raw_client

    async def list_vector_stores(
        self,
        organization_id: str,
        *,
        search: typing.Optional[str] = None,
        access_mode: typing.Optional[str] = None,
        flowplate_project_id: typing.Optional[str] = None,
        flow_id: typing.Optional[str] = None,
        skip: typing.Optional[int] = None,
        take: typing.Optional[int] = None,
        sort: typing.Optional[str] = None,
        order: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseListVectorStoreResponse:
        """
        Retrieve a list of all vector stores in an organization that the user has access to. Supports filtering and search.

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

        search : typing.Optional[str]
            Search by vector store name

        access_mode : typing.Optional[str]
            Filter by access mode (public, organization, department, private)

        flowplate_project_id : typing.Optional[str]
            Filter by Flow-plate project ID

        flow_id : typing.Optional[str]
            Filter by Flow-plate flow ID

        skip : typing.Optional[int]
            Number of records to skip

        take : typing.Optional[int]
            Number of records to return

        sort : typing.Optional[str]
            Field to sort by

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

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

        Returns
        -------
        SuccessResponseListVectorStoreResponse
            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.vector_stores.list_vector_stores(
                organization_id="organization_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_vector_stores(
            organization_id,
            search=search,
            access_mode=access_mode,
            flowplate_project_id=flowplate_project_id,
            flow_id=flow_id,
            skip=skip,
            take=take,
            sort=sort,
            order=order,
            request_options=request_options,
        )
        return _response.data

    async def create_vector_store(
        self,
        organization_id: str,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_departments: typing.Optional[typing.Sequence[str]] = OMIT,
        access_users: typing.Optional[typing.Sequence[str]] = OMIT,
        flowplate_project_id: typing.Optional[str] = OMIT,
        flow_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreResponse:
        """
        Create a new vector store for semantic search and RAG

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

        name : str
            Name of the vector store

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

        access_mode : typing.Optional[str]
            Access control level: public, organization, department, private

        access_departments : typing.Optional[typing.Sequence[str]]
            Department IDs that can access (when access_mode is department)

        access_users : typing.Optional[typing.Sequence[str]]
            User IDs that can access (when access_mode is private)

        flowplate_project_id : typing.Optional[str]
            Flow-plate project ID for organizational scoping

        flow_id : typing.Optional[str]
            Flow-plate flow ID for flow-level scoping

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

        Returns
        -------
        SuccessResponseVectorStoreResponse
            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.vector_stores.create_vector_store(
                organization_id="organization_id",
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_vector_store(
            organization_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_departments=access_departments,
            access_users=access_users,
            flowplate_project_id=flowplate_project_id,
            flow_id=flow_id,
            request_options=request_options,
        )
        return _response.data

    async def get_vector_store_usage(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SuccessResponseVectorStoreUsageResponse:
        """
        Get storage usage breakdown by vector store for the organization

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

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

        Returns
        -------
        SuccessResponseVectorStoreUsageResponse
            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.vector_stores.get_vector_store_usage(
                organization_id="organization_id",
            )


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

    async def get_vector_store(
        self, organization_id: str, vector_store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SuccessResponseVectorStoreResponse:
        """
        Get details about a specific vector store by its ID

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

        vector_store_id : str

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

        Returns
        -------
        SuccessResponseVectorStoreResponse
            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.vector_stores.get_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
            )


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

    async def delete_vector_store(
        self, organization_id: str, vector_store_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Permanently delete a vector store and remove all associated files

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

        vector_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.vector_stores.delete_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
            )


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

    async def update_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        access_mode: typing.Optional[str] = OMIT,
        access_departments: typing.Optional[typing.Sequence[str]] = OMIT,
        access_users: typing.Optional[typing.Sequence[str]] = OMIT,
        flowplate_project_id: typing.Optional[str] = OMIT,
        flow_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreResponse:
        """
        Modify the name, description, or access settings of a vector store

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

        vector_store_id : str

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

        description : typing.Optional[str]
            New description for the vector store

        access_mode : typing.Optional[str]
            New access control level: public, organization, department, private

        access_departments : typing.Optional[typing.Sequence[str]]
            Updated list of department IDs with access

        access_users : typing.Optional[typing.Sequence[str]]
            Updated list of user IDs with access

        flowplate_project_id : typing.Optional[str]
            Flow-plate project ID for organizational scoping

        flow_id : typing.Optional[str]
            Flow-plate flow ID for flow-level scoping

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

        Returns
        -------
        SuccessResponseVectorStoreResponse
            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.vector_stores.update_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_vector_store(
            organization_id,
            vector_store_id,
            name=name,
            description=description,
            access_mode=access_mode,
            access_departments=access_departments,
            access_users=access_users,
            flowplate_project_id=flowplate_project_id,
            flow_id=flow_id,
            request_options=request_options,
        )
        return _response.data
