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

import datetime as dt
import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.annotation_review import AnnotationReview
from .raw_client import AsyncRawAnnotationReviewsClient, RawAnnotationReviewsClient

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


class AnnotationReviewsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAnnotationReviewsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAnnotationReviewsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        annotation: typing.Optional[int] = None,
        annotation_task_project: typing.Optional[int] = None,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AnnotationReview]:
        """
        <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 reviews for a specific annotation ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        annotation : typing.Optional[int]

        annotation_task_project : typing.Optional[int]

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

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

        Returns
        -------
        typing.List[AnnotationReview]


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

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

    def create(
        self,
        *,
        annotation: int,
        async_postprocess: typing.Optional[bool] = None,
        accepted: typing.Optional[bool] = OMIT,
        comment: typing.Optional[str] = OMIT,
        last_annotation_history: typing.Optional[int] = OMIT,
        remove_from_queue: typing.Optional[bool] = OMIT,
        result: typing.Optional[typing.Any] = OMIT,
        started_at: typing.Optional[dt.datetime] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AnnotationReview:
        """
        <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>
        Create a review for a specific annotation ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        annotation : int
            Corresponding annotation

        async_postprocess : typing.Optional[bool]
            Whether to postprocess the review asynchronously.

        accepted : typing.Optional[bool]
            Accepted or rejected (if false) flag

        comment : typing.Optional[str]

        last_annotation_history : typing.Optional[int]

        remove_from_queue : typing.Optional[bool]

        result : typing.Optional[typing.Any]

        started_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        AnnotationReview


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_reviews.create(
            annotation=1,
        )
        """
        _response = self._raw_client.create(
            annotation=annotation,
            async_postprocess=async_postprocess,
            accepted=accepted,
            comment=comment,
            last_annotation_history=last_annotation_history,
            remove_from_queue=remove_from_queue,
            result=result,
            started_at=started_at,
            request_options=request_options,
        )
        return _response.data

    def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> AnnotationReview:
        """
        <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>
        Retrieve a specific review by ID for an annotation. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        id : int
            A unique integer value identifying this annotation review.

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

        Returns
        -------
        AnnotationReview


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_reviews.get(
            id=1,
        )
        """
        _response = self._raw_client.get(id, request_options=request_options)
        return _response.data

    def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        <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 a review by ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        id : int
            A unique integer value identifying this annotation review.

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

        Returns
        -------
        None

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_reviews.delete(
            id=1,
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data

    def update(
        self,
        id: int,
        *,
        accepted: typing.Optional[bool] = OMIT,
        annotation: typing.Optional[int] = OMIT,
        comment: typing.Optional[str] = OMIT,
        last_annotation_history: typing.Optional[int] = OMIT,
        remove_from_queue: typing.Optional[bool] = OMIT,
        result: typing.Optional[typing.Any] = OMIT,
        started_at: typing.Optional[dt.datetime] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AnnotationReview:
        """
        <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>
        Update a specific review by ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        id : int
            A unique integer value identifying this annotation review.

        accepted : typing.Optional[bool]
            Accepted or rejected (if false) flag

        annotation : typing.Optional[int]
            Corresponding annotation

        comment : typing.Optional[str]

        last_annotation_history : typing.Optional[int]

        remove_from_queue : typing.Optional[bool]

        result : typing.Optional[typing.Any]

        started_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        AnnotationReview


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.annotation_reviews.update(
            id=1,
        )
        """
        _response = self._raw_client.update(
            id,
            accepted=accepted,
            annotation=annotation,
            comment=comment,
            last_annotation_history=last_annotation_history,
            remove_from_queue=remove_from_queue,
            result=result,
            started_at=started_at,
            request_options=request_options,
        )
        return _response.data


class AsyncAnnotationReviewsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAnnotationReviewsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAnnotationReviewsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        annotation: typing.Optional[int] = None,
        annotation_task_project: typing.Optional[int] = None,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AnnotationReview]:
        """
        <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 reviews for a specific annotation ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        annotation : typing.Optional[int]

        annotation_task_project : typing.Optional[int]

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

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

        Returns
        -------
        typing.List[AnnotationReview]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create(
        self,
        *,
        annotation: int,
        async_postprocess: typing.Optional[bool] = None,
        accepted: typing.Optional[bool] = OMIT,
        comment: typing.Optional[str] = OMIT,
        last_annotation_history: typing.Optional[int] = OMIT,
        remove_from_queue: typing.Optional[bool] = OMIT,
        result: typing.Optional[typing.Any] = OMIT,
        started_at: typing.Optional[dt.datetime] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AnnotationReview:
        """
        <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>
        Create a review for a specific annotation ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        annotation : int
            Corresponding annotation

        async_postprocess : typing.Optional[bool]
            Whether to postprocess the review asynchronously.

        accepted : typing.Optional[bool]
            Accepted or rejected (if false) flag

        comment : typing.Optional[str]

        last_annotation_history : typing.Optional[int]

        remove_from_queue : typing.Optional[bool]

        result : typing.Optional[typing.Any]

        started_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        AnnotationReview


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.annotation_reviews.create(
                annotation=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            annotation=annotation,
            async_postprocess=async_postprocess,
            accepted=accepted,
            comment=comment,
            last_annotation_history=last_annotation_history,
            remove_from_queue=remove_from_queue,
            result=result,
            started_at=started_at,
            request_options=request_options,
        )
        return _response.data

    async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> AnnotationReview:
        """
        <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>
        Retrieve a specific review by ID for an annotation. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        id : int
            A unique integer value identifying this annotation review.

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

        Returns
        -------
        AnnotationReview


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        <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 a review by ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        id : int
            A unique integer value identifying this annotation review.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def update(
        self,
        id: int,
        *,
        accepted: typing.Optional[bool] = OMIT,
        annotation: typing.Optional[int] = OMIT,
        comment: typing.Optional[str] = OMIT,
        last_annotation_history: typing.Optional[int] = OMIT,
        remove_from_queue: typing.Optional[bool] = OMIT,
        result: typing.Optional[typing.Any] = OMIT,
        started_at: typing.Optional[dt.datetime] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AnnotationReview:
        """
        <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>
        Update a specific review by ID. Only allowed for organizations with reviewing features enabled.

        Parameters
        ----------
        id : int
            A unique integer value identifying this annotation review.

        accepted : typing.Optional[bool]
            Accepted or rejected (if false) flag

        annotation : typing.Optional[int]
            Corresponding annotation

        comment : typing.Optional[str]

        last_annotation_history : typing.Optional[int]

        remove_from_queue : typing.Optional[bool]

        result : typing.Optional[typing.Any]

        started_at : typing.Optional[dt.datetime]

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

        Returns
        -------
        AnnotationReview


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            accepted=accepted,
            annotation=annotation,
            comment=comment,
            last_annotation_history=last_annotation_history,
            remove_from_queue=remove_from_queue,
            result=result,
            started_at=started_at,
            request_options=request_options,
        )
        return _response.data
