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

import typing
from json.decoder import JSONDecodeError

from ...core.api_error import ApiError
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.http_response import AsyncHttpResponse, HttpResponse
from ...core.jsonable_encoder import jsonable_encoder
from ...core.request_options import RequestOptions
from ...core.serialization import convert_and_respect_annotation_metadata
from ...core.unchecked_base_model import construct_type
from ..errors.bad_request_error import BadRequestError
from ..errors.forbidden_error import ForbiddenError
from ..errors.internal_server_error import InternalServerError
from ..errors.not_found_error import NotFoundError
from ..errors.unauthorized_error import UnauthorizedError
from ..types.create_agent_request_background_sound import CreateAgentRequestBackgroundSound
from ..types.create_agent_request_language import CreateAgentRequestLanguage
from ..types.create_agent_request_slm_model import CreateAgentRequestSlmModel
from ..types.create_agent_request_synthesizer import CreateAgentRequestSynthesizer
from ..types.workflow_type import WorkflowType
from .types.delete_agent_agent_id_webhook_subscriptions_response import DeleteAgentAgentIdWebhookSubscriptionsResponse
from .types.delete_agent_id_response import DeleteAgentIdResponse
from .types.get_agent_agent_id_webhook_subscriptions_response import GetAgentAgentIdWebhookSubscriptionsResponse
from .types.get_agent_id_response import GetAgentIdResponse
from .types.get_agent_id_workflow_response import GetAgentIdWorkflowResponse
from .types.get_agent_response import GetAgentResponse
from .types.patch_agent_id_request_language import PatchAgentIdRequestLanguage
from .types.patch_agent_id_request_slm_model import PatchAgentIdRequestSlmModel
from .types.patch_agent_id_request_synthesizer import PatchAgentIdRequestSynthesizer
from .types.patch_agent_id_response import PatchAgentIdResponse
from .types.post_agent_agent_id_webhook_subscriptions_request_event_types_item import (
    PostAgentAgentIdWebhookSubscriptionsRequestEventTypesItem,
)
from .types.post_agent_agent_id_webhook_subscriptions_response import PostAgentAgentIdWebhookSubscriptionsResponse
from .types.post_agent_response import PostAgentResponse

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


class RawAgentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def get_all_agents(
        self,
        *,
        page: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[GetAgentResponse]:
        """
        Agents are the main entities in the system. Agents are used to create conversations. You can create workflow for an agent and configure it for different use cases. You can also create custom workflows for an agent. This API will give you the list of agents created by organization you are a part of.

        Parameters
        ----------
        page : typing.Optional[int]

        offset : typing.Optional[int]

        search : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[GetAgentResponse]
            Successful response
        """
        _response = self._client_wrapper.httpx_client.request(
            "agent",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            params={
                "page": page,
                "offset": offset,
                "search": search,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentResponse,
                    construct_type(
                        type_=GetAgentResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_a_new_agent(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        background_sound: typing.Optional[CreateAgentRequestBackgroundSound] = OMIT,
        language: typing.Optional[CreateAgentRequestLanguage] = OMIT,
        synthesizer: typing.Optional[CreateAgentRequestSynthesizer] = OMIT,
        global_knowledge_base_id: typing.Optional[str] = OMIT,
        slm_model: typing.Optional[CreateAgentRequestSlmModel] = OMIT,
        default_variables: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        global_prompt: typing.Optional[str] = OMIT,
        telephony_product_id: typing.Optional[str] = OMIT,
        workflow_type: typing.Optional[WorkflowType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PostAgentResponse]:
        """
        You can create a new agent by passing the name of the agent in the request body. You can use update-workflow endpoint next to assign custom workflow to the agent.

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

        description : typing.Optional[str]

        background_sound : typing.Optional[CreateAgentRequestBackgroundSound]
            Ambient background sound during calls. Options: '' (none), 'office', 'cafe', 'call_center', 'static'.

        language : typing.Optional[CreateAgentRequestLanguage]
            Language configuration for the agent. You can enable or disable language switching for the agent. This will be used to determine the language of the agent.

        synthesizer : typing.Optional[CreateAgentRequestSynthesizer]
            Synthesizer configuration for the agent. You can configure the synthesizer to use different voices and models. Currently we support 3 types of models for the synthesizer. Waves, Waves Lightning Large and Waves Lightning Large Voice Clone. You can clone your voice using waves platform https://waves.smallest.ai/voice-clone and use the voiceId for this field and select the model as waves_lightning_large_voice_clone to use your cloned voice. When updating the synthesizer configuration to voice clone model, you have to provide model and voiceId and gender all are required fields but when selecting the model as waves or waves and waves_lightning_large, you have to provide only model field and voiceId.

        global_knowledge_base_id : typing.Optional[str]
            The global knowledge base ID of the agent. You can create a global knowledge base by using the /knowledgebase endpoint and assign it to the agent. The agent will use this knowledge base for its responses.

        slm_model : typing.Optional[CreateAgentRequestSlmModel]
            The LLM model to use for the agent. LLM model will be used to generate the response and take decisions based on the user's query.

        default_variables : typing.Optional[typing.Dict[str, typing.Any]]
            The default variables to use for the agent. These variables will be used if no variables are provided when initiating a conversation with the agent.

        global_prompt : typing.Optional[str]
            Set global instructions for your agent's personality, role, and behavior throughout conversations.
            Note: Only used for workflow_graph agents.

        telephony_product_id : typing.Optional[str]
            The telephony product ID of the agent. This is the product ID of the telephony product that will be used to make the outbound call. You can buy telephone number and assign it to the agent.

        workflow_type : typing.Optional[WorkflowType]
            The type of workflow to create for the agent. Defaults to workflow_graph if not specified.

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

        Returns
        -------
        HttpResponse[PostAgentResponse]
            Agent created successfully
        """
        _response = self._client_wrapper.httpx_client.request(
            "agent",
            base_url=self._client_wrapper.get_environment().atoms,
            method="POST",
            json={
                "name": name,
                "description": description,
                "backgroundSound": background_sound,
                "language": convert_and_respect_annotation_metadata(
                    object_=language, annotation=CreateAgentRequestLanguage, direction="write"
                ),
                "synthesizer": convert_and_respect_annotation_metadata(
                    object_=synthesizer, annotation=CreateAgentRequestSynthesizer, direction="write"
                ),
                "globalKnowledgeBaseId": global_knowledge_base_id,
                "slmModel": slm_model,
                "defaultVariables": default_variables,
                "globalPrompt": global_prompt,
                "telephonyProductId": telephony_product_id,
                "workflowType": workflow_type,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PostAgentResponse,
                    construct_type(
                        type_=PostAgentResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_agent_by_id(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[GetAgentIdResponse]:
        """
        Agents are the main entities in the system. Agents are used to create conversations. You can create workflow for an agent and configure it for different use cases. You can also create custom workflows for an agent.

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

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

        Returns
        -------
        HttpResponse[GetAgentIdResponse]
            Successful response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentIdResponse,
                    construct_type(
                        type_=GetAgentIdResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete_an_agent(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[DeleteAgentIdResponse]:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        HttpResponse[DeleteAgentIdResponse]
            Agent deleted successfully
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}",
            base_url=self._client_wrapper.get_environment().atoms,
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    DeleteAgentIdResponse,
                    construct_type(
                        type_=DeleteAgentIdResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def update_an_agent(
        self,
        id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        language: typing.Optional[PatchAgentIdRequestLanguage] = OMIT,
        synthesizer: typing.Optional[PatchAgentIdRequestSynthesizer] = OMIT,
        global_knowledge_base_id: typing.Optional[str] = OMIT,
        slm_model: typing.Optional[PatchAgentIdRequestSlmModel] = OMIT,
        default_variables: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        global_prompt: typing.Optional[str] = OMIT,
        telephony_product_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PatchAgentIdResponse]:
        """
        Parameters
        ----------
        id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        language : typing.Optional[PatchAgentIdRequestLanguage]
            Language configuration for the agent. You can enable or disable language switching for the agent. This will be used to determine the language of the agent.

        synthesizer : typing.Optional[PatchAgentIdRequestSynthesizer]
            Synthesizer configuration for the agent. You can configure the synthesizer to use different voices and models. Currently we support 3 types of models for the synthesizer. Waves, Waves Lightning Large and Waves Lightning Large Voice Clone. You can clone your voice using waves platform https://waves.smallest.ai/voice-clone and use the voiceId for this field and select the model as waves_lightning_large_voice_clone to use your cloned voice. When updating the synthesizer configuration to voice clone model, you have to provide model and voiceId and gender all are required fields but when selecting the model as waves or waves and waves_lightning_large, you have to provide only model field and voiceId.

        global_knowledge_base_id : typing.Optional[str]

        slm_model : typing.Optional[PatchAgentIdRequestSlmModel]

        default_variables : typing.Optional[typing.Dict[str, typing.Any]]
            The default variables to use for the agent. These variables will be used if no variables are provided when initiating a conversation with the agent.

        global_prompt : typing.Optional[str]
            Set global instructions for your agent's personality, role, and behavior throughout conversations.
            Note: Only used for workflow_graph agents.

        telephony_product_id : typing.Optional[str]
            The telephony product ID of the agent. This is the product ID of the telephony product that will be used to make the outbound call. You can buy telephone number and assign it to the agent.

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

        Returns
        -------
        HttpResponse[PatchAgentIdResponse]
            Agent updated successfully
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}",
            base_url=self._client_wrapper.get_environment().atoms,
            method="PATCH",
            json={
                "name": name,
                "description": description,
                "language": convert_and_respect_annotation_metadata(
                    object_=language, annotation=PatchAgentIdRequestLanguage, direction="write"
                ),
                "synthesizer": convert_and_respect_annotation_metadata(
                    object_=synthesizer, annotation=PatchAgentIdRequestSynthesizer, direction="write"
                ),
                "globalKnowledgeBaseId": global_knowledge_base_id,
                "slmModel": slm_model,
                "defaultVariables": default_variables,
                "globalPrompt": global_prompt,
                "telephonyProductId": telephony_product_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PatchAgentIdResponse,
                    construct_type(
                        type_=PatchAgentIdResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_agent_workflow(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[GetAgentIdWorkflowResponse]:
        """
        Retrieve the workflow configuration for a specific agent. The workflow contains nodes and edges that define the conversation flow and logic for the agent.

        Parameters
        ----------
        id : str
            The ID of the agent

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

        Returns
        -------
        HttpResponse[GetAgentIdWorkflowResponse]
            Successful response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}/workflow",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentIdWorkflowResponse,
                    construct_type(
                        type_=GetAgentIdWorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_webhook_subscriptions_for_an_agent(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[GetAgentAgentIdWebhookSubscriptionsResponse]:
        """
        Retrieve webhook subscriptions for a given agent ID

        Parameters
        ----------
        agent_id : str
            The ID of the agent

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

        Returns
        -------
        HttpResponse[GetAgentAgentIdWebhookSubscriptionsResponse]
            Successful response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(agent_id)}/webhook-subscriptions",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentAgentIdWebhookSubscriptionsResponse,
                    construct_type(
                        type_=GetAgentAgentIdWebhookSubscriptionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_webhook_subscriptions_for_an_agent(
        self,
        agent_id: str,
        *,
        event_types: typing.Sequence[PostAgentAgentIdWebhookSubscriptionsRequestEventTypesItem],
        webhook_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[PostAgentAgentIdWebhookSubscriptionsResponse]:
        """
        Create webhook subscriptions for a specific agent with selected event types

        Parameters
        ----------
        agent_id : str
            The ID of the agent to create subscriptions for

        event_types : typing.Sequence[PostAgentAgentIdWebhookSubscriptionsRequestEventTypesItem]
            Array of event types to subscribe to

        webhook_id : str
            The ID of the webhook to subscribe to

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

        Returns
        -------
        HttpResponse[PostAgentAgentIdWebhookSubscriptionsResponse]
            Subscriptions created successfully
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(agent_id)}/webhook-subscriptions",
            base_url=self._client_wrapper.get_environment().atoms,
            method="POST",
            json={
                "eventTypes": event_types,
                "webhookId": webhook_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PostAgentAgentIdWebhookSubscriptionsResponse,
                    construct_type(
                        type_=PostAgentAgentIdWebhookSubscriptionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete_webhook_subscriptions_for_an_agent(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[DeleteAgentAgentIdWebhookSubscriptionsResponse]:
        """
        Delete webhook subscriptions for a given agent ID

        Parameters
        ----------
        agent_id : str
            The ID of the agent to filter subscriptions by

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

        Returns
        -------
        HttpResponse[DeleteAgentAgentIdWebhookSubscriptionsResponse]
            Subscriptions deleted successfully
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(agent_id)}/webhook-subscriptions",
            base_url=self._client_wrapper.get_environment().atoms,
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    DeleteAgentAgentIdWebhookSubscriptionsResponse,
                    construct_type(
                        type_=DeleteAgentAgentIdWebhookSubscriptionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawAgentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def get_all_agents(
        self,
        *,
        page: typing.Optional[int] = None,
        offset: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[GetAgentResponse]:
        """
        Agents are the main entities in the system. Agents are used to create conversations. You can create workflow for an agent and configure it for different use cases. You can also create custom workflows for an agent. This API will give you the list of agents created by organization you are a part of.

        Parameters
        ----------
        page : typing.Optional[int]

        offset : typing.Optional[int]

        search : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[GetAgentResponse]
            Successful response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "agent",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            params={
                "page": page,
                "offset": offset,
                "search": search,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentResponse,
                    construct_type(
                        type_=GetAgentResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create_a_new_agent(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        background_sound: typing.Optional[CreateAgentRequestBackgroundSound] = OMIT,
        language: typing.Optional[CreateAgentRequestLanguage] = OMIT,
        synthesizer: typing.Optional[CreateAgentRequestSynthesizer] = OMIT,
        global_knowledge_base_id: typing.Optional[str] = OMIT,
        slm_model: typing.Optional[CreateAgentRequestSlmModel] = OMIT,
        default_variables: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        global_prompt: typing.Optional[str] = OMIT,
        telephony_product_id: typing.Optional[str] = OMIT,
        workflow_type: typing.Optional[WorkflowType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PostAgentResponse]:
        """
        You can create a new agent by passing the name of the agent in the request body. You can use update-workflow endpoint next to assign custom workflow to the agent.

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

        description : typing.Optional[str]

        background_sound : typing.Optional[CreateAgentRequestBackgroundSound]
            Ambient background sound during calls. Options: '' (none), 'office', 'cafe', 'call_center', 'static'.

        language : typing.Optional[CreateAgentRequestLanguage]
            Language configuration for the agent. You can enable or disable language switching for the agent. This will be used to determine the language of the agent.

        synthesizer : typing.Optional[CreateAgentRequestSynthesizer]
            Synthesizer configuration for the agent. You can configure the synthesizer to use different voices and models. Currently we support 3 types of models for the synthesizer. Waves, Waves Lightning Large and Waves Lightning Large Voice Clone. You can clone your voice using waves platform https://waves.smallest.ai/voice-clone and use the voiceId for this field and select the model as waves_lightning_large_voice_clone to use your cloned voice. When updating the synthesizer configuration to voice clone model, you have to provide model and voiceId and gender all are required fields but when selecting the model as waves or waves and waves_lightning_large, you have to provide only model field and voiceId.

        global_knowledge_base_id : typing.Optional[str]
            The global knowledge base ID of the agent. You can create a global knowledge base by using the /knowledgebase endpoint and assign it to the agent. The agent will use this knowledge base for its responses.

        slm_model : typing.Optional[CreateAgentRequestSlmModel]
            The LLM model to use for the agent. LLM model will be used to generate the response and take decisions based on the user's query.

        default_variables : typing.Optional[typing.Dict[str, typing.Any]]
            The default variables to use for the agent. These variables will be used if no variables are provided when initiating a conversation with the agent.

        global_prompt : typing.Optional[str]
            Set global instructions for your agent's personality, role, and behavior throughout conversations.
            Note: Only used for workflow_graph agents.

        telephony_product_id : typing.Optional[str]
            The telephony product ID of the agent. This is the product ID of the telephony product that will be used to make the outbound call. You can buy telephone number and assign it to the agent.

        workflow_type : typing.Optional[WorkflowType]
            The type of workflow to create for the agent. Defaults to workflow_graph if not specified.

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

        Returns
        -------
        AsyncHttpResponse[PostAgentResponse]
            Agent created successfully
        """
        _response = await self._client_wrapper.httpx_client.request(
            "agent",
            base_url=self._client_wrapper.get_environment().atoms,
            method="POST",
            json={
                "name": name,
                "description": description,
                "backgroundSound": background_sound,
                "language": convert_and_respect_annotation_metadata(
                    object_=language, annotation=CreateAgentRequestLanguage, direction="write"
                ),
                "synthesizer": convert_and_respect_annotation_metadata(
                    object_=synthesizer, annotation=CreateAgentRequestSynthesizer, direction="write"
                ),
                "globalKnowledgeBaseId": global_knowledge_base_id,
                "slmModel": slm_model,
                "defaultVariables": default_variables,
                "globalPrompt": global_prompt,
                "telephonyProductId": telephony_product_id,
                "workflowType": workflow_type,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PostAgentResponse,
                    construct_type(
                        type_=PostAgentResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_agent_by_id(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[GetAgentIdResponse]:
        """
        Agents are the main entities in the system. Agents are used to create conversations. You can create workflow for an agent and configure it for different use cases. You can also create custom workflows for an agent.

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

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

        Returns
        -------
        AsyncHttpResponse[GetAgentIdResponse]
            Successful response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentIdResponse,
                    construct_type(
                        type_=GetAgentIdResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete_an_agent(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[DeleteAgentIdResponse]:
        """
        Parameters
        ----------
        id : str

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

        Returns
        -------
        AsyncHttpResponse[DeleteAgentIdResponse]
            Agent deleted successfully
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}",
            base_url=self._client_wrapper.get_environment().atoms,
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    DeleteAgentIdResponse,
                    construct_type(
                        type_=DeleteAgentIdResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 403:
                raise ForbiddenError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def update_an_agent(
        self,
        id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        language: typing.Optional[PatchAgentIdRequestLanguage] = OMIT,
        synthesizer: typing.Optional[PatchAgentIdRequestSynthesizer] = OMIT,
        global_knowledge_base_id: typing.Optional[str] = OMIT,
        slm_model: typing.Optional[PatchAgentIdRequestSlmModel] = OMIT,
        default_variables: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        global_prompt: typing.Optional[str] = OMIT,
        telephony_product_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PatchAgentIdResponse]:
        """
        Parameters
        ----------
        id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        language : typing.Optional[PatchAgentIdRequestLanguage]
            Language configuration for the agent. You can enable or disable language switching for the agent. This will be used to determine the language of the agent.

        synthesizer : typing.Optional[PatchAgentIdRequestSynthesizer]
            Synthesizer configuration for the agent. You can configure the synthesizer to use different voices and models. Currently we support 3 types of models for the synthesizer. Waves, Waves Lightning Large and Waves Lightning Large Voice Clone. You can clone your voice using waves platform https://waves.smallest.ai/voice-clone and use the voiceId for this field and select the model as waves_lightning_large_voice_clone to use your cloned voice. When updating the synthesizer configuration to voice clone model, you have to provide model and voiceId and gender all are required fields but when selecting the model as waves or waves and waves_lightning_large, you have to provide only model field and voiceId.

        global_knowledge_base_id : typing.Optional[str]

        slm_model : typing.Optional[PatchAgentIdRequestSlmModel]

        default_variables : typing.Optional[typing.Dict[str, typing.Any]]
            The default variables to use for the agent. These variables will be used if no variables are provided when initiating a conversation with the agent.

        global_prompt : typing.Optional[str]
            Set global instructions for your agent's personality, role, and behavior throughout conversations.
            Note: Only used for workflow_graph agents.

        telephony_product_id : typing.Optional[str]
            The telephony product ID of the agent. This is the product ID of the telephony product that will be used to make the outbound call. You can buy telephone number and assign it to the agent.

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

        Returns
        -------
        AsyncHttpResponse[PatchAgentIdResponse]
            Agent updated successfully
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}",
            base_url=self._client_wrapper.get_environment().atoms,
            method="PATCH",
            json={
                "name": name,
                "description": description,
                "language": convert_and_respect_annotation_metadata(
                    object_=language, annotation=PatchAgentIdRequestLanguage, direction="write"
                ),
                "synthesizer": convert_and_respect_annotation_metadata(
                    object_=synthesizer, annotation=PatchAgentIdRequestSynthesizer, direction="write"
                ),
                "globalKnowledgeBaseId": global_knowledge_base_id,
                "slmModel": slm_model,
                "defaultVariables": default_variables,
                "globalPrompt": global_prompt,
                "telephonyProductId": telephony_product_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PatchAgentIdResponse,
                    construct_type(
                        type_=PatchAgentIdResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_agent_workflow(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[GetAgentIdWorkflowResponse]:
        """
        Retrieve the workflow configuration for a specific agent. The workflow contains nodes and edges that define the conversation flow and logic for the agent.

        Parameters
        ----------
        id : str
            The ID of the agent

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

        Returns
        -------
        AsyncHttpResponse[GetAgentIdWorkflowResponse]
            Successful response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(id)}/workflow",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentIdWorkflowResponse,
                    construct_type(
                        type_=GetAgentIdWorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_webhook_subscriptions_for_an_agent(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[GetAgentAgentIdWebhookSubscriptionsResponse]:
        """
        Retrieve webhook subscriptions for a given agent ID

        Parameters
        ----------
        agent_id : str
            The ID of the agent

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

        Returns
        -------
        AsyncHttpResponse[GetAgentAgentIdWebhookSubscriptionsResponse]
            Successful response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(agent_id)}/webhook-subscriptions",
            base_url=self._client_wrapper.get_environment().atoms,
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAgentAgentIdWebhookSubscriptionsResponse,
                    construct_type(
                        type_=GetAgentAgentIdWebhookSubscriptionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create_webhook_subscriptions_for_an_agent(
        self,
        agent_id: str,
        *,
        event_types: typing.Sequence[PostAgentAgentIdWebhookSubscriptionsRequestEventTypesItem],
        webhook_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[PostAgentAgentIdWebhookSubscriptionsResponse]:
        """
        Create webhook subscriptions for a specific agent with selected event types

        Parameters
        ----------
        agent_id : str
            The ID of the agent to create subscriptions for

        event_types : typing.Sequence[PostAgentAgentIdWebhookSubscriptionsRequestEventTypesItem]
            Array of event types to subscribe to

        webhook_id : str
            The ID of the webhook to subscribe to

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

        Returns
        -------
        AsyncHttpResponse[PostAgentAgentIdWebhookSubscriptionsResponse]
            Subscriptions created successfully
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(agent_id)}/webhook-subscriptions",
            base_url=self._client_wrapper.get_environment().atoms,
            method="POST",
            json={
                "eventTypes": event_types,
                "webhookId": webhook_id,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    PostAgentAgentIdWebhookSubscriptionsResponse,
                    construct_type(
                        type_=PostAgentAgentIdWebhookSubscriptionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete_webhook_subscriptions_for_an_agent(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[DeleteAgentAgentIdWebhookSubscriptionsResponse]:
        """
        Delete webhook subscriptions for a given agent ID

        Parameters
        ----------
        agent_id : str
            The ID of the agent to filter subscriptions by

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

        Returns
        -------
        AsyncHttpResponse[DeleteAgentAgentIdWebhookSubscriptionsResponse]
            Subscriptions deleted successfully
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agent/{jsonable_encoder(agent_id)}/webhook-subscriptions",
            base_url=self._client_wrapper.get_environment().atoms,
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    DeleteAgentAgentIdWebhookSubscriptionsResponse,
                    construct_type(
                        type_=DeleteAgentAgentIdWebhookSubscriptionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 400:
                raise BadRequestError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 401:
                raise UnauthorizedError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 404:
                raise NotFoundError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            if _response.status_code == 500:
                raise InternalServerError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        construct_type(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
