floopy/types/
decisions.rs1use serde::Deserialize;
2use serde_json::Value;
3
4#[derive(Debug, Clone, Deserialize)]
7pub struct Decision {
8 pub request_id: String,
10 pub session_id: Option<String>,
12 pub request_created_at: String,
14 pub provider: Option<String>,
16 pub model: Option<String>,
18 pub status: String,
20 pub latency_ms: Option<i64>,
22 pub cost_micro_usd: Option<i64>,
24 pub cache_enabled: Option<bool>,
26 pub threat: Option<String>,
28 pub decision_trace: Option<Value>,
30 pub confidence: Option<f64>,
32 pub confidence_reason: Option<String>,
34 pub explanation: Option<String>,
36}
37
38#[derive(Debug, Clone, Deserialize)]
40pub struct DecisionListPage {
41 pub items: Vec<Decision>,
43 pub next_cursor: Option<String>,
45 pub has_more: bool,
47}
48
49#[derive(Debug, Clone, Default)]
52pub struct DecisionListParams {
53 pub session_id: Option<String>,
55 pub from: Option<String>,
57 pub to: Option<String>,
59 pub limit: Option<u32>,
61 pub cursor: Option<String>,
63}
64
65impl DecisionListParams {
66 pub(crate) fn query(&self) -> Vec<(String, String)> {
67 let mut q = Vec::new();
68 if let Some(v) = &self.session_id {
69 q.push(("session_id".to_owned(), v.clone()));
70 }
71 if let Some(v) = &self.from {
72 q.push(("from".to_owned(), v.clone()));
73 }
74 if let Some(v) = &self.to {
75 q.push(("to".to_owned(), v.clone()));
76 }
77 if let Some(v) = self.limit {
78 q.push(("limit".to_owned(), v.to_string()));
79 }
80 if let Some(v) = &self.cursor {
81 q.push(("cursor".to_owned(), v.clone()));
82 }
83 q
84 }
85}