use of com.google.cloud.secretmanager.v1.SecretName in project spring-cloud-gcp by spring-cloud.
the class SecretManagerTemplate method deleteSecret.
@Override
public void deleteSecret(String secretId, String projectId) {
SecretName name = SecretName.of(projectId, secretId);
DeleteSecretRequest request = DeleteSecretRequest.newBuilder().setName(name.toString()).build();
this.secretManagerServiceClient.deleteSecret(request);
}
use of com.google.cloud.secretmanager.v1.SecretName in project spring-cloud-gcp by spring-cloud.
the class SecretManagerTemplateTests method verifyDeleteSecretRequest.
private void verifyDeleteSecretRequest(String secretId, String projectId) {
SecretName name = SecretName.of(projectId, secretId);
DeleteSecretRequest request = DeleteSecretRequest.newBuilder().setName(name.toString()).build();
verify(this.client).deleteSecret(request);
}
use of com.google.cloud.secretmanager.v1.SecretName in project spring-cloud-config by spring-cloud.
the class GoogleSecretManagerV1AccessStrategy method getSecretVersions.
private List<SecretVersion> getSecretVersions(Secret secret) {
SecretName parent = SecretName.parse(secret.getName());
// Create the request.
ListSecretVersionsRequest listVersionRequest = ListSecretVersionsRequest.newBuilder().setParent(parent.toString()).build();
// Get all versions.
SecretManagerServiceClient.ListSecretVersionsPagedResponse pagedListVersionResponse = client.listSecretVersions(listVersionRequest);
List<SecretVersion> result = new ArrayList<SecretVersion>();
pagedListVersionResponse.iterateAll().forEach(result::add);
return result;
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class QuickstartIT method afterAll.
@AfterClass
public static void afterAll() throws Exception {
Assert.assertFalse("missing GOOGLE_CLOUD_PROJECT", Strings.isNullOrEmpty(PROJECT_ID));
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Delete the secret created by quickstart
SecretName name = SecretName.of(PROJECT_ID, SECRET_ID);
DeleteSecretRequest deleteRequest = DeleteSecretRequest.newBuilder().setName(name.toString()).build();
client.deleteSecret(deleteRequest);
}
}
use of com.google.cloud.secretmanager.v1.SecretName in project java-docs-samples by GoogleCloudPlatform.
the class AddSecretVersion method addSecretVersion.
// Add a new version to the existing secret.
public static void addSecretVersion(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()) {
SecretName secretName = SecretName.of(projectId, secretId);
// Create the secret payload.
SecretPayload payload = SecretPayload.newBuilder().setData(ByteString.copyFromUtf8("my super secret data")).build();
// Add the secret version.
SecretVersion version = client.addSecretVersion(secretName, payload);
System.out.printf("Added secret version %s\n", version.getName());
}
}
Aggregations