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

import datetime as dt
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.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.delete_response import DeleteResponse
from ..types.http_validation_error import HttpValidationError
from ..types.pause_schedule_request import PauseScheduleRequest
from ..types.schedule_list_response import ScheduleListResponse
from ..types.schedule_response import ScheduleResponse
from ..types.unpause_schedule_request import UnpauseScheduleRequest

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


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

    def agents_schedules_list(
        self,
        agent_id: str,
        *,
        page_size: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[ScheduleListResponse]:
        """
        List all schedules for an agent.

        Parameters
        ----------
        agent_id : str

        page_size : typing.Optional[int]

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

        Returns
        -------
        HttpResponse[ScheduleListResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules",
            method="GET",
            params={
                "page_size": page_size,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleListResponse,
                    parse_obj_as(
                        type_=ScheduleListResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_create(
        self,
        agent_id: str,
        *,
        name: str,
        task_queue: str,
        workflow_name: str,
        cron_expression: typing.Optional[str] = OMIT,
        end_at: typing.Optional[dt.datetime] = OMIT,
        execution_timeout_seconds: typing.Optional[int] = OMIT,
        interval_seconds: typing.Optional[int] = OMIT,
        paused: typing.Optional[bool] = OMIT,
        start_at: typing.Optional[dt.datetime] = OMIT,
        workflow_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[ScheduleResponse]:
        """
        Create a new schedule for recurring workflow execution for an agent.

        Parameters
        ----------
        agent_id : str

        name : str
            Human-readable name for the schedule (e.g., 'weekly-profiling'). Will be combined with agent_id to form the full schedule_id.

        task_queue : str
            Temporal task queue where the agent's worker is listening

        workflow_name : str
            Name of the Temporal workflow to execute (e.g., 'sae-orchestrator')

        cron_expression : typing.Optional[str]
            Cron expression for scheduling (e.g., '0 0 * * 0' for weekly on Sunday)

        end_at : typing.Optional[dt.datetime]
            When the schedule should stop being active

        execution_timeout_seconds : typing.Optional[int]
            Maximum time in seconds for each workflow execution

        interval_seconds : typing.Optional[int]
            Alternative to cron - run every N seconds

        paused : typing.Optional[bool]
            Whether to create the schedule in a paused state

        start_at : typing.Optional[dt.datetime]
            When the schedule should start being active

        workflow_params : typing.Optional[typing.Dict[str, typing.Any]]
            Parameters to pass to the workflow

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

        Returns
        -------
        HttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules",
            method="POST",
            json={
                "cron_expression": cron_expression,
                "end_at": end_at,
                "execution_timeout_seconds": execution_timeout_seconds,
                "interval_seconds": interval_seconds,
                "name": name,
                "paused": paused,
                "start_at": start_at,
                "task_queue": task_queue,
                "workflow_name": workflow_name,
                "workflow_params": workflow_params,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_retrieve(
        self, agent_id: str, schedule_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[ScheduleResponse]:
        """
        Get details of a schedule by its name.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

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

        Returns
        -------
        HttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_delete(
        self, agent_id: str, schedule_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[DeleteResponse]:
        """
        Delete a schedule permanently.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

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

        Returns
        -------
        HttpResponse[DeleteResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    DeleteResponse,
                    parse_obj_as(
                        type_=DeleteResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_pause(
        self,
        agent_id: str,
        schedule_name: str,
        *,
        request: typing.Optional[PauseScheduleRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[ScheduleResponse]:
        """
        Pause a schedule to stop it from executing.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

        request : typing.Optional[PauseScheduleRequest]

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

        Returns
        -------
        HttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}/pause",
            method="POST",
            json=convert_and_respect_annotation_metadata(
                object_=request, annotation=typing.Optional[PauseScheduleRequest], direction="write"
            ),
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_trigger(
        self, agent_id: str, schedule_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[ScheduleResponse]:
        """
        Trigger a schedule to run immediately, regardless of its regular schedule.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

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

        Returns
        -------
        HttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}/trigger",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_unpause(
        self,
        agent_id: str,
        schedule_name: str,
        *,
        request: typing.Optional[UnpauseScheduleRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[ScheduleResponse]:
        """
        Unpause/resume a schedule to allow it to execute again.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

        request : typing.Optional[UnpauseScheduleRequest]

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

        Returns
        -------
        HttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}/unpause",
            method="POST",
            json=convert_and_respect_annotation_metadata(
                object_=request, annotation=typing.Optional[UnpauseScheduleRequest], direction="write"
            ),
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 AsyncRawSchedulesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def agents_schedules_list(
        self,
        agent_id: str,
        *,
        page_size: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[ScheduleListResponse]:
        """
        List all schedules for an agent.

        Parameters
        ----------
        agent_id : str

        page_size : typing.Optional[int]

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

        Returns
        -------
        AsyncHttpResponse[ScheduleListResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules",
            method="GET",
            params={
                "page_size": page_size,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleListResponse,
                    parse_obj_as(
                        type_=ScheduleListResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_create(
        self,
        agent_id: str,
        *,
        name: str,
        task_queue: str,
        workflow_name: str,
        cron_expression: typing.Optional[str] = OMIT,
        end_at: typing.Optional[dt.datetime] = OMIT,
        execution_timeout_seconds: typing.Optional[int] = OMIT,
        interval_seconds: typing.Optional[int] = OMIT,
        paused: typing.Optional[bool] = OMIT,
        start_at: typing.Optional[dt.datetime] = OMIT,
        workflow_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[ScheduleResponse]:
        """
        Create a new schedule for recurring workflow execution for an agent.

        Parameters
        ----------
        agent_id : str

        name : str
            Human-readable name for the schedule (e.g., 'weekly-profiling'). Will be combined with agent_id to form the full schedule_id.

        task_queue : str
            Temporal task queue where the agent's worker is listening

        workflow_name : str
            Name of the Temporal workflow to execute (e.g., 'sae-orchestrator')

        cron_expression : typing.Optional[str]
            Cron expression for scheduling (e.g., '0 0 * * 0' for weekly on Sunday)

        end_at : typing.Optional[dt.datetime]
            When the schedule should stop being active

        execution_timeout_seconds : typing.Optional[int]
            Maximum time in seconds for each workflow execution

        interval_seconds : typing.Optional[int]
            Alternative to cron - run every N seconds

        paused : typing.Optional[bool]
            Whether to create the schedule in a paused state

        start_at : typing.Optional[dt.datetime]
            When the schedule should start being active

        workflow_params : typing.Optional[typing.Dict[str, typing.Any]]
            Parameters to pass to the workflow

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

        Returns
        -------
        AsyncHttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules",
            method="POST",
            json={
                "cron_expression": cron_expression,
                "end_at": end_at,
                "execution_timeout_seconds": execution_timeout_seconds,
                "interval_seconds": interval_seconds,
                "name": name,
                "paused": paused,
                "start_at": start_at,
                "task_queue": task_queue,
                "workflow_name": workflow_name,
                "workflow_params": workflow_params,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_retrieve(
        self, agent_id: str, schedule_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[ScheduleResponse]:
        """
        Get details of a schedule by its name.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

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

        Returns
        -------
        AsyncHttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_delete(
        self, agent_id: str, schedule_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[DeleteResponse]:
        """
        Delete a schedule permanently.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

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

        Returns
        -------
        AsyncHttpResponse[DeleteResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    DeleteResponse,
                    parse_obj_as(
                        type_=DeleteResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_pause(
        self,
        agent_id: str,
        schedule_name: str,
        *,
        request: typing.Optional[PauseScheduleRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[ScheduleResponse]:
        """
        Pause a schedule to stop it from executing.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

        request : typing.Optional[PauseScheduleRequest]

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

        Returns
        -------
        AsyncHttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}/pause",
            method="POST",
            json=convert_and_respect_annotation_metadata(
                object_=request, annotation=typing.Optional[PauseScheduleRequest], direction="write"
            ),
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_trigger(
        self, agent_id: str, schedule_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[ScheduleResponse]:
        """
        Trigger a schedule to run immediately, regardless of its regular schedule.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

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

        Returns
        -------
        AsyncHttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}/trigger",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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 agents_schedules_unpause(
        self,
        agent_id: str,
        schedule_name: str,
        *,
        request: typing.Optional[UnpauseScheduleRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[ScheduleResponse]:
        """
        Unpause/resume a schedule to allow it to execute again.

        Parameters
        ----------
        agent_id : str

        schedule_name : str

        request : typing.Optional[UnpauseScheduleRequest]

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

        Returns
        -------
        AsyncHttpResponse[ScheduleResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"agents/{jsonable_encoder(agent_id)}/schedules/{jsonable_encoder(schedule_name)}/unpause",
            method="POST",
            json=convert_and_respect_annotation_metadata(
                object_=request, annotation=typing.Optional[UnpauseScheduleRequest], direction="write"
            ),
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    ScheduleResponse,
                    parse_obj_as(
                        type_=ScheduleResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # 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)
