2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.servlets;
23 import com.jcabi.aspects.Loggable;
24 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
25 import io.swagger.v3.oas.annotations.Operation;
26 import io.swagger.v3.oas.annotations.Parameter;
27 import io.swagger.v3.oas.annotations.info.Info;
28 import io.swagger.v3.oas.annotations.media.ArraySchema;
29 import io.swagger.v3.oas.annotations.media.Content;
30 import io.swagger.v3.oas.annotations.media.Schema;
31 import io.swagger.v3.oas.annotations.responses.ApiResponse;
32 import io.swagger.v3.oas.annotations.responses.ApiResponses;
33 import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
34 import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
35 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
36 import org.openecomp.sdc.be.impl.ComponentsUtils;
37 import org.openecomp.sdc.be.mixin.GroupTypeMixin;
38 import org.openecomp.sdc.be.model.GroupTypeDefinition;
39 import org.openecomp.sdc.be.user.UserBusinessLogic;
40 import org.openecomp.sdc.be.view.ResponseView;
41 import org.openecomp.sdc.common.api.Constants;
42 import org.springframework.stereotype.Controller;
44 import javax.ws.rs.Consumes;
45 import javax.ws.rs.GET;
46 import javax.ws.rs.HeaderParam;
47 import javax.ws.rs.Path;
48 import javax.ws.rs.Produces;
49 import javax.ws.rs.QueryParam;
50 import javax.ws.rs.core.MediaType;
51 import java.util.List;
53 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
55 @OpenAPIDefinition(info = @Info(title = "group types resource"))
57 @Consumes(MediaType.APPLICATION_JSON)
58 @Produces(MediaType.APPLICATION_JSON)
59 public class GroupTypesEndpoint extends BeGenericServlet{
61 private final GroupTypeBusinessLogic groupTypeBusinessLogic;
63 public GroupTypesEndpoint(UserBusinessLogic userBusinessLogic,
64 ComponentsUtils componentsUtils, GroupTypeBusinessLogic groupTypeBusinessLogic) {
65 super(userBusinessLogic, componentsUtils);
66 this.groupTypeBusinessLogic = groupTypeBusinessLogic;
71 @Operation(description = "Get group types ", method = "GET", summary = "Returns group types",
72 responses = @ApiResponse(content = @Content(
73 array = @ArraySchema(schema = @Schema(implementation = GroupTypeDefinition.class)))))
74 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "group types found"), @ApiResponse(
76 description = "field name invalid type/length, characters; mandatory field is absent, already exists (name)"),
77 @ApiResponse(responseCode = "403", description = "Restricted operation"),
78 @ApiResponse(responseCode = "500", description = "Internal Error")})
79 @ResponseView(mixin = {GroupTypeMixin.class})
80 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
81 public List<GroupTypeDefinition> getGroupTypes(@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
83 description = "An optional parameter to indicate the type of the container from where this call is executed") @QueryParam("internalComponentType") String internalComponentType) {
84 return groupTypeBusinessLogic.getAllGroupTypes(userId, internalComponentType);