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