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

The following examples show how to use com.amazonaws.services.dynamodbv2.model.ListTablesRequest. 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: 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 #2
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 #3
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 #4
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 #5
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 #6
Source File: InventoryUtil.java    From pacbot with Apache License 2.0 4 votes vote down vote up
/**
 * Fetch dynamo DB tables.
 *
 * @param temporaryCredentials the temporary credentials
 * @param skipRegions the skip regions
 * @param accountId the accountId
 * @param accountName the account name
 * @return the map
 */
public static Map<String,List<DynamoVH>> fetchDynamoDBTables(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){
	Map<String,List<DynamoVH>> dynamodbtables = new LinkedHashMap<>();

	String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"DynamoDB\" , \"region\":\"" ;
	for(Region region : RegionUtils.getRegions()){
		try{
			if(!skipRegions.contains(region.getName())){
				AmazonDynamoDB awsClient= AmazonDynamoDBClientBuilder.standard().
					 withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
				String marker = null;
				List<String> tables = new ArrayList<>();
				ListTablesResult listTableResult;
				do{
					listTableResult = awsClient.listTables(new ListTablesRequest().withExclusiveStartTableName(marker));
					marker = listTableResult.getLastEvaluatedTableName();
					tables.addAll(listTableResult.getTableNames());
				}while(marker!=null);

				List<DynamoVH> dynamodbtablesTemp = new ArrayList<>();
				tables.parallelStream().forEach(tblName -> {
					TableDescription table = awsClient.describeTable(tblName).getTable();
					List<com.amazonaws.services.dynamodbv2.model.Tag> tags = awsClient.listTagsOfResource(new ListTagsOfResourceRequest().withResourceArn( table.getTableArn())).getTags();
					synchronized (dynamodbtablesTemp) {
						dynamodbtablesTemp.add(new DynamoVH(table,tags));
					}

				});
				if(!dynamodbtablesTemp.isEmpty() ){
					log.debug(InventoryConstants.ACCOUNT + accountId +" Type : DynamoDB "+region.getName() + " >> "+dynamodbtablesTemp.size());
					dynamodbtables.put(accountId+delimiter+accountName+delimiter+region.getName(), dynamodbtablesTemp);
				}

			}
		}catch(Exception e){
			if(region.isServiceSupported(AmazonDynamoDB.ENDPOINT_PREFIX)){
				log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
				ErrorManageUtil.uploadError(accountId,region.getName(),"dynamodb",e.getMessage());
			}
		}
	}
	return dynamodbtables;
}
 
Example #7
Source File: PostgresDynamoDB.java    From podyn with Apache License 2.0 4 votes vote down vote up
@Override
public ListTablesResult listTables(ListTablesRequest listTablesRequest) {
	
	throw new UnsupportedOperationException();
}
 
Example #8
Source File: ListTables.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
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!");
}
 
Example #9
Source File: DynamoDBStoreManager.java    From dynamodb-janusgraph-storage-backend with Apache License 2.0 4 votes vote down vote up
@Override
public boolean exists() throws BackendException {
    return client.getDelegate().listTables(new ListTablesRequest()) != null;
}
 
Example #10
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 #11
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 #12
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");
}