class AssetListController {

    @ApiOperation(httpMethod = "POST", value = "Get the list of assets in an asset group. Optional filters -'application','environment','resourceType' ")
    @PostMapping(value = "/v1/list/assets")
    public ResponseEntity<Object> listAssets(@RequestBody(required = true) Request request,
            @RequestParam(name = "domain", required = false) String domain) {

        String assetGroup = request.getAg();

        int from = request.getFrom();
        int size = request.getSize();
        if (from < 0) {
            return ResponseUtils.buildFailureResponse(new Exception(AssetConstants.ERROR_FROM_NEGATIVE));
        }

        String searchText = request.getSearchtext();
        Map<String, String> filter = request.getFilter();
        if (filter == null) {
            filter = new HashMap<>();
        }

        List<String> acceptedFilterKeys = Arrays.asList(AssetConstants.FILTER_APPLICATION,
                AssetConstants.FILTER_ENVIRONMENT, AssetConstants.FILTER_RES_TYPE, AssetConstants.FILTER_DOMAIN);
        for (Map.Entry<String, String> entry : filter.entrySet()) {
            if (!acceptedFilterKeys.contains(entry.getKey())) {
                return ResponseUtils.buildFailureResponse(new Exception(AssetConstants.ERROR_FILTER_ACCEPTS
                        + StringUtils.join(acceptedFilterKeys, ", ")));
            }
        }

        ResponseWithCount response;
        try {
            long count = assetService.getAssetCount(assetGroup, filter, searchText);
            List<Map<String, Object>> masterDetailList = assetService.getListAssets(assetGroup, filter, from, size,
                    searchText);
            response = new ResponseWithCount(masterDetailList, count);

        } catch (Exception e) {
            LOGGER.error("Error in listAssets ",e);
            return ResponseUtils.buildFailureResponse(e);
        }
        return ResponseUtils.buildSucessResponse(response);
    }

}