Skip to main content

windmill_api/models/
new_nats_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.647.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 NewNatsTrigger {
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    /// Path to the NATS resource containing connection configuration
26    #[serde(rename = "nats_resource_path")]
27    pub nats_resource_path: String,
28    /// If true, uses NATS JetStream for durable message delivery
29    #[serde(rename = "use_jetstream")]
30    pub use_jetstream: bool,
31    /// JetStream stream name (required when use_jetstream is true)
32    #[serde(rename = "stream_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
33    pub stream_name: Option<Option<String>>,
34    /// JetStream consumer name (required when use_jetstream is true)
35    #[serde(rename = "consumer_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
36    pub consumer_name: Option<Option<String>>,
37    /// Array of NATS subjects to subscribe to
38    #[serde(rename = "subjects")]
39    pub subjects: Vec<String>,
40    #[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
41    pub mode: Option<models::TriggerMode>,
42    /// Path to a script or flow to run when the triggered job fails
43    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
44    pub error_handler_path: Option<String>,
45    /// The arguments to pass to the script or flow
46    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
47    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
48    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
49    pub retry: Option<Box<models::Retry>>,
50    /// Email of the user who triggered jobs run as. Used during deployment to preserve the original trigger owner.
51    #[serde(rename = "email", skip_serializing_if = "Option::is_none")]
52    pub email: Option<String>,
53    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original email value instead of overwriting it.
54    #[serde(rename = "preserve_email", skip_serializing_if = "Option::is_none")]
55    pub preserve_email: Option<bool>,
56}
57
58impl NewNatsTrigger {
59    pub fn new(path: String, script_path: String, is_flow: bool, nats_resource_path: String, use_jetstream: bool, subjects: Vec<String>) -> NewNatsTrigger {
60        NewNatsTrigger {
61            path,
62            script_path,
63            is_flow,
64            nats_resource_path,
65            use_jetstream,
66            stream_name: None,
67            consumer_name: None,
68            subjects,
69            mode: None,
70            error_handler_path: None,
71            error_handler_args: None,
72            retry: None,
73            email: None,
74            preserve_email: None,
75        }
76    }
77}
78