# 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.include_total_count import IncludeTotalCount
from ..types.request_after_opaque_cursor import RequestAfterOpaqueCursor
from ..types.request_page_size import RequestPageSize
from ..types.update_user_roles_response import UpdateUserRolesResponse
from ..types.user_roles_response import UserRolesResponse
from ..types.uuid_ import Uuid
from .raw_client import AsyncRawFolderPermissionsClient, RawFolderPermissionsClient
from .types.update_user_roles_params_data import UpdateUserRolesParamsData

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


class FolderPermissionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawFolderPermissionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawFolderPermissionsClient
        """
        return self._raw_client

    def folder_user_roles_index(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include_deactivated: typing.Optional[bool] = None,
        after: typing.Optional[RequestAfterOpaqueCursor] = None,
        page_size: typing.Optional[RequestPageSize] = None,
        include_total_count: typing.Optional[IncludeTotalCount] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserRolesResponse:
        """
        List user roles for a given folder. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        folder_id : Uuid


        include_deactivated : typing.Optional[bool]
            Supports including deactivated users in the response. Default is false.

        after : typing.Optional[RequestAfterOpaqueCursor]
            Opaque Cursor query param for requests returning paginated results.
            <br/>
            NOTE: this value is auto-generated and included as part of links from a previous response. It is not intended to be human readable.

        page_size : typing.Optional[RequestPageSize]


        include_total_count : typing.Optional[IncludeTotalCount]


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

        Returns
        -------
        UserRolesResponse
            OK

        Examples
        --------
        from frameio_experimental import FrameioExperimental

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.folder_permissions.folder_user_roles_index(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            include_deactivated=True,
            after="<opaque_cursor>",
            page_size=10,
            include_total_count=False,
        )
        """
        _response = self._raw_client.folder_user_roles_index(
            account_id,
            folder_id,
            include_deactivated=include_deactivated,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )
        return _response.data

    def delete(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        user_id: Uuid,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Remove a user from a given folder. <br/>Rate Limits: 60 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        folder_id : Uuid


        user_id : Uuid


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

        Returns
        -------
        None

        Examples
        --------
        from frameio_experimental import FrameioExperimental

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.folder_permissions.delete(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            user_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
        )
        """
        _response = self._raw_client.delete(account_id, folder_id, user_id, request_options=request_options)
        return _response.data

    def folder_user_roles_update(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        user_id: Uuid,
        *,
        data: UpdateUserRolesParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateUserRolesResponse:
        """
        Update user roles for the given folder if the user is already added to the folder. If the user is
            not added to the folder, the user will be added with the given role. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        folder_id : Uuid


        user_id : Uuid


        data : UpdateUserRolesParamsData

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

        Returns
        -------
        UpdateUserRolesResponse
            OK

        Examples
        --------
        from frameio_experimental import FrameioExperimental
        from frameio_experimental.folder_permissions import UpdateUserRolesParamsData

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.folder_permissions.folder_user_roles_update(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            user_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=UpdateUserRolesParamsData(
                role="editor",
            ),
        )
        """
        _response = self._raw_client.folder_user_roles_update(
            account_id, folder_id, user_id, data=data, request_options=request_options
        )
        return _response.data


class AsyncFolderPermissionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawFolderPermissionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawFolderPermissionsClient
        """
        return self._raw_client

    async def folder_user_roles_index(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        *,
        include_deactivated: typing.Optional[bool] = None,
        after: typing.Optional[RequestAfterOpaqueCursor] = None,
        page_size: typing.Optional[RequestPageSize] = None,
        include_total_count: typing.Optional[IncludeTotalCount] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserRolesResponse:
        """
        List user roles for a given folder. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        folder_id : Uuid


        include_deactivated : typing.Optional[bool]
            Supports including deactivated users in the response. Default is false.

        after : typing.Optional[RequestAfterOpaqueCursor]
            Opaque Cursor query param for requests returning paginated results.
            <br/>
            NOTE: this value is auto-generated and included as part of links from a previous response. It is not intended to be human readable.

        page_size : typing.Optional[RequestPageSize]


        include_total_count : typing.Optional[IncludeTotalCount]


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

        Returns
        -------
        UserRolesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental

        client = AsyncFrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.folder_permissions.folder_user_roles_index(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                include_deactivated=True,
                after="<opaque_cursor>",
                page_size=10,
                include_total_count=False,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.folder_user_roles_index(
            account_id,
            folder_id,
            include_deactivated=include_deactivated,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )
        return _response.data

    async def delete(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        user_id: Uuid,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Remove a user from a given folder. <br/>Rate Limits: 60 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        folder_id : Uuid


        user_id : Uuid


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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental

        client = AsyncFrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.folder_permissions.delete(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                user_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(account_id, folder_id, user_id, request_options=request_options)
        return _response.data

    async def folder_user_roles_update(
        self,
        account_id: Uuid,
        folder_id: Uuid,
        user_id: Uuid,
        *,
        data: UpdateUserRolesParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateUserRolesResponse:
        """
        Update user roles for the given folder if the user is already added to the folder. If the user is
            not added to the folder, the user will be added with the given role. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        folder_id : Uuid


        user_id : Uuid


        data : UpdateUserRolesParamsData

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

        Returns
        -------
        UpdateUserRolesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental
        from frameio_experimental.folder_permissions import UpdateUserRolesParamsData

        client = AsyncFrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.folder_permissions.folder_user_roles_update(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                folder_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                user_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=UpdateUserRolesParamsData(
                    role="editor",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.folder_user_roles_update(
            account_id, folder_id, user_id, data=data, request_options=request_options
        )
        return _response.data
