use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testDestroySecretVersionWithEtag.
@Test
public void testDestroySecretVersionWithEtag() throws IOException {
SecretVersionName name = SecretVersionName.parse(TEST_SECRET_VERSION_TO_DESTROY_WITH_ETAG.getName());
String etag = TEST_SECRET_VERSION_TO_DESTROY_WITH_ETAG.getEtag();
DestroySecretVersionWithEtag.destroySecretVersion(name.getProject(), name.getSecret(), name.getSecretVersion(), etag);
assertThat(stdOut.toString()).contains("Destroyed secret version");
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testDisableSecretVersionWithEtag.
@Test
public void testDisableSecretVersionWithEtag() throws IOException {
SecretVersionName name = SecretVersionName.parse(TEST_SECRET_VERSION_TO_DISABLE_WITH_ETAG.getName());
String etag = TEST_SECRET_VERSION_TO_DISABLE_WITH_ETAG.getEtag();
DisableSecretVersionWithEtag.disableSecretVersion(name.getProject(), name.getSecret(), name.getSecretVersion(), etag);
assertThat(stdOut.toString()).contains("Disabled secret version");
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testEnableSecretVersionWithEtag.
@Test
public void testEnableSecretVersionWithEtag() throws IOException {
SecretVersionName name = SecretVersionName.parse(TEST_SECRET_VERSION_TO_ENABLE_WITH_ETAG.getName());
String etag = TEST_SECRET_VERSION_TO_ENABLE_WITH_ETAG.getEtag();
EnableSecretVersionWithEtag.enableSecretVersion(name.getProject(), name.getSecret(), name.getSecretVersion(), etag);
assertThat(stdOut.toString()).contains("Enabled secret version");
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testEnableSecretVersion.
@Test
public void testEnableSecretVersion() throws IOException {
SecretVersionName name = SecretVersionName.parse(TEST_SECRET_VERSION_TO_ENABLE.getName());
EnableSecretVersion.enableSecretVersion(name.getProject(), name.getSecret(), name.getSecretVersion());
assertThat(stdOut.toString()).contains("Enabled secret version");
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project java-docs-samples by GoogleCloudPlatform.
the class DisableSecretVersion method disableSecretVersion.
// Disable an existing secret version.
public static void disableSecretVersion(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);
// Disable the secret version.
SecretVersion version = client.disableSecretVersion(secretVersionName);
System.out.printf("Disabled secret version %s\n", version.getName());
}
}
Aggregations