class EC2InventoryUtil {

	public static Map<String,List<InstanceInformation>> fetchSSMInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String accountId,String accountName) {

		Map<String,List<InstanceInformation>> ssmInstanceList = new LinkedHashMap<>();

		AWSSimpleSystemsManagement ssmClient;
		String expPrefix = InventoryConstants.ERROR_PREFIX_CODE + accountId
				+ "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"SSM\" , \"region\":\"";

		List<InstanceInformation> ssmInstanceListTemp ;
		
		for (Region region : RegionUtils.getRegions()) {
			try {
				if (!skipRegions.contains(region.getName())) {
					ssmInstanceListTemp = new ArrayList<>();
					ssmClient = AWSSimpleSystemsManagementClientBuilder.standard()
							.withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials))
							.withRegion(region.getName()).build();
					String nextToken = null;
					DescribeInstanceInformationResult describeInstanceInfoRslt;
					do {
						describeInstanceInfoRslt = ssmClient.describeInstanceInformation(
								new DescribeInstanceInformationRequest().withNextToken(nextToken));
						nextToken = describeInstanceInfoRslt.getNextToken();
						ssmInstanceListTemp.addAll(describeInstanceInfoRslt
								.getInstanceInformationList());
					} while (nextToken != null);
					if(! ssmInstanceListTemp.isEmpty() ) {
						log.debug(InventoryConstants.ACCOUNT + accountId + " Type : SSM "+region.getName() + " >> "+ssmInstanceListTemp.size());
						ssmInstanceList.put(accountId+delimiter+accountName+delimiter+region.getName(), ssmInstanceListTemp);
					}
				}

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

	private  EC2InventoryUtil();

}