# 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.base64file_upload import Base64FileUpload
from ..types.success_response_dict import SuccessResponseDict
from ..types.success_response_processing_status_response import SuccessResponseProcessingStatusResponse
from ..types.success_response_vector_store_file_list_response import SuccessResponseVectorStoreFileListResponse
from ..types.success_response_vector_store_file_response import SuccessResponseVectorStoreFileResponse
from ..types.vector_store_base64upload_response import VectorStoreBase64UploadResponse
from .raw_client import AsyncRawVectorStoreFilesClient, RawVectorStoreFilesClient

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


class VectorStoreFilesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVectorStoreFilesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawVectorStoreFilesClient
        """
        return self._raw_client

    def list_files_in_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        status: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreFileListResponse:
        """
        Get a list of all files attached to a vector store. Supports both user and API key authentication.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        page : typing.Optional[int]
            Page number for pagination

        page_size : typing.Optional[int]
            Number of items per page

        status : typing.Optional[str]
            Filter by processing status (comma-separated)

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

        Returns
        -------
        SuccessResponseVectorStoreFileListResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_store_files.list_files_in_vector_store(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
        )
        """
        _response = self._raw_client.list_files_in_vector_store(
            organization_id,
            vector_store_id,
            page=page,
            page_size=page_size,
            status=status,
            request_options=request_options,
        )
        return _response.data

    def add_file_to_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        file_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreFileResponse:
        """
        Attach an uploaded file to a vector store for semantic search. Supports both user and API key authentication.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The ID of the file to add to the vector store

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

        Returns
        -------
        SuccessResponseVectorStoreFileResponse
            Successful Response

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

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

    def upload_base64files_to_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        files: typing.Sequence[Base64FileUpload],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VectorStoreBase64UploadResponse:
        """
        Upload one or more base64-encoded files directly to a vector store in a single request. Handles file upload, registration, and vector store attachment automatically.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        files : typing.Sequence[Base64FileUpload]
            List of base64-encoded files to upload

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

        Returns
        -------
        VectorStoreBase64UploadResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos, Base64FileUpload

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_store_files.upload_base64files_to_vector_store(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
            files=[
                Base64FileUpload(
                    filename="filename",
                    content="content",
                    mime_type="mime_type",
                )
            ],
        )
        """
        _response = self._raw_client.upload_base64files_to_vector_store(
            organization_id, vector_store_id, files=files, request_options=request_options
        )
        return _response.data

    def get_processing_status(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseProcessingStatusResponse:
        """
        Get the processing status of a file in a vector store.

        Parameters
        ----------
        organization_id : str
            Organization ID

        vector_store_id : str
            Vector Store ID

        file_id : str
            File ID

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

        Returns
        -------
        SuccessResponseProcessingStatusResponse
            Successful Response

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

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

    def retry_failed_processing(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        reset_error: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseProcessingStatusResponse:
        """
        Retry processing for a file that failed.

        Parameters
        ----------
        organization_id : str
            Organization ID

        vector_store_id : str
            Vector Store ID

        file_id : str
            File ID

        reset_error : typing.Optional[bool]
            Clear previous error message

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

        Returns
        -------
        SuccessResponseProcessingStatusResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.vector_store_files.retry_failed_processing(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
            file_id="file_id",
        )
        """
        _response = self._raw_client.retry_failed_processing(
            organization_id, vector_store_id, file_id, reset_error=reset_error, request_options=request_options
        )
        return _response.data

    def get_file_details(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreFileResponse:
        """
        Get complete details about a specific file in a vector store, including processing status and metadata.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The unique identifier of the file

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

        Returns
        -------
        SuccessResponseVectorStoreFileResponse
            Successful Response

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

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

    def remove_file_from_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Remove a file from a vector store, making it unavailable for semantic search. Supports both user and API key authentication.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The unique identifier of the file

        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_store_files.remove_file_from_vector_store(
            organization_id="organization_id",
            vector_store_id="vector_store_id",
            file_id="file_id",
        )
        """
        _response = self._raw_client.remove_file_from_vector_store(
            organization_id, vector_store_id, file_id, request_options=request_options
        )
        return _response.data

    def get_file_processing_logs(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseDict:
        """
        Get processing logs and history for a file, useful for debugging processing issues.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The unique identifier of the file

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

        Returns
        -------
        SuccessResponseDict
            Successful Response

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

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


class AsyncVectorStoreFilesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVectorStoreFilesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawVectorStoreFilesClient
        """
        return self._raw_client

    async def list_files_in_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        status: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreFileListResponse:
        """
        Get a list of all files attached to a vector store. Supports both user and API key authentication.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        page : typing.Optional[int]
            Page number for pagination

        page_size : typing.Optional[int]
            Number of items per page

        status : typing.Optional[str]
            Filter by processing status (comma-separated)

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

        Returns
        -------
        SuccessResponseVectorStoreFileListResponse
            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_store_files.list_files_in_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_files_in_vector_store(
            organization_id,
            vector_store_id,
            page=page,
            page_size=page_size,
            status=status,
            request_options=request_options,
        )
        return _response.data

    async def add_file_to_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        file_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreFileResponse:
        """
        Attach an uploaded file to a vector store for semantic search. Supports both user and API key authentication.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The ID of the file to add to the vector store

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

        Returns
        -------
        SuccessResponseVectorStoreFileResponse
            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_store_files.add_file_to_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                file_id="file_id",
            )


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

    async def upload_base64files_to_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        *,
        files: typing.Sequence[Base64FileUpload],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> VectorStoreBase64UploadResponse:
        """
        Upload one or more base64-encoded files directly to a vector store in a single request. Handles file upload, registration, and vector store attachment automatically.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        files : typing.Sequence[Base64FileUpload]
            List of base64-encoded files to upload

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

        Returns
        -------
        VectorStoreBase64UploadResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos, Base64FileUpload

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


        async def main() -> None:
            await client.vector_store_files.upload_base64files_to_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                files=[
                    Base64FileUpload(
                        filename="filename",
                        content="content",
                        mime_type="mime_type",
                    )
                ],
            )


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

    async def get_processing_status(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseProcessingStatusResponse:
        """
        Get the processing status of a file in a vector store.

        Parameters
        ----------
        organization_id : str
            Organization ID

        vector_store_id : str
            Vector Store ID

        file_id : str
            File ID

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

        Returns
        -------
        SuccessResponseProcessingStatusResponse
            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_store_files.get_processing_status(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                file_id="file_id",
            )


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

    async def retry_failed_processing(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        reset_error: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseProcessingStatusResponse:
        """
        Retry processing for a file that failed.

        Parameters
        ----------
        organization_id : str
            Organization ID

        vector_store_id : str
            Vector Store ID

        file_id : str
            File ID

        reset_error : typing.Optional[bool]
            Clear previous error message

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

        Returns
        -------
        SuccessResponseProcessingStatusResponse
            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_store_files.retry_failed_processing(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                file_id="file_id",
            )


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

    async def get_file_details(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseVectorStoreFileResponse:
        """
        Get complete details about a specific file in a vector store, including processing status and metadata.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The unique identifier of the file

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

        Returns
        -------
        SuccessResponseVectorStoreFileResponse
            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_store_files.get_file_details(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                file_id="file_id",
            )


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

    async def remove_file_from_vector_store(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Remove a file from a vector store, making it unavailable for semantic search. Supports both user and API key authentication.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The unique identifier of the file

        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_store_files.remove_file_from_vector_store(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                file_id="file_id",
            )


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

    async def get_file_processing_logs(
        self,
        organization_id: str,
        vector_store_id: str,
        file_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SuccessResponseDict:
        """
        Get processing logs and history for a file, useful for debugging processing issues.

        Parameters
        ----------
        organization_id : str
            The unique identifier of the organization

        vector_store_id : str
            The unique identifier of the vector store

        file_id : str
            The unique identifier of the file

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

        Returns
        -------
        SuccessResponseDict
            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_store_files.get_file_processing_logs(
                organization_id="organization_id",
                vector_store_id="vector_store_id",
                file_id="file_id",
            )


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