use of com.google.cloud.secretmanager.v1beta1.AddSecretVersionRequest in project spring-cloud-gcp by GoogleCloudPlatform.
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);
}
use of com.google.cloud.secretmanager.v1beta1.AddSecretVersionRequest in project spring-cloud-gcp by spring-cloud.
the class SecretManagerTemplateTests method verifyAddSecretRequest.
private void verifyAddSecretRequest(String secretId, String payload, String projectId) {
AddSecretVersionRequest addSecretVersionRequest = AddSecretVersionRequest.newBuilder().setParent("projects/" + projectId + "/secrets/" + secretId).setPayload(SecretPayload.newBuilder().setData(ByteString.copyFromUtf8(payload))).build();
verify(this.client).addSecretVersion(addSecretVersionRequest);
}
use of com.google.cloud.secretmanager.v1beta1.AddSecretVersionRequest 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);
}
use of com.google.cloud.secretmanager.v1beta1.AddSecretVersionRequest in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method addSecretVersion.
private static SecretVersion addSecretVersion(Secret secret) throws IOException {
SecretName parent = SecretName.parse(secret.getName());
AddSecretVersionRequest request = AddSecretVersionRequest.newBuilder().setParent(parent.toString()).setPayload(SecretPayload.newBuilder().setData(ByteString.copyFromUtf8("my super secret data")).build()).build();
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
return client.addSecretVersion(request);
}
}
use of com.google.cloud.secretmanager.v1beta1.AddSecretVersionRequest in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerTemplateTests method verifyAddSecretRequest.
private void verifyAddSecretRequest(String secretId, String payload, String projectId) {
AddSecretVersionRequest addSecretVersionRequest = AddSecretVersionRequest.newBuilder().setParent("projects/" + projectId + "/secrets/" + secretId).setPayload(SecretPayload.newBuilder().setData(ByteString.copyFromUtf8(payload))).build();
verify(this.client).addSecretVersion(addSecretVersionRequest);
}
Aggregations