use of com.google.cloud.secretmanager.v1.Secret in project nomulus by google.
the class SecretManagerClientImpl method createSecret.
@Override
public void createSecret(String secretId) {
checkNotNull(secretId, "secretId");
Secret secretSettings = Secret.newBuilder().setReplication(defaultReplicationPolicy()).build();
callSecretManager(() -> csmClient.createSecret(ProjectName.of(project), secretId, secretSettings));
}
use of com.google.cloud.secretmanager.v1.Secret in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerPropertyUtilsTests method testShortProperty_secretId.
@Test
void testShortProperty_secretId() {
String property = "sm://the-secret";
SecretVersionName secretIdentifier = SecretManagerPropertyUtils.getSecretVersionName(property, DEFAULT_PROJECT_ID_PROVIDER);
assertThat(secretIdentifier.getProject()).isEqualTo("defaultProject");
assertThat(secretIdentifier.getSecret()).isEqualTo("the-secret");
assertThat(secretIdentifier.getSecretVersion()).isEqualTo("latest");
}
use of com.google.cloud.secretmanager.v1.Secret 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.v1.Secret in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerPropertyUtilsTests method testLongProperty_projectSecretVersion.
@Test
void testLongProperty_projectSecretVersion() {
String property = "sm://projects/my-project/secrets/the-secret/versions/3";
SecretVersionName secretIdentifier = SecretManagerPropertyUtils.getSecretVersionName(property, DEFAULT_PROJECT_ID_PROVIDER);
assertThat(secretIdentifier.getProject()).isEqualTo("my-project");
assertThat(secretIdentifier.getSecret()).isEqualTo("the-secret");
assertThat(secretIdentifier.getSecretVersion()).isEqualTo("3");
}
use of com.google.cloud.secretmanager.v1.Secret in project native-image-support-java by GoogleCloudPlatform.
the class SecretManagerSampleApplication method hasSecret.
static boolean hasSecret(SecretManagerServiceClient client, String projectId, String secretId) {
ProjectName projectName = ProjectName.of(projectId);
ListSecretsPagedResponse pagedResponse = client.listSecrets(projectName);
for (Secret secret : pagedResponse.iterateAll()) {
String otherSecretId = extractSecretId(secret);
if (secretId.equals(otherSecretId)) {
return true;
}
}
return false;
}
Aggregations