/*
 * Orvanta API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.2.0
 * Contact: contact@orvanta.cloud
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// FlowModuleTool : A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FlowModuleTool {
    #[serde(rename = "input_transforms")]
    pub input_transforms: Box<models::AiAgentInputTransforms>,
    /// The script source code. Should export a 'main' function
    #[serde(rename = "content")]
    pub content: String,
    /// Programming language for this script
    #[serde(rename = "language")]
    pub language: Language,
    /// Path to the flow in the workspace (e.g., 'f/flows/process_user')
    #[serde(rename = "path")]
    pub path: String,
    /// Lock file content for dependencies
    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
    pub lock: Option<String>,
    #[serde(rename = "type")]
    pub r#type: Type,
    /// Worker group tag for execution routing
    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
    pub tag: Option<String>,
    /// Maximum concurrent executions of this script
    #[serde(rename = "concurrent_limit", skip_serializing_if = "Option::is_none")]
    pub concurrent_limit: Option<f64>,
    /// Time window for concurrent_limit
    #[serde(rename = "concurrency_time_window_s", skip_serializing_if = "Option::is_none")]
    pub concurrency_time_window_s: Option<f64>,
    /// Custom key for grouping concurrent executions
    #[serde(rename = "custom_concurrency_key", skip_serializing_if = "Option::is_none")]
    pub custom_concurrency_key: Option<String>,
    /// If true, this script is a trigger that can start the flow
    #[serde(rename = "is_trigger", skip_serializing_if = "Option::is_none")]
    pub is_trigger: Option<bool>,
    /// External resources this script accesses (S3 objects, resources, etc.)
    #[serde(rename = "assets", skip_serializing_if = "Option::is_none")]
    pub assets: Option<Vec<models::RawScriptAssetsInner>>,
    /// Optional specific version hash of the script to use
    #[serde(rename = "hash", skip_serializing_if = "Option::is_none")]
    pub hash: Option<String>,
    /// Override the script's default worker group tag
    #[serde(rename = "tag_override", skip_serializing_if = "Option::is_none")]
    pub tag_override: Option<String>,
    /// Steps to execute in each iteration. Use stop_after_if to control when the loop ends
    #[serde(rename = "modules")]
    pub modules: Vec<models::FlowModule>,
    #[serde(rename = "iterator")]
    pub iterator: Box<models::InputTransform>,
    /// If true, iteration failures don't stop the loop. Failed iterations return null
    #[serde(rename = "skip_failures")]
    pub skip_failures: bool,
    /// If true, the agent can execute multiple tool calls in parallel
    #[serde(rename = "parallel", skip_serializing_if = "Option::is_none")]
    pub parallel: Option<bool>,
    #[serde(rename = "parallelism", skip_serializing_if = "Option::is_none")]
    pub parallelism: Option<Box<models::InputTransform>>,
    #[serde(rename = "squash", skip_serializing_if = "Option::is_none")]
    pub squash: Option<bool>,
    /// Array of branches that all execute (either in parallel or sequentially)
    #[serde(rename = "branches")]
    pub branches: Vec<models::BranchAllBranchesInner>,
    /// Steps to execute if no branch expressions match
    #[serde(rename = "default")]
    pub default: Vec<models::FlowModule>,
    /// If true, marks this as a flow identity (special handling)
    #[serde(rename = "flow", skip_serializing_if = "Option::is_none")]
    pub flow: Option<bool>,
    /// Array of tools the agent can use. The agent decides which tools to call based on the task
    #[serde(rename = "tools")]
    pub tools: Vec<models::AgentTool>,
    /// If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled.
    #[serde(rename = "omit_output_from_conversation", skip_serializing_if = "Option::is_none")]
    pub omit_output_from_conversation: Option<bool>,
    #[serde(rename = "tool_type")]
    pub tool_type: ToolType,
}

impl FlowModuleTool {
    /// A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module
    pub fn new(input_transforms: models::AiAgentInputTransforms, content: String, language: Language, path: String, r#type: Type, modules: Vec<models::FlowModule>, iterator: models::InputTransform, skip_failures: bool, branches: Vec<models::BranchAllBranchesInner>, default: Vec<models::FlowModule>, tools: Vec<models::AgentTool>, tool_type: ToolType) -> FlowModuleTool {
        FlowModuleTool {
            input_transforms: Box::new(input_transforms),
            content,
            language,
            path,
            lock: None,
            r#type,
            tag: None,
            concurrent_limit: None,
            concurrency_time_window_s: None,
            custom_concurrency_key: None,
            is_trigger: None,
            assets: None,
            hash: None,
            tag_override: None,
            modules,
            iterator: Box::new(iterator),
            skip_failures,
            parallel: None,
            parallelism: None,
            squash: None,
            branches,
            default,
            flow: None,
            tools,
            omit_output_from_conversation: None,
            tool_type,
        }
    }
}
/// Programming language for this script
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Language {
    #[serde(rename = "deno")]
    Deno,
    #[serde(rename = "bun")]
    Bun,
    #[serde(rename = "python3")]
    Python3,
    #[serde(rename = "go")]
    Go,
    #[serde(rename = "bash")]
    Bash,
    #[serde(rename = "powershell")]
    Powershell,
    #[serde(rename = "postgresql")]
    Postgresql,
    #[serde(rename = "mysql")]
    Mysql,
    #[serde(rename = "bigquery")]
    Bigquery,
    #[serde(rename = "snowflake")]
    Snowflake,
    #[serde(rename = "mssql")]
    Mssql,
    #[serde(rename = "oracledb")]
    Oracledb,
    #[serde(rename = "graphql")]
    Graphql,
    #[serde(rename = "nativets")]
    Nativets,
    #[serde(rename = "php")]
    Php,
    #[serde(rename = "rust")]
    Rust,
    #[serde(rename = "ansible")]
    Ansible,
    #[serde(rename = "csharp")]
    Csharp,
    #[serde(rename = "nu")]
    Nu,
    #[serde(rename = "java")]
    Java,
    #[serde(rename = "ruby")]
    Ruby,
    #[serde(rename = "rlang")]
    Rlang,
    #[serde(rename = "duckdb")]
    Duckdb,
}

impl Default for Language {
    fn default() -> Language {
        Self::Deno
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "aiagent")]
    Aiagent,
}

impl Default for Type {
    fn default() -> Type {
        Self::Aiagent
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ToolType {
    #[serde(rename = "flowmodule")]
    Flowmodule,
}

impl Default for ToolType {
    fn default() -> ToolType {
        Self::Flowmodule
    }
}

