pub struct Client<T>where
T: Auth,{ /* private fields */ }Expand description
The Client struct represents a single Vault-Connection/Session that can be used for any further requests to vault
Implementations§
Source§impl<T> Client<T>where
T: Auth,
impl<T> Client<T>where
T: Auth,
Sourcepub fn new(conf: Config, auth_opts: T) -> Result<Client<T>, Error>
pub fn new(conf: Config, auth_opts: T) -> Result<Client<T>, Error>
This function is used to obtain a new vault session with the given config and auth settings
Sourcepub fn renew_background(&self) -> Result<(), RenewError>
pub fn renew_background(&self) -> Result<(), RenewError>
This function will enter an infitive Loop and blocks the current thread. It will do everything related to renewing the token/session. This will idealy run inside it’s own thread as to not block anything else important
Sourcepub fn get_token(&self) -> String
pub fn get_token(&self) -> String
A simple method to get the underlying vault session/client token for the current vault session. It is not recommended to use this function, but rather stick to other more integrated parts, like the vault_request function
Sourcepub async fn check_session(&self) -> Result<(), Error>
pub async fn check_session(&self) -> Result<(), Error>
This function is used to check if the current session is still valid and if not to renew the session/obtain a new one and update all data related to it
Sourcepub async fn vault_request<P: Serialize>(
&self,
method: Method,
path: &str,
body: Option<&P>,
) -> Result<Response, Error>
pub async fn vault_request<P: Serialize>( &self, method: Method, path: &str, body: Option<&P>, ) -> Result<Response, Error>
This function is a general way to directly make requests to vault using the current session. This can be used to make custom requests or to make requests to mounts that are not directly covered by this crate.