# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import os
import typing

import httpx
from .core.api_error import ApiError
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .core.request_options import RequestOptions
from .raw_client import AsyncRawTerminalUseBase, RawTerminalUseBase
from .types.search_response import SearchResponse

if typing.TYPE_CHECKING:
    from .agent_api_keys.client import AgentApiKeysClient, AsyncAgentApiKeysClient
    from .agents.client import AgentsClient, AsyncAgentsClient
    from .api_keys.client import ApiKeysClient, AsyncApiKeysClient
    from .authentication.client import AsyncAuthenticationClient, AuthenticationClient
    from .branches.client import AsyncBranchesClient, BranchesClient
    from .builds.client import AsyncBuildsClient, BuildsClient
    from .cli_authentication.client import AsyncCliAuthenticationClient, CliAuthenticationClient
    from .events.client import AsyncEventsClient, EventsClient
    from .filesystems.client import AsyncFilesystemsClient, FilesystemsClient
    from .groups.client import AsyncGroupsClient, GroupsClient
    from .logs.client import AsyncLogsClient, LogsClient
    from .messages_v2.client import AsyncMessagesV2Client, MessagesV2Client
    from .namespaces.client import AsyncNamespacesClient, NamespacesClient
    from .o_auth.client import AsyncOAuthClient, OAuthClient
    from .organizations.client import AsyncOrganizationsClient, OrganizationsClient
    from .projects.client import AsyncProjectsClient, ProjectsClient
    from .raw_events.client import AsyncRawEventsClient, RawEventsClient
    from .registry.client import AsyncRegistryClient, RegistryClient
    from .schedules.client import AsyncSchedulesClient, SchedulesClient
    from .spans.client import AsyncSpansClient, SpansClient
    from .states.client import AsyncStatesClient, StatesClient
    from .tasks.client import AsyncTasksClient, TasksClient
    from .telemetry.client import AsyncTelemetryClient, TelemetryClient
    from .tracker.client import AsyncTrackerClient, TrackerClient
    from .version_events.client import AsyncVersionEventsClient, VersionEventsClient
    from .versions.client import AsyncVersionsClient, VersionsClient


