Skip to main content

windmill_api/models/
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.863.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 KafkaTrigger {
16    /// Path to the Kafka resource containing connection configuration
17    #[serde(rename = "kafka_resource_path")]
18    pub kafka_resource_path: String,
19    /// Kafka consumer group ID for this trigger
20    #[serde(rename = "group_id")]
21    pub group_id: String,
22    /// Array of Kafka topic names to subscribe to
23    #[serde(rename = "topics")]
24    pub topics: Vec<String>,
25    /// 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`.
26    #[serde(rename = "filters")]
27    pub filters: Vec<models::TriggerFilter>,
28    /// 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.
29    #[serde(rename = "filter_logic", skip_serializing_if = "Option::is_none")]
30    pub filter_logic: Option<FilterLogic>,
31    /// 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.
32    #[serde(rename = "run_on_filter_error", skip_serializing_if = "Option::is_none")]
33    pub run_on_filter_error: Option<bool>,
34    /// Initial offset behavior when consumer group has no committed offset. 'latest' starts from new messages only, 'earliest' starts from the beginning.
35    #[serde(rename = "auto_offset_reset", skip_serializing_if = "Option::is_none")]
36    pub auto_offset_reset: Option<AutoOffsetReset>,
37    /// When true (default), offsets are committed automatically after receiving each message. When false, you must manually commit offsets using the commit_offsets endpoint.
38    #[serde(rename = "auto_commit", skip_serializing_if = "Option::is_none")]
39    pub auto_commit: Option<bool>,
40    /// ID of the server currently handling this trigger (internal)
41    #[serde(rename = "server_id", skip_serializing_if = "Option::is_none")]
42    pub server_id: Option<String>,
43    /// Timestamp of last server heartbeat (internal)
44    #[serde(rename = "last_server_ping", skip_serializing_if = "Option::is_none")]
45    pub last_server_ping: Option<String>,
46    /// Last error message if the trigger failed
47    #[serde(rename = "error", skip_serializing_if = "Option::is_none")]
48    pub error: Option<String>,
49    /// 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.
50    #[serde(rename = "error_handler_path", skip_serializing_if = "Option::is_none")]
51    pub error_handler_path: Option<String>,
52    /// The arguments to pass to the script or flow
53    #[serde(rename = "error_handler_args", skip_serializing_if = "Option::is_none")]
54    pub error_handler_args: Option<std::collections::HashMap<String, serde_json::Value>>,
55    #[serde(rename = "retry", skip_serializing_if = "Option::is_none")]
56    pub retry: Option<Box<models::Retry>>,
57    /// 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.
58    #[serde(rename = "path")]
59    pub path: String,
60    /// Path to the script or flow to execute when triggered
61    #[serde(rename = "script_path")]
62    pub script_path: String,
63    /// The user or group this trigger runs as (permissioned_as)
64    #[serde(rename = "permissioned_as")]
65    pub permissioned_as: String,
66    /// Additional permissions for this trigger
67    #[serde(rename = "extra_perms")]
68    pub extra_perms: std::collections::HashMap<String, bool>,
69    /// The workspace this trigger belongs to
70    #[serde(rename = "workspace_id")]
71    pub workspace_id: String,
72    /// Username of the last person who edited this trigger
73    #[serde(rename = "edited_by")]
74    pub edited_by: String,
75    /// Timestamp of the last edit
76    #[serde(rename = "edited_at")]
77    pub edited_at: String,
78    /// True if script_path points to a flow, false if it points to a script
79    #[serde(rename = "is_flow")]
80    pub is_flow: bool,
81    #[serde(rename = "mode")]
82    pub mode: models::TriggerMode,
83    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
84    pub labels: Option<Vec<String>>,
85    /// True when this row is a per-user draft with no deployed trigger at the same path. Set by list endpoints when `include_draft_only=true` synthesizes the row from the draft. Frontend renders a \"Draft\" badge. 
86    #[serde(rename = "draft_only", skip_serializing_if = "Option::is_none")]
87    pub draft_only: Option<bool>,
88    /// True when the authed user has a per-user draft at this path (over a deployed row or a synthesized draft-only row). Frontend appends a `*` to the displayed name. 
89    #[serde(rename = "is_draft", skip_serializing_if = "Option::is_none")]
90    pub is_draft: Option<bool>,
91}
92
93impl KafkaTrigger {
94    pub fn new(kafka_resource_path: String, group_id: String, topics: Vec<String>, filters: Vec<models::TriggerFilter>, path: String, script_path: String, permissioned_as: String, extra_perms: std::collections::HashMap<String, bool>, workspace_id: String, edited_by: String, edited_at: String, is_flow: bool, mode: models::TriggerMode) -> KafkaTrigger {
95        KafkaTrigger {
96            kafka_resource_path,
97            group_id,
98            topics,
99            filters,
100            filter_logic: None,
101            run_on_filter_error: None,
102            auto_offset_reset: None,
103            auto_commit: None,
104            server_id: None,
105            last_server_ping: None,
106            error: None,
107            error_handler_path: None,
108            error_handler_args: None,
109            retry: None,
110            path,
111            script_path,
112            permissioned_as,
113            extra_perms,
114            workspace_id,
115            edited_by,
116            edited_at,
117            is_flow,
118            mode,
119            labels: None,
120            draft_only: None,
121            is_draft: None,
122        }
123    }
124}
125/// 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.
126#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
127pub enum FilterLogic {
128    #[serde(rename = "and")]
129    And,
130    #[serde(rename = "or")]
131    Or,
132}
133
134impl Default for FilterLogic {
135    fn default() -> FilterLogic {
136        Self::And
137    }
138}
139/// Initial offset behavior when consumer group has no committed offset. 'latest' starts from new messages only, 'earliest' starts from the beginning.
140#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
141pub enum AutoOffsetReset {
142    #[serde(rename = "latest")]
143    Latest,
144    #[serde(rename = "earliest")]
145    Earliest,
146}
147
148impl Default for AutoOffsetReset {
149    fn default() -> AutoOffsetReset {
150        Self::Latest
151    }
152}
153