use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class ListSecretVersions method listSecretVersions.
// List all secret versions for a secret.
public static void listSecretVersions(String projectId, String secretId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the parent name.
SecretName secretName = SecretName.of(projectId, secretId);
// Get all versions.
ListSecretVersionsPagedResponse pagedResponse = client.listSecretVersions(secretName);
// List all versions and their state.
pagedResponse.iterateAll().forEach(version -> {
System.out.printf("Secret version %s, %s\n", version.getName(), version.getState());
});
}
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testIamGrantAccess.
@Test
public void testIamGrantAccess() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
IamGrantAccess.iamGrantAccess(name.getProject(), name.getSecret(), IAM_USER);
assertThat(stdOut.toString()).contains("Updated IAM policy");
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testCreateSecret.
@Test
public void testCreateSecret() throws IOException {
SecretName name = TEST_SECRET_TO_CREATE_NAME;
CreateSecret.createSecret(name.getProject(), name.getSecret());
assertThat(stdOut.toString()).contains("Created secret");
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testDeleteSecretWithEtag.
@Test
public void testDeleteSecretWithEtag() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET_TO_DELETE_WITH_ETAG.getName());
String etag = TEST_SECRET_TO_DELETE_WITH_ETAG.getEtag();
DeleteSecretWithEtag.deleteSecret(name.getProject(), name.getSecret(), etag);
assertThat(stdOut.toString()).contains("Deleted secret");
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method testIamRevokeAccess.
@Test
public void testIamRevokeAccess() throws IOException {
SecretName name = SecretName.parse(TEST_SECRET.getName());
IamRevokeAccess.iamRevokeAccess(name.getProject(), name.getSecret(), IAM_USER);
assertThat(stdOut.toString()).contains("Updated IAM policy");
}
Aggregations