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.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 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    #[serde(rename = "heartbeat", skip_serializing_if = "Option::is_none")]
47    pub heartbeat: Option<Box<models::WebsocketHeartbeat>>,
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    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
63    pub labels: Option<Vec<String>>,
64}
65
66impl EditWebsocketTrigger {
67    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 {
68        EditWebsocketTrigger {
69            url,
70            path,
71            script_path,
72            is_flow,
73            filters,
74            filter_logic: None,
75            initial_messages: None,
76            url_runnable_args: None,
77            can_return_message,
78            can_return_error_result,
79            heartbeat: None,
80            error_handler_path: None,
81            error_handler_args: None,
82            retry: None,
83            permissioned_as: None,
84            preserve_permissioned_as: None,
85            labels: None,
86        }
87    }
88}
89/// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
90#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
91pub enum FilterLogic {
92    #[serde(rename = "and")]
93    And,
94    #[serde(rename = "or")]
95    Or,
96}
97
98impl Default for FilterLogic {
99    fn default() -> FilterLogic {
100        Self::And
101    }
102}
103