Search in sources :

Example 26 with SecretName

use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.

the class SnippetsIT method testListSecretVersions.

@Test
public void testListSecretVersions() throws IOException {
    SecretName name = SecretName.parse(TEST_SECRET_WITH_VERSIONS.getName());
    new ListSecretVersions().listSecretVersions(name.getProject(), name.getSecret());
    assertThat(stdOut.toString()).contains("Secret version");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Example 27 with SecretName

use of com.google.cloud.secretmanager.v1.SecretName in project java-secretmanager by googleapis.

the class SnippetsIT method testAddSecretVersion.

@Test
public void testAddSecretVersion() throws IOException {
    SecretName name = SecretName.parse(TEST_SECRET_WITH_VERSIONS.getName());
    new AddSecretVersion().addSecretVersion(name.getProject(), name.getSecret());
    assertThat(stdOut.toString()).contains("Added secret version");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Example 28 with SecretName

use of com.google.cloud.secretmanager.v1.SecretName in project spring-cloud-gcp by spring-cloud.

the class SecretManagerTemplate method createNewSecretVersion.

/**
 * Create a new version of the secret with the specified payload under a {@link Secret}.
 * Will also create the parent secret if it does not already exist.
 */
private void createNewSecretVersion(String secretId, ByteString payload, String projectId) {
    if (!secretExists(secretId, projectId)) {
        createSecretInternal(secretId, projectId);
    }
    SecretName name = SecretName.of(projectId, secretId);
    AddSecretVersionRequest payloadRequest = AddSecretVersionRequest.newBuilder().setParent(name.toString()).setPayload(SecretPayload.newBuilder().setData(payload)).build();
    secretManagerServiceClient.addSecretVersion(payloadRequest);
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) AddSecretVersionRequest(com.google.cloud.secretmanager.v1.AddSecretVersionRequest)

Example 29 with SecretName

use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.

the class SnippetsIT method testListSecretVersionsWithFilter.

@Test
public void testListSecretVersionsWithFilter() throws IOException {
    SecretName name = SecretName.parse(TEST_SECRET_WITH_VERSIONS.getName());
    ListSecretVersionsWithFilter.listSecretVersions(name.getProject(), name.getSecret(), "name:1");
    assertThat(stdOut.toString()).contains("Secret version");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Example 30 with SecretName

use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.

the class SnippetsIT method testDeleteSecret.

@Test
public void testDeleteSecret() throws IOException {
    SecretName name = SecretName.parse(TEST_SECRET_TO_DELETE.getName());
    DeleteSecret.deleteSecret(name.getProject(), name.getSecret());
    assertThat(stdOut.toString()).contains("Deleted secret");
}
Also used : SecretName(com.google.cloud.secretmanager.v1.SecretName) Test(org.junit.Test)

Aggregations

SecretName (com.google.cloud.secretmanager.v1.SecretName)52 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)23 Test (org.junit.Test)22 DeleteSecretRequest (com.google.cloud.secretmanager.v1.DeleteSecretRequest)8 Secret (com.google.cloud.secretmanager.v1.Secret)5 SecretVersion (com.google.cloud.secretmanager.v1.SecretVersion)5 AddSecretVersionRequest (com.google.cloud.secretmanager.v1.AddSecretVersionRequest)4 ListSecretVersionsPagedResponse (com.google.cloud.secretmanager.v1.SecretManagerServiceClient.ListSecretVersionsPagedResponse)4 SecretPayload (com.google.cloud.secretmanager.v1.SecretPayload)4 Binding (com.google.iam.v1.Binding)4 Policy (com.google.iam.v1.Policy)4 FieldMask (com.google.protobuf.FieldMask)3 AfterClass (org.junit.AfterClass)3 ListSecretVersionsRequest (com.google.cloud.secretmanager.v1.ListSecretVersionsRequest)2 AccessSecretVersionResponse (com.google.cloud.secretmanager.v1.AccessSecretVersionResponse)1 SecretVersionName (com.google.cloud.secretmanager.v1.SecretVersionName)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 ByteString (com.google.protobuf.ByteString)1 EventListener (io.micronaut.runtime.event.annotation.EventListener)1 ArrayList (java.util.ArrayList)1