async_openai/admin/
project_spend_limit.rs1use crate::{
2 config::Config,
3 error::OpenAIError,
4 types::admin::projects::{
5 ProjectSpendLimitDeletedResource, ProjectSpendLimitResource, UpdateProjectSpendLimitBody,
6 },
7 Client, RequestOptions,
8};
9
10pub struct ProjectSpendLimit<'c, C: Config> {
11 client: &'c Client<C>,
12 pub(crate) request_options: RequestOptions,
13 pub project_id: String,
14}
15
16impl<'c, C: Config> ProjectSpendLimit<'c, C> {
17 pub fn new(client: &'c Client<C>, project_id: &str) -> Self {
18 Self {
19 client,
20 request_options: RequestOptions::new(),
21 project_id: project_id.into(),
22 }
23 }
24
25 #[crate::byot(R = serde::de::DeserializeOwned)]
27 pub async fn retrieve(&self) -> Result<ProjectSpendLimitResource, OpenAIError> {
28 self.client
29 .get(
30 &format!(
31 "/organization/projects/{project_id}/spend_limit",
32 project_id = self.project_id
33 ),
34 &self.request_options,
35 )
36 .await
37 }
38
39 #[crate::byot(R = serde::de::DeserializeOwned)]
41 pub async fn delete(&self) -> Result<ProjectSpendLimitDeletedResource, OpenAIError> {
42 self.client
43 .delete(
44 &format!(
45 "/organization/projects/{project_id}/spend_limit",
46 project_id = self.project_id
47 ),
48 &self.request_options,
49 )
50 .await
51 }
52
53 #[crate::byot(T0 = serde::Serialize, R = serde::de::DeserializeOwned)]
55 pub async fn update(
56 &self,
57 request: UpdateProjectSpendLimitBody,
58 ) -> Result<ProjectSpendLimitResource, OpenAIError> {
59 self.client
60 .post(
61 &format!(
62 "/organization/projects/{project_id}/spend_limit",
63 project_id = self.project_id
64 ),
65 request,
66 &self.request_options,
67 )
68 .await
69 }
70}