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