class AssetListController {

    @ApiOperation(httpMethod = "POST", value = "Get the list of patchable assets in an asset group. Optional filters -'application', 'environment', 'resourceType', 'patched'{true/false}, 'executiveSponsor' and 'director'.")
    @PostMapping(value = "/v1/list/assets/patchable")
    public ResponseEntity<Object> listPatchableAssets(@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_PATCHED,
                AssetConstants.FILTER_EXEC_SPONSOR, AssetConstants.FILTER_DIRECTOR);
        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, ", ")));
            }
        }

        List<Map<String, Object>> masterList;
        try {

            if (filter.containsKey(AssetConstants.FILTER_RES_TYPE) && !isEC2OrOnPremServer(filter)) {
                return ResponseUtils.buildFailureResponse(new Exception(
                        "Value of resourceType must be ec2 or onpremserver"));
            }
            masterList = assetService.getListAssetsPatchable(assetGroup, filter);
        } catch (Exception e) {
            LOGGER.error("Error in listPatchableAssets ",e);
            return ResponseUtils.buildFailureResponse(e);
        }
        return formResponseWithCount(masterList, from, size, searchText);
    }

}