use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class DestroySecretVersionWithEtag method destroySecretVersion.
// Destroy an existing secret version.
public static void destroySecretVersion(String projectId, String secretId, String versionId, String etag) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the name from the version.
SecretVersionName secretVersionName = SecretVersionName.of(projectId, secretId, versionId);
// Build the request.
DestroySecretVersionRequest request = DestroySecretVersionRequest.newBuilder().setName(secretVersionName.toString()).setEtag(etag).build();
// Destroy the secret version.
SecretVersion version = client.destroySecretVersion(request);
System.out.printf("Destroyed secret version %s\n", version.getName());
}
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class DisableSecretVersionWithEtag method disableSecretVersion.
// Disable an existing secret version.
public static void disableSecretVersion(String projectId, String secretId, String versionId, String etag) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the name from the version.
SecretVersionName secretVersionName = SecretVersionName.of(projectId, secretId, versionId);
// Build the request.
DisableSecretVersionRequest request = DisableSecretVersionRequest.newBuilder().setName(secretVersionName.toString()).setEtag(etag).build();
// Disable the secret version.
SecretVersion version = client.disableSecretVersion(request);
System.out.printf("Disabled secret version %s\n", version.getName());
}
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class EnableSecretVersion method enableSecretVersion.
// Enable an existing secret version.
public static void enableSecretVersion(String projectId, String secretId, String versionId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the name from the version.
SecretVersionName secretVersionName = SecretVersionName.of(projectId, secretId, versionId);
// Enable the secret version.
SecretVersion version = client.enableSecretVersion(secretVersionName);
System.out.printf("Enabled secret version %s\n", version.getName());
}
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class EnableSecretVersionWithEtag method enableSecretVersion.
// Enable an existing secret version.
public static void enableSecretVersion(String projectId, String secretId, String versionId, String etag) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the name from the version.
SecretVersionName secretVersionName = SecretVersionName.of(projectId, secretId, versionId);
// Build the request.
EnableSecretVersionRequest request = EnableSecretVersionRequest.newBuilder().setName(secretVersionName.toString()).setEtag(etag).build();
// Enable the secret version.
SecretVersion version = client.enableSecretVersion(request);
System.out.printf("Enabled secret version %s\n", version.getName());
}
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class GetSecretVersion method getSecretVersion.
// Get an existing secret version.
public static void getSecretVersion(String projectId, String secretId, String versionId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the name from the version.
SecretVersionName secretVersionName = SecretVersionName.of(projectId, secretId, versionId);
// Create the secret.
SecretVersion version = client.getSecretVersion(secretVersionName);
System.out.printf("Secret version %s, state %s\n", version.getName(), version.getState());
}
}
Aggregations