Search in sources :

Example 1 with ListTablesResult

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

the class DocumentAPITableExample method listMyTables.

static void listMyTables() {
    TableCollection<ListTablesResult> tables = dynamoDB.listTables();
    Iterator<Table> iterator = tables.iterator();
    System.out.println("Listing table names");
    while (iterator.hasNext()) {
        Table table = iterator.next();
        System.out.println(table.getTableName());
    }
}
Also used : ListTablesResult(com.amazonaws.services.dynamodbv2.model.ListTablesResult) Table(com.amazonaws.services.dynamodbv2.document.Table)

Example 2 with ListTablesResult

use of com.amazonaws.services.dynamodbv2.model.ListTablesResult 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)

Example 3 with ListTablesResult

use of com.amazonaws.services.dynamodbv2.model.ListTablesResult 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)

Aggregations

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