/*
 * Orvanta API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.2
 * 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 Script {
    #[serde(rename = "workspace_id", skip_serializing_if = "Option::is_none")]
    pub workspace_id: Option<String>,
    #[serde(rename = "hash")]
    pub hash: String,
    #[serde(rename = "path")]
    pub path: String,
    /// The first element is the direct parent of the script, the second is the parent of the first, etc 
    #[serde(rename = "parent_hashes", skip_serializing_if = "Option::is_none")]
    pub parent_hashes: Option<Vec<String>>,
    #[serde(rename = "summary")]
    pub summary: String,
    #[serde(rename = "description")]
    pub description: String,
    #[serde(rename = "content")]
    pub content: String,
    #[serde(rename = "created_by")]
    pub created_by: String,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(rename = "archived")]
    pub archived: bool,
    #[serde(rename = "schema", skip_serializing_if = "Option::is_none")]
    pub schema: Option<serde_json::Value>,
    #[serde(rename = "deleted")]
    pub deleted: bool,
    #[serde(rename = "is_template")]
    pub is_template: bool,
    #[serde(rename = "extra_perms")]
    pub extra_perms: std::collections::HashMap<String, bool>,
    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
    pub lock: Option<String>,
    #[serde(rename = "lock_error_logs", skip_serializing_if = "Option::is_none")]
    pub lock_error_logs: Option<String>,
    #[serde(rename = "language")]
    pub language: models::ScriptLang,
    #[serde(rename = "kind")]
    pub kind: Kind,
    #[serde(rename = "starred")]
    pub starred: bool,
    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
    pub tag: Option<String>,
    #[serde(rename = "has_draft", skip_serializing_if = "Option::is_none")]
    pub has_draft: Option<bool>,
    #[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 = "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 = "cache_ttl", skip_serializing_if = "Option::is_none")]
    pub cache_ttl: Option<f64>,
    #[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 = "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")]
    pub has_preprocessor: bool,
    #[serde(rename = "on_behalf_of_email", skip_serializing_if = "Option::is_none")]
    pub on_behalf_of_email: 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>>>,
    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<String>>,
}

impl Script {
    pub fn new(hash: String, path: String, summary: String, description: String, content: String, created_by: String, created_at: String, archived: bool, deleted: bool, is_template: bool, extra_perms: std::collections::HashMap<String, bool>, language: models::ScriptLang, kind: Kind, starred: bool, has_preprocessor: bool) -> Script {
        Script {
            workspace_id: None,
            hash,
            path,
            parent_hashes: None,
            summary,
            description,
            content,
            created_by,
            created_at,
            archived,
            schema: None,
            deleted,
            is_template,
            extra_perms,
            lock: None,
            lock_error_logs: None,
            language,
            kind,
            starred,
            tag: None,
            has_draft: None,
            draft_only: None,
            envs: None,
            concurrent_limit: None,
            concurrency_time_window_s: 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,
            cache_ttl: None,
            dedicated_worker: None,
            ws_error_handler_muted: None,
            priority: None,
            restart_unless_cancelled: None,
            timeout: None,
            delete_after_secs: None,
            visible_to_runner_only: None,
            auto_kind: None,
            codebase: None,
            has_preprocessor,
            on_behalf_of_email: 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
    }
}

