# 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.workspace_member_create import WorkspaceMemberCreate
from ...types.workspace_member_list import WorkspaceMemberList
from .raw_client import AsyncRawMembersClient, RawMembersClient

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


class MembersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMembersClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._bulk: typing.Optional[BulkClient] = None
        self._paginated: typing.Optional[PaginatedClient] = None

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

        Returns
        -------
        RawMembersClient
        """
        return self._raw_client

    def list(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[WorkspaceMemberList]:
        """
        <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>
        Get a list of all members in a specific workspace.

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

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

        Returns
        -------
        typing.List[WorkspaceMemberList]
            A list of workspace memberships

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.workspaces.members.list(
            id=1,
        )
        """
        _response = self._raw_client.list(id, request_options=request_options)
        return _response.data

    def create(
        self,
        id: int,
        *,
        user: int,
        workspace: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceMemberCreate:
        """
        <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>
        Add a new workspace member by user ID.

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

        user : int
            User ID

        workspace : typing.Optional[int]
            Workspace ID

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

        Returns
        -------
        WorkspaceMemberCreate


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.workspaces.members.create(
            id=1,
            user=1,
        )
        """
        _response = self._raw_client.create(id, user=user, workspace=workspace, 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>
        Remove a specific member by ID from a workspace. This endpoint expects an object like `{"user_id": 123}`.

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

        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.workspaces.members.delete(
            id=1,
        )
        """
        _response = self._raw_client.delete(id, 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

    @property
    def paginated(self):
        if self._paginated is None:
            from .paginated.client import PaginatedClient  # noqa: E402

            self._paginated = PaginatedClient(client_wrapper=self._client_wrapper)
        return self._paginated


class AsyncMembersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._bulk: typing.Optional[AsyncBulkClient] = None
        self._paginated: typing.Optional[AsyncPaginatedClient] = None

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

        Returns
        -------
        AsyncRawMembersClient
        """
        return self._raw_client

    async def list(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[WorkspaceMemberList]:
        """
        <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>
        Get a list of all members in a specific workspace.

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

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

        Returns
        -------
        typing.List[WorkspaceMemberList]
            A list of workspace memberships

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create(
        self,
        id: int,
        *,
        user: int,
        workspace: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkspaceMemberCreate:
        """
        <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>
        Add a new workspace member by user ID.

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

        user : int
            User ID

        workspace : typing.Optional[int]
            Workspace ID

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

        Returns
        -------
        WorkspaceMemberCreate


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.workspaces.members.create(
                id=1,
                user=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(id, user=user, workspace=workspace, 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>
        Remove a specific member by ID from a workspace. This endpoint expects an object like `{"user_id": 123}`.

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

        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.workspaces.members.delete(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(id, 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

    @property
    def paginated(self):
        if self._paginated is None:
            from .paginated.client import AsyncPaginatedClient  # noqa: E402

            self._paginated = AsyncPaginatedClient(client_wrapper=self._client_wrapper)
        return self._paginated
