com.amazonaws.services.dynamodbv2.model.ListTablesResult Java Examples

The following examples show how to use com.amazonaws.services.dynamodbv2.model.ListTablesResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoDBEmbeddedTest.java    From aws-dynamodb-examples with Apache License 2.0 6 votes vote down vote up
@Test
public void createTableTest() {
    AmazonDynamoDB ddb = DynamoDBEmbedded.create().amazonDynamoDB();
    try {
        String tableName = "Movies";
        String hashKeyName = "film_id";
        CreateTableResult res = createTable(ddb, tableName, hashKeyName);

        TableDescription tableDesc = res.getTableDescription();
        assertEquals(tableName, tableDesc.getTableName());
        assertEquals("[{AttributeName: " + hashKeyName + ",KeyType: HASH}]", tableDesc.getKeySchema().toString());
        assertEquals("[{AttributeName: " + hashKeyName + ",AttributeType: S}]",
            tableDesc.getAttributeDefinitions().toString());
        assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getReadCapacityUnits());
        assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getWriteCapacityUnits());
        assertEquals("ACTIVE", tableDesc.getTableStatus());
        assertEquals("arn:aws:dynamodb:ddblocal:000000000000:table/Movies", tableDesc.getTableArn());

        ListTablesResult tables = ddb.listTables();
        assertEquals(1, tables.getTableNames().size());
    } finally {
        ddb.shutdown();
    }
}
 
Example #2
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 6 votes vote down vote up
@Test
public void test_updateTable() throws Exception {
  createTable();

  DescribeTableResult describeResult = dynamoDb.describeTable(TEST_TABLE_NAME);
  Long readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits();

  assertThat(readUnits, equalTo(UNITS));

  UpdateTableResult updateResult = dynamoDb.updateTable(TEST_TABLE_NAME, new ProvisionedThroughput()
    .withReadCapacityUnits(new Long(200))
    .withWriteCapacityUnits(new Long(200)));
  String tableName = updateResult.getTableDescription().getTableName();

  assertThat(tableName, equalTo(TEST_TABLE_NAME));

  ListTablesResult listResult = listTables();

  describeResult = dynamoDb.describeTable(TEST_TABLE_NAME);
  readUnits = describeResult.getTable().getProvisionedThroughput().getReadCapacityUnits();

  assertThat(readUnits, equalTo(new Long(200)));
}
 
Example #3
Source File: LowLevelTableExample.java    From aws-dynamodb-examples with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: LowLevelTableExample.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: DynamoDBIOTestHelper.java    From beam with Apache License 2.0 6 votes vote down vote up
static void createTestTable(String tableName) {
  CreateTableResult res = createDynamoTable(tableName);

  TableDescription tableDesc = res.getTableDescription();

  Assert.assertEquals(tableName, tableDesc.getTableName());
  Assert.assertTrue(tableDesc.getKeySchema().toString().contains(ATTR_NAME_1));
  Assert.assertTrue(tableDesc.getKeySchema().toString().contains(ATTR_NAME_2));

  Assert.assertEquals(
      tableDesc.getProvisionedThroughput().getReadCapacityUnits(), Long.valueOf(1000));
  Assert.assertEquals(
      tableDesc.getProvisionedThroughput().getWriteCapacityUnits(), Long.valueOf(1000));
  Assert.assertEquals("ACTIVE", tableDesc.getTableStatus());
  Assert.assertEquals(
      "arn:aws:dynamodb:us-east-1:000000000000:table/" + tableName, tableDesc.getTableArn());

  ListTablesResult tables = dynamoDBClient.listTables();
  Assert.assertEquals(1, tables.getTableNames().size());
}
 
Example #6
Source File: DocumentAPITableExample.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
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());
        }
    }
 
