async_openai/
project_rate_limits.rs1use serde::Serialize;
2
3use crate::{
4 config::Config,
5 error::OpenAIError,
6 types::admin::project_rate_limits::{
7 ProjectRateLimit, ProjectRateLimitListResponse, ProjectRateLimitUpdateRequest,
8 },
9 Client,
10};
11
12pub struct ProjectRateLimits<'c, C: Config> {
14 client: &'c Client<C>,
15 pub project_id: String,
16}
17
18impl<'c, C: Config> ProjectRateLimits<'c, C> {
19 pub fn new(client: &'c Client<C>, project_id: &str) -> Self {
20 Self {
21 client,
22 project_id: project_id.into(),
23 }
24 }
25
26 #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
28 pub async fn list<Q>(&self, query: &Q) -> Result<ProjectRateLimitListResponse, OpenAIError>
29 where
30 Q: Serialize + ?Sized,
31 {
32 self.client
33 .get_with_query(
34 format!("/organization/projects/{}/rate_limits", self.project_id).as_str(),
35 &query,
36 )
37 .await
38 }
39
40 #[crate::byot(T0 = std::fmt::Display, T1 = serde::Serialize, R = serde::de::DeserializeOwned)]
42 pub async fn update(
43 &self,
44 rate_limit_id: &str,
45 request: ProjectRateLimitUpdateRequest,
46 ) -> Result<ProjectRateLimit, OpenAIError> {
47 self.client
48 .post(
49 format!(
50 "/organization/projects/{}/rate_limits/{rate_limit_id}",
51 self.project_id
52 )
53 .as_str(),
54 request,
55 )
56 .await
57 }
58}