Sync Integ to Master
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / servlets / GroupTypesEndpoint.java
1 package org.openecomp.sdc.be.servlets;
2
3 import com.jcabi.aspects.Loggable;
4 import io.swagger.annotations.Api;
5 import io.swagger.annotations.ApiOperation;
6 import io.swagger.annotations.ApiParam;
7 import io.swagger.annotations.ApiResponse;
8 import io.swagger.annotations.ApiResponses;
9 import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
10 import org.openecomp.sdc.be.mixin.GroupTypeMixin;
11 import org.openecomp.sdc.be.model.GroupTypeDefinition;
12 import org.openecomp.sdc.be.view.ResponseView;
13 import org.openecomp.sdc.common.api.Constants;
14 import org.springframework.stereotype.Controller;
15
16 import javax.ws.rs.Consumes;
17 import javax.ws.rs.GET;
18 import javax.ws.rs.HeaderParam;
19 import javax.ws.rs.Path;
20 import javax.ws.rs.Produces;
21 import javax.ws.rs.QueryParam;
22 import javax.ws.rs.core.MediaType;
23 import java.util.List;
24
25 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
26 @Path("/v1/catalog")
27 @Api(value = "group types resource")
28 @Controller
29 @Consumes(MediaType.APPLICATION_JSON)
30 @Produces(MediaType.APPLICATION_JSON)
31 public class GroupTypesEndpoint {
32
33     private final GroupTypeBusinessLogic groupTypeBusinessLogic;
34
35     public GroupTypesEndpoint(GroupTypeBusinessLogic groupTypeBusinessLogic) {
36         this.groupTypeBusinessLogic = groupTypeBusinessLogic;
37     }
38
39     @GET
40     @Path("/groupTypes")
41     @ApiOperation(value = "Get group types ", httpMethod = "GET", notes = "Returns group types", response = GroupTypeDefinition.class, responseContainer = "List")
42     @ApiResponses(value = {
43             @ApiResponse(code = 200, message = "group types found"),
44             @ApiResponse(code = 400, message = "field name invalid type/length, characters;  mandatory field is absent, already exists (name)"),
45             @ApiResponse(code = 403, message = "Restricted operation"),
46             @ApiResponse(code = 500, message = "Internal Error")
47     })
48     @ResponseView(mixin = {GroupTypeMixin.class})
49     public List<GroupTypeDefinition> getGroupTypes(@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
50                                                    @ApiParam(value = "An optional parameter to indicate the type of the container from where this call is executed")
51                                                    @QueryParam("internalComponentType") String internalComponentType) {
52         return groupTypeBusinessLogic.getAllGroupTypes(userId, internalComponentType);
53     }
54
55 }