From 90603f6e250266dee19ecd804e92259883d1266c Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Tue, 23 Apr 2024 13:52:04 +0200 Subject: [PATCH] api-types: api: datatore: add notification-mode parameter This one lets the user choose between the old notification behavior (selecting an email address/user and always/error/never behavior per datastore) and the new one (emit notification events to the notification system) Signed-off-by: Lukas Wagner Tested-by: Gabriel Goller Reviewed-by: Gabriel Goller Tested-by: Maximiliano Sandoval Signed-off-by: Thomas Lamprecht --- pbs-api-types/src/datastore.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 45dd41ae..31767417 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -309,6 +309,10 @@ pub struct DataStoreConfig { #[serde(skip_serializing_if = "Option::is_none")] pub notify: Option, + /// Opt in to the new notification system + #[serde(skip_serializing_if = "Option::is_none")] + pub notification_mode: Option, + /// Datastore tuning options #[serde(skip_serializing_if = "Option::is_none")] pub tuning: Option, @@ -318,6 +322,23 @@ pub struct DataStoreConfig { pub maintenance_mode: Option, } +#[api] +#[derive(Serialize, Deserialize, Updater, Clone, PartialEq, Default)] +#[serde(rename_all = "kebab-case")] +/// Configure how notifications for this datastore should be sent. +/// `legacy-sendmail` sends email notifications to the user configured +/// in `notify-user` via the system's `sendmail` executable. +/// `notification-system` emits matchable notification events to the +/// notification system. +pub enum NotificationMode { + /// Send notifications via the system's sendmail command to the user + /// configured in `notify-user` + #[default] + LegacySendmail, + /// Emit notification events to the notification system + NotificationSystem, +} + impl DataStoreConfig { pub fn new(name: String, path: String) -> Self { Self { @@ -330,6 +351,7 @@ impl DataStoreConfig { verify_new: None, notify_user: None, notify: None, + notification_mode: None, tuning: None, maintenance_mode: None, }