"""
Workflows API namespace.

AUTO-GENERATED by scripts/generate_sdk.py - DO NOT EDIT MANUALLY!
Regenerate with: python scripts/generate_sdk.py --category workflows
"""
from __future__ import annotations

from typing import Any, Dict, Optional

from ._base import AsyncBaseAPI, BaseAPI


class WorkflowsAPI(BaseAPI):
    """Workflows namespace: list, map."""

    def list(
        self,
        *,
        source: Optional[str] = None,
        target: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """List available bridge functions

        Args:
        source: Filter by source module
        target: Filter by target module"""
        params: Dict[str, Any] = {}
        if source is not None:
            params["source"] = source
        if target is not None:
            params["target"] = target
        return self._call("workflows.list", params=params, options=options, context=context)

    def map(
        self,
        *,
        bridge: str,
        source_data: Dict[str, Any],
        target_params: Optional[Dict[str, Any]] = None,
        execute: Optional[bool] = False,
        target_action: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Transform data between modules

        Map output from one module to input format of another. Set execute=true to also run the target operation.

        Args:
        bridge: Bridge function name
        source_data: Output data from source operation
        target_params: Additional params for target
        execute: If true, execute target operation
        target_action: Explicit target action (required when execute=true and bridge target has wildcard)"""
        params: Dict[str, Any] = {}
        params["bridge"] = bridge
        params["source_data"] = source_data
        if target_params is not None:
            params["target_params"] = target_params
        if execute is not None:
            params["execute"] = execute
        if target_action is not None:
            params["target_action"] = target_action
        return self._call("workflows.map", params=params, options=options, context=context)



class AsyncWorkflowsAPI(AsyncBaseAPI):
    """Workflows namespace: list, map."""

    async def list(
        self,
        *,
        source: Optional[str] = None,
        target: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """List available bridge functions

        Args:
        source: Filter by source module
        target: Filter by target module"""
        params: Dict[str, Any] = {}
        if source is not None:
            params["source"] = source
        if target is not None:
            params["target"] = target
        return await self._call("workflows.list", params=params, options=options, context=context)

    async def map(
        self,
        *,
        bridge: str,
        source_data: Dict[str, Any],
        target_params: Optional[Dict[str, Any]] = None,
        execute: Optional[bool] = False,
        target_action: Optional[str] = None,
        options: Optional[Dict[str, Any]] = None,
        context: Optional[Dict[str, Any]] = None,
    ) -> Any:
        """Transform data between modules

        Map output from one module to input format of another. Set execute=true to also run the target operation.

        Args:
        bridge: Bridge function name
        source_data: Output data from source operation
        target_params: Additional params for target
        execute: If true, execute target operation
        target_action: Explicit target action (required when execute=true and bridge target has wildcard)"""
        params: Dict[str, Any] = {}
        params["bridge"] = bridge
        params["source_data"] = source_data
        if target_params is not None:
            params["target_params"] = target_params
        if execute is not None:
            params["execute"] = execute
        if target_action is not None:
            params["target_action"] = target_action
        return await self._call("workflows.map", params=params, options=options, context=context)