Example #7
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithExclusiveStartTableName() throws Exception {
  createTable();

  ListTablesResult result = dynamoDb.listTables(TEST_TABLE_NAME);
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example #8
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithLimit() throws Exception {
  createTable();

  ListTablesResult result = dynamoDb.listTables(new Integer(10));
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example #9
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithNpParameters() throws Exception {
  createTable();

  ListTablesResult result = listTables();
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example #10
Source File: AmazonDynamoDBStubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void test_listTables_WithAllParameters() throws Exception {
  createTable();

  ListTablesResult result = dynamoDb.listTables(TEST_TABLE_NAME, new Integer(10));
  List<String> tableNames = result.getTableNames();

  assertThat(tableNames.size(), equalTo(1));
  assertThat(tableNames.get(0), equalTo(TEST_TABLE_NAME));
}
 
Example #11
Source File: DynamoDbDelegate.java    From dynamodb-janusgraph-storage-backend with Apache License 2.0 5 votes vote down vote up
ListTablesResult listTables(final ListTablesRequest request) throws BackendException {
    controlPlaneRateLimiter.acquire();
    final Timer.Context apiTimerContext = getTimerContext(listTablesApiName, null /*tableName*/);
    ListTablesResult result;
    try {
        result = client.listTables(request);
    } catch (final Exception e) {
        throw processDynamoDbApiException(e, LIST_TABLES, null /*tableName*/);
    } finally {
        apiTimerContext.stop();
    }
    return result;
}
 
Example #12
Source File: DynamoDBService.java    From Doradus with Apache License 2.0 5 votes vote down vote up
@Override
public void dropNamespace() {
    if (m_tenantPrefix.length() == 0) {
        m_logger.warn("Drop namespace not supported for legacy DynamoDB instances. "+
                      "Tables for tenant {} must be deleted manually", m_tenant.getName());
        return;
    }
    ListTablesResult tables = m_ddbClient.listTables();
    List<String> tableNames = tables.getTableNames();
    for (String tableName : tableNames) {
        if (tableName.startsWith(m_tenantPrefix)) {
            deleteTable(tableName);
        }
    }
}
 
Example #13
Source File: ListTablesWorker.java    From dynamodb-janusgraph-storage-backend with Apache License 2.0 5 votes vote down vote up
@Override
public ListTablesResult next() throws BackendException {
    final ListTablesResult result = delegate.listTables(request);
    if (result.getLastEvaluatedTableName() != null && !result.getLastEvaluatedTableName().isEmpty()) {
        request.setExclusiveStartTableName(result.getLastEvaluatedTableName());
    } else { //done
        markComplete();
    }

    // c add scanned items
    tableNames.addAll(result.getTableNames());
    return result;
}
 
Example #14
Source File: DynamoDBOperations.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteAll() throws Exception {
  final ListTablesResult tables = client.listTables();
  for (final String tableName : tables.getTableNames()) {
    if ((gwNamespace == null) || tableName.startsWith(gwNamespace)) {
      client.deleteTable(new DeleteTableRequest(tableName));
    }
  }
  tableExistsCache.clear();
}
 
Example #15
Source File: AwsPlatformResourcesTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void noSqlTables() {
    when(awsClient.createDynamoDbClient(any(AwsCredentialView.class), anyString())).thenReturn(amazonDynamoDB);
    when(amazonDynamoDB.listTables(any(ListTablesRequest.class))).thenReturn(
            new ListTablesResult().withTableNames("a", "b").withLastEvaluatedTableName("b"),
            new ListTablesResult().withTableNames("c", "d")
    );

    CloudNoSqlTables cloudNoSqlTables = underTest.noSqlTables(new CloudCredential(), region("region"), null);
    assertThat(cloudNoSqlTables.getCloudNoSqlTables()).hasSameElementsAs(List.of(
            new CloudNoSqlTable("a"),
            new CloudNoSqlTable("b"),
            new CloudNoSqlTable("c"),
            new CloudNoSqlTable("d")));
}
 
Example #16
Source File: DocumentAPITableExample.java    From aws-dynamodb-examples with Apache License 2.0 5 votes vote down vote up
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());
        }
    }
 
Example #17
Source File: InventoryUtilTest.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
 * Fetch dynamo DB tables test.
 *
 * @throws Exception the exception
 */
