pub(crate) mod aggregator;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub(crate) struct ApiAuditPayload {
pub token_name: String,
pub method: String,
pub path: String,
#[serde(default)]
pub client_ip: Option<String>,
pub call_count: u64,
pub duration: f64,
}
impl ApiAuditPayload {
pub(crate) fn entry_name(&self) -> String {
self.token_name.clone()
}
pub(crate) fn to_value(&self) -> Value {
json!({
"token_name": self.token_name,
"method": self.method,
"path": self.path,
"client_ip": self.client_ip,
"call_count": self.call_count,
"duration": self.duration,
})
}
}