# 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.delete_project_member_v1response import DeleteProjectMemberV1Response
from .....types.list_project_members_v1response import ListProjectMembersV1Response
from .raw_client import AsyncRawMembersClient, RawMembersClient

if typing.TYPE_CHECKING:
    from .invites.client import AsyncInvitesClient, InvitesClient
    from .scopes.client import AsyncScopesClient, ScopesClient


class MembersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMembersClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._invites: typing.Optional[InvitesClient] = None
        self._scopes: typing.Optional[ScopesClient] = 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, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListProjectMembersV1Response:
        """
        Retrieves a list of members for a given project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

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

        Returns
        -------
        ListProjectMembersV1Response
            A list of members for a given project

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.manage.v1.projects.members.list(
            project_id="123456-7890-1234-5678-901234",
        )
        """
        _response = self._raw_client.list(project_id, request_options=request_options)
        return _response.data

    def delete(
        self, project_id: str, member_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteProjectMemberV1Response:
        """
        Removes a member from the project using their unique member ID

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        member_id : str
            The unique identifier of the Member

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

        Returns
        -------
        DeleteProjectMemberV1Response
            Delete the specific member from the project

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.manage.v1.projects.members.delete(
            project_id="123456-7890-1234-5678-901234",
            member_id="123456789012345678901234",
        )
        """
        _response = self._raw_client.delete(project_id, member_id, request_options=request_options)
        return _response.data

    @property
    def invites(self):
        if self._invites is None:
            from .invites.client import InvitesClient  # noqa: E402

            self._invites = InvitesClient(client_wrapper=self._client_wrapper)
        return self._invites

    @property
    def scopes(self):
        if self._scopes is None:
            from .scopes.client import ScopesClient  # noqa: E402

            self._scopes = ScopesClient(client_wrapper=self._client_wrapper)
        return self._scopes


class AsyncMembersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._invites: typing.Optional[AsyncInvitesClient] = None
        self._scopes: typing.Optional[AsyncScopesClient] = 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, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListProjectMembersV1Response:
        """
        Retrieves a list of members for a given project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

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

        Returns
        -------
        ListProjectMembersV1Response
            A list of members for a given project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.manage.v1.projects.members.list(
                project_id="123456-7890-1234-5678-901234",
            )


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

    async def delete(
        self, project_id: str, member_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteProjectMemberV1Response:
        """
        Removes a member from the project using their unique member ID

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        member_id : str
            The unique identifier of the Member

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

        Returns
        -------
        DeleteProjectMemberV1Response
            Delete the specific member from the project

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.manage.v1.projects.members.delete(
                project_id="123456-7890-1234-5678-901234",
                member_id="123456789012345678901234",
            )


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

    @property
    def invites(self):
        if self._invites is None:
            from .invites.client import AsyncInvitesClient  # noqa: E402

            self._invites = AsyncInvitesClient(client_wrapper=self._client_wrapper)
        return self._invites

    @property
    def scopes(self):
        if self._scopes is None:
            from .scopes.client import AsyncScopesClient  # noqa: E402

            self._scopes = AsyncScopesClient(client_wrapper=self._client_wrapper)
        return self._scopes
