agentctl_auth/
credential.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Credential {
8 pub provider: String,
9 #[serde(rename = "type")]
10 pub cred_type: String,
11 #[serde(default)]
12 pub token: Option<String>,
13 #[serde(default)]
14 pub keychain_service: Option<String>,
15}
16
17impl Credential {
18 pub fn resolved_token(&self) -> Option<&str> {
22 self.token.as_deref()
23 }
24
25 pub fn is_oauth(&self) -> bool {
27 self.cred_type == "oauth"
28 }
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize, Default)]
33pub struct UsageStats {
34 #[serde(default)]
35 pub last_used: Option<u64>,
36 #[serde(default)]
37 pub error_count: Option<u32>,
38 #[serde(default)]
39 pub cooldown_until: Option<u64>,
40}
41
42#[derive(Debug, Clone, Serialize)]
44pub struct TestResult {
45 pub credential_name: String,
46 pub provider: String,
47 pub success: bool,
48 pub status_code: Option<u16>,
49 pub error: Option<String>,
50 pub latency_ms: u64,
51}