pub mod auth;
pub mod autounseal;
pub mod client;
pub mod common;
pub mod error;
pub mod init;
pub mod operations;
pub mod pki;
pub mod seal;
pub mod setup_root;
pub mod setup_sub;
pub mod status;
#[cfg(test)]
pub mod test_utils;
pub mod transit;
pub mod wizard;
pub use client::VaultClient;
pub use error::VaultError;
#[cfg(any(test, feature = "full-api"))]
pub use init::InitResult;
pub use init::UnsealResult;
pub use pki::PkiResult;
pub use seal::seal_vault;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppRoleCredentials {
pub role_id: String,
pub secret_id: String,
}
#[derive(Debug, Clone)]
pub struct AutoUnsealResult {
pub root_token: String,
pub recovery_keys: Option<Vec<String>>,
pub success: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct VaultConfig {
pub url: String,
pub token: Option<String>,
pub client_cert_path: Option<String>,
pub client_key_path: Option<String>,
pub ca_cert_path: Option<String>,
pub namespace: Option<String>,
}
#[cfg(any(test, feature = "full-api"))]
impl VaultConfig {
pub fn new(url: &str) -> Self {
Self {
url: url.to_string(),
token: None,
client_cert_path: None,
client_key_path: None,
ca_cert_path: None,
namespace: None,
}
}
pub fn with_token(mut self, token: &str) -> Self {
self.token = Some(token.to_string());
self
}
pub fn with_mtls(mut self, client_cert: &str, client_key: &str, ca_cert: Option<&str>) -> Self {
self.client_cert_path = Some(client_cert.to_string());
self.client_key_path = Some(client_key.to_string());
self.ca_cert_path = ca_cert.map(|s| s.to_string());
self
}
pub fn with_namespace(mut self, namespace: &str) -> Self {
self.namespace = Some(namespace.to_string());
self
}
}
impl Default for VaultConfig {
fn default() -> Self {
Self {
url: "http://127.0.0.1:8200".to_string(),
token: None,
client_cert_path: None,
client_key_path: None,
ca_cert_path: None,
namespace: None,
}
}
}