Search in sources :

Example 11 with SecretVersionName

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");
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 12 with SecretVersionName

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");
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 13 with SecretVersionName

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");
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 14 with SecretVersionName

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");
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) Test(org.junit.Test)

Example 15 with SecretVersionName

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());
    }
}
Also used : SecretVersionName(com.google.cloud.secretmanager.v1.SecretVersionName) SecretVersion(com.google.cloud.secretmanager.v1.SecretVersion) SecretManagerServiceClient(com.google.cloud.secretmanager.v1.SecretManagerServiceClient)

Aggregations

SecretVersionName (com.google.cloud.secretmanager.v1.SecretVersionName)63 Test (org.junit.Test)19 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)15 SecretVersion (com.google.cloud.secretmanager.v1.SecretVersion)13 Test (org.junit.jupiter.api.Test)12 AccessSecretVersionResponse (com.google.cloud.secretmanager.v1.AccessSecretVersionResponse)7 ByteString (com.google.protobuf.ByteString)3 ApiException (com.google.api.gax.rpc.ApiException)1 AccessSecretVersionRequest (com.google.cloud.secretmanager.v1.AccessSecretVersionRequest)1 DestroySecretVersionRequest (com.google.cloud.secretmanager.v1.DestroySecretVersionRequest)1 DisableSecretVersionRequest (com.google.cloud.secretmanager.v1.DisableSecretVersionRequest)1 EnableSecretVersionRequest (com.google.cloud.secretmanager.v1.EnableSecretVersionRequest)1 SecretName (com.google.cloud.secretmanager.v1.SecretName)1 SecretPayload (com.google.cloud.secretmanager.v1.SecretPayload)1 IOException (java.io.IOException)1 CRC32C (java.util.zip.CRC32C)1 Checksum (java.util.zip.Checksum)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1