# 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.maybe_expanded_comment import MaybeExpandedComment
from .raw_client import AsyncRawCommentsClient, RawCommentsClient

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


class CommentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCommentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCommentsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        annotation: typing.Optional[int] = None,
        annotators: typing.Optional[str] = None,
        draft: typing.Optional[int] = None,
        expand_created_by: typing.Optional[bool] = None,
        ordering: typing.Optional[str] = None,
        projects: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[MaybeExpandedComment]:
        """
        <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 comments for a specific annotation ID.

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

        annotators : typing.Optional[str]

        draft : typing.Optional[int]

        expand_created_by : typing.Optional[bool]

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

        projects : typing.Optional[str]

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

        Returns
        -------
        typing.List[MaybeExpandedComment]
            List of comments

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.comments.list()
        """
        _response = self._raw_client.list(
            annotation=annotation,
            annotators=annotators,
            draft=draft,
            expand_created_by=expand_created_by,
            ordering=ordering,
            projects=projects,
            request_options=request_options,
        )
        return _response.data

    def create(
        self,
        *,
        expand_created_by: typing.Optional[bool] = None,
        annotation: typing.Optional[int] = OMIT,
        classifications: typing.Optional[typing.Any] = OMIT,
        draft: typing.Optional[int] = OMIT,
        is_resolved: typing.Optional[bool] = OMIT,
        region_ref: typing.Optional[typing.Any] = OMIT,
        text: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MaybeExpandedComment:
        """
        <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 comment for a specific annotation ID.

        Parameters
        ----------
        expand_created_by : typing.Optional[bool]
            Expand the created_by field

        annotation : typing.Optional[int]

        classifications : typing.Optional[typing.Any]
            Classifications applied by a reviewer or annotator

        draft : typing.Optional[int]

        is_resolved : typing.Optional[bool]
            True if the comment is resolved

        region_ref : typing.Optional[typing.Any]
            Set if this comment is related to a specific part of the annotation. Normally contains region ID and control name.

        text : typing.Optional[str]
            Reviewer or annotator comment

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

        Returns
        -------
        MaybeExpandedComment


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.comments.create()
        """
        _response = self._raw_client.create(
            expand_created_by=expand_created_by,
            annotation=annotation,
            classifications=classifications,
            draft=draft,
            is_resolved=is_resolved,
            region_ref=region_ref,
            text=text,
            request_options=request_options,
        )
        return _response.data

    def export(
        self,
        *,
        annotation: typing.Optional[int] = None,
        annotators: typing.Optional[str] = None,
        draft: typing.Optional[int] = None,
        expand_created_by: typing.Optional[bool] = None,
        projects: typing.Optional[str] = None,
        tz: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[bytes]:
        """
        <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>
        Export comments to CSV file

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

        annotators : typing.Optional[str]

        draft : typing.Optional[int]

        expand_created_by : typing.Optional[bool]

        projects : typing.Optional[str]

        tz : typing.Optional[str]
            Timezone in which to export the data. Format IANA timezone name, e.g. "America/New_York"

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            CSV file with comments
        """
        with self._raw_client.export(
            annotation=annotation,
            annotators=annotators,
            draft=draft,
            expand_created_by=expand_created_by,
            projects=projects,
            tz=tz,
            request_options=request_options,
        ) as r:
            yield from r.data

    def get(
        self,
        id: str,
        *,
        expand_created_by: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MaybeExpandedComment:
        """
        <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 comment by ID for an annotation.

        Parameters
        ----------
        id : str

        expand_created_by : typing.Optional[bool]
            Expand the created_by field

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

        Returns
        -------
        MaybeExpandedComment


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

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

    def delete(
        self,
        id: str,
        *,
        expand_created_by: typing.Optional[bool] = None,
        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 comment by ID

        Parameters
        ----------
        id : str

        expand_created_by : typing.Optional[bool]
            Expand the created_by field

        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.comments.delete(
            id="id",
        )
        """
        _response = self._raw_client.delete(id, expand_created_by=expand_created_by, request_options=request_options)
        return _response.data

    def update(
        self,
        id: str,
        *,
        expand_created_by: typing.Optional[bool] = None,
        annotation: typing.Optional[int] = OMIT,
        classifications: typing.Optional[typing.Any] = OMIT,
        draft: typing.Optional[int] = OMIT,
        is_resolved: typing.Optional[bool] = OMIT,
        region_ref: typing.Optional[typing.Any] = OMIT,
        text: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MaybeExpandedComment:
        """
        <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 comment by ID.

        Parameters
        ----------
        id : str

        expand_created_by : typing.Optional[bool]
            Expand the created_by field

        annotation : typing.Optional[int]

        classifications : typing.Optional[typing.Any]
            Classifications applied by a reviewer or annotator

        draft : typing.Optional[int]

        is_resolved : typing.Optional[bool]
            True if the comment is resolved

        region_ref : typing.Optional[typing.Any]
            Set if this comment is related to a specific part of the annotation. Normally contains region ID and control name.

        text : typing.Optional[str]
            Reviewer or annotator comment

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

        Returns
        -------
        MaybeExpandedComment


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.comments.update(
            id="id",
        )
        """
        _response = self._raw_client.update(
            id,
            expand_created_by=expand_created_by,
            annotation=annotation,
            classifications=classifications,
            draft=draft,
            is_resolved=is_resolved,
            region_ref=region_ref,
            text=text,
            request_options=request_options,
        )
        return _response.data


class AsyncCommentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCommentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCommentsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        annotation: typing.Optional[int] = None,
        annotators: typing.Optional[str] = None,
        draft: typing.Optional[int] = None,
        expand_created_by: typing.Optional[bool] = None,
        ordering: typing.Optional[str] = None,
        projects: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[MaybeExpandedComment]:
        """
        <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 comments for a specific annotation ID.

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

        annotators : typing.Optional[str]

        draft : typing.Optional[int]

        expand_created_by : typing.Optional[bool]

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

        projects : typing.Optional[str]

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

        Returns
        -------
        typing.List[MaybeExpandedComment]
            List of comments

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create(
        self,
        *,
        expand_created_by: typing.Optional[bool] = None,
        annotation: typing.Optional[int] = OMIT,
        classifications: typing.Optional[typing.Any] = OMIT,
        draft: typing.Optional[int] = OMIT,
        is_resolved: typing.Optional[bool] = OMIT,
        region_ref: typing.Optional[typing.Any] = OMIT,
        text: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MaybeExpandedComment:
        """
        <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 comment for a specific annotation ID.

        Parameters
        ----------
        expand_created_by : typing.Optional[bool]
            Expand the created_by field

        annotation : typing.Optional[int]

        classifications : typing.Optional[typing.Any]
            Classifications applied by a reviewer or annotator

        draft : typing.Optional[int]

        is_resolved : typing.Optional[bool]
            True if the comment is resolved

        region_ref : typing.Optional[typing.Any]
            Set if this comment is related to a specific part of the annotation. Normally contains region ID and control name.

        text : typing.Optional[str]
            Reviewer or annotator comment

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

        Returns
        -------
        MaybeExpandedComment


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.comments.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            expand_created_by=expand_created_by,
            annotation=annotation,
            classifications=classifications,
            draft=draft,
            is_resolved=is_resolved,
            region_ref=region_ref,
            text=text,
            request_options=request_options,
        )
        return _response.data

    async def export(
        self,
        *,
        annotation: typing.Optional[int] = None,
        annotators: typing.Optional[str] = None,
        draft: typing.Optional[int] = None,
        expand_created_by: typing.Optional[bool] = None,
        projects: typing.Optional[str] = None,
        tz: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[bytes]:
        """
        <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>
        Export comments to CSV file

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

        annotators : typing.Optional[str]

        draft : typing.Optional[int]

        expand_created_by : typing.Optional[bool]

        projects : typing.Optional[str]

        tz : typing.Optional[str]
            Timezone in which to export the data. Format IANA timezone name, e.g. "America/New_York"

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            CSV file with comments
        """
        async with self._raw_client.export(
            annotation=annotation,
            annotators=annotators,
            draft=draft,
            expand_created_by=expand_created_by,
            projects=projects,
            tz=tz,
            request_options=request_options,
        ) as r:
            async for _chunk in r.data:
                yield _chunk

    async def get(
        self,
        id: str,
        *,
        expand_created_by: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MaybeExpandedComment:
        """
        <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 comment by ID for an annotation.

        Parameters
        ----------
        id : str

        expand_created_by : typing.Optional[bool]
            Expand the created_by field

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

        Returns
        -------
        MaybeExpandedComment


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def delete(
        self,
        id: str,
        *,
        expand_created_by: typing.Optional[bool] = None,
        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 comment by ID

        Parameters
        ----------
        id : str

        expand_created_by : typing.Optional[bool]
            Expand the created_by field

        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.comments.delete(
                id="id",
            )


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

    async def update(
        self,
        id: str,
        *,
        expand_created_by: typing.Optional[bool] = None,
        annotation: typing.Optional[int] = OMIT,
        classifications: typing.Optional[typing.Any] = OMIT,
        draft: typing.Optional[int] = OMIT,
        is_resolved: typing.Optional[bool] = OMIT,
        region_ref: typing.Optional[typing.Any] = OMIT,
        text: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MaybeExpandedComment:
        """
        <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 comment by ID.

        Parameters
        ----------
        id : str

        expand_created_by : typing.Optional[bool]
            Expand the created_by field

        annotation : typing.Optional[int]

        classifications : typing.Optional[typing.Any]
            Classifications applied by a reviewer or annotator

        draft : typing.Optional[int]

        is_resolved : typing.Optional[bool]
            True if the comment is resolved

        region_ref : typing.Optional[typing.Any]
            Set if this comment is related to a specific part of the annotation. Normally contains region ID and control name.

        text : typing.Optional[str]
            Reviewer or annotator comment

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

        Returns
        -------
        MaybeExpandedComment


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            expand_created_by=expand_created_by,
            annotation=annotation,
            classifications=classifications,
            draft=draft,
            is_resolved=is_resolved,
            region_ref=region_ref,
            text=text,
            request_options=request_options,
        )
        return _response.data
