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.626.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    /// Messages to send immediately after connecting (can be raw strings or computed by runnables)
32    #[serde(rename = "initial_messages", skip_serializing_if = "Option::is_none")]
33    pub initial_messages: Option<Vec<models::WebsocketTriggerInitialMessage>>,
34    /// The arguments to pass to the script or flow
35    #[serde(rename = "url_runnable_args", skip_serializing_if = "Option::is_none")]
36    pub url_runnable_args: Option<std::collections::HashMap<String, serde_json::Value>>,
37    /// If true, the script can return a message to send back through the WebSocket
38    #[serde(rename = "can_return_message")]
39    pub can_return_message: bool,
40    /// If true, error results are sent back through the WebSocket
41    #[serde(rename = "can_return_error_result")]
42    pub can_return_error_result: bool,
43    /// Path to a script or flow to run when the triggered job fails
44    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
45    pub error_handler_path: Option<String>,
46    /// The arguments to pass to the script or flow
47    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
48    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
49    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
50    pub retry: Option<Box<models::Retry>>,
51    /// The unique path identifier for this trigger
52    #[serde(rename = "path")]
53    pub path: String,
54    /// Path to the script or flow to execute when triggered
55    #[serde(rename = "script_path")]
56    pub script_path: String,
57    /// Email of the user who owns this trigger, used for permissioned_as
58    #[serde(rename = "email")]
59    pub email: String,
60    /// Additional permissions for this trigger
61    #[serde(rename = "extra_perms")]
62    pub extra_perms: std::collections::HashMap<String, bool>,
63    /// The workspace this trigger belongs to
64    #[serde(rename = "workspace_id")]
65    pub workspace_id: String,
66    /// Username of the last person who edited this trigger
67    #[serde(rename = "edited_by")]
68    pub edited_by: String,
69    /// Timestamp of the last edit
70    #[serde(rename = "edited_at")]
71    pub edited_at: String,
72    /// True if script_path points to a flow, false if it points to a script
73    #[serde(rename = "is_flow")]
74    pub is_flow: bool,
75    #[serde(rename = "mode")]
76    pub mode: models::TriggerMode,
77}
78
79impl WebsocketTrigger {
80    pub fn new(url: String, filters: Vec<serde_json::Value>, can_return_message: bool, can_return_error_result: bool, path: String, script_path: String, email: String, extra_perms: std::collections::HashMap<String, bool>, workspace_id: String, edited_by: String, edited_at: String, is_flow: bool, mode: models::TriggerMode) -> WebsocketTrigger {
81        WebsocketTrigger {
82            url,
83            server_id: None,
84            last_server_ping: None,
85            error: None,
86            filters,
87            initial_messages: None,
88            url_runnable_args: None,
89            can_return_message,
90            can_return_error_result,
91            error_handler_path: None,
92            error_handler_args: None,
93            retry: None,
94            path,
95            script_path,
96            email,
97            extra_perms,
98            workspace_id,
99            edited_by,
100            edited_at,
101            is_flow,
102            mode,
103        }
104    }
105}
106