# 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.my_access_response import MyAccessResponse
from ..types.remove_user_request import RemoveUserRequest
from ..types.ui_access_response import UiAccessResponse
from ..types.user_v2response import UserV2Response
from .raw_client import AsyncRawUsersV2Client, RawUsersV2Client

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


class UsersV2Client:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawUsersV2Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawUsersV2Client
        """
        return self._raw_client

    def remove_user(
        self,
        organization_id: str,
        user_id: str,
        *,
        request: typing.Optional[RemoveUserRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Remove a user from an organization.

        Parameters
        ----------
        organization_id : str

        user_id : str

        request : typing.Optional[RemoveUserRequest]

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

        Returns
        -------
        None

        Examples
        --------
        from aitronos import Aitronos, RemoveUserRequest

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.remove_user(
            organization_id="organization_id",
            user_id="user_id",
            request=RemoveUserRequest(),
        )
        """
        _response = self._raw_client.remove_user(
            organization_id, user_id, request=request, request_options=request_options
        )
        return _response.data

    def deactivate_user(
        self,
        organization_id: str,
        user_id: str,
        *,
        transfer_resources_to_department_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserV2Response:
        """
        Deactivate a user in an organization.

        Parameters
        ----------
        organization_id : str

        user_id : str

        transfer_resources_to_department_id : str

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.deactivate_user(
            organization_id="organization_id",
            user_id="user_id",
            transfer_resources_to_department_id="transfer_resources_to_department_id",
        )
        """
        _response = self._raw_client.deactivate_user(
            organization_id,
            user_id,
            transfer_resources_to_department_id=transfer_resources_to_department_id,
            request_options=request_options,
        )
        return _response.data

    def invite_user_v2(
        self,
        organization_id: str,
        *,
        email: str,
        full_name: typing.Optional[str] = OMIT,
        role_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        department_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        send_invitation: typing.Optional[bool] = OMIT,
        custom_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserV2Response:
        """
        Invite a user to an organization with roles and departments.

        Parameters
        ----------
        organization_id : str

        email : str

        full_name : typing.Optional[str]

        role_ids : typing.Optional[typing.Sequence[str]]

        department_ids : typing.Optional[typing.Sequence[str]]

        send_invitation : typing.Optional[bool]

        custom_message : typing.Optional[str]

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.invite_user_v2(
            organization_id="organization_id",
            email="email",
        )
        """
        _response = self._raw_client.invite_user_v2(
            organization_id,
            email=email,
            full_name=full_name,
            role_ids=role_ids,
            department_ids=department_ids,
            send_invitation=send_invitation,
            custom_message=custom_message,
            request_options=request_options,
        )
        return _response.data

    def update_memberships(
        self,
        organization_id: str,
        user_id: str,
        *,
        role_ids: typing.Sequence[str],
        department_ids: typing.Sequence[str],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserV2Response:
        """
        Update a user's role and department assignments.

        Parameters
        ----------
        organization_id : str

        user_id : str

        role_ids : typing.Sequence[str]

        department_ids : typing.Sequence[str]

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.update_memberships(
            organization_id="organization_id",
            user_id="user_id",
            role_ids=["role_ids"],
            department_ids=["department_ids"],
        )
        """
        _response = self._raw_client.update_memberships(
            organization_id, user_id, role_ids=role_ids, department_ids=department_ids, request_options=request_options
        )
        return _response.data

    def reactivate_user(
        self, organization_id: str, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> UserV2Response:
        """
        Reactivate a deactivated user in an organization.

        Parameters
        ----------
        organization_id : str

        user_id : str

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.reactivate_user(
            organization_id="organization_id",
            user_id="user_id",
        )
        """
        _response = self._raw_client.reactivate_user(organization_id, user_id, request_options=request_options)
        return _response.data

    def get_ui_access(
        self, organization_id: str, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> UiAccessResponse:
        """
        Return UI access flags for a user.

        Parameters
        ----------
        organization_id : str

        user_id : str

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

        Returns
        -------
        UiAccessResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.get_ui_access(
            organization_id="organization_id",
            user_id="user_id",
        )
        """
        _response = self._raw_client.get_ui_access(organization_id, user_id, request_options=request_options)
        return _response.data

    def get_my_access(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> MyAccessResponse:
        """
        Get a comprehensive view of what the current user can and cannot do.

        Parameters
        ----------
        organization_id : str

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

        Returns
        -------
        MyAccessResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.users_v2.get_my_access(
            organization_id="organization_id",
        )
        """
        _response = self._raw_client.get_my_access(organization_id, request_options=request_options)
        return _response.data


class AsyncUsersV2Client:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawUsersV2Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawUsersV2Client
        """
        return self._raw_client

    async def remove_user(
        self,
        organization_id: str,
        user_id: str,
        *,
        request: typing.Optional[RemoveUserRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Remove a user from an organization.

        Parameters
        ----------
        organization_id : str

        user_id : str

        request : typing.Optional[RemoveUserRequest]

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos, RemoveUserRequest

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.remove_user(
                organization_id="organization_id",
                user_id="user_id",
                request=RemoveUserRequest(),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.remove_user(
            organization_id, user_id, request=request, request_options=request_options
        )
        return _response.data

    async def deactivate_user(
        self,
        organization_id: str,
        user_id: str,
        *,
        transfer_resources_to_department_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserV2Response:
        """
        Deactivate a user in an organization.

        Parameters
        ----------
        organization_id : str

        user_id : str

        transfer_resources_to_department_id : str

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.deactivate_user(
                organization_id="organization_id",
                user_id="user_id",
                transfer_resources_to_department_id="transfer_resources_to_department_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.deactivate_user(
            organization_id,
            user_id,
            transfer_resources_to_department_id=transfer_resources_to_department_id,
            request_options=request_options,
        )
        return _response.data

    async def invite_user_v2(
        self,
        organization_id: str,
        *,
        email: str,
        full_name: typing.Optional[str] = OMIT,
        role_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        department_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        send_invitation: typing.Optional[bool] = OMIT,
        custom_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserV2Response:
        """
        Invite a user to an organization with roles and departments.

        Parameters
        ----------
        organization_id : str

        email : str

        full_name : typing.Optional[str]

        role_ids : typing.Optional[typing.Sequence[str]]

        department_ids : typing.Optional[typing.Sequence[str]]

        send_invitation : typing.Optional[bool]

        custom_message : typing.Optional[str]

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.invite_user_v2(
                organization_id="organization_id",
                email="email",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.invite_user_v2(
            organization_id,
            email=email,
            full_name=full_name,
            role_ids=role_ids,
            department_ids=department_ids,
            send_invitation=send_invitation,
            custom_message=custom_message,
            request_options=request_options,
        )
        return _response.data

    async def update_memberships(
        self,
        organization_id: str,
        user_id: str,
        *,
        role_ids: typing.Sequence[str],
        department_ids: typing.Sequence[str],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserV2Response:
        """
        Update a user's role and department assignments.

        Parameters
        ----------
        organization_id : str

        user_id : str

        role_ids : typing.Sequence[str]

        department_ids : typing.Sequence[str]

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.update_memberships(
                organization_id="organization_id",
                user_id="user_id",
                role_ids=["role_ids"],
                department_ids=["department_ids"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_memberships(
            organization_id, user_id, role_ids=role_ids, department_ids=department_ids, request_options=request_options
        )
        return _response.data

    async def reactivate_user(
        self, organization_id: str, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> UserV2Response:
        """
        Reactivate a deactivated user in an organization.

        Parameters
        ----------
        organization_id : str

        user_id : str

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

        Returns
        -------
        UserV2Response
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.reactivate_user(
                organization_id="organization_id",
                user_id="user_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.reactivate_user(organization_id, user_id, request_options=request_options)
        return _response.data

    async def get_ui_access(
        self, organization_id: str, user_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> UiAccessResponse:
        """
        Return UI access flags for a user.

        Parameters
        ----------
        organization_id : str

        user_id : str

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

        Returns
        -------
        UiAccessResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.get_ui_access(
                organization_id="organization_id",
                user_id="user_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_ui_access(organization_id, user_id, request_options=request_options)
        return _response.data

    async def get_my_access(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> MyAccessResponse:
        """
        Get a comprehensive view of what the current user can and cannot do.

        Parameters
        ----------
        organization_id : str

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

        Returns
        -------
        MyAccessResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.users_v2.get_my_access(
                organization_id="organization_id",
            )


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