summaryrefslogtreecommitdiffstats
path: root/plugins/plugin_notification/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/plugin_notification/src/config.rs')
-rw-r--r--plugins/plugin_notification/src/config.rs37
1 files changed, 35 insertions, 2 deletions
diff --git a/plugins/plugin_notification/src/config.rs b/plugins/plugin_notification/src/config.rs
index 95078a7a..523467ef 100644
--- a/plugins/plugin_notification/src/config.rs
+++ b/plugins/plugin_notification/src/config.rs
@@ -1,12 +1,17 @@
use tedge_lib::notification::Notification;
-#[derive(Debug, serde::Deserialize)]
+#[derive(Debug, serde::Deserialize, tedge_api::Config)]
pub struct Config {
+ /// The name of the plugin to forward messages to
pub(crate) forward_to: String,
+ /// The name of the plugin to send notifications to
pub(crate) notify: String,
+ /// The type of the notification to raise
pub(crate) raise: NotificationType,
+
+ /// The message to attach to the notification
pub(crate) raise_message: String,
}
@@ -23,6 +28,35 @@ pub enum NotificationType {
Error,
}
+impl tedge_api::AsConfig for NotificationType {
+ fn as_config() -> tedge_api::ConfigDescription {
+ tedge_api::ConfigDescription::new(
+ "NotificationType".to_string(),
+ tedge_api::ConfigKind::Enum(
+ tedge_api::config::ConfigEnumKind::Untagged,
+ vec![
+ (
+ "String",
+ Some("Set the notification level to 'info'"),
+ tedge_api::config::EnumVariantRepresentation::String("info"),
+ ),
+ (
+ "String",
+ Some("Set the notification level to 'warning'"),
+ tedge_api::config::EnumVariantRepresentation::String("warning"),
+ ),
+ (
+ "String",
+ Some("Set the notification level to 'error'"),
+ tedge_api::config::EnumVariantRepresentation::String("error"),
+ ),
+ ],
+ ),
+ None,
+ )
+ }
+}
+
impl NotificationType {
pub(crate) fn into_notification(self, message: String) -> Notification {
match self {
@@ -53,4 +87,3 @@ mod tests {
assert_eq!(cfg.raise_message, String::from("it is getting warm here"));
}
}
-