use of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest in project camel by apache.
the class UpdateItemCommand method execute.
@Override
public void execute() {
UpdateItemResult result = ddbClient.updateItem(new UpdateItemRequest().withTableName(determineTableName()).withKey(determineKey()).withAttributeUpdates(determineUpdateValues()).withExpected(determineUpdateCondition()).withReturnValues(determineReturnValues()));
addAttributesToResult(result.getAttributes());
}
use of com.amazonaws.services.dynamodbv2.model.UpdateItemRequest in project jcabi-dynamo by jcabi.
the class AwsItem method put.
@Override
public Map<String, AttributeValue> put(final Map<String, AttributeValueUpdate> attrs) throws IOException {
final AmazonDynamoDB aws = this.credentials.aws();
final Attributes expected = this.attributes.only(this.keys);
try {
final UpdateItemRequest request = new UpdateItemRequest().withTableName(this.name).withExpected(expected.asKeys()).withKey(expected).withAttributeUpdates(attrs).withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL).withReturnValues(ReturnValue.UPDATED_NEW);
final long start = System.currentTimeMillis();
final UpdateItemResult result = aws.updateItem(request);
Logger.info(this, "#put('%s'): updated item to DynamoDB, %s, in %[ms]s", attrs, new PrintableConsumedCapacity(result.getConsumedCapacity()).print(), System.currentTimeMillis() - start);
return result.getAttributes();
} catch (final AmazonClientException ex) {
throw new IOException(String.format("Failed to put %s into \"%s\" with %s", attrs, this.name, this.keys), ex);
} finally {
aws.shutdown();
}
}
Aggregations