# 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.event import Event
from .raw_client import AsyncRawEventsClient, RawEventsClient


class EventsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawEventsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawEventsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        task_id: str,
        agent_id: str,
        last_processed_event_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Event]:
        """
        List events for a specific task and agent.

        Optionally filter for events after a specific sequence ID.
        Results are ordered by sequence_id.

        Parameters
        ----------
        task_id : str
            The task ID

        agent_id : str
            The agent ID

        last_processed_event_id : typing.Optional[str]
            Optional event ID to get events after this ID

        limit : typing.Optional[int]
            Optional limit on number of results

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

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

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.events.list(
            task_id="task_id",
            agent_id="agent_id",
        )
        """
        _response = self._raw_client.list(
            task_id=task_id,
            agent_id=agent_id,
            last_processed_event_id=last_processed_event_id,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    def retrieve(self, event_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Event:
        """
        Parameters
        ----------
        event_id : str

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

        Returns
        -------
        Event
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.events.retrieve(
            event_id="event_id",
        )
        """
        _response = self._raw_client.retrieve(event_id, request_options=request_options)
        return _response.data


class AsyncEventsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawEventsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawEventsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        task_id: str,
        agent_id: str,
        last_processed_event_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Event]:
        """
        List events for a specific task and agent.

        Optionally filter for events after a specific sequence ID.
        Results are ordered by sequence_id.

        Parameters
        ----------
        task_id : str
            The task ID

        agent_id : str
            The agent ID

        last_processed_event_id : typing.Optional[str]
            Optional event ID to get events after this ID

        limit : typing.Optional[int]
            Optional limit on number of results

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

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

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.events.list(
                task_id="task_id",
                agent_id="agent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            task_id=task_id,
            agent_id=agent_id,
            last_processed_event_id=last_processed_event_id,
            limit=limit,
            request_options=request_options,
        )
        return _response.data

    async def retrieve(self, event_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Event:
        """
        Parameters
        ----------
        event_id : str

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

        Returns
        -------
        Event
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.events.retrieve(
                event_id="event_id",
            )


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