# 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.agent_api_key import AgentApiKey
from ..types.agent_api_key_type import AgentApiKeyType
from ..types.create_api_key_response import CreateApiKeyResponse
from .raw_client import AsyncRawAgentApiKeysClient, RawAgentApiKeysClient

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


class AgentApiKeysClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAgentApiKeysClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAgentApiKeysClient
        """
        return self._raw_client

    def agent_api_keys_list(
        self,
        *,
        agent_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page_number: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AgentApiKey]:
        """
        List API keys for an agent ID.

        Parameters
        ----------
        agent_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        limit : typing.Optional[int]

        page_number : typing.Optional[int]

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

        Returns
        -------
        typing.List[AgentApiKey]
            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.agent_api_keys.agent_api_keys_list()
        """
        _response = self._raw_client.agent_api_keys_list(
            agent_id=agent_id,
            agent_name=agent_name,
            limit=limit,
            page_number=page_number,
            request_options=request_options,
        )
        return _response.data

    def agent_api_keys_create(
        self,
        *,
        name: str,
        agent_id: typing.Optional[str] = OMIT,
        agent_name: typing.Optional[str] = OMIT,
        api_key: typing.Optional[str] = OMIT,
        api_key_type: typing.Optional[AgentApiKeyType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateApiKeyResponse:
        """
        Parameters
        ----------
        name : str
            The name of the agent's API key.

        agent_id : typing.Optional[str]
            The UUID of the agent

        agent_name : typing.Optional[str]
            The name of the agent - if not provided, the agent_id must be set.

        api_key : typing.Optional[str]
            Optionally provide the API key value - if not set, one will be generated.

        api_key_type : typing.Optional[AgentApiKeyType]
            The type of the agent API key (external by default).

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

        Returns
        -------
        CreateApiKeyResponse
            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.agent_api_keys.agent_api_keys_create(
            name="name",
        )
        """
        _response = self._raw_client.agent_api_keys_create(
            name=name,
            agent_id=agent_id,
            agent_name=agent_name,
            api_key=api_key,
            api_key_type=api_key_type,
            request_options=request_options,
        )
        return _response.data

    def agent_api_keys_name_delete(
        self,
        api_key_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        api_key_type: typing.Optional[AgentApiKeyType] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> str:
        """
        Delete API key by name.

        Parameters
        ----------
        api_key_name : str

        agent_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        api_key_type : typing.Optional[AgentApiKeyType]

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

        Returns
        -------
        str
            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.agent_api_keys.agent_api_keys_name_delete(
            api_key_name="api_key_name",
        )
        """
        _response = self._raw_client.agent_api_keys_name_delete(
            api_key_name,
            agent_id=agent_id,
            agent_name=agent_name,
            api_key_type=api_key_type,
            request_options=request_options,
        )
        return _response.data

    def agent_api_keys_name_retrieve(
        self,
        name: str,
        *,
        agent_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        api_key_type: typing.Optional[AgentApiKeyType] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentApiKey:
        """
        Return named API key for the agent ID.

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

        agent_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        api_key_type : typing.Optional[AgentApiKeyType]

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

        Returns
        -------
        AgentApiKey
            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.agent_api_keys.agent_api_keys_name_retrieve(
            name="name",
        )
        """
        _response = self._raw_client.agent_api_keys_name_retrieve(
            name, agent_id=agent_id, agent_name=agent_name, api_key_type=api_key_type, request_options=request_options
        )
        return _response.data

    def agent_api_keys_retrieve(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentApiKey:
        """
        Return API key by ID.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        AgentApiKey
            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.agent_api_keys.agent_api_keys_retrieve(
            id="id",
        )
        """
        _response = self._raw_client.agent_api_keys_retrieve(id, request_options=request_options)
        return _response.data

    def agent_api_keys_delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> str:
        """
        Delete API key by ID.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        str
            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.agent_api_keys.agent_api_keys_delete(
            id="id",
        )
        """
        _response = self._raw_client.agent_api_keys_delete(id, request_options=request_options)
        return _response.data


class AsyncAgentApiKeysClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAgentApiKeysClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAgentApiKeysClient
        """
        return self._raw_client

    async def agent_api_keys_list(
        self,
        *,
        agent_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page_number: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[AgentApiKey]:
        """
        List API keys for an agent ID.

        Parameters
        ----------
        agent_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        limit : typing.Optional[int]

        page_number : typing.Optional[int]

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

        Returns
        -------
        typing.List[AgentApiKey]
            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.agent_api_keys.agent_api_keys_list()


        asyncio.run(main())
        """
        _response = await self._raw_client.agent_api_keys_list(
            agent_id=agent_id,
            agent_name=agent_name,
            limit=limit,
            page_number=page_number,
            request_options=request_options,
        )
        return _response.data

    async def agent_api_keys_create(
        self,
        *,
        name: str,
        agent_id: typing.Optional[str] = OMIT,
        agent_name: typing.Optional[str] = OMIT,
        api_key: typing.Optional[str] = OMIT,
        api_key_type: typing.Optional[AgentApiKeyType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateApiKeyResponse:
        """
        Parameters
        ----------
        name : str
            The name of the agent's API key.

        agent_id : typing.Optional[str]
            The UUID of the agent

        agent_name : typing.Optional[str]
            The name of the agent - if not provided, the agent_id must be set.

        api_key : typing.Optional[str]
            Optionally provide the API key value - if not set, one will be generated.

        api_key_type : typing.Optional[AgentApiKeyType]
            The type of the agent API key (external by default).

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

        Returns
        -------
        CreateApiKeyResponse
            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.agent_api_keys.agent_api_keys_create(
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.agent_api_keys_create(
            name=name,
            agent_id=agent_id,
            agent_name=agent_name,
            api_key=api_key,
            api_key_type=api_key_type,
            request_options=request_options,
        )
        return _response.data

    async def agent_api_keys_name_delete(
        self,
        api_key_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        api_key_type: typing.Optional[AgentApiKeyType] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> str:
        """
        Delete API key by name.

        Parameters
        ----------
        api_key_name : str

        agent_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        api_key_type : typing.Optional[AgentApiKeyType]

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

        Returns
        -------
        str
            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.agent_api_keys.agent_api_keys_name_delete(
                api_key_name="api_key_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.agent_api_keys_name_delete(
            api_key_name,
            agent_id=agent_id,
            agent_name=agent_name,
            api_key_type=api_key_type,
            request_options=request_options,
        )
        return _response.data

    async def agent_api_keys_name_retrieve(
        self,
        name: str,
        *,
        agent_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        api_key_type: typing.Optional[AgentApiKeyType] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentApiKey:
        """
        Return named API key for the agent ID.

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

        agent_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        api_key_type : typing.Optional[AgentApiKeyType]

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

        Returns
        -------
        AgentApiKey
            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.agent_api_keys.agent_api_keys_name_retrieve(
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.agent_api_keys_name_retrieve(
            name, agent_id=agent_id, agent_name=agent_name, api_key_type=api_key_type, request_options=request_options
        )
        return _response.data

    async def agent_api_keys_retrieve(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentApiKey:
        """
        Return API key by ID.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        AgentApiKey
            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.agent_api_keys.agent_api_keys_retrieve(
                id="id",
            )


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

    async def agent_api_keys_delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> str:
        """
        Delete API key by ID.

        Parameters
        ----------
        id : str

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

        Returns
        -------
        str
            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.agent_api_keys.agent_api_keys_delete(
                id="id",
            )


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