alertmanager_webhook_types/
lib.rs

1pub mod v4;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Debug)]
6#[non_exhaustive]
7#[serde(tag = "version")]
8pub enum Webhook {
9    /// Webhook payload based on Prometheus docs
10    #[serde(rename = "4")]
11    Webhook4(v4::Webhook),
12}
13
14#[cfg(test)]
15mod tests {
16    #[test]
17    fn decode_sample_v4_payload() {
18        // Sample taken from https://www.puppeteers.net/blog/testing-alertmanager-webhooks-with-curl/
19        let json_string = include_str!("../assets/sample-v4-payload.json");
20        let json_value: Result<super::Webhook, _> = serde_json::from_str(json_string);
21        assert!(json_value.is_ok());
22    }
23}