use of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient in project aws-doc-sdk-examples by awsdocs.
the class EnhancedGetItem method main.
public static void main(String[] args) {
Region region = Region.US_EAST_1;
DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(ddb).build();
String result = getItem(enhancedClient);
System.out.println(result);
ddb.close();
}
use of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient in project aws-doc-sdk-examples by awsdocs.
the class EnhancedPutItem method main.
public static void main(String[] args) {
Region region = Region.US_EAST_1;
DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(ddb).build();
putRecord(enhancedClient);
ddb.close();
}
use of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient in project aws-doc-sdk-examples by awsdocs.
the class EnhancedModifyItem method main.
public static void main(String[] args) {
String usage = "Usage:\n" + " <key> <email> \n\n" + "Where:\n" + " key - the name of the key in the table (id120).\n" + " email - the value of the modified email column.\n";
if (args.length != 2) {
System.out.println(usage);
System.exit(1);
}
String key = args[0];
String email = args[1];
Region region = Region.US_EAST_1;
DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(ddb).build();
String updatedValue = modifyItem(enhancedClient, key, email);
System.out.println("The updated name value is " + updatedValue);
ddb.close();
}
use of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient in project aws-doc-sdk-examples by awsdocs.
the class EnhancedQueryRecords method main.
public static void main(String[] args) {
Region region = Region.US_EAST_1;
DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(ddb).build();
String result = queryTable(enhancedClient);
System.out.println(result);
ddb.close();
}
use of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient in project aws-doc-sdk-examples by awsdocs.
the class DynamoDBService method persistItem.
// Persist the PPE Items into the Gear table.
public void persistItem(List<ArrayList<GearItem>> gearList) {
DynamoDbClient ddb = getClient();
try {
DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(ddb).build();
DynamoDbTable<Gear> gearTable = enhancedClient.table("Gear", TableSchema.fromBean(Gear.class));
Gear gearRecord;
// Create an Instant.
// current date and time
LocalDateTime now = LocalDateTime.now();
LocalDateTime timeVal = now.toLocalDate().atStartOfDay();
Instant instant = timeVal.toInstant(ZoneOffset.UTC);
// Persist the data into a DynamoDB table.
for (Object o : gearList) {
// Need to get the WorkItem from each list.
List innerList = (List) o;
for (Object value : innerList) {
gearRecord = new Gear();
UUID uuid = UUID.randomUUID();
GearItem gearItem = (GearItem) value;
gearRecord.setId(uuid.toString());
gearRecord.setKey(gearItem.getKey());
gearRecord.setDate(instant.toString());
gearRecord.setItem(gearItem.getName());
gearRecord.setCoverDescription(gearItem.getBodyCoverDescription());
gearRecord.setItemDescription(gearItem.getItemDescription());
gearRecord.setConfidence(gearItem.getConfidence());
// Put PPE data into a DynamoDB table.
gearTable.putItem(gearRecord);
}
}
} catch (DynamoDbException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
Aggregations