pub async fn list(&self, path: &str) -> Result<Vec<String>> {
        let url = self.addr.join(&format!("v1/secret/{}?list=true", path))?;
        debug!("LIST {}", url);

        let mkerr = || ErrorKind::Url(url.clone());
        let res = self
            .client
            .get(url.clone())
            .header("X-Vault-Token", self.token.clone())
            .send()
            .await
            .chain_err(&mkerr)?;

        // Generate informative errors for HTTP failures, because these can
        // be caused by everything from bad URLs to overly restrictive vault policies
        if !res.status().is_success() {
            let status = res.status().to_owned();
            let err: Error = ErrorKind::UnexpectedHttpStatus(status).into();
            return Err(err).chain_err(&mkerr);
        }

        let body = res.text().await?;

        let lsec: ListSecrets = serde_json::from_str(&body)?;
        if !lsec.data.contains_key("keys") {
            bail!(
                "secret list {} does not contain keys list from vault api!?: {}",
                url,
                body
            );
        }
        let res = lsec.data["keys"]
            .iter()
            .filter(|e| !e.ends_with('/')) // skip sub folders
            .map(|e| e.to_string())
            .collect::<Vec<String>>();
        Ok(res)
    }
/// List secrets
///
/// Does a HTTP LIST on the folder a service is in and returns the keys
List secrets
Does a HTTP LIST on the folder a service is in and returns the keys
List secrets Does a HTTP LIST on the folder a service is in and returns the keys
pub async fn list(&self, path: &str) -> Result<Vec<String>> {
        let url = self.addr.join(&format!("v1/secret/{}?list=true", path))?;
        debug!("LIST {}", url);
        let mkerr = || ErrorKind::Url(url.clone());
        let res = self
            .client
            .get(url.clone())
            .header("X-Vault-Token", self.token.clone())
            .send()
            .await
            .chain_err(&mkerr)?;
        // Generate informative errors for HTTP failures, because these can
        // be caused by everything from bad URLs to overly restrictive vault policies
        if !res.status().is_success() {
            let status = res.status().to_owned();
            let err: Error = ErrorKind::UnexpectedHttpStatus(status).into();
            return Err(err).chain_err(&mkerr);
        }
        let body = res.text().await?;
        let lsec: ListSecrets = serde_json::from_str(&body)?;
        if !lsec.data.contains_key("keys") {
            bail!(
                "secret list {} does not contain keys list from vault api!?: {}",
                url,
                body
            );
        }
        let res = lsec.data["keys"]
            .iter()
            .filter(|e| !e.ends_with('/')) // skip sub folders
            .map(|e| e.to_string())
            .collect::<Vec<String>>();
        Ok(res)
    }
pub async fn list ( & self , path : & str ) -> Result < Vec < String > > { let url = self . addr . join ( & format ! ( " " path ) ) ? ; debug ! ( " " url ) ; let mkerr = | | ErrorKind :: Url ( url . clone ( ) ) ; let res = self . client . get ( url . clone ( ) ) . header ( " " , self . token . clone ( ) ) . send ( ) . await . chain_err ( & mkerr ) ? ; // Generate informative errors for HTTP failures, because these can // be caused by everything from bad URLs to overly restrictive vault policies if ! res . status ( ) . is_success ( ) { let status = res . status ( ) . to_owned ( ) ; let err : Error = ErrorKind :: UnexpectedHttpStatus ( status ) . into ( ) ; return Err ( err ) . chain_err ( & mkerr ) ; } let body = res . text ( ) . await ? ; let lsec : ListSecrets = serde_json :: from_str ( & body ) ? ; if ! lsec . data . contains_key ( " " ) { bail ! ( " " url body ) ; } let res = lsec . data [ " " ] . iter ( ) . filter ( | e | ! e . ends_with ( '/' ) ) // skip sub folders . map ( | e | e . to_string ( ) ) . collect :: < Vec < String > > ( ) ; Ok ( res ) }
List secrets
Does a HTTP LIST on the folder a service is in and returns the keys
List secrets Does a HTTP LIST on the folder a service is in and returns the keys
&self
path
&str
&self
path
&str