2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.sdc.be.servlets;
\r
23 import java.util.List;
\r
24 import javax.ws.rs.Consumes;
\r
25 import javax.ws.rs.GET;
\r
26 import javax.ws.rs.HeaderParam;
\r
27 import javax.ws.rs.Path;
\r
28 import javax.ws.rs.Produces;
\r
29 import javax.ws.rs.QueryParam;
\r
30 import javax.ws.rs.core.MediaType;
\r
31 import org.openecomp.sdc.be.components.impl.PolicyTypeBusinessLogic;
\r
32 import org.openecomp.sdc.be.mixin.PolicyTypeMixin;
\r
33 import org.openecomp.sdc.be.model.PolicyTypeDefinition;
\r
34 import org.openecomp.sdc.be.view.ResponseView;
\r
35 import org.openecomp.sdc.common.api.Constants;
\r
36 import org.openecomp.sdc.common.log.wrappers.Logger;
\r
37 import org.springframework.stereotype.Controller;
\r
38 import com.jcabi.aspects.Loggable;
\r
39 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
\r
40 import io.swagger.v3.oas.annotations.Operation;
\r
41 import io.swagger.v3.oas.annotations.Parameter;
\r
42 import io.swagger.v3.oas.annotations.info.Info;
\r
43 import io.swagger.v3.oas.annotations.media.ArraySchema;
\r
44 import io.swagger.v3.oas.annotations.media.Content;
\r
45 import io.swagger.v3.oas.annotations.media.Schema;
\r
46 import io.swagger.v3.oas.annotations.responses.ApiResponse;
\r
47 import io.swagger.v3.oas.annotations.responses.ApiResponses;
\r
49 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
\r
50 @Path("/v1/catalog")
\r
51 @OpenAPIDefinition(info = @Info(title = "policy types resource"))
\r
53 @Consumes(MediaType.APPLICATION_JSON)
\r
54 @Produces(MediaType.APPLICATION_JSON)
\r
55 public class PolicyTypesEndpoint {
\r
57 private static final Logger log = Logger.getLogger(PolicyTypesEndpoint.class);
\r
59 private final PolicyTypeBusinessLogic policyTypeBusinessLogic;
\r
61 public PolicyTypesEndpoint(PolicyTypeBusinessLogic policyTypeBusinessLogic) {
\r
62 this.policyTypeBusinessLogic = policyTypeBusinessLogic;
\r
66 @Path("/policyTypes")
\r
67 @Operation(description = "Get policy types ", method = "GET", summary = "Returns policy types",responses = @ApiResponse(
\r
68 content = @Content(array = @ArraySchema(schema = @Schema(implementation = PolicyTypeDefinition.class)))))
\r
69 @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "policy types found"),
\r
70 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
71 @ApiResponse(responseCode = "500", description = "The GET request failed due to internal SDC problem.")})
\r
72 @ResponseView(mixin = {PolicyTypeMixin.class})
\r
73 public List<PolicyTypeDefinition> getPolicyTypes(@Parameter(description = "An optional parameter to indicate the type of the container from where this call is executed")
\r
74 @QueryParam("internalComponentType") String internalComponentType,
\r
75 @Parameter(description = "The user id", required = true) @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
\r
76 log.debug("(get) Start handle request of GET policyTypes");
\r
77 return policyTypeBusinessLogic.getAllPolicyTypes(userId, internalComponentType);
\r