pub struct GaiaClient { /* private fields */ }Expand description
A client for interacting with the Gaia secret management daemon.
The client uses mutual TLS (mTLS) for secure communication and provides methods to retrieve secrets and check daemon status.
Implementations§
Source§impl GaiaClient
impl GaiaClient
Sourcepub async fn connect(config: GaiaClientConfig) -> Result<Self>
pub async fn connect(config: GaiaClientConfig) -> Result<Self>
Connects to the Gaia daemon using the provided configuration.
§Arguments
config- Configuration containing server address and TLS certificates
§Errors
Returns an error if:
- TLS certificates cannot be loaded
- Connection to the daemon fails
§Example
use gaia_client::{GaiaClient, GaiaClientConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = GaiaClientConfig::new(
"localhost:50051",
"/etc/gaia/certs/ca.crt",
"/etc/gaia/certs/client.crt",
"/etc/gaia/certs/client.key",
);
let client = GaiaClient::connect(config).await?;
Ok(())
}Sourcepub async fn get_secret(&mut self, namespace: &str, id: &str) -> Result<Secret>
pub async fn get_secret(&mut self, namespace: &str, id: &str) -> Result<Secret>
Retrieves a secret from the specified namespace.
§Arguments
namespace- The namespace containing the secretid- The secret identifier
§Errors
Returns an error if:
- The daemon is locked
- The secret does not exist
- A network error occurs
§Example
let secret = client.get_secret("production", "database_url").await?;
println!("Secret: {}", secret.value);Sourcepub async fn list_secrets(
&mut self,
namespace: Option<String>,
) -> Result<Vec<Namespace>>
pub async fn list_secrets( &mut self, namespace: Option<String>, ) -> Result<Vec<Namespace>>
Lists all secrets for the authenticated client.
Returns secrets from the client’s own namespaces plus the common namespace. If a namespace filter is provided, only secrets from that namespace are returned.
§Arguments
namespace- Optional namespace filter
§Example
// Get all secrets (client's own + common)
let all_secrets = client.list_secrets(None).await?;
// Get only secrets from a specific namespace
let prod_secrets = client.list_secrets(Some("production".to_string())).await?;
for namespace in all_secrets {
println!("Namespace: {}", namespace.name);
for secret in namespace.secrets {
println!(" - {}: {}", secret.id, secret.value);
}
}Sourcepub async fn load_env(&mut self, options: Option<LoadEnvOptions>) -> Result<()>
pub async fn load_env(&mut self, options: Option<LoadEnvOptions>) -> Result<()>
Fetches all accessible secrets and loads them into the current process’s environment.
By default, environment variables are named after the secret key, converted to uppercase
with hyphens replaced by underscores. Optional prefix and namespace inclusion can be
configured via LoadEnvOptions.
§Arguments
options- Optional configuration for env var naming
§Example
// Load with default behavior (key only)
client.load_env(None).await?;
// Load with prefix and namespace: GAIA_PRODUCTION_DATABASE_URL
client.load_env(Some(LoadEnvOptions::new().with_prefix("GAIA").with_namespace(true))).await?;Auto Trait Implementations§
impl !Freeze for GaiaClient
impl !RefUnwindSafe for GaiaClient
impl Send for GaiaClient
impl Sync for GaiaClient
impl Unpin for GaiaClient
impl UnsafeUnpin for GaiaClient
impl !UnwindSafe for GaiaClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request