class TerminalUseBase:
    """
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : str
        The base url to use for requests from the client.

    agent_api_key : typing.Optional[str]
    token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.Client]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    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",
    )
    """

    def __init__(
        self,
        *,
        base_url: str,
        agent_api_key: typing.Optional[str] = os.getenv("TERMINALUSE_AGENT_API_KEY"),
        token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("TERMINALUSE_API_KEY"),
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.Client] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
        )
        if agent_api_key is None:
            raise ApiError(
                body="The client must be instantiated be either passing in agent_api_key or setting TERMINALUSE_AGENT_API_KEY"
            )
        if token is None:
            raise ApiError(
                body="The client must be instantiated be either passing in token or setting TERMINALUSE_API_KEY"
            )
        self._client_wrapper = SyncClientWrapper(
            base_url=base_url,
            agent_api_key=agent_api_key,
            token=token,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.Client(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
        )
        self._raw_client = RawTerminalUseBase(client_wrapper=self._client_wrapper)
        self._telemetry: typing.Optional[TelemetryClient] = None
        self._agent_api_keys: typing.Optional[AgentApiKeysClient] = None
        self._agents: typing.Optional[AgentsClient] = None
        self._schedules: typing.Optional[SchedulesClient] = None
        self._branches: typing.Optional[BranchesClient] = None
        self._api_keys: typing.Optional[ApiKeysClient] = None
        self._builds: typing.Optional[BuildsClient] = None
        self._events: typing.Optional[EventsClient] = None
        self._filesystems: typing.Optional[FilesystemsClient] = None
        self._groups: typing.Optional[GroupsClient] = None
        self._logs: typing.Optional[LogsClient] = None
        self._namespaces: typing.Optional[NamespacesClient] = None
        self._projects: typing.Optional[ProjectsClient] = None
        self._raw_events: typing.Optional[RawEventsClient] = None
        self._registry: typing.Optional[RegistryClient] = None
        self._spans: typing.Optional[SpansClient] = None
        self._states: typing.Optional[StatesClient] = None
        self._tasks: typing.Optional[TasksClient] = None
        self._tracker: typing.Optional[TrackerClient] = None
        self._cli_authentication: typing.Optional[CliAuthenticationClient] = None
        self._authentication: typing.Optional[AuthenticationClient] = None
        self._o_auth: typing.Optional[OAuthClient] = None
        self._organizations: typing.Optional[OrganizationsClient] = None
        self._messages_v2: typing.Optional[MessagesV2Client] = None
        self._versions: typing.Optional[VersionsClient] = None
        self._version_events: typing.Optional[VersionEventsClient] = None

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

        Returns
        -------
        RawTerminalUseBase
        """
        return self._raw_client

    def search(
        self,
        *,
        q: str,
        types: typing.Optional[str] = None,
        namespace_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SearchResponse:
        """
        Unified search endpoint for agents, tasks, and workspaces.

            Searches by name using case-insensitive matching.
            Results are sorted by relevance (exact matches first, then prefix matches, then contains).

        Parameters
        ----------
        q : str
            Search query (minimum 2 characters)

        types : typing.Optional[str]
            Comma-separated list of types to search (agents,tasks,workspaces). If not provided, searches all types.

        namespace_id : typing.Optional[str]
            Optional namespace ID to filter results

        limit : typing.Optional[int]
            Maximum number of results per type (max 50)

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

        Returns
        -------
        SearchResponse
            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.search(
            q="q",
        )
        """
        _response = self._raw_client.search(
            q=q, types=types, namespace_id=namespace_id, limit=limit, request_options=request_options
        )
        return _response.data

    @property
    def telemetry(self):
        if self._telemetry is None:
            from .telemetry.client import TelemetryClient  # noqa: E402

            self._telemetry = TelemetryClient(client_wrapper=self._client_wrapper)
        return self._telemetry

    @property
    def agent_api_keys(self):
        if self._agent_api_keys is None:
            from .agent_api_keys.client import AgentApiKeysClient  # noqa: E402

            self._agent_api_keys = AgentApiKeysClient(client_wrapper=self._client_wrapper)
        return self._agent_api_keys

    @property
    def agents(self):
        if self._agents is None:
            from .agents.client import AgentsClient  # noqa: E402

            self._agents = AgentsClient(client_wrapper=self._client_wrapper)
        return self._agents

    @property
    def schedules(self):
        if self._schedules is None:
            from .schedules.client import SchedulesClient  # noqa: E402

            self._schedules = SchedulesClient(client_wrapper=self._client_wrapper)
        return self._schedules

    @property
    def branches(self):
        if self._branches is None:
            from .branches.client import BranchesClient  # noqa: E402

            self._branches = BranchesClient(client_wrapper=self._client_wrapper)
        return self._branches

    @property
    def api_keys(self):
        if self._api_keys is None:
            from .api_keys.client import ApiKeysClient  # noqa: E402

            self._api_keys = ApiKeysClient(client_wrapper=self._client_wrapper)
        return self._api_keys

    @property
    def builds(self):
        if self._builds is None:
            from .builds.client import BuildsClient  # noqa: E402

            self._builds = BuildsClient(client_wrapper=self._client_wrapper)
        return self._builds

    @property
    def events(self):
        if self._events is None:
            from .events.client import EventsClient  # noqa: E402

            self._events = EventsClient(client_wrapper=self._client_wrapper)
        return self._events

    @property
    def filesystems(self):
        if self._filesystems is None:
            from .filesystems.client import FilesystemsClient  # noqa: E402

            self._filesystems = FilesystemsClient(client_wrapper=self._client_wrapper)
        return self._filesystems

    @property
    def groups(self):
        if self._groups is None:
            from .groups.client import GroupsClient  # noqa: E402

            self._groups = GroupsClient(client_wrapper=self._client_wrapper)
        return self._groups

    @property
    def logs(self):
        if self._logs is None:
            from .logs.client import LogsClient  # noqa: E402

            self._logs = LogsClient(client_wrapper=self._client_wrapper)
        return self._logs

    @property
    def namespaces(self):
        if self._namespaces is None:
            from .namespaces.client import NamespacesClient  # noqa: E402

            self._namespaces = NamespacesClient(client_wrapper=self._client_wrapper)
        return self._namespaces

    @property
    def projects(self):
        if self._projects is None:
            from .projects.client import ProjectsClient  # noqa: E402

            self._projects = ProjectsClient(client_wrapper=self._client_wrapper)
        return self._projects

    @property
    def raw_events(self):
        if self._raw_events is None:
            from .raw_events.client import RawEventsClient  # noqa: E402

            self._raw_events = RawEventsClient(client_wrapper=self._client_wrapper)
        return self._raw_events

    @property
    def registry(self):
        if self._registry is None:
            from .registry.client import RegistryClient  # noqa: E402

            self._registry = RegistryClient(client_wrapper=self._client_wrapper)
        return self._registry

    @property
    def spans(self):
        if self._spans is None:
            from .spans.client import SpansClient  # noqa: E402

            self._spans = SpansClient(client_wrapper=self._client_wrapper)
        return self._spans

    @property
    def states(self):
        if self._states is None:
            from .states.client import StatesClient  # noqa: E402

            self._states = StatesClient(client_wrapper=self._client_wrapper)
        return self._states

    @property
    def tasks(self):
        if self._tasks is None:
            from .tasks.client import TasksClient  # noqa: E402

            self._tasks = TasksClient(client_wrapper=self._client_wrapper)
        return self._tasks

    @property
    def tracker(self):
        if self._tracker is None:
            from .tracker.client import TrackerClient  # noqa: E402

            self._tracker = TrackerClient(client_wrapper=self._client_wrapper)
        return self._tracker

    @property
    def cli_authentication(self):
        if self._cli_authentication is None:
            from .cli_authentication.client import CliAuthenticationClient  # noqa: E402

            self._cli_authentication = CliAuthenticationClient(client_wrapper=self._client_wrapper)
        return self._cli_authentication

    @property
    def authentication(self):
        if self._authentication is None:
            from .authentication.client import AuthenticationClient  # noqa: E402

            self._authentication = AuthenticationClient(client_wrapper=self._client_wrapper)
        return self._authentication

    @property
    def o_auth(self):
        if self._o_auth is None:
            from .o_auth.client import OAuthClient  # noqa: E402

            self._o_auth = OAuthClient(client_wrapper=self._client_wrapper)
        return self._o_auth

    @property
    def organizations(self):
        if self._organizations is None:
            from .organizations.client import OrganizationsClient  # noqa: E402

            self._organizations = OrganizationsClient(client_wrapper=self._client_wrapper)
        return self._organizations

    @property
    def messages_v2(self):
        if self._messages_v2 is None:
            from .messages_v2.client import MessagesV2Client  # noqa: E402

            self._messages_v2 = MessagesV2Client(client_wrapper=self._client_wrapper)
        return self._messages_v2

    @property
    def versions(self):
        if self._versions is None:
            from .versions.client import VersionsClient  # noqa: E402

            self._versions = VersionsClient(client_wrapper=self._client_wrapper)
        return self._versions

    @property
    def version_events(self):
        if self._version_events is None:
            from .version_events.client import VersionEventsClient  # noqa: E402

            self._version_events = VersionEventsClient(client_wrapper=self._client_wrapper)
        return self._version_events


class AsyncTerminalUseBase:
    """
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : str
        The base url to use for requests from the client.

    agent_api_key : typing.Optional[str]
    token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.AsyncClient]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    Examples
    --------
    from terminaluse import AsyncTerminalUseBase

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

    def __init__(
        self,
        *,
        base_url: str,
        agent_api_key: typing.Optional[str] = os.getenv("TERMINALUSE_AGENT_API_KEY"),
        token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("TERMINALUSE_API_KEY"),
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.AsyncClient] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
        )
        if agent_api_key is None:
            raise ApiError(
                body="The client must be instantiated be either passing in agent_api_key or setting TERMINALUSE_AGENT_API_KEY"
            )
        if token is None:
            raise ApiError(
                body="The client must be instantiated be either passing in token or setting TERMINALUSE_API_KEY"
            )
        self._client_wrapper = AsyncClientWrapper(
            base_url=base_url,
            agent_api_key=agent_api_key,
            token=token,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
        )
        self._raw_client = AsyncRawTerminalUseBase(client_wrapper=self._client_wrapper)
        self._telemetry: typing.Optional[AsyncTelemetryClient] = None
        self._agent_api_keys: typing.Optional[AsyncAgentApiKeysClient] = None
        self._agents: typing.Optional[AsyncAgentsClient] = None
        self._schedules: typing.Optional[AsyncSchedulesClient] = None
        self._branches: typing.Optional[AsyncBranchesClient] = None
        self._api_keys: typing.Optional[AsyncApiKeysClient] = None
        self._builds: typing.Optional[AsyncBuildsClient] = None
        self._events: typing.Optional[AsyncEventsClient] = None
        self._filesystems: typing.Optional[AsyncFilesystemsClient] = None
        self._groups: typing.Optional[AsyncGroupsClient] = None
        self._logs: typing.Optional[AsyncLogsClient] = None
        self._namespaces: typing.Optional[AsyncNamespacesClient] = None
        self._projects: typing.Optional[AsyncProjectsClient] = None
        self._raw_events: typing.Optional[AsyncRawEventsClient] = None
        self._registry: typing.Optional[AsyncRegistryClient] = None
        self._spans: typing.Optional[AsyncSpansClient] = None
        self._states: typing.Optional[AsyncStatesClient] = None
        self._tasks: typing.Optional[AsyncTasksClient] = None
        self._tracker: typing.Optional[AsyncTrackerClient] = None
        self._cli_authentication: typing.Optional[AsyncCliAuthenticationClient] = None
        self._authentication: typing.Optional[AsyncAuthenticationClient] = None
        self._o_auth: typing.Optional[AsyncOAuthClient] = None
        self._organizations: typing.Optional[AsyncOrganizationsClient] = None
        self._messages_v2: typing.Optional[AsyncMessagesV2Client] = None
        self._versions: typing.Optional[AsyncVersionsClient] = None
        self._version_events: typing.Optional[AsyncVersionEventsClient] = None

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

        Returns
        -------
        AsyncRawTerminalUseBase
        """
        return self._raw_client

    async def search(
        self,
        *,
        q: str,
        types: typing.Optional[str] = None,
        namespace_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SearchResponse:
        """
        Unified search endpoint for agents, tasks, and workspaces.

            Searches by name using case-insensitive matching.
            Results are sorted by relevance (exact matches first, then prefix matches, then contains).

        Parameters
        ----------
        q : str
            Search query (minimum 2 characters)

        types : typing.Optional[str]
            Comma-separated list of types to search (agents,tasks,workspaces). If not provided, searches all types.

        namespace_id : typing.Optional[str]
            Optional namespace ID to filter results

        limit : typing.Optional[int]
            Maximum number of results per type (max 50)

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

        Returns
        -------
        SearchResponse
            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.search(
                q="q",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.search(
            q=q, types=types, namespace_id=namespace_id, limit=limit, request_options=request_options
        )
        return _response.data

    @property
    def telemetry(self):
        if self._telemetry is None:
            from .telemetry.client import AsyncTelemetryClient  # noqa: E402

            self._telemetry = AsyncTelemetryClient(client_wrapper=self._client_wrapper)
        return self._telemetry

    @property
    def agent_api_keys(self):
        if self._agent_api_keys is None:
            from .agent_api_keys.client import AsyncAgentApiKeysClient  # noqa: E402

            self._agent_api_keys = AsyncAgentApiKeysClient(client_wrapper=self._client_wrapper)
        return self._agent_api_keys

    @property
    def agents(self):
        if self._agents is None:
            from .agents.client import AsyncAgentsClient  # noqa: E402

            self._agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
        return self._agents

    @property
    def schedules(self):
        if self._schedules is None:
            from .schedules.client import AsyncSchedulesClient  # noqa: E402

            self._schedules = AsyncSchedulesClient(client_wrapper=self._client_wrapper)
        return self._schedules

    @property
    def branches(self):
        if self._branches is None:
            from .branches.client import AsyncBranchesClient  # noqa: E402

            self._branches = AsyncBranchesClient(client_wrapper=self._client_wrapper)
        return self._branches

    @property
    def api_keys(self):
        if self._api_keys is None:
            from .api_keys.client import AsyncApiKeysClient  # noqa: E402

            self._api_keys = AsyncApiKeysClient(client_wrapper=self._client_wrapper)
        return self._api_keys

    @property
    def builds(self):
        if self._builds is None:
            from .builds.client import AsyncBuildsClient  # noqa: E402

            self._builds = AsyncBuildsClient(client_wrapper=self._client_wrapper)
        return self._builds

    @property
    def events(self):
        if self._events is None:
            from .events.client import AsyncEventsClient  # noqa: E402

            self._events = AsyncEventsClient(client_wrapper=self._client_wrapper)
        return self._events

    @property
    def filesystems(self):
        if self._filesystems is None:
            from .filesystems.client import AsyncFilesystemsClient  # noqa: E402

            self._filesystems = AsyncFilesystemsClient(client_wrapper=self._client_wrapper)
        return self._filesystems

    @property
    def groups(self):
        if self._groups is None:
            from .groups.client import AsyncGroupsClient  # noqa: E402

            self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper)
        return self._groups

    @property
    def logs(self):
        if self._logs is None:
            from .logs.client import AsyncLogsClient  # noqa: E402

            self._logs = AsyncLogsClient(client_wrapper=self._client_wrapper)
        return self._logs

    @property
    def namespaces(self):
        if self._namespaces is None:
            from .namespaces.client import AsyncNamespacesClient  # noqa: E402

            self._namespaces = AsyncNamespacesClient(client_wrapper=self._client_wrapper)
        return self._namespaces

    @property
    def projects(self):
        if self._projects is None:
            from .projects.client import AsyncProjectsClient  # noqa: E402

            self._projects = AsyncProjectsClient(client_wrapper=self._client_wrapper)
        return self._projects

    @property
    def raw_events(self):
        if self._raw_events is None:
            from .raw_events.client import AsyncRawEventsClient  # noqa: E402

            self._raw_events = AsyncRawEventsClient(client_wrapper=self._client_wrapper)
        return self._raw_events

    @property
    def registry(self):
        if self._registry is None:
            from .registry.client import AsyncRegistryClient  # noqa: E402

            self._registry = AsyncRegistryClient(client_wrapper=self._client_wrapper)
        return self._registry

    @property
    def spans(self):
        if self._spans is None:
            from .spans.client import AsyncSpansClient  # noqa: E402

            self._spans = AsyncSpansClient(client_wrapper=self._client_wrapper)
        return self._spans

    @property
    def states(self):
        if self._states is None:
            from .states.client import AsyncStatesClient  # noqa: E402

            self._states = AsyncStatesClient(client_wrapper=self._client_wrapper)
        return self._states

    @property
    def tasks(self):
        if self._tasks is None:
            from .tasks.client import AsyncTasksClient  # noqa: E402

            self._tasks = AsyncTasksClient(client_wrapper=self._client_wrapper)
        return self._tasks

    @property
    def tracker(self):
        if self._tracker is None:
            from .tracker.client import AsyncTrackerClient  # noqa: E402

            self._tracker = AsyncTrackerClient(client_wrapper=self._client_wrapper)
        return self._tracker

    @property
    def cli_authentication(self):
        if self._cli_authentication is None:
            from .cli_authentication.client import AsyncCliAuthenticationClient  # noqa: E402

            self._cli_authentication = AsyncCliAuthenticationClient(client_wrapper=self._client_wrapper)
        return self._cli_authentication

    @property
    def authentication(self):
        if self._authentication is None:
            from .authentication.client import AsyncAuthenticationClient  # noqa: E402

            self._authentication = AsyncAuthenticationClient(client_wrapper=self._client_wrapper)
        return self._authentication

    @property
    def o_auth(self):
        if self._o_auth is None:
            from .o_auth.client import AsyncOAuthClient  # noqa: E402

            self._o_auth = AsyncOAuthClient(client_wrapper=self._client_wrapper)
        return self._o_auth

    @property
    def organizations(self):
        if self._organizations is None:
            from .organizations.client import AsyncOrganizationsClient  # noqa: E402

            self._organizations = AsyncOrganizationsClient(client_wrapper=self._client_wrapper)
        return self._organizations

    @property
    def messages_v2(self):
        if self._messages_v2 is None:
            from .messages_v2.client import AsyncMessagesV2Client  # noqa: E402

            self._messages_v2 = AsyncMessagesV2Client(client_wrapper=self._client_wrapper)
        return self._messages_v2

    @property
    def versions(self):
        if self._versions is None:
            from .versions.client import AsyncVersionsClient  # noqa: E402

            self._versions = AsyncVersionsClient(client_wrapper=self._client_wrapper)
        return self._versions

    @property
    def version_events(self):
        if self._version_events is None:
            from .version_events.client import AsyncVersionEventsClient  # noqa: E402

            self._version_events = AsyncVersionEventsClient(client_wrapper=self._client_wrapper)
        return self._version_events
