Skip to main content

windmill_api/models/
new_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.674.2
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 NewWebsocketTrigger {
16    /// The unique path identifier for this trigger
17    #[serde(rename = "path")]
18    pub path: String,
19    /// Path to the script or flow to execute when a message is received
20    #[serde(rename = "script_path")]
21    pub script_path: String,
22    /// True if script_path points to a flow, false if it points to a script
23    #[serde(rename = "is_flow")]
24    pub is_flow: bool,
25    /// The WebSocket URL to connect to (can be a static URL or computed by a runnable)
26    #[serde(rename = "url")]
27    pub url: String,
28    #[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
29    pub mode: Option<models::TriggerMode>,
30    /// Array of key-value filters to match incoming messages (only matching messages trigger the script)
31    #[serde(rename = "filters")]
32    pub filters: Vec<models::NewWebsocketTriggerFiltersInner>,
33    /// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
34    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
35    pub filter_logic: Option<FilterLogic>,
36    /// Messages to send immediately after connecting (can be raw strings or computed by runnables)
37    #[serde(rename = "initial_messages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
38    pub initial_messages: Option<Option<Vec<models::WebsocketTriggerInitialMessage>>>,
39    /// The arguments to pass to the script or flow
40    #[serde(rename = "url_runnable_args", skip_serializing_if = "Option::is_none")]
41    pub url_runnable_args: Option<std::collections::HashMap<String, serde_json::Value>>,
42    /// If true, the script can return a message to send back through the WebSocket
43    #[serde(rename = "can_return_message")]
44    pub can_return_message: bool,
45    /// If true, error results are sent back through the WebSocket
46    #[serde(rename = "can_return_error_result")]
47    pub can_return_error_result: bool,
48    #[serde(rename = "heartbeat", skip_serializing_if = "Option::is_none")]
49    pub heartbeat: Option<Box<models::WebsocketHeartbeat>>,
50    /// Path to a script or flow to run when the triggered job fails
51    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
52    pub error_handler_path: Option<String>,
53    /// The arguments to pass to the script or flow
54    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
55    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
56    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
57    pub retry: Option<Box<models::Retry>>,
58    /// The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
59    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
60    pub permissioned_as: Option<String>,
61    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
62    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
63    pub preserve_permissioned_as: Option<bool>,
64    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
65    pub labels: Option<Vec<String>>,
66}
67
68impl NewWebsocketTrigger {
69    pub fn new(path: String, script_path: String, is_flow: bool, url: String, filters: Vec<models::NewWebsocketTriggerFiltersInner>, can_return_message: bool, can_return_error_result: bool) -> NewWebsocketTrigger {
70        NewWebsocketTrigger {
71            path,
72            script_path,
73            is_flow,
74            url,
75            mode: None,
76            filters,
77            filter_logic: None,
78            initial_messages: None,
79            url_runnable_args: None,
80            can_return_message,
81            can_return_error_result,
82            heartbeat: None,
83            error_handler_path: None,
84            error_handler_args: None,
85            retry: None,
86            permissioned_as: None,
87            preserve_permissioned_as: None,
88            labels: None,
89        }
90    }
91}
92/// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
93#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
94pub enum FilterLogic {
95    #[serde(rename = "and")]
96    And,
97    #[serde(rename = "or")]
98    Or,
99}
100
101impl Default for FilterLogic {
102    fn default() -> FilterLogic {
103        Self::And
104    }
105}
106