Class AwsSecretsManagerClient
java.lang.Object
codes.grow.packages.awssecretsmanager.AwsSecretsManagerClient
- All Implemented Interfaces:
AutoCloseable
Client for AWS Secrets Manager, built on the official AWS SDK for Java v2 (SPEC section 2.3
"Cloud SDK services").
It builds a SecretsManagerClient from the Grow configuration (region, credentials,
optional assume-role, endpoint override, timeouts, retries, TLS, proxy, headers, User-Agent,
hooks) or wraps one the caller passes (withSdkClient(SecretsManagerClient)).
Thread-safe; create one per account and region and close it when done.
try (AwsSecretsManagerClient client = AwsSecretsManagerClient.fromEnv()) {
AwsSecretValue db = client.getSecretValue("prod/db");
String password = client.getJsonField("prod/db", "password").map(JsonNode::asText).orElseThrow();
}
Every I/O method has a blocking form and an …Async form returning CompletableFuture; cancelling the future interrupts the call (CancelledException).
Errors are mapped by AWS error code to the AwsSecretsManagerException subclasses.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder that configures and creates a client in one chain. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAWS Secrets Manager API version (the API contract date; AWS exposes no server version).static final StringDefault version stage.static final StringStage of a version being rotated in.static final StringStage of the previous current version.static final intMaximum ids perBatchGetSecretValuecall; longer id lists are split. -
Method Summary
Modifier and TypeMethodDescriptionbatchGetSecretValue(BatchGetSelector selector) Reads many secrets (BatchGetSecretValue) by ids or by filters with the default page size.batchGetSecretValue(BatchGetSelector selector, BatchGetOptions options) Reads many secrets (BatchGetSecretValue) by ids or by filters (every page is read).batchGetSecretValue(List<String> ids) Reads many secrets by id (BatchGetSecretValue); lists longer than 20 ids are split and the values come back in request order.batchGetSecretValueAsync(BatchGetSelector selector, BatchGetOptions options) AsynchronousbatchGetSecretValue(BatchGetSelector, BatchGetOptions).AsynchronousbatchGetSecretValue(List).builder()Starts a client builder.cancelRotateSecret(String secretId) Turns rotation off and cancels a rotation in progress (CancelRotateSecret).cancelRotateSecretAsync(String secretId) AsynchronouscancelRotateSecret(String).voidclose()Stops the watchers of every provider created bysecrets(), closes registered resources and the SDK client this instance built (never a caller-supplied one).config()Returns the configuration.static AwsSecretsManagerClientcreate(AwsSecretsManagerConfig config) Creates a client.createSecret(String name, Object value) Creates a secret (CreateSecret).createSecret(String name, Object value, CreateSecretOptions options) Creates a secret (CreateSecret) with description, KMS key, tags, idempotency token or replica regions.createSecretAsync(String name, Object value, CreateSecretOptions options) AsynchronouscreateSecret(String, Object, CreateSecretOptions).deleteResourcePolicy(String secretId) Removes the resource policy (DeleteResourcePolicy).deleteResourcePolicyAsync(String secretId) AsynchronousdeleteResourcePolicy(String).deleteSecret(String secretId) Schedules deletion with the AWS default recovery window of 30 days (DeleteSecret).deleteSecret(String secretId, DeleteSecretOptions options) Schedules deletion afterrecoveryWindowDaysor deletes immediately withforceDeleteWithoutRecovery(DeleteSecret).deleteSecretAsync(String secretId, DeleteSecretOptions options) AsynchronousdeleteSecret(String, DeleteSecretOptions).describeSecret(String secretId) Reads the metadata of a secret (DescribeSecret), never the value.describeSecretAsync(String secretId) AsynchronousdescribeSecret(String).static AwsSecretsManagerClientfromEnv()Creates a client fromGROW_AWS_SECRETS_MANAGER_*and the standard AWS environment variables.Optional<com.fasterxml.jackson.databind.JsonNode> getJsonField(String secretId, String field) Reads one field of a JSON secret (AWSCURRENT).Optional<com.fasterxml.jackson.databind.JsonNode> getJsonField(String secretId, String field, GetSecretValueOptions options) Reads one field of a JSON secret:GetSecretValue, parseSecretStringas a JSON object, returnfield(an exact key first, otherwise a dot path).CompletableFuture<Optional<com.fasterxml.jackson.databind.JsonNode>> getJsonFieldAsync(String secretId, String field, GetSecretValueOptions options) AsynchronousgetJsonField(String, String, GetSecretValueOptions).Generates a 32-character random password (GetRandomPassword).getRandomPassword(RandomPasswordOptions options) Generates a random password (GetRandomPassword).AsynchronousgetRandomPassword(RandomPasswordOptions).getResourcePolicy(String secretId) Reads the resource policy (GetResourcePolicy).getResourcePolicyAsync(String secretId) AsynchronousgetResourcePolicy(String).getSecretValue(String secretId) Reads theAWSCURRENTvalue of a secret (GetSecretValue).getSecretValue(String secretId, GetSecretValueOptions options) Reads a secret value (GetSecretValue) by version id or stage label.getSecretValueAsync(String secretId) AsynchronousgetSecretValue(String).getSecretValueAsync(String secretId, GetSecretValueOptions options) AsynchronousgetSecretValue(String, GetSecretValueOptions).health()Liveness: a signedListSecrets {MaxResults: 1}with a short timeout (at most 5 s) and no retries.Asynchronoushealth().booleanisClosed()Returns whetherclose()was called.Lists every secret (ListSecrets) lazily across all pages.listSecrets(ListSecretsOptions options) Lists secrets (ListSecrets) lazily across all pages: iterate it, or callPaginator.toList().listSecretsAsync(ListSecretsOptions options) AsynchronouslistSecrets(ListSecretsOptions): collects every page.listSecretVersionIds(String secretId) Lists the versions of a secret (ListSecretVersionIds) lazily across all pages.listSecretVersionIds(String secretId, ListSecretVersionIdsOptions options) Lists the versions of a secret (ListSecretVersionIds) lazily across all pages.listSecretVersionIdsAsync(String secretId, ListSecretVersionIdsOptions options) AsynchronouslistSecretVersionIds(String, ListSecretVersionIdsOptions): collects every page.ping()Authenticated round trip (ListSecrets {MaxResults: 1}).Asynchronousping().putResourcePolicy(String secretId, Object policy) Attaches a resource policy (PutResourcePolicy).putResourcePolicy(String secretId, Object policy, PutResourcePolicyOptions options) Attaches a resource policy (PutResourcePolicy).putResourcePolicyAsync(String secretId, Object policy, PutResourcePolicyOptions options) putSecretValue(String secretId, Object value) Stores a new version that becomesAWSCURRENT(PutSecretValue); the old current version becomesAWSPREVIOUS.putSecretValue(String secretId, Object value, PutSecretValueOptions options) Stores a new version (PutSecretValue); with customversionStagesonly those labels are attached.putSecretValueAsync(String secretId, Object value, PutSecretValueOptions options) AsynchronousputSecretValue(String, Object, PutSecretValueOptions).voidregister(AutoCloseable resource) Registers a resource (watcher, cache) closed with the client.restoreSecret(String secretId) Cancels a scheduled deletion (RestoreSecret); a no-op for a live secret.restoreSecretAsync(String secretId) AsynchronousrestoreSecret(String).rotateSecret(String secretId, RotateSecretOptions options) Configures and/or starts rotation (RotateSecret).rotateSecretAsync(String secretId, RotateSecretOptions options) AsynchronousrotateSecret(String, RotateSecretOptions).software.amazon.awssdk.services.secretsmanager.SecretsManagerClientsdk()Returns the underlying AWS SDK client (escape hatch for operations not wrapped here).Returns a version-stage aware cache with the AWS caching-client semantics (TTL 1 h, 1 024 entries).secretCache(AwsSecretCache.Options options) Returns a version-stage aware cache with options.secrets()Returns theSecretsProviderview (SPEC section 3) of this client.secrets(AwsSecretsManagerSecretsOptions options) Returns theSecretsProviderview with options.Always throws: AWS Secrets Manager exposes no server version (the API contract date is the constantAPI_VERSION).AsynchronousserverVersion()(always fails withUnsupportedException).voidtagResource(String secretId, Map<String, String> tags) Adds or replaces tags (TagResource).tagResourceAsync(String secretId, Map<String, String> tags) AsynchronoustagResource(String, Map).toString()voiduntagResource(String secretId, List<String> tagKeys) Removes tags by key (UntagResource).untagResourceAsync(String secretId, List<String> tagKeys) AsynchronousuntagResource(String, List).updateSecret(String secretId, UpdateSecretOptions options) Updates description, KMS key and/or value (UpdateSecret); a new version is created only when a value is given.updateSecretAsync(String secretId, UpdateSecretOptions options) AsynchronousupdateSecret(String, UpdateSecretOptions).updateSecretVersionStage(String secretId, String versionStage, UpdateSecretVersionStageOptions options) Moves a stage label between versions (UpdateSecretVersionStage).updateSecretVersionStageAsync(String secretId, String versionStage, UpdateSecretVersionStageOptions options) validateResourcePolicy(Object policy) Checks a policy with IAM Access Analyzer (ValidateResourcePolicy).validateResourcePolicy(Object policy, ValidateResourcePolicyOptions options) Checks a policy with IAM Access Analyzer (ValidateResourcePolicy).validateResourcePolicyAsync(Object policy, ValidateResourcePolicyOptions options) static AwsSecretsManagerClientwithSdkClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient sdkClient) Wraps an existing AWS SDK client;close()leaves it open.
-
Field Details
-
API_VERSION
AWS Secrets Manager API version (the API contract date; AWS exposes no server version).- See Also:
-
AWSCURRENT
Default version stage.- See Also:
-
AWSPREVIOUS
Stage of the previous current version.- See Also:
-
AWSPENDING
Stage of a version being rotated in.- See Also:
-
BATCH_GET_MAX_IDS
public static final int BATCH_GET_MAX_IDSMaximum ids perBatchGetSecretValuecall; longer id lists are split.- See Also:
-
-
Method Details
-
create
Creates a client.- Parameters:
config- validated configuration- Returns:
- a new client
- Throws:
ConfigException- when the configuration is invalid or no region can be resolved
-
fromEnv
Creates a client fromGROW_AWS_SECRETS_MANAGER_*and the standard AWS environment variables.- Returns:
- a new client
-
withSdkClient
public static AwsSecretsManagerClient withSdkClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient sdkClient) Wraps an existing AWS SDK client;close()leaves it open.- Parameters:
sdkClient- the client- Returns:
- a new client
-
builder
Starts a client builder.- Returns:
- a new builder
-
config
Returns the configuration.- Returns:
- the configuration
-
sdk
public software.amazon.awssdk.services.secretsmanager.SecretsManagerClient sdk()Returns the underlying AWS SDK client (escape hatch for operations not wrapped here).- Returns:
- the SDK client
-
register
Registers a resource (watcher, cache) closed with the client.- Parameters:
resource- the resource
-
health
Liveness: a signedListSecrets {MaxResults: 1}with a short timeout (at most 5 s) and no retries.okwhen AWS answers (also when the credentials are rejected:details.auth = "failed"),degradedwhen throttled,unhealthyon HTTP 5xx,unreachableon network errors.- Returns:
- the health status
- Throws:
CancelledException- when interrupted or when the client is closed
-
healthAsync
Asynchronoushealth().- Returns:
- a future with the health status
-
ping
Authenticated round trip (ListSecrets {MaxResults: 1}).- Returns:
- the latency
- Throws:
AuthenticationException- for unknown keys or bad signaturesPermissionDeniedException- when the principal may not callsecretsmanager:ListSecrets
-
pingAsync
Asynchronousping().- Returns:
- a future with the latency
-
serverVersion
Always throws: AWS Secrets Manager exposes no server version (the API contract date is the constantAPI_VERSION).- Returns:
- never returns
- Throws:
UnsupportedException- always
-
serverVersionAsync
AsynchronousserverVersion()(always fails withUnsupportedException).- Returns:
- a failed future
-
isClosed
public boolean isClosed()Returns whetherclose()was called.- Returns:
- true once closed
-
close
public void close()Stops the watchers of every provider created bysecrets(), closes registered resources and the SDK client this instance built (never a caller-supplied one). Idempotent; later calls fail withCancelledException.- Specified by:
closein interfaceAutoCloseable
-
secrets
Returns theSecretsProviderview (SPEC section 3) of this client.close()of the client stops its watchers.- Returns:
- a new provider
-
secrets
Returns theSecretsProviderview with options.- Parameters:
options- provider options- Returns:
- a new provider
-
secretCache
Returns a version-stage aware cache with the AWS caching-client semantics (TTL 1 h, 1 024 entries).- Returns:
- a new cache
-
secretCache
Returns a version-stage aware cache with options.- Parameters:
options- cache options- Returns:
- a new cache
-
getSecretValue
Reads theAWSCURRENTvalue of a secret (GetSecretValue).- Parameters:
secretId- name or ARN- Returns:
- the value
- Throws:
NotFoundException- when the secret does not exist or has no valueConflictException- when the secret is scheduled for deletion
-
getSecretValue
Reads a secret value (GetSecretValue) by version id or stage label.- Parameters:
secretId- name or ARNoptions- version selection- Returns:
- the value
- Throws:
NotFoundException- when the secret, version or stage does not existConflictException- when the secret is scheduled for deletion
-
getSecretValueAsync
AsynchronousgetSecretValue(String).- Parameters:
secretId- name or ARN- Returns:
- a future with the value
-
getSecretValueAsync
public CompletableFuture<AwsSecretValue> getSecretValueAsync(String secretId, GetSecretValueOptions options) AsynchronousgetSecretValue(String, GetSecretValueOptions).- Parameters:
secretId- name or ARNoptions- version selection- Returns:
- a future with the value
-
batchGetSecretValue
Reads many secrets by id (BatchGetSecretValue); lists longer than 20 ids are split and the values come back in request order. Per-secret failures are returned inerrors.- Parameters:
ids- names or ARNs- Returns:
- the values and per-secret errors
-
batchGetSecretValue
Reads many secrets (BatchGetSecretValue) by ids or by filters with the default page size.- Parameters:
selector- ids or filters- Returns:
- the values and per-secret errors
-
batchGetSecretValue
Reads many secrets (BatchGetSecretValue) by ids or by filters (every page is read).- Parameters:
selector- ids or filtersoptions- page size of the filter form- Returns:
- the values and per-secret errors
- Throws:
ValidationException- when both or neither ids and filters are given
-
batchGetSecretValueAsync
AsynchronousbatchGetSecretValue(List).- Parameters:
ids- names or ARNs- Returns:
- a future with the result
-
batchGetSecretValueAsync
public CompletableFuture<BatchGetResult> batchGetSecretValueAsync(BatchGetSelector selector, BatchGetOptions options) AsynchronousbatchGetSecretValue(BatchGetSelector, BatchGetOptions).- Parameters:
selector- ids or filtersoptions- page size- Returns:
- a future with the result
-
describeSecret
Reads the metadata of a secret (DescribeSecret), never the value.- Parameters:
secretId- name or ARN- Returns:
- the metadata
- Throws:
NotFoundException- when the secret does not exist
-
describeSecretAsync
AsynchronousdescribeSecret(String).- Parameters:
secretId- name or ARN- Returns:
- a future with the metadata
-
listSecrets
Lists every secret (ListSecrets) lazily across all pages.- Returns:
- a paginator
-
listSecrets
Lists secrets (ListSecrets) lazily across all pages: iterate it, or callPaginator.toList().- Parameters:
options- filters, planned deletions, sort order, page size- Returns:
- a paginator
-
listSecretsAsync
AsynchronouslistSecrets(ListSecretsOptions): collects every page.- Parameters:
options- list options- Returns:
- a future with every secret
-
listSecretVersionIds
Lists the versions of a secret (ListSecretVersionIds) lazily across all pages.- Parameters:
secretId- name or ARN- Returns:
- a paginator
-
listSecretVersionIds
public Paginator<SecretVersion> listSecretVersionIds(String secretId, ListSecretVersionIdsOptions options) Lists the versions of a secret (ListSecretVersionIds) lazily across all pages.- Parameters:
secretId- name or ARNoptions- deprecated versions, page size- Returns:
- a paginator
-
listSecretVersionIdsAsync
public CompletableFuture<List<SecretVersion>> listSecretVersionIdsAsync(String secretId, ListSecretVersionIdsOptions options) AsynchronouslistSecretVersionIds(String, ListSecretVersionIdsOptions): collects every page.- Parameters:
secretId- name or ARNoptions- list options- Returns:
- a future with every version
-
createSecret
Creates a secret (CreateSecret).- Parameters:
name- secret namevalue-String→SecretString,byte[]→SecretBinary, other objects → JSONSecretString,null→ a secret without a version- Returns:
- ARN, name and the new version id
- Throws:
ConflictException- when the name exists or is scheduled for deletion
-
createSecret
Creates a secret (CreateSecret) with description, KMS key, tags, idempotency token or replica regions.- Parameters:
name- secret namevalue- the value, ornullfor a secret without a versionoptions- create options- Returns:
- ARN, name and the new version id
- Throws:
ConflictException- when the name exists or is scheduled for deletion
-
createSecretAsync
public CompletableFuture<SecretWriteResult> createSecretAsync(String name, Object value, CreateSecretOptions options) AsynchronouscreateSecret(String, Object, CreateSecretOptions).- Parameters:
name- secret namevalue- the valueoptions- create options- Returns:
- a future with the result
-
putSecretValue
Stores a new version that becomesAWSCURRENT(PutSecretValue); the old current version becomesAWSPREVIOUS.- Parameters:
secretId- name or ARNvalue- the value (seecreateSecret(String, Object))- Returns:
- the new version
- Throws:
NotFoundException- when the secret does not exist
-
putSecretValue
public PutSecretValueResult putSecretValue(String secretId, Object value, PutSecretValueOptions options) Stores a new version (PutSecretValue); with customversionStagesonly those labels are attached.- Parameters:
secretId- name or ARNvalue- the valueoptions- stages and idempotency token- Returns:
- the new version
- Throws:
NotFoundException- when the secret does not existConflictException- when the token was used with a different value
-
putSecretValueAsync
public CompletableFuture<PutSecretValueResult> putSecretValueAsync(String secretId, Object value, PutSecretValueOptions options) AsynchronousputSecretValue(String, Object, PutSecretValueOptions).- Parameters:
secretId- name or ARNvalue- the valueoptions- put options- Returns:
- a future with the new version
-
updateSecret
Updates description, KMS key and/or value (UpdateSecret); a new version is created only when a value is given.- Parameters:
secretId- name or ARNoptions- what to change- Returns:
- ARN, name and the new version id (absent without a value)
- Throws:
NotFoundException- when the secret does not exist
-
updateSecretAsync
public CompletableFuture<SecretWriteResult> updateSecretAsync(String secretId, UpdateSecretOptions options) AsynchronousupdateSecret(String, UpdateSecretOptions).- Parameters:
secretId- name or ARNoptions- what to change- Returns:
- a future with the result
-
updateSecretVersionStage
public SecretRef updateSecretVersionStage(String secretId, String versionStage, UpdateSecretVersionStageOptions options) Moves a stage label between versions (UpdateSecretVersionStage). MovingAWSCURRENTneedsremoveFromVersionId= the current version; the old current version getsAWSPREVIOUS.- Parameters:
secretId- name or ARNversionStage- the labeloptions- source and/or target version (at least one)- Returns:
- ARN and name
- Throws:
ValidationException- when neither version is given or AWS rejects the move
-
updateSecretVersionStageAsync
public CompletableFuture<SecretRef> updateSecretVersionStageAsync(String secretId, String versionStage, UpdateSecretVersionStageOptions options) - Parameters:
secretId- name or ARNversionStage- the labeloptions- versions- Returns:
- a future with ARN and name
-
deleteSecret
Schedules deletion with the AWS default recovery window of 30 days (DeleteSecret).- Parameters:
secretId- name or ARN- Returns:
- ARN, name and deletion date
- Throws:
NotFoundException- when the secret does not exist
-
deleteSecret
Schedules deletion afterrecoveryWindowDaysor deletes immediately withforceDeleteWithoutRecovery(DeleteSecret). AWS answers success for a forced delete of a secret that does not exist.- Parameters:
secretId- name or ARNoptions- recovery window or force (never both)- Returns:
- ARN, name and deletion date
- Throws:
ValidationException- when both options are given or the window is outside 7–30
-
deleteSecretAsync
public CompletableFuture<DeleteSecretResult> deleteSecretAsync(String secretId, DeleteSecretOptions options) AsynchronousdeleteSecret(String, DeleteSecretOptions).- Parameters:
secretId- name or ARNoptions- delete options- Returns:
- a future with the result
-
restoreSecret
Cancels a scheduled deletion (RestoreSecret); a no-op for a live secret.- Parameters:
secretId- name or ARN- Returns:
- ARN and name
- Throws:
NotFoundException- when the secret does not exist
-
restoreSecretAsync
AsynchronousrestoreSecret(String).- Parameters:
secretId- name or ARN- Returns:
- a future with ARN and name
-
tagResource
Adds or replaces tags (TagResource).- Parameters:
secretId- name or ARNtags- tags to set- Throws:
NotFoundException- when the secret does not exist
-
tagResourceAsync
AsynchronoustagResource(String, Map).- Parameters:
secretId- name or ARNtags- tags- Returns:
- a future completed when done
-
untagResource
Removes tags by key (UntagResource).- Parameters:
secretId- name or ARNtagKeys- keys to remove- Throws:
NotFoundException- when the secret does not exist
-
untagResourceAsync
AsynchronousuntagResource(String, List).- Parameters:
secretId- name or ARNtagKeys- keys- Returns:
- a future completed when done
-
putResourcePolicy
Attaches a resource policy (PutResourcePolicy).- Parameters:
secretId- name or ARNpolicy- JSON text, or an object that is JSON-encoded- Returns:
- ARN and name
- Throws:
NotFoundException- when the secret does not exist
-
putResourcePolicy
public SecretRef putResourcePolicy(String secretId, Object policy, PutResourcePolicyOptions options) Attaches a resource policy (PutResourcePolicy).- Parameters:
secretId- name or ARNpolicy- JSON text, or an object that is JSON-encodedoptions- public-policy check- Returns:
- ARN and name
- Throws:
NotFoundException- when the secret does not exist
-
putResourcePolicyAsync
public CompletableFuture<SecretRef> putResourcePolicyAsync(String secretId, Object policy, PutResourcePolicyOptions options) - Parameters:
secretId- name or ARNpolicy- the policyoptions- options- Returns:
- a future with ARN and name
-
getResourcePolicy
Reads the resource policy (GetResourcePolicy).- Parameters:
secretId- name or ARN- Returns:
- the policy text and parsed object (
nullwhen there is none) - Throws:
NotFoundException- when the secret does not exist
-
getResourcePolicyAsync
AsynchronousgetResourcePolicy(String).- Parameters:
secretId- name or ARN- Returns:
- a future with the policy
-
deleteResourcePolicy
Removes the resource policy (DeleteResourcePolicy).- Parameters:
secretId- name or ARN- Returns:
- ARN and name
- Throws:
NotFoundException- when the secret does not exist
-
deleteResourcePolicyAsync
AsynchronousdeleteResourcePolicy(String).- Parameters:
secretId- name or ARN- Returns:
- a future with ARN and name
-
validateResourcePolicy
Checks a policy with IAM Access Analyzer (ValidateResourcePolicy).- Parameters:
policy- JSON text or an object- Returns:
- whether it passed and the problems found
- Throws:
UnsupportedException- on emulators that lack the operation (Moto 5.2.4)
-
validateResourcePolicy
public ValidateResourcePolicyResult validateResourcePolicy(Object policy, ValidateResourcePolicyOptions options) Checks a policy with IAM Access Analyzer (ValidateResourcePolicy).- Parameters:
policy- JSON text or an objectoptions- the secret the policy would be attached to- Returns:
- whether it passed and the problems found
- Throws:
UnsupportedException- on emulators that lack the operation (Moto 5.2.4)
-
validateResourcePolicyAsync
public CompletableFuture<ValidateResourcePolicyResult> validateResourcePolicyAsync(Object policy, ValidateResourcePolicyOptions options) - Parameters:
policy- the policyoptions- options- Returns:
- a future with the result
-
rotateSecret
Configures and/or starts rotation (RotateSecret). WithoutlambdaArnthe secret's managed or existing rotation function is used.- Parameters:
secretId- name or ARNoptions- Lambda, schedule, immediacy, idempotency token- Returns:
- ARN, name and the new version id
- Throws:
NotFoundException- when the secret (or the Lambda) does not existConflictException- when a rotation is already in progress
-
rotateSecretAsync
public CompletableFuture<SecretWriteResult> rotateSecretAsync(String secretId, RotateSecretOptions options) AsynchronousrotateSecret(String, RotateSecretOptions).- Parameters:
secretId- name or ARNoptions- rotation options- Returns:
- a future with the result
-
cancelRotateSecret
Turns rotation off and cancels a rotation in progress (CancelRotateSecret).- Parameters:
secretId- name or ARN- Returns:
- ARN, name and the version id of the cancelled rotation
- Throws:
NotFoundException- when the secret does not exist
-
cancelRotateSecretAsync
AsynchronouscancelRotateSecret(String).- Parameters:
secretId- name or ARN- Returns:
- a future with the result
-
getRandomPassword
Generates a 32-character random password (GetRandomPassword).- Returns:
- the password as a redacting
Secret
-
getRandomPassword
Generates a random password (GetRandomPassword).- Parameters:
options- length and character classes- Returns:
- the password as a redacting
Secret - Throws:
ValidationException- when the options cannot be satisfied
-
getRandomPasswordAsync
AsynchronousgetRandomPassword(RandomPasswordOptions).- Parameters:
options- password options- Returns:
- a future with the password
-
getJsonField
public Optional<com.fasterxml.jackson.databind.JsonNode> getJsonField(String secretId, String field) Reads one field of a JSON secret (AWSCURRENT).- Parameters:
secretId- name or ARNfield- exact key, or a dot path such asdb.host- Returns:
- the field, or empty when absent or JSON
null - Throws:
ValidationException- when the value is binary or not a JSON objectNotFoundException- when the secret does not exist
-
getJsonField
public Optional<com.fasterxml.jackson.databind.JsonNode> getJsonField(String secretId, String field, GetSecretValueOptions options) Reads one field of a JSON secret:GetSecretValue, parseSecretStringas a JSON object, returnfield(an exact key first, otherwise a dot path).- Parameters:
secretId- name or ARNfield- exact key or dot pathoptions- version selection- Returns:
- the field, or empty when absent or JSON
null - Throws:
ValidationException- when the value is binary or not a JSON objectNotFoundException- when the secret does not exist
-
getJsonFieldAsync
public CompletableFuture<Optional<com.fasterxml.jackson.databind.JsonNode>> getJsonFieldAsync(String secretId, String field, GetSecretValueOptions options) AsynchronousgetJsonField(String, String, GetSecretValueOptions).- Parameters:
secretId- name or ARNfield- exact key or dot pathoptions- version selection- Returns:
- a future with the field
-
toString
-