aws_lambda_events/event/activemq/
mod.rs

1use serde::{Deserialize, Serialize};
2#[cfg(feature = "catch-all-fields")]
3use serde_json::Value;
4use std::collections::HashMap;
5
6use crate::custom_serde::deserialize_lambda_map;
7
8#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct ActiveMqEvent {
11    #[serde(default)]
12    pub event_source: Option<String>,
13    #[serde(default)]
14    pub event_source_arn: Option<String>,
15    pub messages: Vec<ActiveMqMessage>,
16    /// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
17    /// Enabled with Cargo feature `catch-all-fields`.
18    /// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
19    #[cfg(feature = "catch-all-fields")]
20    #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
21    #[serde(flatten)]
22    pub other: serde_json::Map<String, Value>,
23}
24
25#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
26#[serde(rename_all = "camelCase")]
27pub struct ActiveMqMessage {
28    #[serde(default)]
29    #[serde(rename = "messageID")]
30    pub message_id: Option<String>,
31    #[serde(default)]
32    pub message_type: Option<String>,
33    pub timestamp: i64,
34    pub delivery_mode: i64,
35    #[serde(default)]
36    #[serde(rename = "correlationID")]
37    pub correlation_id: Option<String>,
38    #[serde(default)]
39    pub reply_to: Option<String>,
40    pub destination: ActiveMqDestination,
41    pub redelivered: bool,
42    #[serde(default)]
43    pub type_: Option<String>,
44    pub expiration: i64,
45    pub priority: i64,
46    #[serde(default)]
47    pub data: Option<String>,
48    pub broker_in_time: i64,
49    pub broker_out_time: i64,
50    #[serde(deserialize_with = "deserialize_lambda_map")]
51    #[serde(default)]
52    pub properties: HashMap<String, String>,
53    /// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
54    /// Enabled with Cargo feature `catch-all-fields`.
55    /// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
56    #[cfg(feature = "catch-all-fields")]
57    #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
58    #[serde(flatten)]
59    pub other: serde_json::Map<String, Value>,
60}
61
62#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
63#[serde(rename_all = "camelCase")]
64pub struct ActiveMqDestination {
65    #[serde(default)]
66    pub physical_name: Option<String>,
67    /// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
68    /// Enabled with Cargo feature `catch-all-fields`.
69    /// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
70    #[cfg(feature = "catch-all-fields")]
71    #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
72    #[serde(flatten)]
73    pub other: serde_json::Map<String, Value>,
74}
75
76#[cfg(test)]
77mod test {
78    use super::*;
79
80    #[test]
81    #[cfg(feature = "activemq")]
82    fn example_activemq_event() {
83        let data = include_bytes!("../../fixtures/example-activemq-event.json");
84        let parsed: ActiveMqEvent = serde_json::from_slice(data).unwrap();
85        let output: String = serde_json::to_string(&parsed).unwrap();
86        let reparsed: ActiveMqEvent = serde_json::from_slice(output.as_bytes()).unwrap();
87        assert_eq!(parsed, reparsed);
88    }
89}