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.864.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 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.
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    /// 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`.
29    #[serde(rename = "filters")]
30    pub filters: Vec<models::TriggerFilter>,
31    /// 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.
32    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
33    pub filter_logic: Option<FilterLogic>,
34    /// 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.
35    #[serde(rename = "run_on_filter_error", skip_serializing_if = "Option::is_none")]
36    pub run_on_filter_error: Option<bool>,
37    /// Messages to send immediately after connecting (can be raw strings or computed by runnables)
38    #[serde(rename = "initial_messages", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
39    pub initial_messages: Option<Option<Vec<models::WebsocketTriggerInitialMessage>>>,
40    /// The arguments to pass to the script or flow
41    #[serde(rename = "url_runnable_args", skip_serializing_if = "Option::is_none")]
42    pub url_runnable_args: Option<std::collections::HashMap<String, serde_json::Value>>,
43    /// If true, the script can return a message to send back through the WebSocket
44    #[serde(rename = "can_return_message")]
45    pub can_return_message: bool,
46    /// If true, error results are sent back through the WebSocket
47    #[serde(rename = "can_return_error_result")]
48    pub can_return_error_result: bool,
49    #[serde(rename = "heartbeat", skip_serializing_if = "Option::is_none")]
50    pub heartbeat: Option<Box<models::WebsocketHeartbeat>>,
51    /// 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.
52    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
53    pub error_handler_path: Option<String>,
54    /// The arguments to pass to the script or flow
55    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
56    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
57    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
58    pub retry: Option<Box<models::Retry>>,
59    /// The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
60    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
61    pub permissioned_as: Option<String>,
62    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
63    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
64    pub preserve_permissioned_as: Option<bool>,
65    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
66    pub labels: Option<Vec<String>>,
67}
68
69impl EditWebsocketTrigger {
70    pub fn new(url: String, path: String, script_path: String, is_flow: bool, filters: Vec<models::TriggerFilter>, can_return_message: bool, can_return_error_result: bool) -> EditWebsocketTrigger {
71        EditWebsocketTrigger {
72            url,
73            path,
74            script_path,
75            is_flow,
76            filters,
77            filter_logic: None,
78            run_on_filter_error: None,
79            initial_messages: None,
80            url_runnable_args: None,
81            can_return_message,
82            can_return_error_result,
83            heartbeat: None,
84            error_handler_path: None,
85            error_handler_args: None,
86            retry: None,
87            permissioned_as: None,
88            preserve_permissioned_as: None,
89            labels: None,
90        }
91    }
92}
93/// 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.
94#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
95pub enum FilterLogic {
96    #[serde(rename = "and")]
97    And,
98    #[serde(rename = "or")]
99    Or,
100}
101
102impl Default for FilterLogic {
103    fn default() -> FilterLogic {
104        Self::And
105    }
106}
107