class AssetCountController {

    @GetMapping(value = "/v1/count/byenvironment")
    public ResponseEntity<Object> geAssetCountByTypeEnvironment(
            @RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "type", required = true) String type) {

        if (Util.isValidTargetType(assetGroup, type)) {
            List<Map<String, Object>> countMap = null;
            try {
                countMap = assetService.getAssetCountByEnvironment(assetGroup, application, type);
            } catch (Exception e) {
                return ResponseUtils.buildFailureResponse(e);
            }

            Map<String, Object> response = new LinkedHashMap<>();
            response.put("ag", assetGroup);
            response.put("type", type);
            response.put(AssetConstants.ASSET_COUNT, countMap);
            return ResponseUtils.buildSucessResponse(response);
        } else {
            return ResponseUtils.buildFailureResponse(new Exception("Invalid Target type for the assetgroup "));
        }
    }

}