Skip to main content

windmill_api/models/
edit_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 EditWebsocketTrigger {
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    /// The unique path identifier for this trigger
20    #[serde(rename = "path")]
21    pub path: String,
22    /// Path to the script or flow to execute when a message is received
23    #[serde(rename = "script_path")]
24    pub script_path: String,
25    /// True if script_path points to a flow, false if it points to a script
26    #[serde(rename = "is_flow")]
27    pub is_flow: bool,
28    /// Array of key-value filters to match incoming messages (only matching messages trigger the script)
29    #[serde(rename = "filters")]
30    pub filters: Vec<models::NewWebsocketTriggerFiltersInner>,
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 user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
55    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
56    pub permissioned_as: Option<String>,
57    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
58    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
59    pub preserve_permissioned_as: Option<bool>,
60}
61
62impl EditWebsocketTrigger {
63    pub fn new(url: String, path: String, script_path: String, is_flow: bool, filters: Vec<models::NewWebsocketTriggerFiltersInner>, can_return_message: bool, can_return_error_result: bool) -> EditWebsocketTrigger {
64        EditWebsocketTrigger {
65            url,
66            path,
67            script_path,
68            is_flow,
69            filters,
70            filter_logic: None,
71            initial_messages: None,
72            url_runnable_args: None,
73            can_return_message,
74            can_return_error_result,
75            error_handler_path: None,
76            error_handler_args: None,
77            retry: None,
78            permissioned_as: None,
79            preserve_permissioned_as: None,
80        }
81    }
82}
83/// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
84#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
85pub enum FilterLogic {
86    #[serde(rename = "and")]
87    And,
88    #[serde(rename = "or")]
89    Or,
90}
91
92impl Default for FilterLogic {
93    fn default() -> FilterLogic {
94        Self::And
95    }
96}
97