class InventoryUtil {

	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;
	}

	private  InventoryUtil();

}