Search in sources :

Example 1 with ListTablesRequest

use of com.amazonaws.services.dynamodbv2.model.ListTablesRequest in project aws-doc-sdk-examples by awsdocs.

the class ListTables method main.

public static void main(String[] args) {
    System.out.println("Your DynamoDB tables:\n");
    final AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
    ListTablesRequest request;
    boolean more_tables = true;
    String last_name = null;
    while (more_tables) {
        try {
            if (last_name == null) {
                request = new ListTablesRequest().withLimit(10);
            } else {
                request = new ListTablesRequest().withLimit(10).withExclusiveStartTableName(last_name);
            }
            ListTablesResult table_list = ddb.listTables(request);
            List<String> table_names = table_list.getTableNames();
            if (table_names.size() > 0) {
                for (String cur_name : table_names) {
                    System.out.format("* %s\n", cur_name);
                }
            } else {
                System.out.println("No tables found!");
                System.exit(0);
            }
            last_name = table_list.getLastEvaluatedTableName();
            if (last_name == null) {
                more_tables = false;
            }
        } catch (AmazonServiceException e) {
            System.err.println(e.getErrorMessage());
            System.exit(1);
        }
    }
    System.out.println("\nDone!");
}
Also used : ListTablesResult(com.amazonaws.services.dynamodbv2.model.ListTablesResult) AmazonServiceException(com.amazonaws.AmazonServiceException) ListTablesRequest(com.amazonaws.services.dynamodbv2.model.ListTablesRequest) AmazonDynamoDB(com.amazonaws.services.dynamodbv2.AmazonDynamoDB)

Example 2 with ListTablesRequest

use of com.amazonaws.services.dynamodbv2.model.ListTablesRequest in project aws-doc-sdk-examples by awsdocs.

the class LowLevelTableExample method listMyTables.

static void listMyTables() {
    String lastEvaluatedTableName = null;
    do {
        ListTablesRequest listTablesRequest = new ListTablesRequest().withLimit(10).withExclusiveStartTableName(lastEvaluatedTableName);
        ListTablesResult result = client.listTables(listTablesRequest);
        lastEvaluatedTableName = result.getLastEvaluatedTableName();
        for (String name : result.getTableNames()) {
            System.out.println(name);
        }
    } while (lastEvaluatedTableName != null);
}
Also used : ListTablesResult(com.amazonaws.services.dynamodbv2.model.ListTablesResult) ListTablesRequest(com.amazonaws.services.dynamodbv2.model.ListTablesRequest)

Aggregations

ListTablesRequest (com.amazonaws.services.dynamodbv2.model.ListTablesRequest)2 ListTablesResult (com.amazonaws.services.dynamodbv2.model.ListTablesResult)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)1