Skip to main content

adk_deploy/
models.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{DeploymentManifest, DeploymentStrategyKind};
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(rename_all = "camelCase")]
7pub struct WorkspaceSummary {
8    pub id: String,
9    pub name: String,
10    pub plan: String,
11    pub region: String,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
15#[serde(rename_all = "camelCase")]
16pub struct EnvironmentSummary {
17    pub name: String,
18    pub agents: usize,
19    pub status: String,
20    pub region: String,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
24#[serde(rename_all = "camelCase")]
25pub struct AgentSummary {
26    pub name: String,
27    pub environment: String,
28    pub version: String,
29    pub health: String,
30    pub instances: usize,
31    pub request_rate: String,
32    pub latency_p95: String,
33    pub deployed_at: String,
34    pub source_kind: String,
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub source_reference: Option<String>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
40#[serde(rename_all = "camelCase")]
41/// Compact trace summary used in dashboard and overview surfaces.
42pub struct TraceSummary {
43    pub id: String,
44    pub status: String,
45    pub agent_name: String,
46    pub environment: String,
47    pub trigger_type: String,
48    pub started_at: String,
49    pub duration_ms: u64,
50    pub session_label: String,
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub total_tokens: Option<i32>,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
56#[serde(rename_all = "camelCase")]
57/// Token usage captured for one trace span, invocation, or session aggregate.
58pub struct TraceTokenUsage {
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub prompt_tokens: Option<i32>,
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub candidate_tokens: Option<i32>,
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub total_tokens: Option<i32>,
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub cache_read_input_tokens: Option<i32>,
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub cache_creation_input_tokens: Option<i32>,
69    #[serde(skip_serializing_if = "Option::is_none")]
70    pub thinking_tokens: Option<i32>,
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub audio_input_tokens: Option<i32>,
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub audio_output_tokens: Option<i32>,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
78#[serde(rename_all = "camelCase")]
79/// Stable ADK session identity carried by runtime requests when defined.
80pub struct TraceAdkIdentity {
81    pub app_name: String,
82    pub user_id: String,
83    pub session_id: String,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
87#[serde(rename_all = "camelCase")]
88/// Execution-scoped identity for one invocation within a session trace.
89pub struct TraceExecutionIdentity {
90    pub invocation_id: String,
91    pub branch: String,
92    pub agent_name: String,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
96#[serde(rename_all = "camelCase")]
97/// One recorded span in an invocation tree.
98pub struct TraceSpan {
99    pub id: String,
100    #[serde(skip_serializing_if = "Option::is_none")]
101    pub parent_id: Option<String>,
102    pub kind: String,
103    pub label: String,
104    pub status: String,
105    pub started_at: String,
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub ended_at: Option<String>,
108    pub duration_ms: u64,
109    #[serde(skip_serializing_if = "Option::is_none")]
110    pub actor: Option<String>,
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub summary: Option<String>,
113    #[serde(skip_serializing_if = "Option::is_none")]
114    pub usage: Option<TraceTokenUsage>,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
118#[serde(rename_all = "camelCase")]
119/// One invocation captured by the deploy control plane.
120pub struct TraceInvocation {
121    pub id: String,
122    pub environment: String,
123    pub agent_name: String,
124    pub trigger_type: String,
125    pub request_path: String,
126    pub status: String,
127    pub started_at: String,
128    pub ended_at: String,
129    pub duration_ms: u64,
130    #[serde(skip_serializing_if = "Option::is_none")]
131    pub adk_identity: Option<TraceAdkIdentity>,
132    #[serde(skip_serializing_if = "Option::is_none")]
133    pub execution_identity: Option<TraceExecutionIdentity>,
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub input_summary: Option<String>,
136    #[serde(skip_serializing_if = "Option::is_none")]
137    pub output_summary: Option<String>,
138    #[serde(skip_serializing_if = "Option::is_none")]
139    pub usage: Option<TraceTokenUsage>,
140    #[serde(default)]
141    pub spans: Vec<TraceSpan>,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
145#[serde(rename_all = "camelCase")]
146/// Session-oriented trace view grouping invocations by ADK identity when available.
147pub struct TraceSession {
148    pub id: String,
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub adk_identity: Option<TraceAdkIdentity>,
151    pub label: String,
152    pub started_at: String,
153    pub ended_at: String,
154    pub invocation_count: usize,
155    #[serde(skip_serializing_if = "Option::is_none")]
156    pub usage: Option<TraceTokenUsage>,
157    #[serde(default)]
158    pub invocations: Vec<TraceInvocation>,
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
162#[serde(rename_all = "camelCase")]
163pub struct LogEntry {
164    pub time: String,
165    pub level: String,
166    pub instance: String,
167    pub message: String,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
171#[serde(rename_all = "camelCase")]
172pub struct HitlCheckpoint {
173    pub id: String,
174    pub agent: String,
175    pub wait: String,
176    pub checkpoint_type: String,
177    pub state: String,
178}
179
180#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
181#[serde(rename_all = "camelCase")]
182pub struct BillingSummary {
183    pub label: String,
184    pub value: String,
185    pub sub: String,
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
189#[serde(rename_all = "camelCase")]
190pub struct AlertSummary {
191    pub name: String,
192    pub state: String,
193    pub description: String,
194}
195
196#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
197#[serde(rename_all = "camelCase")]
198pub struct DashboardResponse {
199    pub workspace: WorkspaceSummary,
200    pub agents: Vec<AgentSummary>,
201    pub traces: Vec<TraceSummary>,
202    pub logs: Vec<LogEntry>,
203    pub hitl: Vec<HitlCheckpoint>,
204    pub environments: Vec<EnvironmentSummary>,
205    pub usage: Vec<BillingSummary>,
206    pub alerts: Vec<AlertSummary>,
207    pub active_strategy: DeploymentStrategyKind,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
211#[serde(rename_all = "camelCase")]
212pub struct MetricPoint {
213    pub label: String,
214    pub value: u32,
215}
216
217#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
218#[serde(rename_all = "camelCase")]
219pub struct ActiveInstance {
220    pub id: String,
221    pub state: String,
222    pub stats: String,
223}
224
225#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
226#[serde(rename_all = "camelCase")]
227pub struct DeploymentSummary {
228    pub version: String,
229    pub timestamp: String,
230    pub status: String,
231    pub strategy: DeploymentStrategyKind,
232    pub triggered_by: String,
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
236#[serde(rename_all = "camelCase")]
237pub struct AgentDetail {
238    pub name: String,
239    pub environment: String,
240    pub description: String,
241    pub endpoint: String,
242    pub strategy: DeploymentStrategyKind,
243    pub scaling_policy: String,
244    pub deployment_source: String,
245    pub uptime: String,
246    pub error_rate: String,
247    pub metrics: Vec<MetricPoint>,
248    pub instances: Vec<ActiveInstance>,
249    pub deployments: Vec<DeploymentSummary>,
250}
251
252#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
253#[serde(rename_all = "camelCase")]
254pub struct DeploymentActionState {
255    pub enabled: bool,
256    #[serde(default, skip_serializing_if = "Option::is_none")]
257    pub reason: Option<String>,
258}
259
260impl Default for DeploymentActionState {
261    fn default() -> Self {
262        Self { enabled: true, reason: None }
263    }
264}
265
266#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
267#[serde(rename_all = "camelCase")]
268pub struct DeploymentActions {
269    #[serde(default)]
270    pub promote: DeploymentActionState,
271    #[serde(default)]
272    pub restart: DeploymentActionState,
273    #[serde(default)]
274    pub rollback: DeploymentActionState,
275    #[serde(default)]
276    pub delete: DeploymentActionState,
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
280#[serde(rename_all = "camelCase")]
281pub struct MetricsSummary {
282    pub request_rate: String,
283    pub latency_p50: String,
284    pub latency_p95: String,
285    pub latency_p99: String,
286    pub error_rate: String,
287    pub active_connections: usize,
288}
289
290#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
291#[serde(rename_all = "camelCase")]
292pub struct DeploymentRecord {
293    pub id: String,
294    pub workspace_id: String,
295    pub environment: String,
296    pub agent_name: String,
297    pub version: String,
298    pub status: DeploymentStatusValue,
299    pub strategy: DeploymentStrategyKind,
300    pub rollout_phase: String,
301    pub endpoint_url: String,
302    pub checksum_sha256: String,
303    pub source_kind: String,
304    #[serde(default, skip_serializing_if = "Option::is_none")]
305    pub source_reference: Option<String>,
306    pub created_at: String,
307    pub manifest: DeploymentManifest,
308}
309
310#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
311#[serde(rename_all = "kebab-case")]
312pub enum DeploymentStatusValue {
313    Pending,
314    Building,
315    Deploying,
316    Healthy,
317    Degraded,
318    Failed,
319    RolledBack,
320}
321
322#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
323#[serde(rename_all = "camelCase")]
324pub struct PushDeploymentRequest {
325    pub workspace_id: Option<String>,
326    pub environment: String,
327    pub manifest: DeploymentManifest,
328    pub bundle_path: String,
329    pub checksum_sha256: String,
330    #[serde(default, skip_serializing_if = "Option::is_none")]
331    pub binary_path: Option<String>,
332}
333
334#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
335#[serde(rename_all = "camelCase")]
336pub struct PushDeploymentResponse {
337    pub deployment: DeploymentRecord,
338}
339
340#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
341#[serde(rename_all = "camelCase")]
342pub struct DeploymentStatusResponse {
343    pub deployment: DeploymentRecord,
344    pub metrics: MetricsSummary,
345    #[serde(default)]
346    pub actions: DeploymentActions,
347}
348
349#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
350#[serde(rename_all = "camelCase")]
351pub struct DeploymentHistoryResponse {
352    pub items: Vec<DeploymentRecord>,
353}
354
355#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
356#[serde(rename_all = "camelCase")]
357pub struct SecretSetRequest {
358    pub environment: String,
359    pub key: String,
360    pub value: String,
361}
362
363#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
364#[serde(rename_all = "camelCase")]
365pub struct SecretListResponse {
366    pub environment: String,
367    pub keys: Vec<String>,
368}
369
370#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
371#[serde(rename_all = "camelCase")]
372pub struct LoginRequest {
373    pub email: String,
374    #[serde(default, skip_serializing_if = "Option::is_none")]
375    pub workspace_name: Option<String>,
376}
377
378#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
379#[serde(rename_all = "camelCase")]
380pub struct LoginResponse {
381    pub token: String,
382    pub workspace_id: String,
383}
384
385#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
386#[serde(rename_all = "camelCase")]
387pub struct AuthSessionResponse {
388    pub user_id: String,
389    pub workspace_id: String,
390    pub workspace_name: String,
391    #[serde(default)]
392    pub scopes: Vec<String>,
393}
394
395#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
396#[serde(rename_all = "camelCase")]
397pub struct AuditEvent {
398    pub timestamp: String,
399    pub action: String,
400    pub resource: String,
401    pub result: String,
402}