Search in sources :

Example 1 with DescribeSecretRequest

use of com.amazonaws.services.secretsmanager.model.DescribeSecretRequest in project aws-secretsmanager-caching-java by aws.

the class SecretCacheItem method executeRefresh.

/**
 * Execute the logic to perform the actual refresh of the item.
 *
 * @return The result from AWS Secrets Manager for the refresh.
 */
@Override
protected DescribeSecretResult executeRefresh() {
    DescribeSecretResult describeSecretResult = client.describeSecret(updateUserAgent(new DescribeSecretRequest().withSecretId(this.secretId)));
    long ttl = this.config.getCacheItemTTL();
    this.nextRefreshTime = System.currentTimeMillis() + ThreadLocalRandom.current().nextLong(ttl / 2, ttl + 1);
    return describeSecretResult;
}
Also used : DescribeSecretResult(com.amazonaws.services.secretsmanager.model.DescribeSecretResult) DescribeSecretRequest(com.amazonaws.services.secretsmanager.model.DescribeSecretRequest)

Example 2 with DescribeSecretRequest

use of com.amazonaws.services.secretsmanager.model.DescribeSecretRequest in project fernet-java8 by l0s.

the class SecretsManagerTest method verifyDescribeSecretPassesThrough.

@Test
public final void verifyDescribeSecretPassesThrough() {
    // given
    final DescribeSecretRequest request = new DescribeSecretRequest();
    request.setSecretId("secret");
    final DescribeSecretResult sampleResult = new DescribeSecretResult();
    sampleResult.setRotationEnabled(true);
    sampleResult.addVersionIdsToStagesEntry("version", singletonList("AWSPREVIOUS"));
    given(delegate.describeSecret(eq(request))).willReturn(sampleResult);
    // when
    final DescribeSecretResult result = manager.describeSecret("secret");
    // then
    assertTrue(result.isRotationEnabled());
    assertTrue(result.getVersionIdsToStages().get("version").contains("AWSPREVIOUS"));
}
Also used : DescribeSecretResult(com.amazonaws.services.secretsmanager.model.DescribeSecretResult) DescribeSecretRequest(com.amazonaws.services.secretsmanager.model.DescribeSecretRequest) Test(org.junit.Test)

Example 3 with DescribeSecretRequest

use of com.amazonaws.services.secretsmanager.model.DescribeSecretRequest in project fernet-java8 by l0s.

the class SecretsManager method describeSecret.

/**
 * Obtain a secret's metadata. This requires the permission <code>secretsmanager:DescribeSecret</code>
 *
 * @param secretId the ARN of the secret
 * @return the secret's metadata
 */
public DescribeSecretResult describeSecret(final String secretId) {
    final DescribeSecretRequest describeSecretRequest = new DescribeSecretRequest();
    describeSecretRequest.setSecretId(secretId);
    return getDelegate().describeSecret(describeSecretRequest);
}
Also used : DescribeSecretRequest(com.amazonaws.services.secretsmanager.model.DescribeSecretRequest)

Aggregations

DescribeSecretRequest (com.amazonaws.services.secretsmanager.model.DescribeSecretRequest)3 DescribeSecretResult (com.amazonaws.services.secretsmanager.model.DescribeSecretResult)2 Test (org.junit.Test)1