Skip to main content

windmill_api/models/
edit_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 EditKafkaTrigger {
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.
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    /// 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.
41    #[serde(rename = "path")]
42    pub path: String,
43    /// Path to the script or flow to execute when a message is received
44    #[serde(rename = "script_path")]
45    pub script_path: String,
46    /// True if script_path points to a flow, false if it points to a script
47    #[serde(rename = "is_flow")]
48    pub is_flow: bool,
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 user or group this trigger runs as. Used during deployment to preserve the original trigger owner.
58    #[serde(rename = "permissioned_as", skip_serializing_if = "Option::is_none")]
59    pub permissioned_as: Option<String>,
60    /// When true and the caller is a member of the 'wm_deployers' group, preserves the original permissioned_as value instead of overwriting it.
61    #[serde(rename = "preserve_permissioned_as", skip_serializing_if = "Option::is_none")]
62    pub preserve_permissioned_as: Option<bool>,
63    #[serde(rename = "labels", skip_serializing_if = "Option::is_none")]
64    pub labels: Option<Vec<String>>,
65}
66
67impl EditKafkaTrigger {
68    pub fn new(kafka_resource_path: String, group_id: String, topics: Vec<String>, filters: Vec<models::TriggerFilter>, path: String, script_path: String, is_flow: bool) -> EditKafkaTrigger {
69        EditKafkaTrigger {
70            kafka_resource_path,
71            group_id,
72            topics,
73            filters,
74            filter_logic: None,
75            run_on_filter_error: None,
76            auto_offset_reset: None,
77            auto_commit: None,
78            path,
79            script_path,
80            is_flow,
81            error_handler_path: None,
82            error_handler_args: None,
83            retry: None,
84            permissioned_as: None,
85            preserve_permissioned_as: None,
86            labels: None,
87        }
88    }
89}
90/// 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.
91#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
92pub enum FilterLogic {
93    #[serde(rename = "and")]
94    And,
95    #[serde(rename = "or")]
96    Or,
97}
98
99impl Default for FilterLogic {
100    fn default() -> FilterLogic {
101        Self::And
102    }
103}
104/// Initial offset behavior when consumer group has no committed offset.
105#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
106pub enum AutoOffsetReset {
107    #[serde(rename = "latest")]
108    Latest,
109    #[serde(rename = "earliest")]
110    Earliest,
111}
112
113impl Default for AutoOffsetReset {
114    fn default() -> AutoOffsetReset {
115        Self::Latest
116    }
117}
118