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

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Preview {
    /// The code to run
    #[serde(rename = "content", skip_serializing_if = "Option::is_none")]
    pub content: Option<String>,
    /// The path to the script
    #[serde(rename = "path", skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// The hash of the script
    #[serde(rename = "script_hash", skip_serializing_if = "Option::is_none")]
    pub script_hash: Option<String>,
    /// The arguments to pass to the script or flow
    #[serde(rename = "args")]
    pub args: std::collections::HashMap<String, serde_json::Value>,
    #[serde(rename = "language", skip_serializing_if = "Option::is_none")]
    pub language: Option<models::ScriptLang>,
    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
    pub tag: Option<String>,
    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
    pub kind: Option<Kind>,
    #[serde(rename = "dedicated_worker", skip_serializing_if = "Option::is_none")]
    pub dedicated_worker: Option<bool>,
    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
    pub lock: Option<String>,
    #[serde(rename = "flow_path", skip_serializing_if = "Option::is_none")]
    pub flow_path: Option<String>,
    /// Additional script modules keyed by relative file path
    #[serde(rename = "modules", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub modules: Option<Option<std::collections::HashMap<String, models::ScriptModule>>>,
}

impl Preview {
    pub fn new(args: std::collections::HashMap<String, serde_json::Value>) -> Preview {
        Preview {
            content: None,
            path: None,
            script_hash: None,
            args,
            language: None,
            tag: None,
            kind: None,
            dedicated_worker: None,
            lock: None,
            flow_path: None,
            modules: None,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Kind {
    #[serde(rename = "code")]
    Code,
    #[serde(rename = "identity")]
    Identity,
    #[serde(rename = "http")]
    Http,
}

impl Default for Kind {
    fn default() -> Kind {
        Self::Code
    }
}

