Package overit.geocall.secrets
Interface SecretsManager
- All Known Implementing Classes:
CachedSecretsManager
public interface SecretsManager
Interface representing a generic secret manager.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all the secrets saved in a local cache.Fetches aSecretby its name, returning it if found, otherwise aSecretsManagerExceptionis thrown.Fetches aSecretby its name and versionId, returning it if found, otherwise aSecretsManagerExceptionis thrown.getPrevious(@NotNull String name) Retrieves the previous value of theSecretif found, otherwise aSecretsManagerExceptionis thrown.optionalGet(@NotNull String name) optionalGet(@NotNull String name, @NotNull String versionId) Fetches the previous value of aSecretby its name returning anOptional(Optional.empty()if not found).voidremoveFromCache(@NotNull String name) Removes aSecretfrom the local cache if present.voidremoveFromCache(@NotNull String name, @NotNull String versionId) Removes aSecretfrom the local cache if present.
-
Field Details
-
LOG
-
NAME_CANNOT_BE_NULL
- See Also:
-
VERSION_ID_CANNOT_BE_NULL
- See Also:
-
THE_SECRET_HAS_NOT_BEEN_FOUND_FOR_THE_VERSION
- See Also:
-
CURRENT_SUFFIX
- See Also:
-
PREVIOUS_SUFFIX
- See Also:
-
-
Method Details
-
get
Fetches aSecretby its name, returning it if found, otherwise aSecretsManagerExceptionis thrown.- Parameters:
name- the unique name of the secret- Returns:
- the secret if found, otherwise a
SecretsManagerExceptionis thrown. - Throws:
SecretsManagerException- in case of errors while communicating with the secret manager or in case the requested secret has not been found.
-
get
Secret get(@NotNull @NotNull String name, @NotNull @NotNull String versionId) throws SecretsManagerException Fetches aSecretby its name and versionId, returning it if found, otherwise aSecretsManagerExceptionis thrown.- Parameters:
name- the unique name of the secretversionId- the version identifier of the secret- Returns:
- the secret if found, otherwise a
SecretsManagerExceptionis thrown. - Throws:
SecretsManagerException- in case of errors while communicating with the secret manager or in case the requested secret has not been found.
-
getPrevious
Retrieves the previous value of theSecretif found, otherwise aSecretsManagerExceptionis thrown.- Parameters:
name- the unique name of the secret- Returns:
- the previous value of the secret if found, otherwise a
SecretsManagerExceptionis thrown. - Throws:
SecretsManagerException- in case of errors while communicating with the secret manager or in case the requested secret has not been found.
-
optionalGet
- Parameters:
name- the unique name of the secret- Returns:
- the Optional of the secret (
Optional.empty()if not found) - Throws:
SecretsManagerException- in case of errors while communicating with the secret manager.
-
optionalGet
Optional<Secret> optionalGet(@NotNull @NotNull String name, @NotNull @NotNull String versionId) throws SecretsManagerException - Parameters:
name- the unique name of the secretversionId- the version identifier of the secret- Returns:
- the Optional of the secret (
Optional.empty()if not found) - Throws:
SecretsManagerException- in case of errors while communicating with the secret manager.
-
optionalGetPrevious
Fetches the previous value of aSecretby its name returning anOptional(Optional.empty()if not found).- Parameters:
name- the unique name of the secret- Returns:
- the Optional of the secret (
Optional.empty()if not found) - Throws:
SecretsManagerException- in case of errors while communicating with the secret manager.
-
clearCache
void clearCache()Clears all the secrets saved in a local cache. -
removeFromCache
Removes aSecretfrom the local cache if present.- Parameters:
name- the unique name of the secret.- Throws:
SecretsManagerException- in case of errors while communicating with the secret manager.
-
removeFromCache
Removes aSecretfrom the local cache if present.- Parameters:
name- the unique name of the secretversionId- the version identifier of the secret
-