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