Skip to main content

icinga2_api/api/query/monitoring_objects/
notification.rs

1//! Icinga2 notifications
2
3crate::types::query::query_with_joins!(
4    ListNotifications,
5    ListNotificationsBuilder,
6    monitoring_objects,
7    notification,
8    IcingaNotification,
9    IcingaNotificationJoinTypes,
10    IcingaNotificationJoins,
11    IcingaObjectType::Notification,
12    "v1/objects/notifications"
13);
14
15#[cfg(test)]
16mod test {
17    use super::*;
18    use std::error::Error;
19    use tracing_test::traced_test;
20
21    use crate::api::blocking::Icinga2;
22
23    #[traced_test]
24    #[test]
25    fn test_notifications() -> Result<(), Box<dyn Error>> {
26        dotenvy::dotenv()?;
27        let icinga2 = Icinga2::from_config_file(std::path::Path::new(&std::env::var(
28            "ICINGA_TEST_INSTANCE_CONFIG",
29        )?))?;
30        let api_endpoint = ListNotifications::builder()
31            .joins(IcingaJoins::AllJoins)
32            .meta([IcingaMetadataType::UsedBy, IcingaMetadataType::Location])
33            .build()?;
34        let _response: ResultsWrapper<
35            QueryResultObjectWithJoins<IcingaNotification, IcingaNotificationJoins>,
36        > = icinga2.rest(api_endpoint)?;
37        Ok(())
38    }
39}