Skip to main content

windmill_api/models/
new_kafka_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.679.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 NewKafkaTrigger {
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 Kafka resource containing connection configuration
26    #[serde(rename = "kafka_resource_path")]
27    pub kafka_resource_path: String,
28    /// Kafka consumer group ID for this trigger
29    #[serde(rename = "group_id")]
30    pub group_id: String,
31    /// Array of Kafka topic names to subscribe to
32    #[serde(rename = "topics")]
33    pub topics: Vec<String>,
34    #[serde(rename = "filters")]
35    pub filters: Vec<models::NewWebsocketTriggerFiltersInner>,
36    /// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
37    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
38    pub filter_logic: Option<FilterLogic>,
39    /// Initial offset behavior when consumer group has no committed offset.
40    #[serde(rename = "auto_offset_reset", skip_serializing_if = "Option::is_none")]
41    pub auto_offset_reset: Option<AutoOffsetReset>,
42    /// When true (default), offsets are committed automatically after receiving each message. When false, you must manually commit offsets using the commit_offsets endpoint.
43    #[serde(rename = "auto_commit", skip_serializing_if = "Option::is_none")]
44    pub auto_commit: Option<bool>,
45    #[serde(rename = "mode", skip_serializing_if = "Option::is_none")]
46    pub mode: Option<models::TriggerMode>,
47    /// Path to a script or flow to run when the triggered job fails
48    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
49    pub error_handler_path: Option<String>,
50    /// The arguments to pass to the script or flow
51    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
52    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
53    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
54    pub retry: Option<Box<models::Retry>>,
55    /// The user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
56    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
57    pub permissioned_as: Option<String>,
58    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
59    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
60    pub preserve_permissioned_as: Option<bool>,
61    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
62    pub labels: Option<Vec<String>>,
63}
64
65impl NewKafkaTrigger {
66    pub fn new(path: String, script_path: String, is_flow: bool, kafka_resource_path: String, group_id: String, topics: Vec<String>, filters: Vec<models::NewWebsocketTriggerFiltersInner>) -> NewKafkaTrigger {
67        NewKafkaTrigger {
68            path,
69            script_path,
70            is_flow,
71            kafka_resource_path,
72            group_id,
73            topics,
74            filters,
75            filter_logic: None,
76            auto_offset_reset: None,
77            auto_commit: None,
78            mode: None,
79            error_handler_path: None,
80            error_handler_args: None,
81            retry: None,
82            permissioned_as: None,
83            preserve_permissioned_as: None,
84            labels: None,
85        }
86    }
87}
88/// Logic to apply when evaluating filters. 'and' requires all filters to match, 'or' requires any filter to match.
89#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
90pub enum FilterLogic {
91    #[serde(rename = "and")]
92    And,
93    #[serde(rename = "or")]
94    Or,
95}
96
97impl Default for FilterLogic {
98    fn default() -> FilterLogic {
99        Self::And
100    }
101}
102/// Initial offset behavior when consumer group has no committed offset.
103#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
104pub enum AutoOffsetReset {
105    #[serde(rename = "latest")]
106    Latest,
107    #[serde(rename = "earliest")]
108    Earliest,
109}
110
111impl Default for AutoOffsetReset {
112    fn default() -> AutoOffsetReset {
113        Self::Latest
114    }
115}
116