use of com.google.cloud.secretmanager.v1beta1.DestroySecretVersionRequest in project java-secretmanager by googleapis.
the class ITSystemTest method tearDown.
@AfterClass
public static void tearDown() {
/* destroy secret version */
DestroySecretVersionRequest versionRequest = DestroySecretVersionRequest.newBuilder().setName(formattedSecretVersion).build();
SecretVersion actualSecretVersion = client.destroySecretVersion(versionRequest);
assertEquals(secretVersion.getCreateTime(), actualSecretVersion.getCreateTime());
assertEquals(SecretVersion.State.DESTROYED, actualSecretVersion.getState());
/* delete secret */
DeleteSecretRequest secretRequest = DeleteSecretRequest.newBuilder().setName(formattedSecretName).build();
client.deleteSecret(secretRequest);
client.close();
}
use of com.google.cloud.secretmanager.v1beta1.DestroySecretVersionRequest 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());
}
}
Aggregations