use of software.amazon.awssdk.services.dynamodb.model.ListTablesResponse in project aws-doc-sdk-examples by awsdocs.
the class AsyncPagination method useThirdPartySubscriber_Reactor.
private static void useThirdPartySubscriber_Reactor() {
System.out.println("running AutoPagination - using third party subscriber...\n");
DynamoDbAsyncClient asyncClient = DynamoDbAsyncClient.create();
ListTablesPublisher publisher = asyncClient.listTablesPaginator(ListTablesRequest.builder().build());
// The Flux class has many helper methods that work with any reactive streams compatible publisher implementation
List<String> tables = Flux.from(publisher).flatMapIterable(ListTablesResponse::tableNames).collectList().block();
System.out.println(tables);
}
use of software.amazon.awssdk.services.dynamodb.model.ListTablesResponse 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.model.ListTablesResponse in project aws-doc-sdk-examples by awsdocs.
the class ListTables method listAllTables.
// snippet-start:[dynamodb.java2.list_tables.main]
public static void listAllTables(DynamoDbClient ddb) {
boolean moreTables = true;
String lastName = null;
while (moreTables) {
try {
ListTablesResponse response = null;
if (lastName == null) {
ListTablesRequest request = ListTablesRequest.builder().build();
response = ddb.listTables(request);
} else {
ListTablesRequest request = ListTablesRequest.builder().exclusiveStartTableName(lastName).build();
response = ddb.listTables(request);
}
List<String> tableNames = response.tableNames();
if (tableNames.size() > 0) {
for (String curName : tableNames) {
System.out.format("* %s\n", curName);
}
} else {
System.out.println("No tables found!");
System.exit(0);
}
lastName = response.lastEvaluatedTableName();
if (lastName == null) {
moreTables = false;
}
} catch (DynamoDbException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
System.out.println("\nDone!");
}
use of software.amazon.awssdk.services.dynamodb.model.ListTablesResponse in project syndesis-qe by syndesisio.
the class DynamoDbUtils method deleteTable.
public void deleteTable() {
log.info("deleting the AWS dynamoDb: " + tableName);
ListTablesResponse listTables = dynamoDb.listTables(ListTablesRequest.builder().build());
if (listTables.tableNames().contains(tableName)) {
dynamoDb.deleteTable(DeleteTableRequest.builder().tableName(tableName).build());
} else {
log.debug("The AWS dynamoDb table {} doesn't exist, continuing.", tableName);
}
}
Aggregations