use std::time::Duration;
use uuid::Uuid;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CallerTier {
Free,
Pro,
Team,
Scale,
}
impl CallerTier {
#[must_use]
pub fn ttl_secs(self) -> u64 {
match self {
CallerTier::Free => 24 * 60 * 60,
CallerTier::Pro | CallerTier::Team => 7 * 24 * 60 * 60,
CallerTier::Scale => 30 * 24 * 60 * 60,
}
}
}
#[derive(Debug, Clone)]
pub struct RequestContext {
pub trace_id: Uuid,
pub org_id: Uuid,
pub api_key_id: Uuid,
pub credentials: ProviderCredentials,
pub tag: Option<String>,
pub deadline: Option<Duration>,
}
#[derive(Debug, Clone)]
pub struct ProviderCredentials {
pub api_key: SecretString,
pub base_url: Option<String>,
pub extra_headers: Vec<(String, String)>,
}
#[derive(Clone)]
pub struct SecretString(String);
impl SecretString {
pub fn new(s: impl Into<String>) -> Self {
Self(s.into())
}
pub fn expose(&self) -> &str {
&self.0
}
}
impl std::fmt::Debug for SecretString {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "SecretString(****)")
}
}