vault_client_rs/api/sys/
audit.rs1use std::collections::HashMap;
2
3use reqwest::Method;
4
5use crate::client::{encode_path, to_body};
6use crate::types::error::VaultError;
7use crate::types::sys::{AuditDevice, AuditParams};
8
9use super::SysHandler;
10
11impl SysHandler<'_> {
12 pub async fn list_audit_devices(&self) -> Result<HashMap<String, AuditDevice>, VaultError> {
13 self.client
14 .exec_with_data(Method::GET, "sys/audit", None)
15 .await
16 }
17
18 pub async fn enable_audit(&self, path: &str, params: &AuditParams) -> Result<(), VaultError> {
19 let body = to_body(params)?;
20 self.client
21 .exec_empty(
22 Method::PUT,
23 &format!("sys/audit/{}", encode_path(path)),
24 Some(&body),
25 )
26 .await
27 }
28
29 pub async fn disable_audit(&self, path: &str) -> Result<(), VaultError> {
30 self.client
31 .exec_empty(
32 Method::DELETE,
33 &format!("sys/audit/{}", encode_path(path)),
34 None,
35 )
36 .await
37 }
38}