pub struct ApiClient { /* private fields */ }
Expand description
High-level API client for cstats operations
Implementations§
Source§impl ApiClient
impl ApiClient
Sourcepub fn with_cache(config: ApiConfig, cache_config: CacheConfig) -> Result<Self>
pub fn with_cache(config: ApiConfig, cache_config: CacheConfig) -> Result<Self>
Create API client with cache enabled
Sourcepub async fn from_config_with_cache(config: Config) -> Result<Self>
pub async fn from_config_with_cache(config: Config) -> Result<Self>
Create API client from loaded configuration with cache
Sourcepub async fn from_env_with_cache() -> Result<Self>
pub async fn from_env_with_cache() -> Result<Self>
Create API client from environment variables with cache (loads config file with env overrides)
Sourcepub fn anthropic(&self) -> Option<&AnthropicApiClient>
pub fn anthropic(&self) -> Option<&AnthropicApiClient>
Get the Anthropic API client if configured
Sourcepub async fn fetch_claude_usage_stats(
&self,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
) -> Result<AnthropicUsageStats>
pub async fn fetch_claude_usage_stats( &self, start_time: DateTime<Utc>, end_time: DateTime<Utc>, ) -> Result<AnthropicUsageStats>
Fetch Claude Code usage statistics from Anthropic API
Sourcepub async fn fetch_rate_limit_info(&self) -> Result<RateLimitInfo>
pub async fn fetch_rate_limit_info(&self) -> Result<RateLimitInfo>
Fetch rate limit information from Anthropic API
Sourcepub async fn fetch_billing_info(
&self,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
) -> Result<CostBreakdown>
pub async fn fetch_billing_info( &self, start_time: DateTime<Utc>, end_time: DateTime<Utc>, ) -> Result<CostBreakdown>
Fetch billing information from Anthropic API
Sourcepub async fn fetch_daily_usage_stats(&self) -> Result<AnthropicUsageStats>
pub async fn fetch_daily_usage_stats(&self) -> Result<AnthropicUsageStats>
Fetch usage stats for the last 24 hours
Sourcepub async fn fetch_weekly_usage_stats(&self) -> Result<AnthropicUsageStats>
pub async fn fetch_weekly_usage_stats(&self) -> Result<AnthropicUsageStats>
Fetch usage stats for the last 7 days
Sourcepub async fn fetch_monthly_usage_stats(&self) -> Result<AnthropicUsageStats>
pub async fn fetch_monthly_usage_stats(&self) -> Result<AnthropicUsageStats>
Fetch usage stats for the last 30 days
Sourcepub async fn fetch_current_month_usage_stats(
&self,
) -> Result<AnthropicUsageStats>
pub async fn fetch_current_month_usage_stats( &self, ) -> Result<AnthropicUsageStats>
Fetch usage stats for the current month
Sourcepub async fn fetch_current_month_billing(&self) -> Result<CostBreakdown>
pub async fn fetch_current_month_billing(&self) -> Result<CostBreakdown>
Fetch billing info for the current month
Sourcepub async fn get_usage_summary(&self) -> Result<UsageSummary>
pub async fn get_usage_summary(&self) -> Result<UsageSummary>
Get a comprehensive usage summary
Sourcepub async fn submit_statistics(&self, data: &StatisticsData) -> Result<()>
pub async fn submit_statistics(&self, data: &StatisticsData) -> Result<()>
Submit statistics data to the API
Sourcepub async fn get_metrics(&self, query: &str) -> Result<Vec<MetricData>>
pub async fn get_metrics(&self, query: &str) -> Result<Vec<MetricData>>
Retrieve metrics from the API
Sourcepub async fn health_check(&self) -> Result<bool>
pub async fn health_check(&self) -> Result<bool>
Health check for the API
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiClient
impl !RefUnwindSafe for ApiClient
impl Send for ApiClient
impl Sync for ApiClient
impl Unpin for ApiClient
impl !UnwindSafe for ApiClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more