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.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.media.ArraySchema;
27 import io.swagger.v3.oas.annotations.media.Content;
28 import io.swagger.v3.oas.annotations.media.Schema;
29 import io.swagger.v3.oas.annotations.responses.ApiResponse;
30 import io.swagger.v3.oas.annotations.servers.Server;
31 import io.swagger.v3.oas.annotations.servers.Servers;
32 import io.swagger.v3.oas.annotations.tags.Tag;
33 import io.swagger.v3.oas.annotations.tags.Tags;
34 import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
35 import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
36 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
37 import org.openecomp.sdc.be.impl.ComponentsUtils;
38 import org.openecomp.sdc.be.mixin.GroupTypeMixin;
39 import org.openecomp.sdc.be.model.GroupTypeDefinition;
40 import org.openecomp.sdc.be.user.UserBusinessLogic;
41 import org.openecomp.sdc.be.view.ResponseView;
42 import org.openecomp.sdc.common.api.Constants;
43 import org.springframework.stereotype.Controller;
45 import javax.ws.rs.Consumes;
46 import javax.ws.rs.GET;
47 import javax.ws.rs.HeaderParam;
48 import javax.ws.rs.Path;
49 import javax.ws.rs.Produces;
50 import javax.ws.rs.QueryParam;
51 import javax.ws.rs.core.MediaType;
52 import java.util.List;
54 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
56 @Tags({@Tag(name = "SDC Internal APIs")})
57 @Servers({@Server(url = "/sdc2/rest")})
59 @Consumes(MediaType.APPLICATION_JSON)
60 @Produces(MediaType.APPLICATION_JSON)
61 public class GroupTypesEndpoint extends BeGenericServlet{
63 private final GroupTypeBusinessLogic groupTypeBusinessLogic;
65 public GroupTypesEndpoint(UserBusinessLogic userBusinessLogic,
66 ComponentsUtils componentsUtils, GroupTypeBusinessLogic groupTypeBusinessLogic) {
67 super(userBusinessLogic, componentsUtils);
68 this.groupTypeBusinessLogic = groupTypeBusinessLogic;
73 @Operation(description = "Get group types ", method = "GET", summary = "Returns group types", responses = {
74 @ApiResponse(content = @Content(
75 array = @ArraySchema(schema = @Schema(implementation = GroupTypeDefinition.class)))),
76 @ApiResponse(responseCode = "200", description = "group types found"), @ApiResponse(responseCode = "400",
77 description = "field name invalid type/length, characters; mandatory field is absent, already exists (name)"),
78 @ApiResponse(responseCode = "403", description = "Restricted operation"),
79 @ApiResponse(responseCode = "500", description = "Internal Error")})
80 @ResponseView(mixin = {GroupTypeMixin.class})
81 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
82 public List<GroupTypeDefinition> getGroupTypes(@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
84 description = "An optional parameter to indicate the type of the container from where this call is executed") @QueryParam("internalComponentType") String internalComponentType) {
85 return groupTypeBusinessLogic.getAllGroupTypes(userId, internalComponentType);