.build()); DeleteItemRequest deleteReq = DeleteItemRequest.builder() .tableName(table_name) .key(key_to_get)
/** * Deletes an order. * @param orderId order id of order to delete * @return the deleted order */ public Order deleteOrder(final String orderId) { final DeleteItemResponse result; try { return Optional.ofNullable(dynamoDb.deleteItem(DeleteItemRequest.builder() .tableName(tableName) .key(Collections.singletonMap(ORDER_ID, AttributeValue.builder().s(orderId).build())) .conditionExpression("attribute_exists(orderId)") .returnValues(ReturnValue.ALL_OLD) .build())) .map(DeleteItemResponse::attributes) .map(this::convert) .orElseThrow(() -> new IllegalStateException( "Condition passed but deleted item was null")); } catch (ConditionalCheckFailedException e) { throw new UnableToDeleteException( "A competing request changed the order while processing this request"); } catch (ResourceNotFoundException e) { throw new TableDoesNotExistException("Order table " + tableName + " does not exist and was deleted after reading the order"); } }
/** * {@inheritDoc} */ public void deleteAll() throws DependencyException, InvalidStateException, ProvisionedThroughputException { List<Lease> allLeases = listLeases(); log.warn("Deleting {} items from table {}", allLeases.size(), table); final AWSExceptionManager exceptionManager = createExceptionManager(); for (final Lease lease : allLeases) { DeleteItemRequest deleteRequest = DeleteItemRequest.builder().tableName(table) .key(serializer.getDynamoHashKey(lease)).build(); try { try { dynamoDBClient.deleteItem(deleteRequest).get(); } catch (ExecutionException e) { throw exceptionManager.apply(e.getCause()); } catch (InterruptedException e) { // TODO: check the behavior throw new DependencyException(e); } } catch (DynamoDbException e) { throw convertAndRethrowExceptions("deleteAll", lease.leaseKey(), e); } } }
ItemCollectionSizeLimitExceededException, TransactionConflictException, RequestLimitExceededException, InternalServerErrorException, AwsServiceException, SdkClientException, DynamoDbException { return deleteItem(DeleteItemRequest.builder().applyMutation(deleteItemRequest).build());
/** * {@inheritDoc} */ @Override public void deleteLease(@NonNull final Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException { log.debug("Deleting lease with leaseKey {}", lease.leaseKey()); DeleteItemRequest deleteRequest = DeleteItemRequest.builder().tableName(table) .key(serializer.getDynamoHashKey(lease)).build(); final AWSExceptionManager exceptionManager = createExceptionManager(); try { try { dynamoDBClient.deleteItem(deleteRequest).get(); } catch (ExecutionException e) { throw exceptionManager.apply(e.getCause()); } catch (InterruptedException e) { // TODO: Check if this is the correct behavior throw new DependencyException(e); } } catch (DynamoDbException e) { throw convertAndRethrowExceptions("delete", lease.leaseKey(), e); } }
return deleteItem(DeleteItemRequest.builder().applyMutation(deleteItemRequest).build());
/** * {@inheritDoc} */ @Override public void deleteLease(@NonNull final Lease lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException { log.debug("Deleting lease with leaseKey {}", lease.leaseKey()); DeleteItemRequest deleteRequest = DeleteItemRequest.builder().tableName(table) .key(serializer.getDynamoHashKey(lease)).build(); final AWSExceptionManager exceptionManager = createExceptionManager(); try { try { dynamoDBClient.deleteItem(deleteRequest).get(); } catch (ExecutionException e) { throw exceptionManager.apply(e.getCause()); } catch (InterruptedException e) { // TODO: Check if this is the correct behavior throw new DependencyException(e); } } catch (DynamoDbException e) { throw convertAndRethrowExceptions("delete", lease.leaseKey(), e); } }
/** * {@inheritDoc} */ public void deleteAll() throws DependencyException, InvalidStateException, ProvisionedThroughputException { List<Lease> allLeases = listLeases(); log.warn("Deleting {} items from table {}", allLeases.size(), table); final AWSExceptionManager exceptionManager = createExceptionManager(); for (final Lease lease : allLeases) { DeleteItemRequest deleteRequest = DeleteItemRequest.builder().tableName(table) .key(serializer.getDynamoHashKey(lease)).build(); try { try { dynamoDBClient.deleteItem(deleteRequest).get(); } catch (ExecutionException e) { throw exceptionManager.apply(e.getCause()); } catch (InterruptedException e) { // TODO: check the behavior throw new DependencyException(e); } } catch (DynamoDbException e) { throw convertAndRethrowExceptions("deleteAll", lease.leaseKey(), e); } } }
final DeleteItemRequest deleteItemRequest = DeleteItemRequest.builder() .tableName(tableName) .key(key)