/*
 * 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 NewScript {
    #[serde(rename = "path")]
    pub path: String,
    #[serde(rename = "parent_hash", skip_serializing_if = "Option::is_none")]
    pub parent_hash: Option<String>,
    #[serde(rename = "summary")]
    pub summary: String,
    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(rename = "content")]
    pub content: String,
    #[serde(rename = "schema", skip_serializing_if = "Option::is_none")]
    pub schema: Option<serde_json::Value>,
    #[serde(rename = "is_template", skip_serializing_if = "Option::is_none")]
    pub is_template: Option<bool>,
    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
    pub lock: Option<String>,
    #[serde(rename = "language")]
    pub language: models::ScriptLang,
    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
    pub kind: Option<Kind>,
    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
    pub tag: Option<String>,
    #[serde(rename = "draft_only", skip_serializing_if = "Option::is_none")]
    pub draft_only: Option<bool>,
    #[serde(rename = "envs", skip_serializing_if = "Option::is_none")]
    pub envs: Option<Vec<String>>,
    #[serde(rename = "concurrent_limit", skip_serializing_if = "Option::is_none")]
    pub concurrent_limit: Option<i32>,
    #[serde(rename = "concurrency_time_window_s", skip_serializing_if = "Option::is_none")]
    pub concurrency_time_window_s: Option<i32>,
    #[serde(rename = "cache_ttl", skip_serializing_if = "Option::is_none")]
    pub cache_ttl: Option<f64>,
    #[serde(rename = "cache_ignore_s3_path", skip_serializing_if = "Option::is_none")]
    pub cache_ignore_s3_path: Option<bool>,
    #[serde(rename = "dedicated_worker", skip_serializing_if = "Option::is_none")]
    pub dedicated_worker: Option<bool>,
    #[serde(rename = "ws_error_handler_muted", skip_serializing_if = "Option::is_none")]
    pub ws_error_handler_muted: Option<bool>,
    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
    pub priority: Option<i32>,
    #[serde(rename = "restart_unless_cancelled", skip_serializing_if = "Option::is_none")]
    pub restart_unless_cancelled: Option<bool>,
    #[serde(rename = "timeout", skip_serializing_if = "Option::is_none")]
    pub timeout: Option<i32>,
    /// If set, delete the job's args, result and logs after this many seconds following job completion
    #[serde(rename = "delete_after_secs", skip_serializing_if = "Option::is_none")]
    pub delete_after_secs: Option<i32>,
    #[serde(rename = "deployment_message", skip_serializing_if = "Option::is_none")]
    pub deployment_message: Option<String>,
    #[serde(rename = "concurrency_key", skip_serializing_if = "Option::is_none")]
    pub concurrency_key: Option<String>,
    #[serde(rename = "debounce_key", skip_serializing_if = "Option::is_none")]
    pub debounce_key: Option<String>,
    #[serde(rename = "debounce_delay_s", skip_serializing_if = "Option::is_none")]
    pub debounce_delay_s: Option<i32>,
    #[serde(rename = "debounce_args_to_accumulate", skip_serializing_if = "Option::is_none")]
    pub debounce_args_to_accumulate: Option<Vec<String>>,
    #[serde(rename = "max_total_debouncing_time", skip_serializing_if = "Option::is_none")]
    pub max_total_debouncing_time: Option<i32>,
    #[serde(rename = "max_total_debounces_amount", skip_serializing_if = "Option::is_none")]
    pub max_total_debounces_amount: Option<i32>,
    #[serde(rename = "visible_to_runner_only", skip_serializing_if = "Option::is_none")]
    pub visible_to_runner_only: Option<bool>,
    #[serde(rename = "auto_kind", skip_serializing_if = "Option::is_none")]
    pub auto_kind: Option<String>,
    #[serde(rename = "codebase", skip_serializing_if = "Option::is_none")]
    pub codebase: Option<String>,
    #[serde(rename = "has_preprocessor", skip_serializing_if = "Option::is_none")]
    pub has_preprocessor: Option<bool>,
    #[serde(rename = "on_behalf_of_email", skip_serializing_if = "Option::is_none")]
    pub on_behalf_of_email: Option<String>,
    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original on_behalf_of_email value instead of overwriting it.
    #[serde(rename = "preserve_on_behalf_of", skip_serializing_if = "Option::is_none")]
    pub preserve_on_behalf_of: Option<bool>,
    #[serde(rename = "assets", skip_serializing_if = "Option::is_none")]
    pub assets: Option<Vec<models::NewScriptAssetsInner>>,
    /// 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>>>,
    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<String>>,
}

impl NewScript {
    pub fn new(path: String, summary: String, content: String, language: models::ScriptLang) -> NewScript {
        NewScript {
            path,
            parent_hash: None,
            summary,
            description: None,
            content,
            schema: None,
            is_template: None,
            lock: None,
            language,
            kind: None,
            tag: None,
            draft_only: None,
            envs: None,
            concurrent_limit: None,
            concurrency_time_window_s: None,
            cache_ttl: None,
            cache_ignore_s3_path: None,
            dedicated_worker: None,
            ws_error_handler_muted: None,
            priority: None,
            restart_unless_cancelled: None,
            timeout: None,
            delete_after_secs: None,
            deployment_message: None,
            concurrency_key: None,
            debounce_key: None,
            debounce_delay_s: None,
            debounce_args_to_accumulate: None,
            max_total_debouncing_time: None,
            max_total_debounces_amount: None,
            visible_to_runner_only: None,
            auto_kind: None,
            codebase: None,
            has_preprocessor: None,
            on_behalf_of_email: None,
            preserve_on_behalf_of: None,
            assets: None,
            modules: None,
            labels: None,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Kind {
    #[serde(rename = "script")]
    Script,
    #[serde(rename = "failure")]
    Failure,
    #[serde(rename = "trigger")]
    Trigger,
    #[serde(rename = "command")]
    Command,
    #[serde(rename = "approval")]
    Approval,
    #[serde(rename = "preprocessor")]
    Preprocessor,
}

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

