class InventoryUtil {

	public static Map<String,List<Stack>> fetchCloudFormationStack(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){
		AmazonCloudFormation cloudFormClient ;
		Map<String,List<Stack>> stacks = new LinkedHashMap<>();
		String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Stack\" , \"region\":\"" ;
		for(Region region : RegionUtils.getRegions()){
			try{
				if(!skipRegions.contains(region.getName())){
					List<Stack> stacksTemp = new ArrayList<>();
					String nextToken = null;
					cloudFormClient = AmazonCloudFormationClientBuilder.standard().
							 withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
					DescribeStacksResult describeResult ;
					do{
						describeResult =  cloudFormClient.describeStacks(new DescribeStacksRequest().withNextToken(nextToken));
						stacksTemp.addAll(describeResult.getStacks());
						nextToken = describeResult.getNextToken();
					}while(nextToken!=null);

					if(! stacksTemp.isEmpty() ){
						log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Cloud Formation Stack "+region.getName() + " >> " + stacksTemp.size());
						stacks.put(accountId+delimiter+accountName+delimiter+region.getName(), stacksTemp);
					}
				}
			}catch(Exception e){
				log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
				ErrorManageUtil.uploadError(accountId,region.getName(),"stack",e.getMessage());
			}
		}
		return stacks;
	}

	private  InventoryUtil();

}