# 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.group_response import GroupResponse
from ..types.group_with_includes_response import GroupWithIncludesResponse
from ..types.groups_with_includes_response import GroupsWithIncludesResponse
from ..types.include_total_count import IncludeTotalCount
from ..types.request_after_opaque_cursor import RequestAfterOpaqueCursor
from ..types.request_page_size import RequestPageSize
from ..types.uuid_ import Uuid
from .raw_client import AsyncRawGroupsClient, RawGroupsClient
from .types.create_group_params_data import CreateGroupParamsData
from .types.groups_index_request_sort import GroupsIndexRequestSort
from .types.update_group_params_data import UpdateGroupParamsData

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


class GroupsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawGroupsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawGroupsClient
        """
        return self._raw_client

    def index(
        self,
        account_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        sort: typing.Optional[GroupsIndexRequestSort] = 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,
    ) -> GroupsWithIncludesResponse:
        """
        List groups in account. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        include : typing.Optional[typing.Literal["creator"]]


        sort : typing.Optional[GroupsIndexRequestSort]
            Sort groups by query params

        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
        -------
        GroupsWithIncludesResponse
            OK

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

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.groups.index(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            sort="creator_asc",
            after="<opaque_cursor>",
            page_size=10,
            include_total_count=False,
        )
        """
        _response = self._raw_client.index(
            account_id,
            include=include,
            sort=sort,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )
        return _response.data

    def create(
        self, account_id: Uuid, *, data: CreateGroupParamsData, request_options: typing.Optional[RequestOptions] = None
    ) -> GroupResponse:
        """
        Create group for the current account. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        data : CreateGroupParamsData

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

        Returns
        -------
        GroupResponse
            Created

        Examples
        --------
        from frameio_experimental import FrameioExperimental
        from frameio_experimental.groups import CreateGroupParamsData

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.groups.create(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=CreateGroupParamsData(
                emoji="smile",
                name="group-1",
            ),
        )
        """
        _response = self._raw_client.create(account_id, data=data, request_options=request_options)
        return _response.data

    def show(
        self,
        account_id: Uuid,
        group_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GroupWithIncludesResponse:
        """
        Show group details. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        group_id : Uuid


        include : typing.Optional[typing.Literal["creator"]]


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

        Returns
        -------
        GroupWithIncludesResponse
            OK

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

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.groups.show(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            group_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
        )
        """
        _response = self._raw_client.show(account_id, group_id, include=include, request_options=request_options)
        return _response.data

    def update(
        self,
        account_id: Uuid,
        group_id: Uuid,
        *,
        data: UpdateGroupParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GroupResponse:
        """
        Update group details. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        group_id : Uuid


        data : UpdateGroupParamsData

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

        Returns
        -------
        GroupResponse
            OK

        Examples
        --------
        from frameio_experimental import FrameioExperimental
        from frameio_experimental.groups import UpdateGroupParamsData

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.groups.update(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            group_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=UpdateGroupParamsData(
                emoji="smile",
                name="group-1",
            ),
        )
        """
        _response = self._raw_client.update(account_id, group_id, data=data, request_options=request_options)
        return _response.data


class AsyncGroupsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawGroupsClient
        """
        return self._raw_client

    async def index(
        self,
        account_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        sort: typing.Optional[GroupsIndexRequestSort] = 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,
    ) -> GroupsWithIncludesResponse:
        """
        List groups in account. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        include : typing.Optional[typing.Literal["creator"]]


        sort : typing.Optional[GroupsIndexRequestSort]
            Sort groups by query params

        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
        -------
        GroupsWithIncludesResponse
            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.groups.index(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                sort="creator_asc",
                after="<opaque_cursor>",
                page_size=10,
                include_total_count=False,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.index(
            account_id,
            include=include,
            sort=sort,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )
        return _response.data

    async def create(
        self, account_id: Uuid, *, data: CreateGroupParamsData, request_options: typing.Optional[RequestOptions] = None
    ) -> GroupResponse:
        """
        Create group for the current account. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        data : CreateGroupParamsData

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

        Returns
        -------
        GroupResponse
            Created

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental
        from frameio_experimental.groups import CreateGroupParamsData

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


        async def main() -> None:
            await client.groups.create(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=CreateGroupParamsData(
                    emoji="smile",
                    name="group-1",
                ),
            )


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

    async def show(
        self,
        account_id: Uuid,
        group_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GroupWithIncludesResponse:
        """
        Show group details. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        group_id : Uuid


        include : typing.Optional[typing.Literal["creator"]]


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

        Returns
        -------
        GroupWithIncludesResponse
            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.groups.show(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                group_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.show(account_id, group_id, include=include, request_options=request_options)
        return _response.data

    async def update(
        self,
        account_id: Uuid,
        group_id: Uuid,
        *,
        data: UpdateGroupParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GroupResponse:
        """
        Update group details. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        group_id : Uuid


        data : UpdateGroupParamsData

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

        Returns
        -------
        GroupResponse
            OK

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental
        from frameio_experimental.groups import UpdateGroupParamsData

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


        async def main() -> None:
            await client.groups.update(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                group_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=UpdateGroupParamsData(
                    emoji="smile",
                    name="group-1",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(account_id, group_id, data=data, request_options=request_options)
        return _response.data
