use of com.google.cloud.secretmanager.v1.CreateSecretRequest in project spring-cloud-gcp by spring-cloud.
the class SecretManagerTemplate method createSecretInternal.
/**
* Creates a new secret for the GCP Project.
*
* <p>
* Note that the {@link Secret} object does not contain the secret payload. You must
* create versions of the secret which stores the payload of the secret.
*/
private void createSecretInternal(String secretId, String projectId) {
ProjectName projectName = ProjectName.of(projectId);
Secret secret = Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.getDefaultInstance())).build();
CreateSecretRequest request = CreateSecretRequest.newBuilder().setParent(projectName.toString()).setSecretId(secretId).setSecret(secret).build();
this.secretManagerServiceClient.createSecret(request);
}
use of com.google.cloud.secretmanager.v1.CreateSecretRequest in project spring-cloud-gcp by spring-cloud.
the class SecretManagerTemplateTests method verifyCreateSecretRequest.
private void verifyCreateSecretRequest(String secretId, String projectId) {
Secret secretToAdd = Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.newBuilder()).build()).build();
CreateSecretRequest createSecretRequest = CreateSecretRequest.newBuilder().setParent("projects/" + projectId).setSecretId(secretId).setSecret(secretToAdd).build();
verify(this.client).createSecret(createSecretRequest);
}
use of com.google.cloud.secretmanager.v1.CreateSecretRequest in project java-docs-samples by GoogleCloudPlatform.
the class SnippetsIT method createSecret.
private static Secret createSecret() throws IOException {
ProjectName parent = ProjectName.of(PROJECT_ID);
CreateSecretRequest request = CreateSecretRequest.newBuilder().setParent(parent.toString()).setSecretId(randomSecretId()).setSecret(Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.newBuilder().build()).build()).build()).build();
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
return client.createSecret(request);
}
}
use of com.google.cloud.secretmanager.v1.CreateSecretRequest in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerTemplate method createSecretInternal.
/**
* Creates a new secret for the GCP Project.
*
* <p>Note that the {@link Secret} object does not contain the secret payload. You must create
* versions of the secret which stores the payload of the secret.
*/
private void createSecretInternal(String secretId, String projectId) {
ProjectName projectName = ProjectName.of(projectId);
Secret secret = Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.getDefaultInstance())).build();
CreateSecretRequest request = CreateSecretRequest.newBuilder().setParent(projectName.toString()).setSecretId(secretId).setSecret(secret).build();
this.secretManagerServiceClient.createSecret(request);
}
use of com.google.cloud.secretmanager.v1.CreateSecretRequest in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerTemplateTests method verifyCreateSecretRequest.
private void verifyCreateSecretRequest(String secretId, String projectId) {
Secret secretToAdd = Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.newBuilder()).build()).build();
CreateSecretRequest createSecretRequest = CreateSecretRequest.newBuilder().setParent("projects/" + projectId).setSecretId(secretId).setSecret(secretToAdd).build();
verify(this.client).createSecret(createSecretRequest);
}
Aggregations