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

from __future__ import annotations

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from ...types.organization_member_tag import OrganizationMemberTag
from ...types.organization_member_tag_assignment_request import OrganizationMemberTagAssignmentRequest
from ...types.paginated_organization_member_tag_list import PaginatedOrganizationMemberTagList
from .raw_client import AsyncRawMemberTagsClient, RawMemberTagsClient
from .types.assign_member_tags_response import AssignMemberTagsResponse

if typing.TYPE_CHECKING:
    from .bulk.client import AsyncBulkClient, BulkClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class MemberTagsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMemberTagsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._bulk: typing.Optional[BulkClient] = None

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

        Returns
        -------
        RawMemberTagsClient
        """
        return self._raw_client

    def list(
        self,
        id: int,
        *,
        page: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PaginatedOrganizationMemberTagList:
        """
        <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 list of all member tags for a specific organization.

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

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

        search : typing.Optional[str]
            Search tags by label (case-insensitive).

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

        Returns
        -------
        PaginatedOrganizationMemberTagList


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.organizations.member_tags.list(
            id=1,
        )
        """
        _response = self._raw_client.list(id, page=page, search=search, request_options=request_options)
        return _response.data

    def create(
        self, id: int, *, label: str, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationMemberTag:
        """
        <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 new member tag for a specific organization.

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

        label : str

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

        Returns
        -------
        OrganizationMemberTag


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.organizations.member_tags.create(
            id=1,
            label="label",
        )
        """
        _response = self._raw_client.create(id, label=label, request_options=request_options)
        return _response.data

    def assign(
        self,
        id: int,
        *,
        assignments: typing.Sequence[OrganizationMemberTagAssignmentRequest],
        overwrite: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AssignMemberTagsResponse:
        """
        <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>
        Assign tags to multiple organization members in bulk.

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

        assignments : typing.Sequence[OrganizationMemberTagAssignmentRequest]
            List of member tag assignments to assign.

        overwrite : typing.Optional[bool]
            If true, replace all existing tag assignments for each user with the provided ones. If false, only add new assignments.

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

        Returns
        -------
        AssignMemberTagsResponse
            Number of tag assignments created

        Examples
        --------
        from label_studio_sdk import LabelStudio, OrganizationMemberTagAssignmentRequest

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.organizations.member_tags.assign(
            id=1,
            assignments=[
                OrganizationMemberTagAssignmentRequest(
                    tag_ids=[1],
                    user_id=1,
                )
            ],
        )
        """
        _response = self._raw_client.assign(
            id, assignments=assignments, overwrite=overwrite, request_options=request_options
        )
        return _response.data

    def get(
        self, id: int, tag_pk: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationMemberTag:
        """
        <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 details of a specific member tag.

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

        tag_pk : int
            A unique integer value identifying this member tag.

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

        Returns
        -------
        OrganizationMemberTag


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

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

    def delete(self, id: int, tag_pk: 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 member tag from the organization.

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

        tag_pk : int
            A unique integer value identifying this member tag.

        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.organizations.member_tags.delete(
            id=1,
            tag_pk=1,
        )
        """
        _response = self._raw_client.delete(id, tag_pk, request_options=request_options)
        return _response.data

    def update(
        self,
        id: int,
        tag_pk: int,
        *,
        label: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationMemberTag:
        """
        <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>
        Partially update an existing member tag.

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

        tag_pk : int
            A unique integer value identifying this member tag.

        label : typing.Optional[str]

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

        Returns
        -------
        OrganizationMemberTag


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.organizations.member_tags.update(
            id=1,
            tag_pk=1,
        )
        """
        _response = self._raw_client.update(id, tag_pk, label=label, request_options=request_options)
        return _response.data

    @property
    def bulk(self):
        if self._bulk is None:
            from .bulk.client import BulkClient  # noqa: E402

            self._bulk = BulkClient(client_wrapper=self._client_wrapper)
        return self._bulk


class AsyncMemberTagsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMemberTagsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._bulk: typing.Optional[AsyncBulkClient] = None

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

        Returns
        -------
        AsyncRawMemberTagsClient
        """
        return self._raw_client

    async def list(
        self,
        id: int,
        *,
        page: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PaginatedOrganizationMemberTagList:
        """
        <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 list of all member tags for a specific organization.

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

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

        search : typing.Optional[str]
            Search tags by label (case-insensitive).

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

        Returns
        -------
        PaginatedOrganizationMemberTagList


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.organizations.member_tags.list(
                id=1,
            )


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

    async def create(
        self, id: int, *, label: str, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationMemberTag:
        """
        <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 new member tag for a specific organization.

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

        label : str

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

        Returns
        -------
        OrganizationMemberTag


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.organizations.member_tags.create(
                id=1,
                label="label",
            )


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

    async def assign(
        self,
        id: int,
        *,
        assignments: typing.Sequence[OrganizationMemberTagAssignmentRequest],
        overwrite: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AssignMemberTagsResponse:
        """
        <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>
        Assign tags to multiple organization members in bulk.

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

        assignments : typing.Sequence[OrganizationMemberTagAssignmentRequest]
            List of member tag assignments to assign.

        overwrite : typing.Optional[bool]
            If true, replace all existing tag assignments for each user with the provided ones. If false, only add new assignments.

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

        Returns
        -------
        AssignMemberTagsResponse
            Number of tag assignments created

        Examples
        --------
        import asyncio

        from label_studio_sdk import (
            AsyncLabelStudio,
            OrganizationMemberTagAssignmentRequest,
        )

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.organizations.member_tags.assign(
                id=1,
                assignments=[
                    OrganizationMemberTagAssignmentRequest(
                        tag_ids=[1],
                        user_id=1,
                    )
                ],
            )


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

    async def get(
        self, id: int, tag_pk: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> OrganizationMemberTag:
        """
        <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 details of a specific member tag.

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

        tag_pk : int
            A unique integer value identifying this member tag.

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

        Returns
        -------
        OrganizationMemberTag


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def delete(self, id: int, tag_pk: 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 member tag from the organization.

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

        tag_pk : int
            A unique integer value identifying this member tag.

        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.organizations.member_tags.delete(
                id=1,
                tag_pk=1,
            )


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

    async def update(
        self,
        id: int,
        tag_pk: int,
        *,
        label: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationMemberTag:
        """
        <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>
        Partially update an existing member tag.

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

        tag_pk : int
            A unique integer value identifying this member tag.

        label : typing.Optional[str]

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

        Returns
        -------
        OrganizationMemberTag


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    @property
    def bulk(self):
        if self._bulk is None:
            from .bulk.client import AsyncBulkClient  # noqa: E402

            self._bulk = AsyncBulkClient(client_wrapper=self._client_wrapper)
        return self._bulk
