icinga2_api/types/monitoring_objects/
dependency.rs

1//! Dependency
2//!
3//! [Official Documentation](https://icinga.com/docs/icinga-2/latest/doc/09-object-types/#dependency)
4//!
5//! [Definition in Icinga Source](https://github.com/Icinga/icinga2/blob/master/lib/icinga/dependency.ti)
6
7use serde::{Deserialize, Serialize};
8
9use crate::serde::{
10    deserialize_empty_string_or_parse, serialize_none_as_empty_string_or_to_string,
11};
12use crate::types::common::custom_var_object::CustomVarHolder;
13use crate::types::names::IcingaTimePeriodName;
14use crate::types::{
15    common::custom_var_object::IcingaCustomVarObject,
16    enums::{host_or_service_state::IcingaHostOrServiceState, object_type::IcingaObjectType},
17    names::{IcingaHostName, IcingaServiceName},
18};
19
20/// attributes on an [IcingaDependency]
21#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
22pub struct IcingaDependency {
23    /// type of icinga object, should always be Dependency for this
24    #[serde(rename = "type")]
25    pub object_type: IcingaObjectType,
26    /// shared config object and custom variable fields
27    #[serde(flatten)]
28    pub custom_var: IcingaCustomVarObject,
29    /// the child host name
30    pub child_host_name: IcingaHostName,
31    /// the child service name
32    #[serde(
33        serialize_with = "serialize_none_as_empty_string_or_to_string",
34        deserialize_with = "deserialize_empty_string_or_parse"
35    )]
36    pub child_service_name: Option<IcingaServiceName>,
37    /// the parent host name
38    pub parent_host_name: IcingaHostName,
39    /// the parent service name
40    #[serde(
41        serialize_with = "serialize_none_as_empty_string_or_to_string",
42        deserialize_with = "deserialize_empty_string_or_parse"
43    )]
44    pub parent_service_name: Option<IcingaServiceName>,
45    /// whether checks are disabled by this dependency
46    pub disable_checks: bool,
47    /// whether notifications are disabled by this dependency
48    pub disable_notifications: bool,
49    /// whether this dependency ignores soft states
50    pub ignore_soft_states: bool,
51    /// the name of the time period when this dependency is active
52    pub period: Option<IcingaTimePeriodName>,
53    /// states when this dependency is enabled
54    pub states: Vec<IcingaHostOrServiceState>,
55}
56
57impl CustomVarHolder for IcingaDependency {
58    fn custom_var_value(&self, name: &str) -> Option<&serde_json::Value> {
59        self.custom_var.custom_var_value(name)
60    }
61}