use of com.google.cloud.secretmanager.v1.SecretVersionName in project nomulus by google.
the class SecretManagerClientImpl method addSecretVersion.
@Override
public String addSecretVersion(String secretId, String data) {
checkNotNull(secretId, "secretId");
checkNotNull(data, "data");
SecretName secretName = SecretName.of(project, secretId);
SecretPayload secretPayload = SecretPayload.newBuilder().setData(ByteString.copyFromUtf8(data)).build();
SecretVersion response = callSecretManager(() -> csmClient.addSecretVersion(secretName, secretPayload));
checkState(SecretVersionName.isParsableFrom(response.getName()));
SecretVersionName secretVersionName = SecretVersionName.parse(response.getName());
return secretVersionName.getSecretVersion();
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerPropertyUtilsTests method testShortProperty_projectSecretIdVersion.
@Test
void testShortProperty_projectSecretIdVersion() {
String property = "sm://my-project/the-secret/2";
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("2");
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerTemplateTests method verifyDeleteSecretVersionRequest.
private void verifyDeleteSecretVersionRequest(String secretId, String version, String projectId) {
SecretVersionName secretVersionName = SecretVersionName.newBuilder().setProject(projectId).setSecret(secretId).setSecretVersion(version).build();
verify(this.client).destroySecretVersion(secretVersionName);
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerTemplate method deleteSecretVersion.
@Override
public void deleteSecretVersion(String secretId, String version, String projectId) {
SecretVersionName secretVersionName = SecretVersionName.newBuilder().setProject(projectId).setSecret(secretId).setSecretVersion(version).build();
this.secretManagerServiceClient.destroySecretVersion(secretVersionName);
}
use of com.google.cloud.secretmanager.v1.SecretVersionName in project spring-cloud-gcp by GoogleCloudPlatform.
the class SecretManagerPropertyUtilsTests method testLongProperty_projectSecret.
@Test
void testLongProperty_projectSecret() {
String property = "sm://projects/my-project/secrets/the-secret";
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("latest");
}
Aggregations