Skip to main content

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::api::blocking::Icinga2;
22
23    #[traced_test]
24    #[test]
25    fn test_dependencies() -> 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 = ListDependencies::builder()
31            .joins(IcingaJoins::AllJoins)
32            .meta([IcingaMetadataType::UsedBy, IcingaMetadataType::Location])
33            .build()?;
34        let _response: ResultsWrapper<
35            QueryResultObjectWithJoins<IcingaDependency, IcingaDependencyJoins>,
36        > = icinga2.rest(api_endpoint)?;
37        Ok(())
38    }
39}