The implementing class for operations on Vault's database backend.
This class is not intended to be constructed directly. Rather, it is meant to used by way of
Vault
in a DSL-style builder pattern. See the Javadoc comments of each public method for
usage examples.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.github.jopenlibs.vault.api.OperationsBase
OperationsBase.EndpointOperation<T> -
Field Summary
Fields inherited from class io.github.jopenlibs.vault.api.OperationsBase
config -
Constructor Summary
ConstructorsConstructorDescriptionDatabase(VaultConfig config) Constructor for use when the Database backend is mounted on the default path (i.e.Database(VaultConfig config, String mountPath) Constructor for use when the Database backend is mounted on some non-default custom path (e.g. -
Method Summary
Modifier and TypeMethodDescriptioncreateOrUpdateRole(String roleName, DatabaseRoleOptions options) Operation to create or update an role using the Database Secret engine.Operation to generate a new set of credentials using the Database backend.deleteRole(String roleName) Operation to delete an role using the Database backend.Operation to retrieve an role using the Database backend.Operation to revike a certificate in the vault using the Database backend.withNameSpace(String nameSpace) Methods inherited from class io.github.jopenlibs.vault.api.OperationsBase
retry
-
Constructor Details
-
Database
Constructor for use when the Database backend is mounted on the default path (i.e./v1/database).- Parameters:
config- A container for the configuration settings needed to initialize aVaultdriver instance
-
Database
Constructor for use when the Database backend is mounted on some non-default custom path (e.g./v1/db123).- Parameters:
config- A container for the configuration settings needed to initialize aVaultdriver instancemountPath- The path on which your Vault Database backend is mounted, without the/v1/prefix (e.g."root-ca")
-
-
Method Details
-
withNameSpace
-
createOrUpdateRole
public DatabaseResponse createOrUpdateRole(String roleName, DatabaseRoleOptions options) throws VaultException Operation to create or update an role using the Database Secret engine. Relies on an authentication token being present in the
VaultConfiginstance.This version of the method accepts a
DatabaseRoleOptionsparameter, containing optional settings for the role creation operation. Example usage:final VaultConfig config = new VaultConfig.address(...).token(...).build(); final Vault vault = Vault.create(config); final DatabaseRoleOptions options = new DatabaseRoleOptions() .dbName("test") .maxTtl("9h"); final DatabaseResponse response = vault.database().createOrUpdateRole("testRole", options); assertEquals(204, response.getRestResponse().getStatus());- Parameters:
roleName- A name for the role to be created or updatedoptions- Optional settings for the role to be created or updated (e.g. db_name, ttl, etc)- Returns:
- A container for the information returned by Vault
- Throws:
VaultException- If any error occurs or unexpected response is received from Vault
-
getRole
Operation to retrieve an role using the Database backend. Relies on an authentication token being present in the
VaultConfiginstance.The role information will be populated in the
roleOptionsfield of theDatabaseResponsereturn value. Example usage:final VaultConfig config = new VaultConfig.address(...).token(...).build(); final Vault vault = Vault.create(config); final DatabaseResponse response = vault.database().getRole("testRole"); final RoleOptions details = response.getRoleOptions();- Parameters:
roleName- The name of the role to retrieve- Returns:
- A container for the information returned by Vault
- Throws:
VaultException- If any error occurs or unexpected response is received from Vault
-
revoke
Operation to revike a certificate in the vault using the Database backend. Relies on an authentication token being present in the
VaultConfiginstance.A successful operation will return a 204 HTTP status. A
VaultExceptionwill be thrown if the role does not exist, or if any other problem occurs. Example usage:final VaultConfig config = new VaultConfig.address(...).token(...).build(); final Vault vault = Vault.create(config); final DatabaseResponse response = vault.database().revoke("serialnumber"); assertEquals(204, response.getRestResponse().getStatus();- Parameters:
serialNumber- The name of the role to delete- Returns:
- A container for the information returned by Vault
- Throws:
VaultException- If any error occurs or unexpected response is received from Vault
-
deleteRole
Operation to delete an role using the Database backend. Relies on an authentication token being present in the
VaultConfiginstance.A successful operation will return a 204 HTTP status. A
VaultExceptionwill be thrown if the role does not exist, or if any other problem occurs. Example usage:final VaultConfig config = new VaultConfig.address(...).token(...).build(); final Vault vault = Vault.create(config); final DatabaseResponse response = vault.database().deleteRole("testRole"); assertEquals(204, response.getRestResponse().getStatus();- Parameters:
roleName- The name of the role to delete- Returns:
- A container for the information returned by Vault
- Throws:
VaultException- If any error occurs or unexpected response is received from Vault
-
creds
Operation to generate a new set of credentials using the Database backend.
A successful operation will return a 204 HTTP status. A
VaultExceptionwill be thrown if the role does not exist, or if any other problem occurs. Credential information will be populated in thecredentialfield of theDatabaseResponsereturn value. Example usage:final VaultConfig config = new VaultConfig.address(...).token(...).build(); final Vault vault = Vault.create(config); final DatabaseResponse response = vault.database().creds("testRole"); assertEquals(204, response.getRestResponse().getStatus();- Parameters:
roleName- The role for which to retrieve credentials- Returns:
- A container for the information returned by Vault
- Throws:
VaultException- If any error occurs or unexpected response is received from Vault
-