2024-04-12 00:34:46 -07:00
|
|
|
use krata::{
|
2024-04-21 21:00:32 -07:00
|
|
|
idm::internal::{MetricFormat, MetricNode},
|
2024-07-18 20:47:18 -07:00
|
|
|
v1::common::{ZoneMetricFormat, ZoneMetricNode},
|
2024-04-12 00:34:46 -07:00
|
|
|
};
|
|
|
|
|
2024-07-18 20:47:18 -07:00
|
|
|
fn idm_metric_format_to_api(format: MetricFormat) -> ZoneMetricFormat {
|
2024-04-12 00:34:46 -07:00
|
|
|
match format {
|
2024-07-18 20:47:18 -07:00
|
|
|
MetricFormat::Unknown => ZoneMetricFormat::Unknown,
|
|
|
|
MetricFormat::Bytes => ZoneMetricFormat::Bytes,
|
|
|
|
MetricFormat::Integer => ZoneMetricFormat::Integer,
|
|
|
|
MetricFormat::DurationSeconds => ZoneMetricFormat::DurationSeconds,
|
2024-04-12 00:34:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-18 20:47:18 -07:00
|
|
|
pub fn idm_metric_to_api(node: MetricNode) -> ZoneMetricNode {
|
2024-04-12 00:34:46 -07:00
|
|
|
let format = node.format();
|
2024-07-18 20:47:18 -07:00
|
|
|
ZoneMetricNode {
|
2024-04-12 00:34:46 -07:00
|
|
|
name: node.name,
|
|
|
|
value: node.value,
|
|
|
|
format: idm_metric_format_to_api(format).into(),
|
|
|
|
children: node
|
|
|
|
.children
|
|
|
|
.into_iter()
|
|
|
|
.map(idm_metric_to_api)
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
}
|
|
|
|
}
|