async_openai/admin/
organization_spend_alerts.rs1use crate::{
2 config::Config,
3 error::OpenAIError,
4 types::admin::organization_spend_alerts::{
5 CreateSpendAlertBody, OrganizationSpendAlert, OrganizationSpendAlertDeletedResource,
6 OrganizationSpendAlertListResource,
7 },
8 Client, RequestOptions,
9};
10
11pub struct OrganizationSpendAlerts<'c, C: Config> {
12 client: &'c Client<C>,
13 pub(crate) request_options: RequestOptions,
14}
15impl<'c, C: Config> OrganizationSpendAlerts<'c, C> {
16 pub fn new(client: &'c Client<C>) -> Self {
17 Self {
18 client,
19 request_options: RequestOptions::new(),
20 }
21 }
22 pub async fn list(&self) -> Result<OrganizationSpendAlertListResource, OpenAIError> {
24 self.client
25 .get("/organization/spend_alerts", &self.request_options)
26 .await
27 }
28
29 pub async fn create(
31 &self,
32 request: CreateSpendAlertBody,
33 ) -> Result<OrganizationSpendAlert, OpenAIError> {
34 self.client
35 .post("/organization/spend_alerts", request, &self.request_options)
36 .await
37 }
38
39 pub async fn retrieve(&self, alert_id: &str) -> Result<OrganizationSpendAlert, OpenAIError> {
41 self.client
42 .get(
43 &format!("/organization/spend_alerts/{alert_id}"),
44 &self.request_options,
45 )
46 .await
47 }
48
49 pub async fn update(
51 &self,
52 alert_id: &str,
53 request: CreateSpendAlertBody,
54 ) -> Result<OrganizationSpendAlert, OpenAIError> {
55 self.client
56 .post(
57 &format!("/organization/spend_alerts/{alert_id}"),
58 request,
59 &self.request_options,
60 )
61 .await
62 }
63
64 pub async fn delete(
66 &self,
67 alert_id: &str,
68 ) -> Result<OrganizationSpendAlertDeletedResource, OpenAIError> {
69 self.client
70 .delete(
71 &format!("/organization/spend_alerts/{alert_id}"),
72 &self.request_options,
73 )
74 .await
75 }
76}