class AssetListController {

    @ApiOperation(httpMethod = "POST", value = "Get the list of taggble assets in an asset group. Optional filters -'application','environment','resourceType','tagged'{true/false} ,'tagName' {Application/Environment/Stack/Role}")
    @PostMapping(value = "/v1/list/assets/taggable")
    public ResponseEntity<Object> listTaggableAssets(@RequestBody(required = true) Request request) {

        String assetGroup = request.getAg();
        if (Strings.isNullOrEmpty(assetGroup)) {
            return ResponseUtils.buildFailureResponse(new Exception(Constants.ASSET_MANDATORY));
        }

        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_TAGGED,
                AssetConstants.FILTER_TAGNAME);
        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, ", ")));
            }
        }

        if (filter.containsKey(AssetConstants.FILTER_TAGNAME) && !filter.containsKey(AssetConstants.FILTER_TAGGED)) {
                return ResponseUtils.buildFailureResponse(new Exception("tagname should always be passed with tagged"));
        }

        List<Map<String, Object>> masterList;
        try {
            masterList = assetService.getListAssetsTaggable(assetGroup, filter);
        } catch (Exception e) {
            LOGGER.error("Error in listTaggableAssets ",e);
            return ResponseUtils.buildFailureResponse(e);
        }
        return formResponseWithCount(masterList, from, size, searchText);
    }

}