From c55f37b8c46786732c7a7b75cc9127b1ae491bf0 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Fri, 19 Apr 2024 16:17:13 +0200 Subject: [PATCH] notify: derive Deserialize/Serialize for Notification struct Signed-off-by: Lukas Wagner Reviewed-by: Fiona Ebner --- proxmox-notify/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs index 91c0b611..292396bc 100644 --- a/proxmox-notify/src/lib.rs +++ b/proxmox-notify/src/lib.rs @@ -159,9 +159,11 @@ pub trait Endpoint { fn disabled(&self) -> bool; } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] pub enum Content { /// Title and body will be rendered as a template + #[serde(rename_all = "kebab-case")] Template { /// Name of the used template template_name: String, @@ -169,6 +171,7 @@ pub enum Content { data: Value, }, #[cfg(feature = "mail-forwarder")] + #[serde(rename_all = "kebab-case")] ForwardedMail { /// Raw mail contents raw: Vec, @@ -182,7 +185,8 @@ pub enum Content { }, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] pub struct Metadata { /// Notification severity severity: Severity, @@ -192,7 +196,8 @@ pub struct Metadata { additional_fields: HashMap, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] /// Notification which can be sent pub struct Notification { /// Notification content