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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.organization_schedule_list_response import OrganizationScheduleListResponse
from ..types.workflow_schedule_list_response import WorkflowScheduleListResponse
from ..types.workflow_schedule_response import WorkflowScheduleResponse
from .raw_client import AsyncRawAgentClient, RawAgentClient
from .types.list_organization_schedules_api_v1schedules_get_request_status import (
    ListOrganizationSchedulesApiV1SchedulesGetRequestStatus,
)

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


class AgentClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAgentClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAgentClient
        """
        return self._raw_client

    def list_organization_schedules(
        self,
        *,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        status: typing.Optional[ListOrganizationSchedulesApiV1SchedulesGetRequestStatus] = None,
        search: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationScheduleListResponse:
        """
        Parameters
        ----------
        page : typing.Optional[int]

        page_size : typing.Optional[int]

        status : typing.Optional[ListOrganizationSchedulesApiV1SchedulesGetRequestStatus]
            Filter by status: 'active' or 'paused'

        search : typing.Optional[str]
            Search by workflow title or schedule name

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

        Returns
        -------
        OrganizationScheduleListResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.list_organization_schedules(
            page=1,
            page_size=1,
            status="active",
            search="search",
        )
        """
        _response = self._raw_client.list_organization_schedules(
            page=page, page_size=page_size, status=status, search=search, request_options=request_options
        )
        return _response.data

    def list_workflow_schedules(
        self, workflow_permanent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> WorkflowScheduleListResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

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

        Returns
        -------
        WorkflowScheduleListResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.list_workflow_schedules(
            workflow_permanent_id="workflow_permanent_id",
        )
        """
        _response = self._raw_client.list_workflow_schedules(workflow_permanent_id, request_options=request_options)
        return _response.data

    def create_workflow_schedule(
        self,
        workflow_permanent_id: str,
        *,
        cron_expression: str,
        timezone: str,
        enabled: typing.Optional[bool] = OMIT,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        cron_expression : str

        timezone : str

        enabled : typing.Optional[bool]

        parameters : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        name : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.create_workflow_schedule(
            workflow_permanent_id="workflow_permanent_id",
            cron_expression="cron_expression",
            timezone="timezone",
        )
        """
        _response = self._raw_client.create_workflow_schedule(
            workflow_permanent_id,
            cron_expression=cron_expression,
            timezone=timezone,
            enabled=enabled,
            parameters=parameters,
            name=name,
            description=description,
            request_options=request_options,
        )
        return _response.data

    def get_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.get_workflow_schedule(
            workflow_permanent_id="workflow_permanent_id",
            workflow_schedule_id="workflow_schedule_id",
        )
        """
        _response = self._raw_client.get_workflow_schedule(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data

    def update_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        cron_expression: str,
        timezone: str,
        enabled: typing.Optional[bool] = OMIT,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

        cron_expression : str

        timezone : str

        enabled : typing.Optional[bool]

        parameters : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        name : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.update_workflow_schedule(
            workflow_permanent_id="workflow_permanent_id",
            workflow_schedule_id="workflow_schedule_id",
            cron_expression="cron_expression",
            timezone="timezone",
        )
        """
        _response = self._raw_client.update_workflow_schedule(
            workflow_permanent_id,
            workflow_schedule_id,
            cron_expression=cron_expression,
            timezone=timezone,
            enabled=enabled,
            parameters=parameters,
            name=name,
            description=description,
            request_options=request_options,
        )
        return _response.data

    def delete_workflow_schedule_route(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, bool]:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        typing.Dict[str, bool]
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.delete_workflow_schedule_route(
            workflow_permanent_id="workflow_permanent_id",
            workflow_schedule_id="workflow_schedule_id",
        )
        """
        _response = self._raw_client.delete_workflow_schedule_route(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data

    def enable_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.enable_workflow_schedule(
            workflow_permanent_id="workflow_permanent_id",
            workflow_schedule_id="workflow_schedule_id",
        )
        """
        _response = self._raw_client.enable_workflow_schedule(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data

    def disable_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.agent.disable_workflow_schedule(
            workflow_permanent_id="workflow_permanent_id",
            workflow_schedule_id="workflow_schedule_id",
        )
        """
        _response = self._raw_client.disable_workflow_schedule(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data


class AsyncAgentClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAgentClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAgentClient
        """
        return self._raw_client

    async def list_organization_schedules(
        self,
        *,
        page: typing.Optional[int] = None,
        page_size: typing.Optional[int] = None,
        status: typing.Optional[ListOrganizationSchedulesApiV1SchedulesGetRequestStatus] = None,
        search: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrganizationScheduleListResponse:
        """
        Parameters
        ----------
        page : typing.Optional[int]

        page_size : typing.Optional[int]

        status : typing.Optional[ListOrganizationSchedulesApiV1SchedulesGetRequestStatus]
            Filter by status: 'active' or 'paused'

        search : typing.Optional[str]
            Search by workflow title or schedule name

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

        Returns
        -------
        OrganizationScheduleListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.list_organization_schedules(
                page=1,
                page_size=1,
                status="active",
                search="search",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_organization_schedules(
            page=page, page_size=page_size, status=status, search=search, request_options=request_options
        )
        return _response.data

    async def list_workflow_schedules(
        self, workflow_permanent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> WorkflowScheduleListResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

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

        Returns
        -------
        WorkflowScheduleListResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.list_workflow_schedules(
                workflow_permanent_id="workflow_permanent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list_workflow_schedules(
            workflow_permanent_id, request_options=request_options
        )
        return _response.data

    async def create_workflow_schedule(
        self,
        workflow_permanent_id: str,
        *,
        cron_expression: str,
        timezone: str,
        enabled: typing.Optional[bool] = OMIT,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        cron_expression : str

        timezone : str

        enabled : typing.Optional[bool]

        parameters : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        name : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.create_workflow_schedule(
                workflow_permanent_id="workflow_permanent_id",
                cron_expression="cron_expression",
                timezone="timezone",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_workflow_schedule(
            workflow_permanent_id,
            cron_expression=cron_expression,
            timezone=timezone,
            enabled=enabled,
            parameters=parameters,
            name=name,
            description=description,
            request_options=request_options,
        )
        return _response.data

    async def get_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.get_workflow_schedule(
                workflow_permanent_id="workflow_permanent_id",
                workflow_schedule_id="workflow_schedule_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_workflow_schedule(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data

    async def update_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        cron_expression: str,
        timezone: str,
        enabled: typing.Optional[bool] = OMIT,
        parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

        cron_expression : str

        timezone : str

        enabled : typing.Optional[bool]

        parameters : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        name : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.update_workflow_schedule(
                workflow_permanent_id="workflow_permanent_id",
                workflow_schedule_id="workflow_schedule_id",
                cron_expression="cron_expression",
                timezone="timezone",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_workflow_schedule(
            workflow_permanent_id,
            workflow_schedule_id,
            cron_expression=cron_expression,
            timezone=timezone,
            enabled=enabled,
            parameters=parameters,
            name=name,
            description=description,
            request_options=request_options,
        )
        return _response.data

    async def delete_workflow_schedule_route(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, bool]:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        typing.Dict[str, bool]
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.delete_workflow_schedule_route(
                workflow_permanent_id="workflow_permanent_id",
                workflow_schedule_id="workflow_schedule_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_workflow_schedule_route(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data

    async def enable_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.enable_workflow_schedule(
                workflow_permanent_id="workflow_permanent_id",
                workflow_schedule_id="workflow_schedule_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.enable_workflow_schedule(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data

    async def disable_workflow_schedule(
        self,
        workflow_permanent_id: str,
        workflow_schedule_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowScheduleResponse:
        """
        Parameters
        ----------
        workflow_permanent_id : str

        workflow_schedule_id : str

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

        Returns
        -------
        WorkflowScheduleResponse
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.agent.disable_workflow_schedule(
                workflow_permanent_id="workflow_permanent_id",
                workflow_schedule_id="workflow_schedule_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.disable_workflow_schedule(
            workflow_permanent_id, workflow_schedule_id, request_options=request_options
        )
        return _response.data
