# 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 .raw_client import AsyncRawEnvironmentsClient, RawEnvironmentsClient

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


class EnvironmentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawEnvironmentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawEnvironmentsClient
        """
        return self._raw_client

    def deploy_to_environment(
        self,
        *,
        environment_name: str,
        variant_id: str,
        commit_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Deploys a given variant to an environment

        Args:
            environment_name: Name of the environment to deploy to.
            variant_id: variant id to deploy.

        Raises:
            HTTPException: If the deployment fails.

        Parameters
        ----------
        environment_name : str

        variant_id : str

        commit_message : typing.Optional[str]

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.environments.deploy_to_environment(
            environment_name="environment_name",
            variant_id="variant_id",
        )
        """
        _response = self._raw_client.deploy_to_environment(
            environment_name=environment_name,
            variant_id=variant_id,
            commit_message=commit_message,
            request_options=request_options,
        )
        return _response.data


class AsyncEnvironmentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawEnvironmentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawEnvironmentsClient
        """
        return self._raw_client

    async def deploy_to_environment(
        self,
        *,
        environment_name: str,
        variant_id: str,
        commit_message: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Deploys a given variant to an environment

        Args:
            environment_name: Name of the environment to deploy to.
            variant_id: variant id to deploy.

        Raises:
            HTTPException: If the deployment fails.

        Parameters
        ----------
        environment_name : str

        variant_id : str

        commit_message : typing.Optional[str]

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.environments.deploy_to_environment(
                environment_name="environment_name",
                variant_id="variant_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.deploy_to_environment(
            environment_name=environment_name,
            variant_id=variant_id,
            commit_message=commit_message,
            request_options=request_options,
        )
        return _response.data
