Skip to main content

windmill_api/models/
script.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.864.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct Script {
16    #[serde(rename = "workspace_id", skip_serializing_if = "Option::is_none")]
17    pub workspace_id: Option<String>,
18    #[serde(rename = "hash")]
19    pub hash: String,
20    #[serde(rename = "path")]
21    pub path: String,
22    /// The first element is the direct parent of the script, the second is the parent of the first, etc 
23    #[serde(rename = "parent_hashes", skip_serializing_if = "Option::is_none")]
24    pub parent_hashes: Option<Vec<String>>,
25    #[serde(rename = "summary")]
26    pub summary: String,
27    #[serde(rename = "description")]
28    pub description: String,
29    #[serde(rename = "content")]
30    pub content: String,
31    #[serde(rename = "created_by")]
32    pub created_by: String,
33    #[serde(rename = "created_at")]
34    pub created_at: String,
35    #[serde(rename = "archived")]
36    pub archived: bool,
37    #[serde(rename = "schema", skip_serializing_if = "Option::is_none")]
38    pub schema: Option<serde_json::Value>,
39    #[serde(rename = "deleted")]
40    pub deleted: bool,
41    #[serde(rename = "is_template")]
42    pub is_template: bool,
43    #[serde(rename = "extra_perms")]
44    pub extra_perms: std::collections::HashMap<String, bool>,
45    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
46    pub lock: Option<String>,
47    #[serde(rename = "lock_error_logs", skip_serializing_if = "Option::is_none")]
48    pub lock_error_logs: Option<String>,
49    #[serde(rename = "language")]
50    pub language: models::ScriptLang,
51    #[serde(rename = "kind")]
52    pub kind: Kind,
53    #[serde(rename = "starred")]
54    pub starred: bool,
55    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
56    pub tag: Option<String>,
57    #[serde(rename = "draft_only", skip_serializing_if = "Option::is_none")]
58    pub draft_only: Option<bool>,
59    #[serde(rename = "envs", skip_serializing_if = "Option::is_none")]
60    pub envs: Option<Vec<String>>,
61    #[serde(rename = "concurrent_limit", skip_serializing_if = "Option::is_none")]
62    pub concurrent_limit: Option<i32>,
63    #[serde(rename = "concurrency_time_window_s", skip_serializing_if = "Option::is_none")]
64    pub concurrency_time_window_s: Option<i32>,
65    /// What a run does when its concurrency limit is reached when a worker picks it up. `queue` (default) re-queues it to a later slot, `fail` ends it immediately as failed.
66    #[serde(rename = "on_concurrency_limit", skip_serializing_if = "Option::is_none")]
67    pub on_concurrency_limit: Option<OnConcurrencyLimit>,
68    #[serde(rename = "concurrency_key", skip_serializing_if = "Option::is_none")]
69    pub concurrency_key: Option<String>,
70    #[serde(rename = "debounce_key", skip_serializing_if = "Option::is_none")]
71    pub debounce_key: Option<String>,
72    #[serde(rename = "debounce_delay_s", skip_serializing_if = "Option::is_none")]
73    pub debounce_delay_s: Option<i32>,
74    #[serde(rename = "debounce_args_to_accumulate", skip_serializing_if = "Option::is_none")]
75    pub debounce_args_to_accumulate: Option<Vec<String>>,
76    #[serde(rename = "max_total_debouncing_time", skip_serializing_if = "Option::is_none")]
77    pub max_total_debouncing_time: Option<i32>,
78    #[serde(rename = "max_total_debounces_amount", skip_serializing_if = "Option::is_none")]
79    pub max_total_debounces_amount: Option<i32>,
80    #[serde(rename = "cache_ttl", skip_serializing_if = "Option::is_none")]
81    pub cache_ttl: Option<f64>,
82    #[serde(rename = "cache_ignore_s3_path", skip_serializing_if = "Option::is_none")]
83    pub cache_ignore_s3_path: Option<bool>,
84    #[serde(rename = "dedicated_worker", skip_serializing_if = "Option::is_none")]
85    pub dedicated_worker: Option<bool>,
86    #[serde(rename = "ws_error_handler_muted", skip_serializing_if = "Option::is_none")]
87    pub ws_error_handler_muted: Option<bool>,
88    #[serde(rename = "priority", skip_serializing_if = "Option::is_none")]
89    pub priority: Option<i32>,
90    #[serde(rename = "restart_unless_cancelled", skip_serializing_if = "Option::is_none")]
91    pub restart_unless_cancelled: Option<bool>,
92    #[serde(rename = "timeout", skip_serializing_if = "Option::is_none")]
93    pub timeout: Option<i32>,
94    /// If set, delete the job's args, result and logs after this many seconds following job completion
95    #[serde(rename = "delete_after_secs", skip_serializing_if = "Option::is_none")]
96    pub delete_after_secs: Option<i32>,
97    #[serde(rename = "visible_to_runner_only", skip_serializing_if = "Option::is_none")]
98    pub visible_to_runner_only: Option<bool>,
99    #[serde(rename = "auto_kind", skip_serializing_if = "Option::is_none")]
100    pub auto_kind: Option<String>,
101    #[serde(rename = "codebase", skip_serializing_if = "Option::is_none")]
102    pub codebase: Option<String>,
103    #[serde(rename = "has_preprocessor")]
104    pub has_preprocessor: bool,
105    #[serde(rename = "on_behalf_of_email", skip_serializing_if = "Option::is_none")]
106    pub on_behalf_of_email: Option<String>,
107    /// Authorization identity the runnable runs as: u/{username}, g/{group}, or a bare email when the username is itself email-shaped. The only stored half of the identity; on_behalf_of_email is derived from it.
108    #[serde(rename = "on_behalf_of", skip_serializing_if = "Option::is_none")]
109    pub on_behalf_of: Option<String>,
110    /// Additional script modules keyed by relative file path
111    #[serde(rename = "modules", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
112    pub modules: Option<Option<std::collections::HashMap<String, models::ScriptModule>>>,
113    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
114    pub labels: Option<Vec<String>>,
115    /// Scopes the token of every job of this runnable is restricted to (domain:action[:resource], e.g. oidc:write). Jobs it starts, flow steps and AI agent tools inherit the restriction. Unset, the job token carries the full permissions of the identity the job runs as; an empty list leaves it no API access beyond its own job.
116    #[serde(rename = "job_token_scopes", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
117    pub job_token_scopes: Option<Option<Vec<String>>>,
118    /// Labels inherited from the parent folder, computed at read time. Read-only — edit them on the folder. 
119    #[serde(rename = "inherited_labels", skip_serializing_if = "Option::is_none")]
120    pub inherited_labels: Option<Vec<String>>,
121}
122
123impl Script {
124    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 {
125        Script {
126            workspace_id: None,
127            hash,
128            path,
129            parent_hashes: None,
130            summary,
131            description,
132            content,
133            created_by,
134            created_at,
135            archived,
136            schema: None,
137            deleted,
138            is_template,
139            extra_perms,
140            lock: None,
141            lock_error_logs: None,
142            language,
143            kind,
144            starred,
145            tag: None,
146            draft_only: None,
147            envs: None,
148            concurrent_limit: None,
149            concurrency_time_window_s: None,
150            on_concurrency_limit: None,
151            concurrency_key: None,
152            debounce_key: None,
153            debounce_delay_s: None,
154            debounce_args_to_accumulate: None,
155            max_total_debouncing_time: None,
156            max_total_debounces_amount: None,
157            cache_ttl: None,
158            cache_ignore_s3_path: None,
159            dedicated_worker: None,
160            ws_error_handler_muted: None,
161            priority: None,
162            restart_unless_cancelled: None,
163            timeout: None,
164            delete_after_secs: None,
165            visible_to_runner_only: None,
166            auto_kind: None,
167            codebase: None,
168            has_preprocessor,
169            on_behalf_of_email: None,
170            on_behalf_of: None,
171            modules: None,
172            labels: None,
173            job_token_scopes: None,
174            inherited_labels: None,
175        }
176    }
177}
178/// 
179#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
180pub enum Kind {
181    #[serde(rename = "script")]
182    Script,
183    #[serde(rename = "failure")]
184    Failure,
185    #[serde(rename = "trigger")]
186    Trigger,
187    #[serde(rename = "command")]
188    Command,
189    #[serde(rename = "approval")]
190    Approval,
191    #[serde(rename = "preprocessor")]
192    Preprocessor,
193}
194
195impl Default for Kind {
196    fn default() -> Kind {
197        Self::Script
198    }
199}
200/// What a run does when its concurrency limit is reached when a worker picks it up. `queue` (default) re-queues it to a later slot, `fail` ends it immediately as failed.
201#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
202pub enum OnConcurrencyLimit {
203    #[serde(rename = "queue")]
204    Queue,
205    #[serde(rename = "fail")]
206    Fail,
207}
208
209impl Default for OnConcurrencyLimit {
210    fn default() -> OnConcurrencyLimit {
211        Self::Queue
212    }
213}
214