use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.
the class SyncPagination method autoPagination.
public static void autoPagination(DynamoDbClient client) {
System.out.println("running AutoPagination...\n");
ListTablesRequest listTablesRequest = ListTablesRequest.builder().limit(3).build();
ListTablesIterable responses = client.listTablesPaginator(listTablesRequest);
System.out.println("AutoPagination: using for loop");
for (final ListTablesResponse response : responses) {
System.out.println(response.tableNames());
}
// Print the table names using the responses stream
System.out.println("AutoPagination: using stream");
responses.stream().forEach(response -> System.out.println(response.tableNames()));
// Convert the stream of responses to stream of table names, then print the table names
System.out.println("AutoPagination: using flatmap to get stream of table names");
responses.stream().flatMap(response -> response.tableNames().stream()).forEach(System.out::println);
System.out.println("AutoPagination: iterating directly on the table names");
Iterable<String> tableNames = responses.tableNames();
tableNames.forEach(System.out::println);
}
use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.
the class SyncPagination method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " SyncPagination <type>\n\n" + "Where:\n" + " type - the type of pagination. (auto, manual, or default). \n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String type = args[0];
Region region = Region.US_EAST_1;
DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
switch(type.toLowerCase()) {
case "manual":
manualPagination(ddb);
break;
case "auto":
autoPagination(ddb);
autoPaginationWithResume(ddb);
break;
default:
manualPagination(ddb);
autoPagination(ddb);
autoPaginationWithResume(ddb);
}
ddb.close();
}
use of software.amazon.awssdk.services.dynamodb.DynamoDbClient 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.services.dynamodb.DynamoDbClient 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.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.
the class CreateTableCompositeKey method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage:\n" + " <tableName>\n\n" + "Where:\n" + " tableName - the Amazon DynamoDB table to create (for example, Music3).\n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String tableName = args[0];
Region region = Region.US_EAST_1;
DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
System.out.format("Creating Amazon DynamoDB table %s\n with a composite primary key:\n", tableName);
System.out.format("* Language - partition key\n");
System.out.format("* Greeting - sort key\n");
String tableId = createTableComKey(ddb, tableName);
System.out.println("The Amazon DynamoDB table Id value is " + tableId);
ddb.close();
}
Aggregations