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