# 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.action_create_response import ActionCreateResponse
from ..types.action_response import ActionResponse
from ..types.action_with_includes_response import ActionWithIncludesResponse
from ..types.actions_with_includes_response import ActionsWithIncludesResponse
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 AsyncRawCustomActionsClient, RawCustomActionsClient
from .types.action_create_params_data import ActionCreateParamsData
from .types.action_update_params_data import ActionUpdateParamsData

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


class CustomActionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCustomActionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCustomActionsClient
        """
        return self._raw_client

    def actions_show(
        self,
        account_id: Uuid,
        action_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ActionWithIncludesResponse:
        """
        Show custom action details. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        action_id : Uuid


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


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

        Returns
        -------
        ActionWithIncludesResponse
            OK

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

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

    def actions_delete(
        self, account_id: Uuid, action_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a custom action. <br/>Rate Limits: 60 calls per 1.00 minute(s) per account_user

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


        action_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.custom_actions.actions_delete(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            action_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
        )
        """
        _response = self._raw_client.actions_delete(account_id, action_id, request_options=request_options)
        return _response.data

    def actions_update(
        self,
        account_id: Uuid,
        action_id: Uuid,
        *,
        data: ActionUpdateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ActionResponse:
        """
        Update custom action details. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        action_id : Uuid


        data : ActionUpdateParamsData

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

        Returns
        -------
        ActionResponse
            OK

        Examples
        --------
        from frameio_experimental import FrameioExperimental
        from frameio_experimental.custom_actions import ActionUpdateParamsData

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.custom_actions.actions_update(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            action_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=ActionUpdateParamsData(
                active=True,
                description="customizing our workflow",
                event="my.event",
                multi_asset=True,
                name="First Custom Action",
                timeout=7,
                url="https://example.com/custom-action",
            ),
        )
        """
        _response = self._raw_client.actions_update(account_id, action_id, data=data, request_options=request_options)
        return _response.data

    def actions_index(
        self,
        account_id: Uuid,
        workspace_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = 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,
    ) -> ActionsWithIncludesResponse:
        """
        List actions in a given workspace. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        workspace_id : Uuid


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


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

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

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

    def actions_create(
        self,
        account_id: Uuid,
        workspace_id: Uuid,
        *,
        data: ActionCreateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ActionCreateResponse:
        """
        Create a custom action in a workspace. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        workspace_id : Uuid


        data : ActionCreateParamsData

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

        Returns
        -------
        ActionCreateResponse
            Created

        Examples
        --------
        from frameio_experimental import FrameioExperimental
        from frameio_experimental.custom_actions import ActionCreateParamsData

        client = FrameioExperimental(
            api_version="YOUR_API_VERSION",
            token="YOUR_TOKEN",
        )
        client.custom_actions.actions_create(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            workspace_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            data=ActionCreateParamsData(
                description="customizing our workflow",
                event="my.event",
                name="First Custom Action",
                timeout=7,
                url="https://example.com/custom-action",
            ),
        )
        """
        _response = self._raw_client.actions_create(
            account_id, workspace_id, data=data, request_options=request_options
        )
        return _response.data


class AsyncCustomActionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCustomActionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCustomActionsClient
        """
        return self._raw_client

    async def actions_show(
        self,
        account_id: Uuid,
        action_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ActionWithIncludesResponse:
        """
        Show custom action details. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        action_id : Uuid


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


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

        Returns
        -------
        ActionWithIncludesResponse
            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.custom_actions.actions_show(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                action_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            )


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

    async def actions_delete(
        self, account_id: Uuid, action_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a custom action. <br/>Rate Limits: 60 calls per 1.00 minute(s) per account_user

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


        action_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.custom_actions.actions_delete(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                action_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            )


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

    async def actions_update(
        self,
        account_id: Uuid,
        action_id: Uuid,
        *,
        data: ActionUpdateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ActionResponse:
        """
        Update custom action details. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        action_id : Uuid


        data : ActionUpdateParamsData

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

        Returns
        -------
        ActionResponse
            OK

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental
        from frameio_experimental.custom_actions import ActionUpdateParamsData

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


        async def main() -> None:
            await client.custom_actions.actions_update(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                action_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=ActionUpdateParamsData(
                    active=True,
                    description="customizing our workflow",
                    event="my.event",
                    multi_asset=True,
                    name="First Custom Action",
                    timeout=7,
                    url="https://example.com/custom-action",
                ),
            )


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

    async def actions_index(
        self,
        account_id: Uuid,
        workspace_id: Uuid,
        *,
        include: typing.Optional[typing.Literal["creator"]] = 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,
    ) -> ActionsWithIncludesResponse:
        """
        List actions in a given workspace. <br/>Rate Limits: 100 calls per 1.00 minute(s) per account_user

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


        workspace_id : Uuid


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


        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
        -------
        ActionsWithIncludesResponse
            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.custom_actions.actions_index(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                workspace_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                after="<opaque_cursor>",
                page_size=10,
                include_total_count=False,
            )


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

    async def actions_create(
        self,
        account_id: Uuid,
        workspace_id: Uuid,
        *,
        data: ActionCreateParamsData,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ActionCreateResponse:
        """
        Create a custom action in a workspace. <br/>Rate Limits: 10 calls per 1.00 minute(s) per account_user

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


        workspace_id : Uuid


        data : ActionCreateParamsData

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

        Returns
        -------
        ActionCreateResponse
            Created

        Examples
        --------
        import asyncio

        from frameio_experimental import AsyncFrameioExperimental
        from frameio_experimental.custom_actions import ActionCreateParamsData

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


        async def main() -> None:
            await client.custom_actions.actions_create(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                workspace_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                data=ActionCreateParamsData(
                    description="customizing our workflow",
                    event="my.event",
                    name="First Custom Action",
                    timeout=7,
                    url="https://example.com/custom-action",
                ),
            )


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