# 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.annotation_history import AnnotationHistory
from ..types.paginated_annotation_history_list import PaginatedAnnotationHistoryList
from .raw_client import AsyncRawAnnotationHistoryClient, RawAnnotationHistoryClient
from .types.delete_annotation_history_response import DeleteAnnotationHistoryResponse


class AnnotationHistoryClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAnnotationHistoryClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAnnotationHistoryClient
        """
        return self._raw_client

    def list(
        self,
        *,
        annotation: typing.Optional[int] = None,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AnnotationHistory]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List annotation history items for an annotation. Annotation history logs all actions performed with annotations, such as: imports, submits, updates, reviews, and more. Users can view annotation history items in the Annotation History panel during labeling.

        Parameters
        ----------
        annotation : typing.Optional[int]
            Annotation ID to get annotation history items for.

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[AnnotationHistory]


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_history.list()
        """
        _response = self._raw_client.list(annotation=annotation, ordering=ordering, request_options=request_options)
        return _response.data

    def delete(
        self,
        *,
        annotation: typing.Optional[int] = None,
        project: typing.Optional[int] = None,
        task: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeleteAnnotationHistoryResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Delete all annotation history items for a specific annotation, task or project. This method is available only for users with administrator roles.

        Parameters
        ----------
        annotation : typing.Optional[int]
            Annotation ID to delete annotation history items for.

        project : typing.Optional[int]
            Project ID to delete annotation history items for.

        task : typing.Optional[int]
            Task ID to delete annotation history items for.

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

        Returns
        -------
        DeleteAnnotationHistoryResponse
            Returns a dict containing the count of removed items.

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_history.delete()
        """
        _response = self._raw_client.delete(
            annotation=annotation, project=project, task=task, request_options=request_options
        )
        return _response.data

    def list_for_project(
        self,
        id: int,
        *,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PaginatedAnnotationHistoryList:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List all annotation history items for the project with pagination.

        Parameters
        ----------
        id : int

        page : typing.Optional[int]
            A page number within the paginated result set.

        page_size : typing.Optional[int]
            Number of results to return per page.

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

        Returns
        -------
        PaginatedAnnotationHistoryList


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_history.list_for_project(
            id=1,
        )
        """
        _response = self._raw_client.list_for_project(
            id, page=page, page_size=page_size, request_options=request_options
        )
        return _response.data


class AsyncAnnotationHistoryClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAnnotationHistoryClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAnnotationHistoryClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        annotation: typing.Optional[int] = None,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AnnotationHistory]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List annotation history items for an annotation. Annotation history logs all actions performed with annotations, such as: imports, submits, updates, reviews, and more. Users can view annotation history items in the Annotation History panel during labeling.

        Parameters
        ----------
        annotation : typing.Optional[int]
            Annotation ID to get annotation history items for.

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[AnnotationHistory]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.annotation_history.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            annotation=annotation, ordering=ordering, request_options=request_options
        )
        return _response.data

    async def delete(
        self,
        *,
        annotation: typing.Optional[int] = None,
        project: typing.Optional[int] = None,
        task: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeleteAnnotationHistoryResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Delete all annotation history items for a specific annotation, task or project. This method is available only for users with administrator roles.

        Parameters
        ----------
        annotation : typing.Optional[int]
            Annotation ID to delete annotation history items for.

        project : typing.Optional[int]
            Project ID to delete annotation history items for.

        task : typing.Optional[int]
            Task ID to delete annotation history items for.

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

        Returns
        -------
        DeleteAnnotationHistoryResponse
            Returns a dict containing the count of removed items.

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.annotation_history.delete()


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(
            annotation=annotation, project=project, task=task, request_options=request_options
        )
        return _response.data

    async def list_for_project(
        self,
        id: int,
        *,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PaginatedAnnotationHistoryList:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        List all annotation history items for the project with pagination.

        Parameters
        ----------
        id : int

        page : typing.Optional[int]
            A page number within the paginated result set.

        page_size : typing.Optional[int]
            Number of results to return per page.

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

        Returns
        -------
        PaginatedAnnotationHistoryList


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.annotation_history.list_for_project(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_for_project(
            id, page=page, page_size=page_size, request_options=request_options
        )
        return _response.data
