public class SecretManagerTemplate extends Object implements SecretManagerOperations
Modifier and Type | Field and Description |
---|---|
static String |
LATEST_VERSION
Default value for the latest version of the secret.
|
Constructor and Description |
---|
SecretManagerTemplate(com.google.cloud.secretmanager.v1beta1.SecretManagerServiceClient secretManagerServiceClient,
GcpProjectIdProvider projectIdProvider) |
Modifier and Type | Method and Description |
---|---|
void |
createSecret(String secretId,
byte[] payload)
Creates a new secret or a new version of existing secret with the provided
payload . |
void |
createSecret(String secretId,
byte[] payload,
String projectId)
Creates a new secret or a new version of existing secret with the provided
payload for a specific projectId . |
void |
createSecret(String secretId,
String payload)
Creates a new secret or a new version of existing secret with the provided
payload . |
void |
deleteSecret(String secretId)
Deletes the specified secret under the default-configured project.
|
void |
deleteSecret(String secretId,
String projectId)
Deletes the specified secret.
|
void |
deleteSecretVersion(String secretId,
String version,
String projectId)
Deletes the specified secret version.
|
void |
disableSecretVersion(String secretId,
String version)
Disables the specified secret version under the default-configured project.
|
void |
disableSecretVersion(String secretId,
String version,
String projectId)
Disables the secret version under the specified project.
|
void |
enableSecretVersion(String secretId,
String version)
Enables the specified secret version under the default-configured project.
|
void |
enableSecretVersion(String secretId,
String version,
String projectId)
Enables the secret version under the specified project.
|
byte[] |
getSecretBytes(String secretIdentifier)
Gets the secret payload of the specified
secretIdentifier secret. |
String |
getSecretString(String secretIdentifier)
Gets the secret payload of the specified
secretIdentifier secret. |
boolean |
secretExists(String secretId)
Returns true if there already exists a secret under the GCP project with the
secretId . |
boolean |
secretExists(String secretId,
String projectId)
Returns true if there already exists a secret under the GCP
projectId with the
secretId . |
public static final String LATEST_VERSION
public SecretManagerTemplate(com.google.cloud.secretmanager.v1beta1.SecretManagerServiceClient secretManagerServiceClient, GcpProjectIdProvider projectIdProvider)
public void createSecret(String secretId, String payload)
SecretManagerOperations
payload
.
If there is already a secret saved in SecretManager with the specified
secretId
, then it simply creates a new version under the secret with the secret
payload
.
createSecret
in interface SecretManagerOperations
secretId
- the secret ID of the secret to create.payload
- the secret payload string.public void createSecret(String secretId, byte[] payload)
SecretManagerOperations
payload
.
If there is already a secret saved in SecretManager with the specified
secretId
, then it simply creates a new version under the secret with the secret
payload
.
createSecret
in interface SecretManagerOperations
secretId
- the secret ID of the secret to create.payload
- the secret payload as a byte array.public void createSecret(String secretId, byte[] payload, String projectId)
SecretManagerOperations
payload
for a specific projectId
.
If there is already a secret saved in SecretManager with the specified
secretId
, then it simply creates a new version under the secret with the secret
payload
.
createSecret
in interface SecretManagerOperations
secretId
- the secret ID of the secret to create.payload
- the secret payload as a byte array.projectId
- unique identifier of your project.public String getSecretString(String secretIdentifier)
SecretManagerOperations
secretIdentifier
secret.
The secretIdentifier
must either be a secret ID or a fully qualified
`sm://` protocol string which specifies the secret (see javadocs of
SecretManagerOperations
for the protocol format).
If the secret ID string is passed in, then this will return the payload of the secret for
the default project at the latest version.
getSecretString
in interface SecretManagerOperations
secretIdentifier
- the GCP secret ID of the secret or an sm:// formatted
string specifying the secret.public byte[] getSecretBytes(String secretIdentifier)
SecretManagerOperations
secretIdentifier
secret.
The secretIdentifier
must either be a secret ID or a fully qualified
`sm://` protocol string which specifies the secret (see javadocs of
SecretManagerOperations
for the protocol format).
If the secret ID string is passed in, then this will return the payload of the secret for
the default project at the latest version.
getSecretBytes
in interface SecretManagerOperations
secretIdentifier
- the GCP secret ID of the secret or an sm:// formatted
string specifying the secret.public boolean secretExists(String secretId)
SecretManagerOperations
secretId
.secretExists
in interface SecretManagerOperations
secretId
- unique identifier of your secret in Secret Manager.public boolean secretExists(String secretId, String projectId)
SecretManagerOperations
projectId
with the
secretId
.secretExists
in interface SecretManagerOperations
secretId
- unique identifier of your secret in Secret Manager.projectId
- unique identifier of your project.public void disableSecretVersion(String secretId, String version)
SecretManagerOperations
disableSecretVersion
in interface SecretManagerOperations
secretId
- the secret ID of the secret to disable.version
- the version to disablepublic void disableSecretVersion(String secretId, String version, String projectId)
SecretManagerOperations
disableSecretVersion
in interface SecretManagerOperations
secretId
- the secret ID of the secret to disable.version
- the version to disableprojectId
- unique identifier of your project.public void enableSecretVersion(String secretId, String version)
SecretManagerOperations
enableSecretVersion
in interface SecretManagerOperations
secretId
- the secret ID of the secret to enable.version
- the version to enablepublic void enableSecretVersion(String secretId, String version, String projectId)
SecretManagerOperations
enableSecretVersion
in interface SecretManagerOperations
secretId
- the secret ID of the secret to enable.version
- the version to enableprojectId
- unique identifier of your project.public void deleteSecret(String secretId)
SecretManagerOperations
deleteSecret
in interface SecretManagerOperations
secretId
- the secret ID of the secret to delete.public void deleteSecret(String secretId, String projectId)
SecretManagerOperations
deleteSecret
in interface SecretManagerOperations
secretId
- the secret ID of the secret to delete.projectId
- the GCP project containing the secret to delete.public void deleteSecretVersion(String secretId, String version, String projectId)
SecretManagerOperations
deleteSecretVersion
in interface SecretManagerOperations
secretId
- the secret ID of the secret to delete.version
- the version to deleteprojectId
- the GCP project containing the secret to delete.Copyright © 2020 Pivotal Software, Inc.. All rights reserved.