class ESInventoryUtil {

	public static Map<String,List<ElasticsearchDomainVH>> fetchESInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){
		
		Map<String,List<ElasticsearchDomainVH>> esDomainMap = new LinkedHashMap<>();
		AWSElasticsearch awsEsClient ;
		String expPrefix = "{\"errcode\": \"NO_RES_REG\" ,\"accountId\": \""+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"elasticsearch\" , \"region\":\"" ;
		for(Region region : RegionUtils.getRegions()){ 
			try{
				if(!skipRegions.contains(region.getName())){ //!skipRegions
					awsEsClient = AWSElasticsearchClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
					List<ElasticsearchDomainVH> elasticSearchDomains = new ArrayList<>();
					DescribeElasticsearchDomainsResult  describeResult ;
					ListDomainNamesResult listReuslt =  awsEsClient.listDomainNames(new ListDomainNamesRequest());
					List<String> domains = new ArrayList<>();
					for(DomainInfo domain: listReuslt.getDomainNames()){
						domains.add(domain.getDomainName());
					}
					
					DescribeElasticsearchDomainsRequest describeElasticsearchDomainsRequest ;
					int i =0;
					List<String> domainsTemp = new ArrayList<>();
					for(String domain : domains){
						domainsTemp.add(domain);
						i++;
						if(i%5 == 0 || i==domains.size()){
							describeElasticsearchDomainsRequest = new DescribeElasticsearchDomainsRequest();
							describeElasticsearchDomainsRequest.setDomainNames(domainsTemp);
							describeResult = awsEsClient.describeElasticsearchDomains(describeElasticsearchDomainsRequest);
							for( ElasticsearchDomainStatus domaininfo  : describeResult.getDomainStatusList()){
								ElasticsearchDomainVH elasticsearchDomainVH = new ElasticsearchDomainVH();
								elasticsearchDomainVH.setElasticsearchDomainStatus(domaininfo);
								elasticsearchDomainVH.setTags(awsEsClient.listTags(new ListTagsRequest().withARN(domaininfo.getARN())).getTagList());
								elasticSearchDomains.add(elasticsearchDomainVH);
							}
							domainsTemp =  new ArrayList<>();
						}
					}
					
					if(!elasticSearchDomains.isEmpty() ) {
						log.debug("Account : " + accountId + " Type : ES Domain "+ region.getName()+" >> " + elasticSearchDomains.size());
						esDomainMap.put(accountId+delimiter+accountName+delimiter+region.getName(), elasticSearchDomains);
					}
				}
			}catch(Exception e){
				log.warn(expPrefix+ region.getName()+"\", \"cause\":\"" +e.getMessage()+"\"}");
				ErrorManageUtil.uploadError(accountId,region.getName(),"elasticsearch",e.getMessage());
			}
		}
		return esDomainMap;
	}

	private  ESInventoryUtil();

}