Search in sources :

Example 1 with DeleteItemEnhancedRequest

use of software.amazon.awssdk.enhanced.dynamodb.model.DeleteItemEnhancedRequest in project aws-sdk-java-v2 by aws.

the class DeleteItemOperation method generateRequest.

@Override
public DeleteItemRequest generateRequest(TableSchema<T> tableSchema, OperationContext operationContext, DynamoDbEnhancedClientExtension extension) {
    if (!TableMetadata.primaryIndexName().equals(operationContext.indexName())) {
        throw new IllegalArgumentException("DeleteItem cannot be executed against a secondary index.");
    }
    Key key = request.map(DeleteItemEnhancedRequest::key, TransactDeleteItemEnhancedRequest::key);
    DeleteItemRequest.Builder requestBuilder = DeleteItemRequest.builder().tableName(operationContext.tableName()).key(key.keyMap(tableSchema, operationContext.indexName())).returnValues(ReturnValue.ALL_OLD);
    if (request.left().isPresent()) {
        requestBuilder = addPlainDeleteItemParameters(requestBuilder, request.left().get());
    }
    requestBuilder = addExpressionsIfExist(requestBuilder);
    return requestBuilder.build();
}
Also used : TransactDeleteItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.TransactDeleteItemEnhancedRequest) TransactDeleteItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.TransactDeleteItemEnhancedRequest) DeleteItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.DeleteItemEnhancedRequest) DeleteItemRequest(software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest) Key(software.amazon.awssdk.enhanced.dynamodb.Key)

Aggregations

Key (software.amazon.awssdk.enhanced.dynamodb.Key)1 DeleteItemEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.DeleteItemEnhancedRequest)1 TransactDeleteItemEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.TransactDeleteItemEnhancedRequest)1 DeleteItemRequest (software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest)1