Skip to main content

vault_client_rs/api/sys/
quotas.rs

1use reqwest::Method;
2
3use crate::client::{encode_path, to_body};
4use crate::types::error::VaultError;
5use crate::types::sys::{RateLimitQuota, RateLimitQuotaRequest};
6
7use super::SysHandler;
8
9impl SysHandler<'_> {
10    pub async fn list_rate_limit_quotas(&self) -> Result<Vec<String>, VaultError> {
11        self.client.exec_list("sys/quotas/rate-limit").await
12    }
13
14    pub async fn read_rate_limit_quota(&self, name: &str) -> Result<RateLimitQuota, VaultError> {
15        self.client
16            .exec_with_data(
17                Method::GET,
18                &format!("sys/quotas/rate-limit/{}", encode_path(name)),
19                None,
20            )
21            .await
22    }
23
24    pub async fn write_rate_limit_quota(
25        &self,
26        name: &str,
27        params: &RateLimitQuotaRequest,
28    ) -> Result<(), VaultError> {
29        let body = to_body(params)?;
30        self.client
31            .exec_empty(
32                Method::POST,
33                &format!("sys/quotas/rate-limit/{}", encode_path(name)),
34                Some(&body),
35            )
36            .await
37    }
38
39    pub async fn delete_rate_limit_quota(&self, name: &str) -> Result<(), VaultError> {
40        self.client
41            .exec_empty(
42                Method::DELETE,
43                &format!("sys/quotas/rate-limit/{}", encode_path(name)),
44                None,
45            )
46            .await
47    }
48}