use of software.amazon.awssdk.services.secretsmanager.model.DescribeSecretResponse in project aws-greengrass-provisioner by awslabs.
the class BasicSecretsManagerHelper method getSecretNameFromArn.
@Override
public String getSecretNameFromArn(String arn) {
DescribeSecretResponse describeSecretResponse = getDescribeSecretResponse(arn);
throwExceptionOnSecretDeleted(describeSecretResponse);
return describeSecretResponse.name();
}
use of software.amazon.awssdk.services.secretsmanager.model.DescribeSecretResponse in project aws-greengrass-provisioner by awslabs.
the class BasicSecretsManagerHelper method getSecretArnFromName.
@Override
public String getSecretArnFromName(String name) {
DescribeSecretResponse describeSecretResponse = getDescribeSecretResponse(name);
throwExceptionOnSecretDeleted(describeSecretResponse);
return describeSecretResponse.arn();
}
use of software.amazon.awssdk.services.secretsmanager.model.DescribeSecretResponse in project signers by ConsenSys.
the class AwsSecretsManagerTest method updateIfDifferentSecretTag.
private void updateIfDifferentSecretTag(final String secretName, final Tag newTag) {
final DescribeSecretResponse describeSecretResponse = testSecretsManagerClient.describeSecret(DescribeSecretRequest.builder().secretId(secretName).build());
final boolean hasDifferentSecretTag = !describeSecretResponse.hasTags() || !describeSecretResponse.tags().equals(List.of(newTag));
if (hasDifferentSecretTag) {
testSecretsManagerClient.untagResource(UntagResourceRequest.builder().secretId(secretName).tagKeys(describeSecretResponse.tags().stream().map(Tag::key).collect(Collectors.toList())).build());
testSecretsManagerClient.tagResource(TagResourceRequest.builder().secretId(secretName).tags(newTag).build());
}
}
use of software.amazon.awssdk.services.secretsmanager.model.DescribeSecretResponse in project aws-doc-sdk-examples by awsdocs.
the class DescribeSecret method describeGivenSecret.
// snippet-start:[secretsmanager.java2.describe_secret.main]
public static void describeGivenSecret(SecretsManagerClient secretsClient, String secretName) {
try {
DescribeSecretRequest secretRequest = DescribeSecretRequest.builder().secretId(secretName).build();
DescribeSecretResponse secretResponse = secretsClient.describeSecret(secretRequest);
Instant lastChangedDate = secretResponse.lastChangedDate();
// Convert the Instant to readable date
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(Locale.US).withZone(ZoneId.systemDefault());
formatter.format(lastChangedDate);
System.out.println("The date of the last change to " + secretResponse.name() + " is " + lastChangedDate);
} catch (SecretsManagerException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations