use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ::jumo_derive::Jumo)]
#[jumo(kind = "struct", domain = "Reporting", module = "Reporting.Pipeline")]
#[serde(deny_unknown_fields)]
pub struct ExporterOutput<T> {
pub api_version: String,
pub kind: String,
pub output_id: String,
pub seq: u64,
pub generated_at: String,
pub source: ExporterSource,
pub payload: T,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ::jumo_derive::Jumo)]
#[jumo(kind = "struct", domain = "Reporting", module = "Reporting.Pipeline")]
#[serde(deny_unknown_fields)]
pub struct ExporterSource {
pub agent_id: String,
pub instance_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub probe: Option<String>,
}
impl ExporterSource {
pub fn new(agent_id: &str, instance_id: &str) -> Self {
Self {
agent_id: agent_id.to_string(),
instance_id: instance_id.to_string(),
probe: None,
}
}
pub fn with_probe(mut self, probe: &str) -> Self {
self.probe = Some(probe.to_string());
self
}
}
impl<T> ExporterOutput<T> {
pub fn new(
kind: &str,
output_id: String,
seq: u64,
generated_at: String,
source: ExporterSource,
payload: T,
) -> Self {
Self {
api_version: "wist/v1".to_string(),
kind: kind.to_string(),
output_id,
seq,
generated_at,
source,
payload,
}
}
}
pub const EXPORTER_API_VERSION: &str = "wist/v1";