icinga2_api/types/
metadata.rsuse serde::{Deserialize, Serialize};
use super::common::{object::IcingaObject, source_location::IcingaSourceLocation};
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub enum IcingaMetadataType {
UsedBy,
Location,
}
impl std::fmt::Display for IcingaMetadataType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
IcingaMetadataType::UsedBy => write!(f, "used_by"),
IcingaMetadataType::Location => write!(f, "location"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct IcingaMetadata {
pub used_by: Option<Vec<IcingaObject>>,
pub location: Option<IcingaSourceLocation>,
}
pub(crate) fn add_meta_to_url(
url: &mut url::Url,
meta: &[IcingaMetadataType],
) -> Result<(), crate::error::Error> {
if !meta.is_empty() {
for v in meta {
url.query_pairs_mut().append_pair("meta", &v.to_string());
}
}
Ok(())
}