Skip to main content

windmill_api/models/
policy.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.812.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 Policy {
16    #[serde(rename = "triggerables", skip_serializing_if = "Option::is_none")]
17    pub triggerables: Option<std::collections::HashMap<String, serde_json::Value>>,
18    #[serde(rename = "triggerables_v2", skip_serializing_if = "Option::is_none")]
19    pub triggerables_v2: Option<std::collections::HashMap<String, serde_json::Value>>,
20    #[serde(rename = "s3_inputs", skip_serializing_if = "Option::is_none")]
21    pub s3_inputs: Option<Vec<serde_json::Value>>,
22    #[serde(rename = "allowed_s3_keys", skip_serializing_if = "Option::is_none")]
23    pub allowed_s3_keys: Option<Vec<models::PolicyAllowedS3KeysInner>>,
24    /// Who may open the app, and who its runnables execute as. Optional, and what omitting it means depends on the operation: creating an app defaults it to `publisher` (runs on behalf of the app's publisher and requires an authenticated viewer), while updating one keeps the mode the app is already deployed under. Neither `anonymous`, which makes the app publicly executable, nor `guest`, which opens it to anyone the identity provider authenticates, is ever assumed. A guest is only admitted where the workspace also has `guest_access_enabled`, which is checked when the session is minted and again on every guest request
25    #[serde(rename = "execution_mode", skip_serializing_if = "Option::is_none")]
26    pub execution_mode: Option<ExecutionMode>,
27    /// The user or group the app runs as in anonymous or publisher mode (e.g. 'u/admin' or 'g/mygroup'). The authority for the app's identity.
28    #[serde(rename = "on_behalf_of", skip_serializing_if = "Option::is_none")]
29    pub on_behalf_of: Option<String>,
30    /// Address of `on_behalf_of`, written through from it on every save and returned as stored. Optional; when absent it is derived from `on_behalf_of`. Sending it is optional too; it must name the same account as `on_behalf_of`, and a pair that disagrees is rejected.
31    #[serde(rename = "on_behalf_of_email", skip_serializing_if = "Option::is_none")]
32    pub on_behalf_of_email: Option<String>,
33    /// Publisher opt-in to app sandbox isolation (alpha). When true the app is isolated from each viewer's Windmill session. When false/absent the app runs same-origin with the viewer's full session (the default, pre-isolation behavior). 
34    #[serde(rename = "sandbox", skip_serializing_if = "Option::is_none")]
35    pub sandbox: Option<bool>,
36    /// Raw apps: author-declared scopes for the frontend SDK token. Takes effect only when `sandbox` is also true — an unsandboxed bundle runs with the viewer's own session, so no token is advertised or minted for it and this list stays inert. On a sandboxed app a non-empty list lets viewers mint (after consenting) a short-lived token carrying their own identity restricted to these scopes, handed to the app bundle so `windmill-client` calls run as the viewer. Must be a subset of the server's curated allowlist (jobs:run, jobs:read, users:read, resources:read, variables:read, flow_conversations:read, flow_conversations:write). 
37    #[serde(rename = "frontend_sdk_scopes", skip_serializing_if = "Option::is_none")]
38    pub frontend_sdk_scopes: Option<Vec<String>>,
39}
40
41impl Policy {
42    pub fn new() -> Policy {
43        Policy {
44            triggerables: None,
45            triggerables_v2: None,
46            s3_inputs: None,
47            allowed_s3_keys: None,
48            execution_mode: None,
49            on_behalf_of: None,
50            on_behalf_of_email: None,
51            sandbox: None,
52            frontend_sdk_scopes: None,
53        }
54    }
55}
56/// Who may open the app, and who its runnables execute as. Optional, and what omitting it means depends on the operation: creating an app defaults it to `publisher` (runs on behalf of the app's publisher and requires an authenticated viewer), while updating one keeps the mode the app is already deployed under. Neither `anonymous`, which makes the app publicly executable, nor `guest`, which opens it to anyone the identity provider authenticates, is ever assumed. A guest is only admitted where the workspace also has `guest_access_enabled`, which is checked when the session is minted and again on every guest request
57#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
58pub enum ExecutionMode {
59    #[serde(rename = "viewer")]
60    Viewer,
61    #[serde(rename = "publisher")]
62    Publisher,
63    #[serde(rename = "guest")]
64    Guest,
65    #[serde(rename = "anonymous")]
66    Anonymous,
67}
68
69impl Default for ExecutionMode {
70    fn default() -> ExecutionMode {
71        Self::Viewer
72    }
73}
74