# 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_deployment_request import AgentDeploymentRequest
from ....types.agent_deployment_response import AgentDeploymentResponse
from .raw_client import AsyncRawDeploymentsClient, RawDeploymentsClient

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


class DeploymentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDeploymentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDeploymentsClient
        """
        return self._raw_client

    def create(
        self,
        agent_id: str,
        *,
        deployment_request: AgentDeploymentRequest,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentDeploymentResponse:
        """
        Create a new deployment for an agent

        Parameters
        ----------
        agent_id : str
            The id of an agent. This is returned on agent creation.

        deployment_request : AgentDeploymentRequest
            Request to create a new deployment

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

        Returns
        -------
        AgentDeploymentResponse
            Successful Response

        Examples
        --------
        from elevenlabs import (
            AgentDeploymentPercentageStrategy,
            AgentDeploymentRequest,
            AgentDeploymentRequestItem,
            ElevenLabs,
        )

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.agents.deployments.create(
            agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
            deployment_request=AgentDeploymentRequest(
                requests=[
                    AgentDeploymentRequestItem(
                        branch_id="agtbrch_8901k4t9z5defmb8vh3e9361y7nj",
                        deployment_strategy=AgentDeploymentPercentageStrategy(
                            traffic_percentage=0.5,
                        ),
                    )
                ],
            ),
        )
        """
        _response = self._raw_client.create(
            agent_id, deployment_request=deployment_request, request_options=request_options
        )
        return _response.data


class AsyncDeploymentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDeploymentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDeploymentsClient
        """
        return self._raw_client

    async def create(
        self,
        agent_id: str,
        *,
        deployment_request: AgentDeploymentRequest,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentDeploymentResponse:
        """
        Create a new deployment for an agent

        Parameters
        ----------
        agent_id : str
            The id of an agent. This is returned on agent creation.

        deployment_request : AgentDeploymentRequest
            Request to create a new deployment

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

        Returns
        -------
        AgentDeploymentResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import (
            AgentDeploymentPercentageStrategy,
            AgentDeploymentRequest,
            AgentDeploymentRequestItem,
            AsyncElevenLabs,
        )

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.agents.deployments.create(
                agent_id="agent_3701k3ttaq12ewp8b7qv5rfyszkz",
                deployment_request=AgentDeploymentRequest(
                    requests=[
                        AgentDeploymentRequestItem(
                            branch_id="agtbrch_8901k4t9z5defmb8vh3e9361y7nj",
                            deployment_strategy=AgentDeploymentPercentageStrategy(
                                traffic_percentage=0.5,
                            ),
                        )
                    ],
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            agent_id, deployment_request=deployment_request, request_options=request_options
        )
        return _response.data
