diff --git a/libs/client-api/src/http_billing.rs b/libs/client-api/src/http_billing.rs index 36a779bd..1e4ac1c3 100644 --- a/libs/client-api/src/http_billing.rs +++ b/libs/client-api/src/http_billing.rs @@ -1,4 +1,5 @@ use crate::Client; +use client_api_entity::billing_dto::WorkspaceUsageAndLimit; use reqwest::Method; use serde_json::json; use shared_entity::{ @@ -134,15 +135,12 @@ impl Client { Ok(portal_url) } + // Deprecated async fn get_workspace_limits( &self, workspace_id: &str, ) -> Result { - let url = format!( - "{}/api/workspace/{}/limit", - self.base_billing_url(), - workspace_id - ); + let url = format!("{}/api/workspace/{}/limit", self.base_url, workspace_id); self .http_client_with_auth(Method::GET, &url) .await? @@ -153,4 +151,23 @@ impl Client { .await? .into_data() } + + pub async fn get_workspace_usage_and_limit( + &self, + workspace_id: &str, + ) -> Result { + let url = format!( + "{}/api/workspace/{}/usage-and-limit", + self.base_url, workspace_id + ); + self + .http_client_with_auth(Method::GET, &url) + .await? + .send() + .await? + .error_for_status()? + .json::>() + .await? + .into_data() + } } diff --git a/libs/shared-entity/src/dto/billing_dto.rs b/libs/shared-entity/src/dto/billing_dto.rs index 70e313eb..38d0ff3d 100644 --- a/libs/shared-entity/src/dto/billing_dto.rs +++ b/libs/shared-entity/src/dto/billing_dto.rs @@ -83,3 +83,16 @@ pub struct WorkspaceUsageLimit { pub single_blob_size: usize, pub member_count: usize, } + +#[derive(Deserialize)] +pub struct WorkspaceUsageAndLimit { + pub member_count: i64, + pub member_count_limit: i64, + pub total_blob_bytes: i64, + pub total_blob_bytes_limit: i64, + pub ai_responses_count: i64, + pub ai_responses_count_limit: i64, + + pub local_ai: bool, + pub ai_responses_unlimited: bool, +}