Interface SecretManagerClient
- All Known Implementing Classes:
SecretManagerClientImpl
public interface SecretManagerClient
A Cloud Secret Manager client for Nomulus, bound to a specific GCP project.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
The resource being requested in the Secret Manager does not exist.static class
The secret to be created already exists.static class
Catch-all class for all SecretManager exceptions.static final record
Contains theState
of an secret version. -
Method Summary
Modifier and TypeMethodDescriptionaddSecretVersion
(String secretId, String data) Adds a new version of data to a secret.void
createSecret
(String secretId) Creates a new secret in the Cloud Secret Manager with no data.default void
createSecretIfAbsent
(String secretId) Creates a secret if it does not already exists.void
deleteSecret
(String secretId) Deletes a secret from the Secret Manager.void
destroySecretVersion
(String secretId, String version) Destroys a secret version.void
disableSecretVersion
(String secretId, String version) Disables a secret version.void
enableSecretVersion
(String secretId, String version) Enables a secret version.Returns the project name with which this client is associated.getSecretData
(String secretId, Optional<String> version) Returns the data of a secret at the given version.Returns all secret IDs in the Cloud Secret Manager.listSecretVersions
(String secretId) Returns theSecretManagerClient.SecretVersionState
of all secrets withsecretId
.listSecretVersions
(String secretId, com.google.cloud.secretmanager.v1.SecretVersion.State state) Returns the version strings of all secrets in the givenstate
withsecretId
.boolean
secretExists
(String secretId) Checks if a secret with the givensecretId
already exists.
-
Method Details
-
getProject
String getProject()Returns the project name with which this client is associated. -
createSecret
Creates a new secret in the Cloud Secret Manager with no data.Use addVersion to add data to this secret.
- Parameters:
secretId
- The ID of the secret, must be unique in a project- Throws:
SecretManagerClient.SecretAlreadyExistsException
- A secret with this secretId already exists
-
secretExists
Checks if a secret with the givensecretId
already exists. -
listSecrets
Returns all secret IDs in the Cloud Secret Manager. -
listSecretVersions
Returns theSecretManagerClient.SecretVersionState
of all secrets withsecretId
. -
createSecretIfAbsent
Creates a secret if it does not already exists. -
listSecretVersions
default Iterable<String> listSecretVersions(String secretId, com.google.cloud.secretmanager.v1.SecretVersion.State state) Returns the version strings of all secrets in the givenstate
withsecretId
. -
addSecretVersion
Adds a new version of data to a secret.- Parameters:
secretId
- The ID of the secretdata
- The secret data to be stored in Cloud Secret Manager, encoded in utf-8 charset- Returns:
- The version string of the newly added secret data
-
getSecretData
Returns the data of a secret at the given version.- Parameters:
secretId
- The ID of the secretversion
- The version of the secret to fetch. If not provided, thelatest
version will be returned
-
enableSecretVersion
Enables a secret version.- Parameters:
secretId
- The ID of the secretversion
- The version of the secret to fetch. If not provided, thelatest
version will be returned
-
disableSecretVersion
Disables a secret version.- Parameters:
secretId
- The ID of the secretversion
- The version of the secret to fetch. If not provided, thelatest
version will be returned
-
destroySecretVersion
Destroys a secret version.- Parameters:
secretId
- The ID of the secretversion
- The version of the secret to destroy
-
deleteSecret
Deletes a secret from the Secret Manager. All versions of this secret will be destroyed.- Parameters:
secretId
- The ID of the secret to be deleted
-