Search in sources :

Example 1 with PromotionEntityStatus

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();
}
Also used : SortableImpl(io.gravitee.rest.api.model.common.SortableImpl) PromotionEntityStatus(io.gravitee.rest.api.model.promotion.PromotionEntityStatus) PromotionEntity(io.gravitee.rest.api.model.promotion.PromotionEntity) PromotionQuery(io.gravitee.rest.api.model.promotion.PromotionQuery) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

SortableImpl (io.gravitee.rest.api.model.common.SortableImpl)1 PromotionEntity (io.gravitee.rest.api.model.promotion.PromotionEntity)1 PromotionEntityStatus (io.gravitee.rest.api.model.promotion.PromotionEntityStatus)1 PromotionQuery (io.gravitee.rest.api.model.promotion.PromotionQuery)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1