class AssetGroupUtil {

    public static List<Map<String, Object>> fetchRuleComplianceInfo(String compapiuri, String ag,
            List<String> domains ,String token) throws Exception {

        List<Map<String, Object>> ruleInfoList = new ArrayList<>();
        try {
            for (String domain : domains) {
                String ruleCommplianceInfo = HttpUtil.post(compapiuri + "/noncompliancepolicy",
                        "{\"ag\":\"" + ag + "\",\"filter\":{\"domain\":\"" + domain + "\"}}",token,"Bearer");
                JsonObject response = new JsonParser().parse(ruleCommplianceInfo).getAsJsonObject();
                JsonArray ruleInfoListJson = response.get("data").getAsJsonObject().get("response").getAsJsonArray();
                JsonObject ruleinfoJson;
                Map<String, Object> ruleInfo;
                for (JsonElement _ruleinfo : ruleInfoListJson) {
                    ruleinfoJson = _ruleinfo.getAsJsonObject();
                    ruleInfo = new HashMap<>();
                    ruleInfo.put(DOMAIN, domain);
                    ruleInfo.put("ruleId", ruleinfoJson.get("ruleId").getAsString());
                    ruleInfo.put("compliance_percent", ruleinfoJson.get("compliance_percent").getAsDouble());
                    ruleInfo.put(TOTAL, ruleinfoJson.get("assetsScanned").getAsLong());
                    ruleInfo.put(COMPLIANT, ruleinfoJson.get("passed").getAsLong());
                    ruleInfo.put(NON_COMPLIANT, ruleinfoJson.get("failed").getAsLong());
                    ruleInfo.put("contribution_percent", ruleinfoJson.get("contribution_percent").getAsDouble());
                    ruleInfoList.add(ruleInfo);
                }
            }
        } catch (Exception e) {
            LOGGER.error("Error retrieving Rule Compliance Info" , e);
            throw e;
        }
        return ruleInfoList;
    }

    private  AssetGroupUtil();

}