# 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.sandbox_provider import SandboxProvider
from ..types.sandbox_response import SandboxResponse
from .raw_client import AsyncRawAioClient, RawAioClient

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


class AioClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper, parent_client: typing.Any = None):
        self._raw_client = RawAioClient(client_wrapper=client_wrapper)
        self._parent_client = parent_client

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

        Returns
        -------
        RawAioClient
        """
        return self._raw_client

    def create(
        self,
        *,
        provider: typing.Optional[SandboxProvider] = OMIT,
        region: typing.Optional[str] = OMIT,
        timeout: typing.Optional[int] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SandboxResponse:
        """
        Create a new all-in-one sandbox with shell, MCP, and VNC capabilities.

        Parameters
        ----------
        provider : typing.Optional[SandboxProvider]
            Provider to use (auto-detected if not specified)

        region : typing.Optional[str]
            Preferred region for the sandbox

        timeout : typing.Optional[int]
            Timeout in minutes

        metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Additional metadata

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

        Returns
        -------
        SandboxResponse
            Successful Response

        Examples
        --------
        from ai_infra import Sandbox

        client = Sandbox(
            token="YOUR_TOKEN",
        )
        client.aio.create()
        """
        _response = self._raw_client.create(
            provider=provider, region=region, timeout=timeout, metadata=metadata, request_options=request_options
        )
        
        sandbox = _response.data
        # Inject parent client reference for convenience methods
        if self._parent_client is not None:
            sandbox._client = self._parent_client
        return sandbox


class AsyncAioClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper, parent_client: typing.Any = None):
        self._raw_client = AsyncRawAioClient(client_wrapper=client_wrapper)
        self._parent_client = parent_client

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

        Returns
        -------
        AsyncRawAioClient
        """
        return self._raw_client

    async def create(
        self,
        *,
        provider: typing.Optional[SandboxProvider] = OMIT,
        region: typing.Optional[str] = OMIT,
        timeout: typing.Optional[int] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SandboxResponse:
        """
        Create a new all-in-one sandbox with shell, MCP, and VNC capabilities.

        Parameters
        ----------
        provider : typing.Optional[SandboxProvider]
            Provider to use (auto-detected if not specified)

        region : typing.Optional[str]
            Preferred region for the sandbox

        timeout : typing.Optional[int]
            Timeout in minutes

        metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
            Additional metadata

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

        Returns
        -------
        SandboxResponse
            Successful Response

        Examples
        --------
        import asyncio

        from ai_infra import AsyncSandbox

        client = AsyncSandbox(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.aio.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            provider=provider, region=region, timeout=timeout, metadata=metadata, request_options=request_options
        )
        
        sandbox = _response.data
        # Inject parent client reference for convenience methods
        if self._parent_client is not None:
            sandbox._client = self._parent_client
        return sandbox
