Skip to main content

async_openai/admin/
organization_spend_limit.rs

1use crate::{
2    config::Config,
3    error::OpenAIError,
4    types::admin::organization_spend_limit::{
5        OrganizationSpendLimitDeletedResource, OrganizationSpendLimitResource,
6        UpdateOrganizationSpendLimitBody,
7    },
8    Client, RequestOptions,
9};
10
11pub struct OrganizationSpendLimit<'c, C: Config> {
12    client: &'c Client<C>,
13    pub(crate) request_options: RequestOptions,
14}
15impl<'c, C: Config> OrganizationSpendLimit<'c, C> {
16    pub fn new(client: &'c Client<C>) -> Self {
17        Self {
18            client,
19            request_options: RequestOptions::new(),
20        }
21    }
22    /// Get the organization's hard spend limit.
23    pub async fn retrieve(&self) -> Result<OrganizationSpendLimitResource, OpenAIError> {
24        self.client
25            .get("/organization/spend_limit", &self.request_options)
26            .await
27    }
28
29    /// Create or replace the organization's hard spend limit.
30    pub async fn update(
31        &self,
32        request: UpdateOrganizationSpendLimitBody,
33    ) -> Result<OrganizationSpendLimitResource, OpenAIError> {
34        self.client
35            .post("/organization/spend_limit", request, &self.request_options)
36            .await
37    }
38
39    /// Delete the organization's hard spend limit.
40    pub async fn delete(&self) -> Result<OrganizationSpendLimitDeletedResource, OpenAIError> {
41        self.client
42            .delete("/organization/spend_limit", &self.request_options)
43            .await
44    }
45}