# 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.convert_to_workflow_response import ConvertToWorkflowResponse
from ..types.detach_workflow_response import DetachWorkflowResponse
from ..types.workflow_response import WorkflowResponse
from .raw_client import AsyncRawAssistantWorkflowsClient, RawAssistantWorkflowsClient

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


class AssistantWorkflowsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAssistantWorkflowsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAssistantWorkflowsClient
        """
        return self._raw_client

    def convert_assistant_to_workflow(
        self,
        assistant_id: str,
        *,
        workflow_name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConvertToWorkflowResponse:
        """
        Create a workflow from an assistant's settings and link it to the assistant.

        Parameters
        ----------
        assistant_id : str

        workflow_name : typing.Optional[str]
            Workflow name (defaults to '{assistant.name} Workflow')

        description : typing.Optional[str]
            Workflow description

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

        Returns
        -------
        ConvertToWorkflowResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.assistant_workflows.convert_assistant_to_workflow(
            assistant_id="assistant_id",
        )
        """
        _response = self._raw_client.convert_assistant_to_workflow(
            assistant_id, workflow_name=workflow_name, description=description, request_options=request_options
        )
        return _response.data

    def get_assistant_workflow(
        self, assistant_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> WorkflowResponse:
        """
        Retrieve the workflow linked to an assistant.

        Parameters
        ----------
        assistant_id : str

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

        Returns
        -------
        WorkflowResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.assistant_workflows.get_assistant_workflow(
            assistant_id="assistant_id",
        )
        """
        _response = self._raw_client.get_assistant_workflow(assistant_id, request_options=request_options)
        return _response.data

    def detach_assistant_workflow(
        self, assistant_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DetachWorkflowResponse:
        """
        Unlink the workflow from an assistant without deleting the workflow itself.

        Parameters
        ----------
        assistant_id : str

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

        Returns
        -------
        DetachWorkflowResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.assistant_workflows.detach_assistant_workflow(
            assistant_id="assistant_id",
        )
        """
        _response = self._raw_client.detach_assistant_workflow(assistant_id, request_options=request_options)
        return _response.data

    def update_assistant_workflow(
        self,
        assistant_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        definition: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        is_active: typing.Optional[bool] = OMIT,
        external_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowResponse:
        """
        Update the workflow definition or metadata linked to an assistant.

        Parameters
        ----------
        assistant_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        definition : typing.Optional[typing.Dict[str, typing.Any]]
            Updated workflow definition

        is_active : typing.Optional[bool]
            Active status

        external_id : typing.Optional[str]
            Flow-plate internal flow ID for correlation

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

        Returns
        -------
        WorkflowResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.assistant_workflows.update_assistant_workflow(
            assistant_id="assistant_id",
        )
        """
        _response = self._raw_client.update_assistant_workflow(
            assistant_id,
            name=name,
            description=description,
            definition=definition,
            is_active=is_active,
            external_id=external_id,
            request_options=request_options,
        )
        return _response.data


class AsyncAssistantWorkflowsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAssistantWorkflowsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAssistantWorkflowsClient
        """
        return self._raw_client

    async def convert_assistant_to_workflow(
        self,
        assistant_id: str,
        *,
        workflow_name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ConvertToWorkflowResponse:
        """
        Create a workflow from an assistant's settings and link it to the assistant.

        Parameters
        ----------
        assistant_id : str

        workflow_name : typing.Optional[str]
            Workflow name (defaults to '{assistant.name} Workflow')

        description : typing.Optional[str]
            Workflow description

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

        Returns
        -------
        ConvertToWorkflowResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.assistant_workflows.convert_assistant_to_workflow(
                assistant_id="assistant_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.convert_assistant_to_workflow(
            assistant_id, workflow_name=workflow_name, description=description, request_options=request_options
        )
        return _response.data

    async def get_assistant_workflow(
        self, assistant_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> WorkflowResponse:
        """
        Retrieve the workflow linked to an assistant.

        Parameters
        ----------
        assistant_id : str

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

        Returns
        -------
        WorkflowResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.assistant_workflows.get_assistant_workflow(
                assistant_id="assistant_id",
            )


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

    async def detach_assistant_workflow(
        self, assistant_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DetachWorkflowResponse:
        """
        Unlink the workflow from an assistant without deleting the workflow itself.

        Parameters
        ----------
        assistant_id : str

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

        Returns
        -------
        DetachWorkflowResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.assistant_workflows.detach_assistant_workflow(
                assistant_id="assistant_id",
            )


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

    async def update_assistant_workflow(
        self,
        assistant_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        definition: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        is_active: typing.Optional[bool] = OMIT,
        external_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowResponse:
        """
        Update the workflow definition or metadata linked to an assistant.

        Parameters
        ----------
        assistant_id : str

        name : typing.Optional[str]

        description : typing.Optional[str]

        definition : typing.Optional[typing.Dict[str, typing.Any]]
            Updated workflow definition

        is_active : typing.Optional[bool]
            Active status

        external_id : typing.Optional[str]
            Flow-plate internal flow ID for correlation

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

        Returns
        -------
        WorkflowResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.assistant_workflows.update_assistant_workflow(
                assistant_id="assistant_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_assistant_workflow(
            assistant_id,
            name=name,
            description=description,
            definition=definition,
            is_active=is_active,
            external_id=external_id,
            request_options=request_options,
        )
        return _response.data
