2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019,2021 Nordix Foundation.
4 * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
5 * Modifications Copyright (C) 2021-2022 Bell Canada. 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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.pap.main.rest;
25 import io.swagger.annotations.ApiOperation;
26 import io.swagger.annotations.ApiParam;
27 import io.swagger.annotations.ApiResponse;
28 import io.swagger.annotations.ApiResponses;
29 import io.swagger.annotations.Authorization;
30 import io.swagger.annotations.Extension;
31 import io.swagger.annotations.ExtensionProperty;
32 import io.swagger.annotations.ResponseHeader;
33 import java.util.UUID;
34 import lombok.RequiredArgsConstructor;
35 import org.onap.policy.models.base.PfModelException;
36 import org.onap.policy.models.pdp.concepts.PdpGroups;
37 import org.onap.policy.pap.main.service.PdpGroupService;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.http.HttpStatus;
41 import org.springframework.http.ResponseEntity;
42 import org.springframework.web.bind.annotation.GetMapping;
43 import org.springframework.web.bind.annotation.RequestHeader;
44 import org.springframework.web.bind.annotation.RequestMapping;
45 import org.springframework.web.bind.annotation.RestController;
48 * Class to provide REST end points for PAP component to query details of all PDP groups.
50 * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
53 @RequestMapping(path = "/policy/pap/v1")
54 @RequiredArgsConstructor
55 public class PdpGroupQueryControllerV1 extends PapRestControllerV1 {
57 private static final Logger LOGGER = LoggerFactory.getLogger(PdpGroupQueryControllerV1.class);
59 private final PdpGroupService pdpGroupService;
62 * Queries details of all PDP groups.
64 * @param requestId request ID used in ONAP logging
66 * @throws PfModelException the exception
70 @ApiOperation(value = "Query details of all PDP groups",
71 notes = "Queries details of all PDP groups, returning all group details",
72 response = PdpGroups.class,
73 tags = {"PdpGroup Query"},
74 authorizations = @Authorization(value = AUTHORIZATION_TYPE),
76 @ResponseHeader(name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
77 response = String.class),
78 @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
79 response = String.class),
80 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
81 response = String.class),
82 @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
83 response = UUID.class)},
85 @Extension(name = EXTENSION_NAME,
87 @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
88 @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
91 @ApiResponses(value = {
92 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
93 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
94 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
97 public ResponseEntity<PdpGroups> queryGroupDetails(@ApiParam(REQUEST_ID_PARAM_DESCRIPTION) @RequestHeader(
99 value = REQUEST_ID_NAME) final UUID requestId) throws PfModelException {
101 final var pdpGroups = new PdpGroups();
102 pdpGroups.setGroups(pdpGroupService.getPdpGroups());
103 LOGGER.debug("PdpGroup Query Response - {}", pdpGroups);
105 return addLoggingHeaders(addVersionControlHeaders(ResponseEntity.status(HttpStatus.OK)), requestId)