icinga2_api/api/query/monitoring_objects/
dependency.rs

1//! Icinga2 dependency
2
3crate::types::query::query_with_joins!(
4    ListDependencies,
5    ListDependenciesBuilder,
6    monitoring_objects,
7    dependency,
8    IcingaDependency,
9    IcingaDependencyJoinTypes,
10    IcingaDependencyJoins,
11    IcingaObjectType::Dependency,
12    "v1/objects/dependencies"
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::{
22        api::blocking::Icinga2,
23        types::{join_types::IcingaJoins, metadata::IcingaMetadataType},
24    };
25
26    #[traced_test]
27    #[test]
28    fn test_dependencies() -> Result<(), Box<dyn Error>> {
29        dotenvy::dotenv()?;
30        let icinga2 = Icinga2::from_config_file(std::path::Path::new(&std::env::var(
31            "ICINGA_TEST_INSTANCE_CONFIG",
32        )?))?;
33        let api_endpoint = ListDependencies::builder()
34            .joins(IcingaJoins::AllJoins)
35            .meta([IcingaMetadataType::UsedBy, IcingaMetadataType::Location])
36            .build()?;
37        let _: ResultsWrapper<QueryResultObjectWithJoins<IcingaDependency, IcingaDependencyJoins>> =
38            icinga2.rest(api_endpoint)?;
39        Ok(())
40    }
41}