class InventoryUtil {

	public static Map<String,List<TargetGroupVH>> fetchTargetGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){
		com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancing elbClient ;
		Map<String,List<TargetGroupVH>> targetGrpMap = new LinkedHashMap<>();
		String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Target Group\" , \"region\":\"" ;
		for(Region region : RegionUtils.getRegions()){
			try{
				if(!skipRegions.contains(region.getName())){
					elbClient = com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClientBuilder.standard().
						 	withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
					String nextMarker = null;
					List<TargetGroupVH> targetGrpList = new ArrayList<>();
					do{
						DescribeTargetGroupsResult  trgtGrpRslt =  elbClient.describeTargetGroups(new DescribeTargetGroupsRequest().withMarker(nextMarker));
						List<TargetGroup> targetGrpListTemp = trgtGrpRslt.getTargetGroups();
						for(TargetGroup tg : targetGrpListTemp) {
							DescribeTargetHealthResult rslt =  elbClient.describeTargetHealth(new DescribeTargetHealthRequest().withTargetGroupArn(tg.getTargetGroupArn()));
							targetGrpList.add(new TargetGroupVH(tg, rslt.getTargetHealthDescriptions()));
						}
						nextMarker = trgtGrpRslt.getNextMarker();
					}while(nextMarker!=null);

					if( !targetGrpList.isEmpty() ) {
						log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Target Group " +region.getName() + "-"+targetGrpList.size());
						targetGrpMap.put(accountId+delimiter+accountName+delimiter+region.getName(), targetGrpList);
					}

				}
			}catch(Exception e){
				log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
				ErrorManageUtil.uploadError(accountId,region.getName(),"targetgroup",e.getMessage());
			}
		}
		return targetGrpMap;
	}

	private  InventoryUtil();

}