Interface DynamoDbEnhancedClient
-
- All Superinterfaces:
DynamoDbEnhancedResource
- All Known Implementing Classes:
DefaultDynamoDbEnhancedClient
@ThreadSafe @Immutable public interface DynamoDbEnhancedClient extends DynamoDbEnhancedResource
Synchronous interface for running commands against a DynamoDb database.By default, all command methods throw an
UnsupportedOperationExceptionto prevent interface extensions from breaking implementing classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDynamoDbEnhancedClient.BuilderThe builder definition for aDynamoDbEnhancedClient.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BatchGetResultPageIterablebatchGetItem(Consumer<BatchGetItemEnhancedRequest.Builder> requestConsumer)Retrieves items from one or more tables by their primary keys, seeKey.default BatchGetResultPageIterablebatchGetItem(BatchGetItemEnhancedRequest request)Retrieves items from one or more tables by their primary keys, seeKey.default BatchWriteResultbatchWriteItem(Consumer<BatchWriteItemEnhancedRequest.Builder> requestConsumer)Puts and/or deletes multiple items in one or more tables.default BatchWriteResultbatchWriteItem(BatchWriteItemEnhancedRequest request)Puts and/or deletes multiple items in one or more tables.static DynamoDbEnhancedClient.Builderbuilder()Creates a default builder forDynamoDbEnhancedClient.static DynamoDbEnhancedClientcreate()Creates aDynamoDbEnhancedClientwith a defaultDynamoDbClient<T> DynamoDbTable<T>table(String tableName, TableSchema<T> tableSchema)Returns a mapped table that can be used to execute commands that work with mapped items against that table.default List<Document>transactGetItems(Consumer<TransactGetItemsEnhancedRequest.Builder> requestConsumer)Retrieves multiple items from one or more tables in a single atomic transaction.default List<Document>transactGetItems(TransactGetItemsEnhancedRequest request)Retrieves multiple items from one or more tables in a single atomic transaction.default VoidtransactWriteItems(Consumer<TransactWriteItemsEnhancedRequest.Builder> requestConsumer)Writes and/or modifies multiple items from one or more tables in a single atomic transaction.default VoidtransactWriteItems(TransactWriteItemsEnhancedRequest request)Writes and/or modifies multiple items from one or more tables in a single atomic transaction.default TransactWriteItemsEnhancedResponsetransactWriteItemsWithResponse(Consumer<TransactWriteItemsEnhancedRequest.Builder> requestConsumer)Writes and/or modifies multiple items from one or more tables in a single atomic transaction.default TransactWriteItemsEnhancedResponsetransactWriteItemsWithResponse(TransactWriteItemsEnhancedRequest request)Writes and/or modifies multiple items from one or more tables in a single atomic transaction.
-
-
-
Method Detail
-
table
<T> DynamoDbTable<T> table(String tableName, TableSchema<T> tableSchema)
Returns a mapped table that can be used to execute commands that work with mapped items against that table.- Type Parameters:
T- The modelled object type being mapped to this table.- Parameters:
tableName- The name of the physical table persisted by DynamoDb.tableSchema- ATableSchemathat maps the table to a modelled object.- Returns:
- A
DynamoDbTableobject that can be used to execute table operations against.
-
batchGetItem
default BatchGetResultPageIterable batchGetItem(BatchGetItemEnhancedRequest request)
Retrieves items from one or more tables by their primary keys, seeKey. BatchGetItem is a composite operation where the request contains one batch ofGetItemEnhancedRequestper targeted table. The operation makes several calls to the database; each time you iterate over the result to retrieve a page, a call is made for the items on that page.The additional configuration parameters that the enhanced client supports are defined in the
BatchGetItemEnhancedRequest.Partial results. A single call to DynamoDb has restraints on how much data can be retrieved. If those limits are exceeded, the call yields a partial result. This may also be the case if provisional throughput is exceeded or there is an internal DynamoDb processing failure. The operation automatically retries any unprocessed keys returned from DynamoDb in subsequent calls for pages.
This operation calls the low-level
DynamoDbClient.batchGetItemPaginator(software.amazon.awssdk.services.dynamodb.model.BatchGetItemRequest)operation. Consult the BatchGetItem documentation for further details and constraints as well as current limits of data retrieval.Example:
BatchGetResultPageIterable batchResults = enhancedClient.batchGetItem( BatchGetItemEnhancedRequest.builder() .readBatches(ReadBatch.builder(FirstItem.class) .mappedTableResource(firstItemTable) .addGetItem(GetItemEnhancedRequest.builder().key(key1).build()) .addGetItem(GetItemEnhancedRequest.builder().key(key2).build()) .build(), ReadBatch.builder(SecondItem.class) .mappedTableResource(secondItemTable) .addGetItem(GetItemEnhancedRequest.builder().key(key3).build()) .build()) .build());The result can be accessed either through iterable
BatchGetResultPages or flattened results belonging to the supplied table across all pages.1) Iterating through pages
batchResults.forEach(page -> { page.resultsForTable(firstItemTable).forEach(item -> System.out.println(item)); page.resultsForTable(secondItemTable).forEach(item -> System.out.println(item)); });2) Iterating through results across all pages
results.resultsForTable(firstItemTable).forEach(item -> System.out.println(item)); results.resultsForTable(secondItemTable).forEach(item -> System.out.println(item));- Parameters:
request- ABatchGetItemEnhancedRequestcontaining keys grouped by tables.- Returns:
- an iterator of type
SdkIterablewith paginated results of typeBatchGetResultPage. - See Also:
batchGetItem(Consumer),DynamoDbClient.batchGetItemPaginator(software.amazon.awssdk.services.dynamodb.model.BatchGetItemRequest)
-
batchGetItem
default BatchGetResultPageIterable batchGetItem(Consumer<BatchGetItemEnhancedRequest.Builder> requestConsumer)
Retrieves items from one or more tables by their primary keys, seeKey. BatchGetItem is a composite operation where the request contains one batch ofGetItemEnhancedRequestper targeted table. The operation makes several calls to the database; each time you iterate over the result to retrieve a page, a call is made for the items on that page.Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
BatchGetItemEnhancedRequest.builder().Example:
BatchGetResultPageIterable batchResults = enhancedClient.batchGetItem(r -> r.addReadBatches( ReadBatch.builder(FirstItem.class) .mappedTableResource(firstItemTable) .addGetItem(i -> i.key(key1)) .addGetItem(i -> i.key(key2)) .build(), ReadBatch.builder(SecondItem.class) .mappedTableResource(secondItemTable) .addGetItem(i -> i.key(key3)) .build()));- Parameters:
requestConsumer- aConsumerofBatchGetItemEnhancedRequest.Buildercontaining keys grouped by tables.- Returns:
- an iterator of type
SdkIterablewith paginated results of typeBatchGetResultPage. - See Also:
batchGetItem(BatchGetItemEnhancedRequest),DynamoDbClient.batchGetItemPaginator(BatchGetItemRequest)
-
batchWriteItem
default BatchWriteResult batchWriteItem(BatchWriteItemEnhancedRequest request)
Puts and/or deletes multiple items in one or more tables. BatchWriteItem is a composite operation where the request contains one batch of (a mix of)PutItemEnhancedRequestandDeleteItemEnhancedRequestper targeted table.The additional configuration parameters that the enhanced client supports are defined in the
BatchWriteItemEnhancedRequest.A single call to BatchWriteItem has the same limit of items as the low-level DynamoDB API BatchWriteItem operation, considering all items across all WriteBatches.
Note: BatchWriteItem cannot update items. Instead, use the individual updateItem operation
DynamoDbTable.updateItem(UpdateItemEnhancedRequest).Partial updates
Each delete or put call is atomic, but the operation as a whole is not. If individual operations fail due to exceeded provisional throughput internal DynamoDb processing failures, the failed requests can be retrieved through the result, seeBatchWriteResult.There are some conditions that cause the whole batch operation to fail. These include non-existing tables, erroneously defined primary key attributes, attempting to put and delete the same item as well as referring more than once to the same hash and range (sort) key.
This operation calls the low-level DynamoDB API BatchWriteItem operation. Consult the BatchWriteItem documentation for further details and constraints, current limits of data to write and/or delete, how to handle partial updates and retries and under which conditions the operation will fail.
Example:
BatchWriteResult batchResult = enhancedClient.batchWriteItem( BatchWriteItemEnhancedRequest.builder() .writeBatches(WriteBatch.builder(FirstItem.class) .mappedTableResource(firstItemTable) .addPutItem(PutItemEnhancedRequest.builder().item(item1).build()) .addDeleteItem(DeleteItemEnhancedRequest.builder() .key(key2) .build()) .build(), WriteBatch.builder(SecondItem.class) .mappedTableResource(secondItemTable) .addPutItem(PutItemEnhancedRequest.builder().item(item3).build()) .build()) .build());- Parameters:
request- ABatchWriteItemEnhancedRequestcontaining keys and items grouped by tables.- Returns:
- a
BatchWriteResultcontaining any unprocessed requests.
-
batchWriteItem
default BatchWriteResult batchWriteItem(Consumer<BatchWriteItemEnhancedRequest.Builder> requestConsumer)
Puts and/or deletes multiple items in one or more tables. BatchWriteItem is a composite operation where the request contains one batch of (a mix of)PutItemEnhancedRequestandDeleteItemEnhancedRequestper targeted table.The additional configuration parameters that the enhanced client supports are defined in the
BatchWriteItemEnhancedRequest.A single call to BatchWriteItem has the same limit of items as the low-level DynamoDB API BatchWriteItem operation, considering all items across all WriteBatches.
Note: BatchWriteItem cannot update items. Instead, use the individual updateItem operation
DynamoDbTable.updateItem(UpdateItemEnhancedRequest).Partial updates
Each delete or put call is atomic, but the operation as a whole is not. If individual operations fail due to exceeded provisional throughput internal DynamoDb processing failures, the failed requests can be retrieved through the result, seeBatchWriteResult.There are some conditions that cause the whole batch operation to fail. These include non-existing tables, erroneously defined primary key attributes, attempting to put and delete the same item as well as referring more than once to the same hash and range (sort) key.
This operation calls the low-level DynamoDB API BatchWriteItem operation. Consult the BatchWriteItem documentation for further details and constraints, current limits of data to write and/or delete, how to handle partial updates and retries and under which conditions the operation will fail.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
BatchWriteItemEnhancedRequest.builder().Example:
BatchWriteResult batchResult = enhancedClient.batchWriteItem(r -> r.writeBatches( WriteBatch.builder(FirstItem.class) .mappedTableResource(firstItemTable) .addPutItem(i -> i.item(item1)) .addDeleteItem(i -> i.key(key2)) .build(), WriteBatch.builder(SecondItem.class) .mappedTableResource(secondItemTable) .addPutItem(i -> i.item(item3)) .build()));- Parameters:
requestConsumer- aConsumerofBatchWriteItemEnhancedRequestcontaining keys and items grouped by tables.- Returns:
- a
BatchWriteResultcontaining any unprocessed requests.
-
transactGetItems
default List<Document> transactGetItems(TransactGetItemsEnhancedRequest request)
Retrieves multiple items from one or more tables in a single atomic transaction. TransactGetItem is a composite operation where the request contains a set of get requests, each containing a table reference and aGetItemEnhancedRequest. The list of results correspond to the ordering of the request definitions; for example the third addGetItem() call on the request builder will match the third result (index 2) of the result.The additional configuration parameters that the enhanced client supports are defined in the
TransactGetItemsEnhancedRequest.DynamoDb will reject a call to TransactGetItems if the call exceeds limits such as provisioned throughput or allowed size of items, if the request contains errors or if there are conflicting operations accessing the same item, for instance updating and reading at the same time.
This operation calls the low-level DynamoDB API TransactGetItems operation. Consult the TransactGetItems documentation for further details and constraints.
Examples:
SeeList<TransactGetResultPage> results = enhancedClient.transactGetItems( TransactGetItemsEnhancedRequest.builder() .addGetItem(firstItemTable, GetItemEnhancedRequest.builder().key(key1).build()) .addGetItem(firstItemTable, GetItemEnhancedRequest.builder().key(key2).build()) .addGetItem(firstItemTable, GetItemEnhancedRequest.builder().key(key3).build()) .addGetItem(secondItemTable, GetItemEnhancedRequest.builder().key(key4).build()) .build()); MyItem item = results.get(3).getItem(secondItemTable);DynamoDbClient.transactGetItems(Consumer)to learn more aboutTransactGetItems.- Parameters:
request- ATransactGetItemsEnhancedRequestcontaining keys with table references.- Returns:
- a list of
Documentwith the results.
-
transactGetItems
default List<Document> transactGetItems(Consumer<TransactGetItemsEnhancedRequest.Builder> requestConsumer)
Retrieves multiple items from one or more tables in a single atomic transaction. TransactGetItem is a composite operation where the request contains a set of get requests, each containing a table reference and aGetItemEnhancedRequest. The list of results correspond to the ordering of the request definitions; for example the third addGetItem() call on the request builder will match the third result (index 2) of the result.The additional configuration parameters that the enhanced client supports are defined in the
TransactGetItemsEnhancedRequest.DynamoDb will reject a call to TransactGetItems if the call exceeds limits such as provisioned throughput or allowed size of items, if the request contains errors or if there are conflicting operations accessing the same item, for instance updating and reading at the same time.
This operation calls the low-level DynamoDB API TransactGetItems operation. Consult the TransactGetItems documentation for further details and constraints.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
TransactGetItemsEnhancedRequest.builder().Examples:
List<TransactGetResultPage> results = enhancedClient.transactGetItems( r -> r.addGetItem(firstItemTable, i -> i.key(k -> k.partitionValue(0))) .addGetItem(firstItemTable, i -> i.key(k -> k.partitionValue(1))) .addGetItem(firstItemTable, i -> i.key(k -> k.partitionValue(2))) .addGetItem(secondItemTable, i -> i.key(k -> k.partitionValue(0)))); MyItem item = results.get(3).getItem(secondItemTable);See
DynamoDbClient.transactGetItems(Consumer)to learn more aboutTransactGetItems.- Parameters:
requestConsumer- aConsumerofTransactGetItemsEnhancedRequestcontaining keys with table references.- Returns:
- a list of
Documentwith the results.
-
transactWriteItems
default Void transactWriteItems(TransactWriteItemsEnhancedRequest request)
Writes and/or modifies multiple items from one or more tables in a single atomic transaction. TransactGetItem is a composite operation where the request contains a set of action requests, each containing a table reference and one of the following requests:- Condition check of item -
ConditionCheck - Delete item -
DeleteItemEnhancedRequest - Put item -
PutItemEnhancedRequest - Update item -
UpdateItemEnhancedRequest
The additional configuration parameters that the enhanced client supports are defined in the
TransactWriteItemsEnhancedRequest.DynamoDb will reject a call to TransactWriteItems if the call exceeds limits such as provisioned throughput or allowed size of items, if the request contains errors or if there are conflicting operations accessing the same item. If the request contains condition checks that aren't met, this will also cause rejection.
This operation calls the low-level DynamoDB API TransactWriteItems operation. Consult the TransactWriteItems documentation for further details and constraints, current limits of data to write and/or delete and under which conditions the operation will fail.
Example:
Seeresult = enhancedClient.transactWriteItems( TransactWriteItemsEnhancedRequest.builder() .addPutItem(firstItemTable, PutItemEnhancedRequest.builder().item(item1).build()) .addDeleteItem(firstItemTable, DeleteItemEnhancedRequest.builder().key(key2).build()) .addConditionCheck(firstItemTable, ConditionCheck.builder() .key(key3) .conditionExpression(conditionExpression) .build()) .addUpdateItem(secondItemTable, UpdateItemEnhancedRequest.builder().item(item4).build()) .build());DynamoDbClient.transactWriteItems(Consumer)to learn more aboutTransactWriteItems.- Parameters:
request- ABatchWriteItemEnhancedRequestcontaining keys grouped by tables.
- Condition check of item -
-
transactWriteItems
default Void transactWriteItems(Consumer<TransactWriteItemsEnhancedRequest.Builder> requestConsumer)
Writes and/or modifies multiple items from one or more tables in a single atomic transaction. TransactGetItem is a composite operation where the request contains a set of action requests, each containing a table reference and one of the following requests:- Condition check of item -
ConditionCheck - Delete item -
DeleteItemEnhancedRequest - Put item -
PutItemEnhancedRequest - Update item -
UpdateItemEnhancedRequest
The additional configuration parameters that the enhanced client supports are defined in the
TransactWriteItemsEnhancedRequest.DynamoDb will reject a call to TransactWriteItems if the call exceeds limits such as provisioned throughput or allowed size of items, if the request contains errors or if there are conflicting operations accessing the same item. If the request contains condition checks that aren't met, this will also cause rejection.
This operation calls the low-level DynamoDB API TransactWriteItems operation. Consult the TransactWriteItems documentation for further details and constraints, current limits of data to write and/or delete and under which conditions the operation will fail.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
TransactWriteItemsEnhancedRequest.builder().Example:
Seeresult = enhancedClient.transactWriteItems(r -> r.addPutItem(firstItemTable, i -> i.item(item1)) .addDeleteItem(firstItemTable, i -> i.key(k -> k.partitionValue(2))) .addConditionCheck(firstItemTable, i -> i.key(key3).conditionExpression(conditionExpression)) .addUpdateItem(secondItemTable, i -> i.item(item4)));DynamoDbClient.transactWriteItems(Consumer)to learn more aboutTransactWriteItems.- Parameters:
requestConsumer- aConsumerofTransactWriteItemsEnhancedRequestcontaining keys and items grouped by tables.
- Condition check of item -
-
transactWriteItemsWithResponse
default TransactWriteItemsEnhancedResponse transactWriteItemsWithResponse(TransactWriteItemsEnhancedRequest request)
Writes and/or modifies multiple items from one or more tables in a single atomic transaction. TransactWriteItems is a composite operation where the request contains a set of action requests, each containing a table reference and one of the following requests:- Condition check of item -
ConditionCheck - Delete item -
DeleteItemEnhancedRequest - Put item -
PutItemEnhancedRequest - Update item -
UpdateItemEnhancedRequest
The additional configuration parameters that the enhanced client supports are defined in the
TransactWriteItemsEnhancedRequest.DynamoDb will reject a call to TransactWriteItems if the call exceeds limits such as provisioned throughput or allowed size of items, if the request contains errors or if there are conflicting operations accessing the same item. If the request contains condition checks that aren't met, this will also cause rejection.
This operation calls the low-level DynamoDB API TransactWriteItems operation. Consult the TransactWriteItems documentation for further details and constraints, current limits of data to write and/or delete and under which conditions the operation will fail.
Example:
Seeresult = enhancedClient.transactWriteItemsWithResponse( TransactWriteItemsEnhancedRequest.builder() .addPutItem(firstItemTable, PutItemEnhancedRequest.builder().item(item1).build()) .addDeleteItem(firstItemTable, DeleteItemEnhancedRequest.builder().key(key2).build()) .addConditionCheck(firstItemTable, ConditionCheck.builder() .key(key3) .conditionExpression(conditionExpression) .build()) .addUpdateItem(secondItemTable, UpdateItemEnhancedRequest.builder().item(item4).build()) .build());DynamoDbClient.transactWriteItems(Consumer)to learn more aboutTransactWriteItems.- Parameters:
request- ABatchWriteItemEnhancedRequestcontaining keys grouped by tables.
- Condition check of item -
-
transactWriteItemsWithResponse
default TransactWriteItemsEnhancedResponse transactWriteItemsWithResponse(Consumer<TransactWriteItemsEnhancedRequest.Builder> requestConsumer)
Writes and/or modifies multiple items from one or more tables in a single atomic transaction. TransactWriteItem is a composite operation where the request contains a set of action requests, each containing a table reference and one of the following requests:- Condition check of item -
ConditionCheck - Delete item -
DeleteItemEnhancedRequest - Put item -
PutItemEnhancedRequest - Update item -
UpdateItemEnhancedRequest
The additional configuration parameters that the enhanced client supports are defined in the
TransactWriteItemsEnhancedRequest.DynamoDb will reject a call to TransactWriteItems if the call exceeds limits such as provisioned throughput or allowed size of items, if the request contains errors or if there are conflicting operations accessing the same item. If the request contains condition checks that aren't met, this will also cause rejection.
This operation calls the low-level DynamoDB API TransactWriteItems operation. Consult the TransactWriteItems documentation for further details and constraints, current limits of data to write and/or delete and under which conditions the operation will fail.
Note: This is a convenience method that creates an instance of the request builder avoiding the need to create one manually via
TransactWriteItemsEnhancedRequest.builder().Example:
Seeresult = enhancedClient.transactWriteItemsWithResponse(r -> r.addPutItem(firstItemTable, i -> i.item(item1)) .addDeleteItem(firstItemTable, i -> i.key(k -> k.partitionValue(2))) .addConditionCheck(firstItemTable, i -> i.key(key3).conditionExpression(conditionExpression)) .addUpdateItem(secondItemTable, i -> i.item(item4)));DynamoDbClient.transactWriteItems(Consumer)to learn more aboutTransactWriteItems.- Parameters:
requestConsumer- aConsumerofTransactWriteItemsEnhancedRequestcontaining keys and items grouped by tables.
- Condition check of item -
-
builder
static DynamoDbEnhancedClient.Builder builder()
Creates a default builder forDynamoDbEnhancedClient.
-
create
static DynamoDbEnhancedClient create()
Creates aDynamoDbEnhancedClientwith a defaultDynamoDbClient
-
-