hc_vault/kv2/
undelete_versions.rs

1use crate::Auth;
2use crate::Client;
3use crate::Error;
4
5use serde::Serialize;
6
7#[derive(Serialize)]
8struct UndeleteVersionsBody {
9    versions: Vec<u32>,
10}
11
12/// This undeletes previously deleted versions, not destroyed versions. These
13/// versions will afterwards appear normally in any further requests as if they
14/// have never been deleted in the first place
15///
16/// [Vault-Documentation](https://www.vaultproject.io/api-docs/secret/kv/kv-v2#undelete-secret-versions)
17pub async fn undelete_versions(
18    client: &Client<impl Auth>,
19    mount: &str,
20    name: &str,
21    versions: Vec<u32>,
22) -> Result<(), Error> {
23    let path = format!("{}/undelete/{}", mount, name);
24
25    let req_body = UndeleteVersionsBody { versions };
26
27    match client
28        .vault_request::<UndeleteVersionsBody>(reqwest::Method::POST, &path, Some(&req_body))
29        .await
30    {
31        Err(e) => Err(e),
32        Ok(_) => Ok(()),
33    }
34}