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.626.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    /// Messages to send immediately after connecting (can be raw strings or computed by runnables)
34    #[serde(rename = "initial_messages", skip_serializing_if = "Option::is_none")]
35    pub initial_messages: Option<Vec<models::WebsocketTriggerInitialMessage>>,
36    /// The arguments to pass to the script or flow
37    #[serde(rename = "url_runnable_args", skip_serializing_if = "Option::is_none")]
38    pub url_runnable_args: Option<std::collections::HashMap<String, serde_json::Value>>,
39    /// If true, the script can return a message to send back through the WebSocket
40    #[serde(rename = "can_return_message")]
41    pub can_return_message: bool,
42    /// If true, error results are sent back through the WebSocket
43    #[serde(rename = "can_return_error_result")]
44    pub can_return_error_result: bool,
45    /// Path to a script or flow to run when the triggered job fails
46    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
47    pub error_handler_path: Option<String>,
48    /// The arguments to pass to the script or flow
49    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
50    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
51    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
52    pub retry: Option<Box<models::Retry>>,
53}
54
55impl NewWebsocketTrigger {
56    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 {
57        NewWebsocketTrigger {
58            path,
59            script_path,
60            is_flow,
61            url,
62            mode: None,
63            filters,
64            initial_messages: None,
65            url_runnable_args: None,
66            can_return_message,
67            can_return_error_result,
68            error_handler_path: None,
69            error_handler_args: None,
70            retry: None,
71        }
72    }
73}
74