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.863.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 Windmill path for this trigger. Must be of the form `u/<user>/<path>` or `f/<folder>/<path>`. This is the trigger object path, not the HTTP route path.
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    /// Filters to match incoming messages (only matching messages trigger the script). Each entry is either a leaf `{key, value}` (top-level field) or `{path, value}` (dotted path into nested objects), or a group `{any_of: [...]}` / `{all_of: [...]}` / `{none_of: [...]}` nesting more entries. Entries at the top level are combined with `filter_logic`.
31    #[serde(rename = "filters")]
32    pub filters: Vec<models::TriggerFilter>,
33    /// Logic to apply when evaluating the top-level filters. 'and' requires all of them to match, 'or' requires any of them to match. Nested `any_of`/`all_of`/`none_of` groups carry their own logic.
34    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
35    pub filter_logic: Option<FilterLogic>,
36    /// Whether a message the filters cannot read (not UTF-8, or not JSON) still runs the target, as if the trigger had no filters. A preprocessor then finds the reason in `event.filter_error`. When false, such a message is skipped.
37    #[serde(rename = "run_on_filter_error", skip_serializing_if = "Option::is_none")]
38    pub run_on_filter_error: Option<bool>,
39    /// Messages to send immediately after connecting (can be raw strings or computed by runnables)
40    #[serde(rename = "initial_messages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
41    pub initial_messages: Option<Option<Vec<models::WebsocketTriggerInitialMessage>>>,
42    /// The arguments to pass to the script or flow
43    #[serde(rename = "url_runnable_args", skip_serializing_if = "Option::is_none")]
44    pub url_runnable_args: Option<std::collections::HashMap<String, serde_json::Value>>,
45    /// If true, the script can return a message to send back through the WebSocket
46    #[serde(rename = "can_return_message")]
47    pub can_return_message: bool,
48    /// If true, error results are sent back through the WebSocket
49    #[serde(rename = "can_return_error_result")]
50    pub can_return_error_result: bool,
51    #[serde(rename = "heartbeat", skip_serializing_if = "Option::is_none")]
52    pub heartbeat: Option<Box<models::WebsocketHeartbeat>>,
53    /// Path to a script to run when the triggered job fails. A bare path, without the script/ or flow/ prefix a schedule error handler takes; it cannot be a flow.
54    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
55    pub error_handler_path: Option<String>,
56    /// The arguments to pass to the script or flow
57    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
58    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
59    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
60    pub retry: Option<Box<models::Retry>>,
61    /// The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
62    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
63    pub permissioned_as: Option<String>,
64    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
65    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
66    pub preserve_permissioned_as: Option<bool>,
67    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
68    pub labels: Option<Vec<String>>,
69}
70
71impl NewWebsocketTrigger {
72    pub fn new(path: String, script_path: String, is_flow: bool, url: String, filters: Vec<models::TriggerFilter>, can_return_message: bool, can_return_error_result: bool) -> NewWebsocketTrigger {
73        NewWebsocketTrigger {
74            path,
75            script_path,
76            is_flow,
77            url,
78            mode: None,
79            filters,
80            filter_logic: None,
81            run_on_filter_error: None,
82            initial_messages: None,
83            url_runnable_args: None,
84            can_return_message,
85            can_return_error_result,
86            heartbeat: None,
87            error_handler_path: None,
88            error_handler_args: None,
89            retry: None,
90            permissioned_as: None,
91            preserve_permissioned_as: None,
92            labels: None,
93        }
94    }
95}
96/// Logic to apply when evaluating the top-level filters. 'and' requires all of them to match, 'or' requires any of them to match. Nested `any_of`/`all_of`/`none_of` groups carry their own logic.
97#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
98pub enum FilterLogic {
99    #[serde(rename = "and")]
100    And,
101    #[serde(rename = "or")]
102    Or,
103}
104
105impl Default for FilterLogic {
106    fn default() -> FilterLogic {
107        Self::And
108    }
109}
110