/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gravitee.rest.api.management.rest.resource;

import io.swagger.annotations.Api;
import javax.ws.rs.Path;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;

/**
 * Defines the REST resources to manage Promotions.
 *
 * @author Yann TAVERNIER (yann.tavernier at graviteesource.com)
 * @author GraviteeSource Team
 */
@Api(tags = { "Promotions" })
public class PromotionsResource extends AbstractResource {

    @Context
    private ResourceContext resourceContext;

    @Path("{promotion}")
    public PromotionResource getPolicyResource() {
        return resourceContext.getResource(PromotionResource.class);
    }
}

@@ -691,59 +691,638 @@
 ort 
-io.swagger.annotations.Api;%0Aimport javax.ws.rs.Path
+static java.util.stream.Collectors.toList;%0A%0Aimport io.gravitee.common.http.MediaType;%0Aimport io.gravitee.rest.api.model.common.SortableImpl;%0Aimport io.gravitee.rest.api.model.promotion.PromotionEntity;%0Aimport io.gravitee.rest.api.model.promotion.PromotionEntityStatus;%0Aimport io.gravitee.rest.api.model.promotion.PromotionQuery;%0Aimport io.gravitee.rest.api.service.promotion.PromotionService;%0Aimport io.swagger.annotations.*;%0Aimport java.util.List;%0Aimport javax.inject.Inject;%0Aimport javax.validation.constraints.NotNull;%0Aimport javax.ws.rs.POST;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.Produces;%0Aimport javax.ws.rs.QueryParam
 ;%0Aim
@@ -1397,16 +1397,50 @@
 Context;
+%0Aimport javax.ws.rs.core.Response;
 %0A%0A/**%0A *
@@ -1741,16 +1741,76 @@
 ntext;%0A%0A
+    @Inject%0A    private PromotionService promotionService;%0A%0A
     @Pat
@@ -1951,11 +1951,1182 @@
 );%0A    %7D
+%0A%0A    @POST%0A    @Path(%22_search%22)%0A    @Produces(MediaType.APPLICATION_JSON)%0A    @ApiOperation(value = %22Search for Promotion%22)%0A    @ApiResponses(%0A        %7B%0A            @ApiResponse(%0A                code = 200,%0A                message = %22List promotions matching request parameters%22,%0A                response = PromotionEntity.class,%0A                responseContainer = %22List%22%0A            ),%0A            @ApiResponse(code = 500, message = %22Internal server error%22),%0A        %7D%0A    )%0A    public Response searchPromotions(%0A        @ApiParam(name = %22statuses%22, required = true) @NotNull @QueryParam(%22statuses%22) List%3CString%3E statuses,%0A        @ApiParam(name = %22apiId%22, required = true) @NotNull @QueryParam(%22apiId%22) String apiId%0A    ) %7B%0A        PromotionQuery promotionQuery = new PromotionQuery();%0A        promotionQuery.setStatuses(statuses.stream().map(PromotionEntityStatus::valueOf).collect(toList()));%0A        promotionQuery.setApiId(apiId);%0A%0A        List%3CPromotionEntity%3E promotions = promotionService%0A            .search(promotionQuery, new SortableImpl(%22created_at%22, false), null)%0A            .getContent();%0A%0A        return Response.ok().entity(promotions).build();%0A    %7D
 %0A%7D%0A

add endpoint to search API promotions