icinga2_api/types/join_types/
dependency.rs

1//! Dependency
2
3use serde::{Deserialize, Serialize};
4
5use crate::types::monitoring_objects::{
6    host::IcingaHost, service::IcingaService, time_period::IcingaTimePeriod,
7};
8
9use super::{IcingaJoinResult, IcingaJoinType};
10
11/// possible joins parameter values for dependencies
12#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
13pub enum IcingaDependencyJoinTypes {
14    /// the child host of the dependency
15    ChildHost,
16    /// the child service of the dependency
17    ChildService,
18    /// the parent host of the dependency
19    ParentHost,
20    /// the parent service of the dependency
21    ParentService,
22    /// the period object for which the dependency is valid
23    Period,
24}
25
26impl IcingaJoinType for IcingaDependencyJoinTypes {}
27
28impl std::fmt::Display for IcingaDependencyJoinTypes {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        match self {
31            IcingaDependencyJoinTypes::ChildHost => write!(f, "child_host"),
32            IcingaDependencyJoinTypes::ChildService => write!(f, "child_service"),
33            IcingaDependencyJoinTypes::ParentHost => write!(f, "parent_host"),
34            IcingaDependencyJoinTypes::ParentService => write!(f, "parent_service"),
35            IcingaDependencyJoinTypes::Period => write!(f, "period"),
36        }
37    }
38}
39
40/// return type joins for dependencies
41#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct IcingaDependencyJoins {
43    /// the child host of the dependency
44    pub child_host: Option<IcingaJoinResult<IcingaHost>>,
45    /// the child service of the dependency
46    pub child_service: Option<IcingaJoinResult<IcingaService>>,
47    /// the parent host of the dependency
48    pub parent_host: Option<IcingaJoinResult<IcingaHost>>,
49    /// the parent service of the dependency
50    pub parent_service: Option<IcingaJoinResult<IcingaService>>,
51    /// the time period for which this dependency applies
52    pub period: Option<IcingaJoinResult<IcingaTimePeriod>>,
53}