# 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.workflow_execution_response import WorkflowExecutionResponse
from ..types.workflow_trigger_response import WorkflowTriggerResponse
from .raw_client import AsyncRawMeetingBuddyWorkflowTriggersClient, RawMeetingBuddyWorkflowTriggersClient

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


class MeetingBuddyWorkflowTriggersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawMeetingBuddyWorkflowTriggersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawMeetingBuddyWorkflowTriggersClient
        """
        return self._raw_client

    def list_workflow_triggers(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[WorkflowTriggerResponse]:
        """
        List all workflow triggers configured for the organization.

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

        Returns
        -------
        typing.List[WorkflowTriggerResponse]
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.meeting_buddy_workflow_triggers.list_workflow_triggers()
        """
        _response = self._raw_client.list_workflow_triggers(request_options=request_options)
        return _response.data

    def create_workflow_trigger(
        self,
        *,
        name: str,
        event_type: str,
        workflow_id: str,
        conditions: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        is_enabled: typing.Optional[bool] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowTriggerResponse:
        """
        Create a new workflow trigger that fires a FlowPlate workflow when an intelligence event occurs.

        Parameters
        ----------
        name : str

        event_type : str
            Event type that fires this trigger (e.g. intelligence_completed, deal_risk_detected)

        workflow_id : str

        conditions : typing.Optional[typing.Dict[str, typing.Any]]
            Optional conditions for trigger evaluation

        is_enabled : typing.Optional[bool]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowTriggerResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.meeting_buddy_workflow_triggers.create_workflow_trigger(
            name="name",
            event_type="event_type",
            workflow_id="workflow_id",
        )
        """
        _response = self._raw_client.create_workflow_trigger(
            name=name,
            event_type=event_type,
            workflow_id=workflow_id,
            conditions=conditions,
            is_enabled=is_enabled,
            description=description,
            request_options=request_options,
        )
        return _response.data

    def delete_workflow_trigger(
        self, trigger_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft-delete a workflow trigger.

        Parameters
        ----------
        trigger_id : str

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

        Returns
        -------
        None

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.meeting_buddy_workflow_triggers.delete_workflow_trigger(
            trigger_id="trigger_id",
        )
        """
        _response = self._raw_client.delete_workflow_trigger(trigger_id, request_options=request_options)
        return _response.data

    def update_workflow_trigger(
        self,
        trigger_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        event_type: typing.Optional[str] = OMIT,
        workflow_id: typing.Optional[str] = OMIT,
        conditions: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        is_enabled: typing.Optional[bool] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowTriggerResponse:
        """
        Update an existing workflow trigger's configuration.

        Parameters
        ----------
        trigger_id : str

        name : typing.Optional[str]

        event_type : typing.Optional[str]

        workflow_id : typing.Optional[str]

        conditions : typing.Optional[typing.Dict[str, typing.Any]]

        is_enabled : typing.Optional[bool]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowTriggerResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.meeting_buddy_workflow_triggers.update_workflow_trigger(
            trigger_id="trigger_id",
        )
        """
        _response = self._raw_client.update_workflow_trigger(
            trigger_id,
            name=name,
            event_type=event_type,
            workflow_id=workflow_id,
            conditions=conditions,
            is_enabled=is_enabled,
            description=description,
            request_options=request_options,
        )
        return _response.data

    def list_session_workflow_executions(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[WorkflowExecutionResponse]:
        """
        Get all workflow executions that ran for a specific meeting session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        typing.List[WorkflowExecutionResponse]
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.meeting_buddy_workflow_triggers.list_session_workflow_executions(
            session_id="session_id",
        )
        """
        _response = self._raw_client.list_session_workflow_executions(session_id, request_options=request_options)
        return _response.data

    def trigger_workflow_manually(
        self,
        session_id: str,
        *,
        workflow_id: str,
        message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowExecutionResponse:
        """
        Manually trigger a FlowPlate workflow for a meeting session, regardless of event conditions.

        Parameters
        ----------
        session_id : str

        workflow_id : str

        message : typing.Optional[str]
            Optional custom prompt for the workflow. If omitted, a default is generated from session context.

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

        Returns
        -------
        WorkflowExecutionResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.meeting_buddy_workflow_triggers.trigger_workflow_manually(
            session_id="session_id",
            workflow_id="workflow_id",
        )
        """
        _response = self._raw_client.trigger_workflow_manually(
            session_id, workflow_id=workflow_id, message=message, request_options=request_options
        )
        return _response.data


class AsyncMeetingBuddyWorkflowTriggersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawMeetingBuddyWorkflowTriggersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawMeetingBuddyWorkflowTriggersClient
        """
        return self._raw_client

    async def list_workflow_triggers(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[WorkflowTriggerResponse]:
        """
        List all workflow triggers configured for the organization.

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

        Returns
        -------
        typing.List[WorkflowTriggerResponse]
            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.meeting_buddy_workflow_triggers.list_workflow_triggers()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_workflow_triggers(request_options=request_options)
        return _response.data

    async def create_workflow_trigger(
        self,
        *,
        name: str,
        event_type: str,
        workflow_id: str,
        conditions: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        is_enabled: typing.Optional[bool] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowTriggerResponse:
        """
        Create a new workflow trigger that fires a FlowPlate workflow when an intelligence event occurs.

        Parameters
        ----------
        name : str

        event_type : str
            Event type that fires this trigger (e.g. intelligence_completed, deal_risk_detected)

        workflow_id : str

        conditions : typing.Optional[typing.Dict[str, typing.Any]]
            Optional conditions for trigger evaluation

        is_enabled : typing.Optional[bool]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowTriggerResponse
            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.meeting_buddy_workflow_triggers.create_workflow_trigger(
                name="name",
                event_type="event_type",
                workflow_id="workflow_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_workflow_trigger(
            name=name,
            event_type=event_type,
            workflow_id=workflow_id,
            conditions=conditions,
            is_enabled=is_enabled,
            description=description,
            request_options=request_options,
        )
        return _response.data

    async def delete_workflow_trigger(
        self, trigger_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Soft-delete a workflow trigger.

        Parameters
        ----------
        trigger_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

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


        async def main() -> None:
            await client.meeting_buddy_workflow_triggers.delete_workflow_trigger(
                trigger_id="trigger_id",
            )


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

    async def update_workflow_trigger(
        self,
        trigger_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        event_type: typing.Optional[str] = OMIT,
        workflow_id: typing.Optional[str] = OMIT,
        conditions: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        is_enabled: typing.Optional[bool] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowTriggerResponse:
        """
        Update an existing workflow trigger's configuration.

        Parameters
        ----------
        trigger_id : str

        name : typing.Optional[str]

        event_type : typing.Optional[str]

        workflow_id : typing.Optional[str]

        conditions : typing.Optional[typing.Dict[str, typing.Any]]

        is_enabled : typing.Optional[bool]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowTriggerResponse
            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.meeting_buddy_workflow_triggers.update_workflow_trigger(
                trigger_id="trigger_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_workflow_trigger(
            trigger_id,
            name=name,
            event_type=event_type,
            workflow_id=workflow_id,
            conditions=conditions,
            is_enabled=is_enabled,
            description=description,
            request_options=request_options,
        )
        return _response.data

    async def list_session_workflow_executions(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[WorkflowExecutionResponse]:
        """
        Get all workflow executions that ran for a specific meeting session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        typing.List[WorkflowExecutionResponse]
            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.meeting_buddy_workflow_triggers.list_session_workflow_executions(
                session_id="session_id",
            )


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

    async def trigger_workflow_manually(
        self,
        session_id: str,
        *,
        workflow_id: str,
        message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowExecutionResponse:
        """
        Manually trigger a FlowPlate workflow for a meeting session, regardless of event conditions.

        Parameters
        ----------
        session_id : str

        workflow_id : str

        message : typing.Optional[str]
            Optional custom prompt for the workflow. If omitted, a default is generated from session context.

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

        Returns
        -------
        WorkflowExecutionResponse
            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.meeting_buddy_workflow_triggers.trigger_workflow_manually(
                session_id="session_id",
                workflow_id="workflow_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.trigger_workflow_manually(
            session_id, workflow_id=workflow_id, message=message, request_options=request_options
        )
        return _response.data
