class InventoryUtil {

	public static Map<String,List<RedshiftVH>> fetchRedshiftInfo(BasicSessionCredentials temporaryCredentials,String skipRegions,String accountId,String accountName) {
		Map<String,List<RedshiftVH>> redshiftMap = new LinkedHashMap<>();
		AmazonRedshift redshiftClient ;
		String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Redshift\" , \"region\":\"" ;
		for(Region region : RegionUtils.getRegions()){
			try{
				if(!skipRegions.contains(region.getName())){
					redshiftClient = AmazonRedshiftClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
					String nextMarker = null;
					DescribeClustersResult result;
					List<com.amazonaws.services.redshift.model.Cluster> redshiftList = new ArrayList<>();
					do{
						 result= redshiftClient.describeClusters(new DescribeClustersRequest().withMarker(nextMarker));
						 redshiftList.addAll(result.getClusters());
						 nextMarker = result.getMarker();
					}while(nextMarker!=null);

					List<RedshiftVH> redshiftVHList = new ArrayList<>();
					for(com.amazonaws.services.redshift.model.Cluster cluster : redshiftList ){
					    RedshiftVH redshift = new RedshiftVH(cluster);
					    redshiftVHList.add(redshift);
					    List<ClusterSubnetGroup> subnetGroups = redshiftClient.describeClusterSubnetGroups(new DescribeClusterSubnetGroupsRequest().withClusterSubnetGroupName(cluster.getClusterSubnetGroupName())).getClusterSubnetGroups();
					    subnetGroups.forEach(subnetGroup-> {
					        redshift.setSubnets(subnetGroup.getSubnets().stream().map(com.amazonaws.services.redshift.model.Subnet::getSubnetIdentifier).collect(Collectors.toList()));
                        });
					}

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

				}

			}catch(Exception e){
				if(region.isServiceSupported(AmazonRedshift.ENDPOINT_PREFIX)){
					log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
					ErrorManageUtil.uploadError(accountId,region.getName(),"redshift",e.getMessage());
				}
			}
		}
		return redshiftMap;
	}

	private  InventoryUtil();

}