@SuppressWarnings("static-access")
@Test
public void fetchDynamoDBTablesTest() throws Exception {
    
    mockStatic(AmazonDynamoDBClientBuilder.class);
    AmazonDynamoDB awsClient = PowerMockito.mock(AmazonDynamoDB.class);
    AmazonDynamoDBClientBuilder amazonDynamoDBClientBuilder = PowerMockito.mock(AmazonDynamoDBClientBuilder.class);
    AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class);
    PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider);
    when(amazonDynamoDBClientBuilder.standard()).thenReturn(amazonDynamoDBClientBuilder);
    when(amazonDynamoDBClientBuilder.withCredentials(anyObject())).thenReturn(amazonDynamoDBClientBuilder);
    when(amazonDynamoDBClientBuilder.withRegion(anyString())).thenReturn(amazonDynamoDBClientBuilder);
    when(amazonDynamoDBClientBuilder.build()).thenReturn(awsClient);
    
    ListTablesResult listTableResult = new ListTablesResult();
    List<String> tables = new ArrayList<>();
    tables.add(new String());
    listTableResult.setTableNames(tables);
    when(awsClient.listTables()).thenReturn(listTableResult);
    
    DescribeTableResult describeTableResult = new DescribeTableResult();
    TableDescription table = new TableDescription();
    table.setTableArn("tableArn");
    describeTableResult.setTable(table);
    when(awsClient.describeTable(anyString())).thenReturn(describeTableResult);
    
    when(awsClient.listTagsOfResource(anyObject())).thenReturn(new ListTagsOfResourceResult());
    assertThat(inventoryUtil.fetchDynamoDBTables(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), 
            "skipRegions", "account","accountName").size(), is(1));
    
}
 
Example #18
Source File: DynamoDBTableResolver.java    From aws-athena-query-federation with Apache License 2.0 5 votes vote down vote up
private List<String> listTablesInternal()
        throws TimeoutException
{
    List<String> tables = new ArrayList<>();
    String nextToken = null;
    do {
        ListTablesRequest ddbRequest = new ListTablesRequest()
                .withExclusiveStartTableName(nextToken);
        ListTablesResult result = invoker.invoke(() -> ddbClient.listTables(ddbRequest));
        tables.addAll(result.getTableNames());
        nextToken = result.getLastEvaluatedTableName();
    }
    while (nextToken != null);
    return tables;
}
 
Example #19
Source File: TransactionManagerDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(ListTablesRequest arg0)
        throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}
 
Example #20
Source File: TransactionManagerDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(String exclusiveStartTableName)
        throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}
 
Example #21
Source File: TransactionDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(Integer limit)
        throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}
 
Example #22
Source File: TransactionManagerDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(String exclusiveStartTableName,
        Integer limit) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}
 
Example #23
Source File: TransactionManagerDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(Integer limit)
        throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}
 
Example #24
Source File: ThreadLocalDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables() throws AmazonServiceException, AmazonClientException {
    return getBackend().listTables();
}
 
Example #25
Source File: ThreadLocalDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(ListTablesRequest request) throws AmazonServiceException, AmazonClientException {
    return getBackend().listTables(request);
}
 
Example #26
Source File: ThreadLocalDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(String exclusiveStartTableName) throws AmazonServiceException, AmazonClientException {
    return getBackend().listTables(exclusiveStartTableName);
}
 
Example #27
Source File: ThreadLocalDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(String exclusiveStartTableName, Integer limit) throws AmazonServiceException, AmazonClientException {
    return getBackend().listTables(exclusiveStartTableName, limit);
}
 
Example #28
Source File: ThreadLocalDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(Integer limit) throws AmazonServiceException, AmazonClientException {
    return getBackend().listTables(limit);
}
 
Example #29
Source File: TransactionDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables() throws AmazonServiceException,
        AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}
 
Example #30
Source File: TransactionDynamoDBFacade.java    From dynamodb-transactions with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(ListTablesRequest arg0)
        throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Use the underlying client instance instead");
}