Search in sources :

Example 1 with CreateSecretRequest

use of com.google.cloud.secretmanager.v1beta1.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);
}
Also used : Secret(com.google.cloud.secretmanager.v1.Secret) ProjectName(com.google.cloud.secretmanager.v1.ProjectName) CreateSecretRequest(com.google.cloud.secretmanager.v1.CreateSecretRequest)

Example 2 with CreateSecretRequest

use of com.google.cloud.secretmanager.v1beta1.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);
}
Also used : Secret(com.google.cloud.secretmanager.v1.Secret) CreateSecretRequest(com.google.cloud.secretmanager.v1.CreateSecretRequest)

Example 3 with CreateSecretRequest

use of com.google.cloud.secretmanager.v1beta1.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);
    }
}
Also used : ProjectName(com.google.cloud.secretmanager.v1.ProjectName) CreateSecretRequest(com.google.cloud.secretmanager.v1.CreateSecretRequest) SecretManagerServiceClient(com.google.cloud.secretmanager.v1.SecretManagerServiceClient)

Example 4 with CreateSecretRequest

use of com.google.cloud.secretmanager.v1beta1.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);
}
Also used : Secret(com.google.cloud.secretmanager.v1.Secret) CreateSecretRequest(com.google.cloud.secretmanager.v1.CreateSecretRequest)

Example 5 with CreateSecretRequest

use of com.google.cloud.secretmanager.v1beta1.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);
}
Also used : Secret(com.google.cloud.secretmanager.v1.Secret) ProjectName(com.google.cloud.secretmanager.v1.ProjectName) CreateSecretRequest(com.google.cloud.secretmanager.v1.CreateSecretRequest)

Aggregations

CreateSecretRequest (com.google.cloud.secretmanager.v1.CreateSecretRequest)6 ProjectName (com.google.cloud.secretmanager.v1.ProjectName)4 Secret (com.google.cloud.secretmanager.v1.Secret)4 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)2 AddSecretVersionRequest (com.google.cloud.secretmanager.v1beta1.AddSecretVersionRequest)1 CreateSecretRequest (com.google.cloud.secretmanager.v1beta1.CreateSecretRequest)1 Replication (com.google.cloud.secretmanager.v1beta1.Replication)1 Secret (com.google.cloud.secretmanager.v1beta1.Secret)1 BeforeClass (org.junit.BeforeClass)1