# 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.single_prompt_config import SinglePromptConfig
from ..types.workflow_type import WorkflowType
from .raw_client import AsyncRawWorkflowsClient, RawWorkflowsClient
from .types.patch_workflow_id_request_workflow_graph import PatchWorkflowIdRequestWorkflowGraph
from .types.patch_workflow_id_response import PatchWorkflowIdResponse

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


class WorkflowsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWorkflowsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawWorkflowsClient
        """
        return self._raw_client

    def update_workflow_configuration(
        self,
        id: str,
        *,
        type: WorkflowType,
        workflow_graph: typing.Optional[PatchWorkflowIdRequestWorkflowGraph] = OMIT,
        single_prompt_config: typing.Optional[SinglePromptConfig] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PatchWorkflowIdResponse:
        """
        Update workflow configuration for an agent. Currently available for single_prompt workflows only. For workflow_graph configurations, please use the UI.

        Parameters
        ----------
        id : str
            The ID of the workflow to update

        type : WorkflowType
            The type of workflow (single_prompt or workflow_graph)

        workflow_graph : typing.Optional[PatchWorkflowIdRequestWorkflowGraph]
            Workflow graph configuration. Required when type is workflow_graph. Exactly one of workflowGraph or singlePromptConfig must be provided.

        single_prompt_config : typing.Optional[SinglePromptConfig]
            Configuration for single_prompt workflow type. Required when type is single_prompt. Exactly one of workflowGraph or singlePromptConfig must be provided.

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

        Returns
        -------
        PatchWorkflowIdResponse
            Workflow updated successfully

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.workflows.update_workflow_configuration(
            id="60d0fe4f5311236168a109ca",
            type="workflow_graph",
        )
        """
        _response = self._raw_client.update_workflow_configuration(
            id,
            type=type,
            workflow_graph=workflow_graph,
            single_prompt_config=single_prompt_config,
            request_options=request_options,
        )
        return _response.data


class AsyncWorkflowsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWorkflowsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawWorkflowsClient
        """
        return self._raw_client

    async def update_workflow_configuration(
        self,
        id: str,
        *,
        type: WorkflowType,
        workflow_graph: typing.Optional[PatchWorkflowIdRequestWorkflowGraph] = OMIT,
        single_prompt_config: typing.Optional[SinglePromptConfig] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PatchWorkflowIdResponse:
        """
        Update workflow configuration for an agent. Currently available for single_prompt workflows only. For workflow_graph configurations, please use the UI.

        Parameters
        ----------
        id : str
            The ID of the workflow to update

        type : WorkflowType
            The type of workflow (single_prompt or workflow_graph)

        workflow_graph : typing.Optional[PatchWorkflowIdRequestWorkflowGraph]
            Workflow graph configuration. Required when type is workflow_graph. Exactly one of workflowGraph or singlePromptConfig must be provided.

        single_prompt_config : typing.Optional[SinglePromptConfig]
            Configuration for single_prompt workflow type. Required when type is single_prompt. Exactly one of workflowGraph or singlePromptConfig must be provided.

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

        Returns
        -------
        PatchWorkflowIdResponse
            Workflow updated successfully

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.workflows.update_workflow_configuration(
                id="60d0fe4f5311236168a109ca",
                type="workflow_graph",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_workflow_configuration(
            id,
            type=type,
            workflow_graph=workflow_graph,
            single_prompt_config=single_prompt_config,
            request_options=request_options,
        )
        return _response.data
