use of io.gravitee.rest.api.model.promotion.PromotionEntityStatus in project gravitee-management-rest-api by gravitee-io.
the class PromotionsResource method searchPromotions.
@POST
@Path("_search")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Search for Promotion")
@ApiResponses({ @ApiResponse(code = 200, message = "List promotions matching request parameters", response = PromotionEntity.class, responseContainer = "List"), @ApiResponse(code = 500, message = "Internal server error") })
public Response searchPromotions(@ApiParam(name = "statuses", required = true) @NotNull @QueryParam("statuses") List<String> statuses, @ApiParam(name = "apiId", required = true) @NotNull @QueryParam("apiId") String apiId) {
PromotionQuery promotionQuery = new PromotionQuery();
promotionQuery.setStatuses(statuses.stream().map(PromotionEntityStatus::valueOf).collect(toList()));
promotionQuery.setApiId(apiId);
List<PromotionEntity> promotions = promotionService.search(promotionQuery, new SortableImpl("created_at", false), null).getContent();
return Response.ok().entity(promotions).build();
}
Aggregations