pub struct AuthyClient { /* private fields */ }Expand description
High-level client for programmatic vault access.
Each operation loads the vault, performs the mutation, saves it back, and appends an audit entry — mirroring the CLI handler pattern.
Implementations§
Source§impl AuthyClient
impl AuthyClient
Sourcepub fn with_passphrase(passphrase: &str) -> Result<Self>
pub fn with_passphrase(passphrase: &str) -> Result<Self>
Authenticate with a passphrase.
Sourcepub fn with_keyfile(keyfile_path: &str) -> Result<Self>
pub fn with_keyfile(keyfile_path: &str) -> Result<Self>
Authenticate with an age keyfile on disk.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Authenticate from environment variables (AUTHY_KEYFILE or AUTHY_PASSPHRASE).
This does not fall through to interactive prompts — it only reads env vars.
Sourcepub fn with_actor(self, actor: impl Into<String>) -> Self
pub fn with_actor(self, actor: impl Into<String>) -> Self
Override the actor label used in audit entries.
Sourcepub fn is_initialized() -> bool
pub fn is_initialized() -> bool
Check whether the vault has been initialized.
Sourcepub fn get(&self, name: &str) -> Result<Option<String>>
pub fn get(&self, name: &str) -> Result<Option<String>>
Retrieve a secret by name. Returns None if not found.
Sourcepub fn get_or_err(&self, name: &str) -> Result<String>
pub fn get_or_err(&self, name: &str) -> Result<String>
Retrieve a secret by name, returning an error if it does not exist.
Sourcepub fn store(&self, name: &str, value: &str, force: bool) -> Result<()>
pub fn store(&self, name: &str, value: &str, force: bool) -> Result<()>
Store a secret. If force is false and the secret already exists,
returns AuthyError::SecretAlreadyExists.
Sourcepub fn remove(&self, name: &str) -> Result<bool>
pub fn remove(&self, name: &str) -> Result<bool>
Remove a secret. Returns true if the secret existed.
Sourcepub fn rotate(&self, name: &str, new_value: &str) -> Result<u32>
pub fn rotate(&self, name: &str, new_value: &str) -> Result<u32>
Rotate a secret to a new value. Returns the new version number. The secret must already exist.
Sourcepub fn list(&self, scope: Option<&str>) -> Result<Vec<String>>
pub fn list(&self, scope: Option<&str>) -> Result<Vec<String>>
List secret names, optionally filtered by a policy scope.
Sourcepub fn init_vault(&self) -> Result<()>
pub fn init_vault(&self) -> Result<()>
Initialize a new vault. The vault must not already exist.
Sourcepub fn audit_entries(&self) -> Result<Vec<AuditEntry>>
pub fn audit_entries(&self) -> Result<Vec<AuditEntry>>
Read all audit entries from the log.
Sourcepub fn verify_audit_chain(&self) -> Result<(usize, bool)>
pub fn verify_audit_chain(&self) -> Result<(usize, bool)>
Verify the integrity of the audit chain.
Returns (entry_count, valid).