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