Skip to main content

windmill_api/models/
websocket_trigger.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.672.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 WebsocketTrigger {
16    /// The WebSocket URL to connect to (can be a static URL or computed by a runnable)
17    #[serde(rename = "url")]
18    pub url: String,
19    /// ID of the server currently handling this trigger (internal)
20    #[serde(rename = "server_id", skip_serializing_if = "Option::is_none")]
21    pub server_id: Option<String>,
22    /// Timestamp of last server heartbeat (internal)
23    #[serde(rename = "last_server_ping", skip_serializing_if = "Option::is_none")]
24    pub last_server_ping: Option<String>,
25    /// Last error message if the trigger failed
26    #[serde(rename = "error", skip_serializing_if = "Option::is_none")]
27    pub error: Option<String>,
28    /// Array of key-value filters to match incoming messages (only matching messages trigger the script)
29    #[serde(rename = "filters")]
30    pub filters: Vec<serde_json::Value>,
31    /// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
32    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
33    pub filter_logic: Option<FilterLogic>,
34    /// Messages to send immediately after connecting (can be raw strings or computed by runnables)
35    #[serde(rename = "initial_messages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
36    pub initial_messages: Option<Option<Vec<models::WebsocketTriggerInitialMessage>>>,
37    /// The arguments to pass to the script or flow
38    #[serde(rename = "url_runnable_args", skip_serializing_if = "Option::is_none")]
39    pub url_runnable_args: Option<std::collections::HashMap<String, serde_json::Value>>,
40    /// If true, the script can return a message to send back through the WebSocket
41    #[serde(rename = "can_return_message")]
42    pub can_return_message: bool,
43    /// If true, error results are sent back through the WebSocket
44    #[serde(rename = "can_return_error_result")]
45    pub can_return_error_result: bool,
46    /// Path to a script or flow to run when the triggered job fails
47    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
48    pub error_handler_path: Option<String>,
49    /// The arguments to pass to the script or flow
50    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
51    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
52    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
53    pub retry: Option<Box<models::Retry>>,
54    /// The unique path identifier for this trigger
55    #[serde(rename = "path")]
56    pub path: String,
57    /// Path to the script or flow to execute when triggered
58    #[serde(rename = "script_path")]
59    pub script_path: String,
60    /// The user or group this trigger runs as (permissioned_as)
61    #[serde(rename = "permissioned_as")]
62    pub permissioned_as: String,
63    /// Additional permissions for this trigger
64    #[serde(rename = "extra_perms")]
65    pub extra_perms: std::collections::HashMap<String, bool>,
66    /// The workspace this trigger belongs to
67    #[serde(rename = "workspace_id")]
68    pub workspace_id: String,
69    /// Username of the last person who edited this trigger
70    #[serde(rename = "edited_by")]
71    pub edited_by: String,
72    /// Timestamp of the last edit
73    #[serde(rename = "edited_at")]
74    pub edited_at: String,
75    /// True if script_path points to a flow, false if it points to a script
76    #[serde(rename = "is_flow")]
77    pub is_flow: bool,
78    #[serde(rename = "mode")]
79    pub mode: models::TriggerMode,
80}
81
82impl WebsocketTrigger {
83    pub fn new(url: String, filters: Vec<serde_json::Value>, can_return_message: bool, can_return_error_result: bool, path: String, script_path: String, permissioned_as: String, extra_perms: std::collections::HashMap<String, bool>, workspace_id: String, edited_by: String, edited_at: String, is_flow: bool, mode: models::TriggerMode) -> WebsocketTrigger {
84        WebsocketTrigger {
85            url,
86            server_id: None,
87            last_server_ping: None,
88            error: None,
89            filters,
90            filter_logic: None,
91            initial_messages: None,
92            url_runnable_args: None,
93            can_return_message,
94            can_return_error_result,
95            error_handler_path: None,
96            error_handler_args: None,
97            retry: None,
98            path,
99            script_path,
100            permissioned_as,
101            extra_perms,
102            workspace_id,
103            edited_by,
104            edited_at,
105            is_flow,
106            mode,
107        }
108    }
109}
110/// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
112pub enum FilterLogic {
113    #[serde(rename = "and")]
114    And,
115    #[serde(rename = "or")]
116    Or,
117}
118
119impl Default for FilterLogic {
120    fn default() -> FilterLogic {
121        Self::And
122    }
123}
124