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.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 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    /// Path to a script or flow to run when the triggered job fails
49    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
50    pub error_handler_path: Option<String>,
51    /// The arguments to pass to the script or flow
52    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
53    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
54    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
55    pub retry: Option<Box<models::Retry>>,
56    /// The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
57    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
58    pub permissioned_as: Option<String>,
59    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
60    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
61    pub preserve_permissioned_as: Option<bool>,
62}
63
64impl NewWebsocketTrigger {
65    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 {
66        NewWebsocketTrigger {
67            path,
68            script_path,
69            is_flow,
70            url,
71            mode: None,
72            filters,
73            filter_logic: None,
74            initial_messages: None,
75            url_runnable_args: None,
76            can_return_message,
77            can_return_error_result,
78            error_handler_path: None,
79            error_handler_args: None,
80            retry: None,
81            permissioned_as: None,
82            preserve_permissioned_as: None,
83        }
84    }
85}
86/// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
87#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
88pub enum FilterLogic {
89    #[serde(rename = "and")]
90    And,
91    #[serde(rename = "or")]
92    Or,
93}
94
95impl Default for FilterLogic {
96    fn default() -> FilterLogic {
97        Self::And
98    }
99}
100