Skip to main content

windmill_api/models/
preview.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.841.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 Preview {
16    /// The code to run
17    #[serde(rename = "content", skip_serializing_if = "Option::is_none")]
18    pub content: Option<String>,
19    /// The path to the script
20    #[serde(rename = "path", skip_serializing_if = "Option::is_none")]
21    pub path: Option<String>,
22    /// The hash of the script
23    #[serde(rename = "script_hash", skip_serializing_if = "Option::is_none")]
24    pub script_hash: Option<String>,
25    /// The arguments to pass to the script or flow
26    #[serde(rename = "args")]
27    pub args: std::collections::HashMap<String, serde_json::Value>,
28    #[serde(rename = "language", skip_serializing_if = "Option::is_none")]
29    pub language: Option<models::ScriptLang>,
30    #[serde(rename = "tag", skip_serializing_if = "Option::is_none")]
31    pub tag: Option<String>,
32    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
33    pub kind: Option<Kind>,
34    #[serde(rename = "dedicated_worker", skip_serializing_if = "Option::is_none")]
35    pub dedicated_worker: Option<bool>,
36    #[serde(rename = "lock", skip_serializing_if = "Option::is_none")]
37    pub lock: Option<String>,
38    #[serde(rename = "flow_path", skip_serializing_if = "Option::is_none")]
39    pub flow_path: Option<String>,
40    /// Additional script modules keyed by relative file path
41    #[serde(rename = "modules", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
42    pub modules: Option<Option<std::collections::HashMap<String, models::ScriptModule>>>,
43    /// Map of relative-import script path -> temp storage hash so the preview job resolves those imports from not-yet-deployed local content instead of the deployed script
44    #[serde(rename = "temp_script_refs", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
45    pub temp_script_refs: Option<Option<std::collections::HashMap<String, String>>>,
46    /// Run the preview as this identity (an email, `u/<username>` or `g/<group>`) instead of the caller. Naming anyone other than yourself requires being an admin or a member of wm_deployers.
47    #[serde(rename = "on_behalf_of", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
48    pub on_behalf_of: Option<Option<String>>,
49    /// Data table and object storage access as the caller rather than as the job's identity, as a full-code app's inline runnable flagged viewer_data_access does for its viewer.
50    #[serde(rename = "viewer_data_access", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
51    pub viewer_data_access: Option<Option<bool>>,
52}
53
54impl Preview {
55    pub fn new(args: std::collections::HashMap<String, serde_json::Value>) -> Preview {
56        Preview {
57            content: None,
58            path: None,
59            script_hash: None,
60            args,
61            language: None,
62            tag: None,
63            kind: None,
64            dedicated_worker: None,
65            lock: None,
66            flow_path: None,
67            modules: None,
68            temp_script_refs: None,
69            on_behalf_of: None,
70            viewer_data_access: None,
71        }
72    }
73}
74/// 
75#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
76pub enum Kind {
77    #[serde(rename = "code")]
78    Code,
79    #[serde(rename = "identity")]
80    Identity,
81    #[serde(rename = "http")]
82    Http,
83}
84
85impl Default for Kind {
86    fn default() -> Kind {
87        Self::Code
88    }
89}
90