class AssetGroupUtil {

    @SuppressWarnings("unchecked")
    public static List<Map<String, Object>> fetchVulnDistribution(String api, String ag ,String token) throws Exception {

        List<Map<String, Object>> vulnInfo = new ArrayList<>();
        try {
            String typeCountJson = HttpUtil.get(api + "/vulnerabilities/distribution?ag=" + ag,token);
            Map<String, Object> vulnMap = Util.parseJson(typeCountJson);
            Map<String, List<Map<String, Object>>> data = (Map<String, List<Map<String, Object>>>) vulnMap.get("data");
            List<Map<String, Object>> apps = data.get("response");
            for (Map<String, Object> app : apps) {
                String application = app.get("application").toString();
                List<Map<String, Object>> envs = (List<Map<String, Object>>) app.get("applicationInfo");
                for (Map<String, Object> env : envs) {
                    String environment = env.get("environment").toString();
                    List<Map<String, Object>> sevinfo = (List<Map<String, Object>>) env.get("severityInfo");
                    for (Map<String, Object> sev : sevinfo) {
                        Map<String, Object> vuln = new HashMap<>();
                        vuln.put("tags.Application", application);
                        vuln.put("tags.Environment", environment);
                        vuln.put("severitylevel", sev.get("severitylevel"));
                        vuln.put(SEVERITY, sev.get(SEVERITY));
                        vuln.put(COUNT, sev.get(COUNT));
                        vulnInfo.add(vuln);
                    }
                }
            }

        } catch (Exception e) {
            LOGGER.error("Error in fetchVulnDistribution" , e);
            throw e;
        }
        return vulnInfo;
    }

    private  AssetGroupUtil();

}