2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property and Nokia
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===================================
20 package org.oransc.ric.portal.dashboard.controller;
22 import java.lang.invoke.MethodHandles;
24 import javax.servlet.http.HttpServletResponse;
26 import org.oransc.ric.anrxapp.client.api.HealthApi;
27 import org.oransc.ric.anrxapp.client.api.NcrtApi;
28 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationDelTable;
29 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationModTable;
30 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationTable;
31 import org.oransc.ric.portal.dashboard.DashboardApplication;
32 import org.oransc.ric.portal.dashboard.DashboardConstants;
33 import org.oransc.ric.portal.dashboard.model.SuccessTransport;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.context.annotation.Configuration;
38 import org.springframework.http.MediaType;
39 import org.springframework.util.Assert;
40 import org.springframework.web.bind.annotation.PathVariable;
41 import org.springframework.web.bind.annotation.RequestBody;
42 import org.springframework.web.bind.annotation.RequestMapping;
43 import org.springframework.web.bind.annotation.RequestMethod;
44 import org.springframework.web.bind.annotation.RequestParam;
45 import org.springframework.web.bind.annotation.RestController;
47 import io.swagger.annotations.ApiOperation;
50 * Provides methods to contact the ANR xApp which manages a Neighbor Cell
51 * Relation Table (NCRT).
55 @RequestMapping(value = DashboardConstants.ENDPOINT_PREFIX + "/xapp/anr", produces = MediaType.APPLICATION_JSON_VALUE)
56 public class AnrXappController {
58 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
60 private static final String CELL_ID = "cellIdentifier";
61 private static final String GGNBID = "ggnbId";
62 private static final String START_INDEX = "startIndex";
63 private static final String LIMIT = "limit";
64 private static final String NRPCI = "neighborCellIdentifierNrpci";
65 private static final String NRCGI = "neighborCellIdentifierNrcgi";
67 // Populated by the autowired constructor
68 private final HealthApi healthApi;
69 private final NcrtApi ncrtApi;
72 public AnrXappController(final HealthApi healthApi, final NcrtApi ncrtApi) {
73 Assert.notNull(healthApi, "API must not be null");
74 Assert.notNull(ncrtApi, "API must not be null");
75 this.healthApi = healthApi;
76 this.ncrtApi = ncrtApi;
79 @ApiOperation(value = "Gets the ANR client library MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class)
80 @RequestMapping(value = DashboardConstants.VERSION_PATH, method = RequestMethod.GET)
81 public SuccessTransport getVersion() {
82 logger.debug("getVersion enter");
83 return new SuccessTransport(200, DashboardApplication.getImplementationVersion(HealthApi.class));
86 @ApiOperation(value = "Performs a liveness probe on the ANR xApp, result expressed as the response code.")
87 @RequestMapping(value = "/health/alive", method = RequestMethod.GET)
88 public void getHealthAlive(HttpServletResponse response) {
89 logger.debug("getHealthAlive");
90 healthApi.getHealthAlive();
91 response.setStatus(healthApi.getApiClient().getStatusCode().value());
94 @ApiOperation(value = "Performs a readiness probe on the ANR xApp, result expressed as the response code.")
95 @RequestMapping(value = "/health/ready", method = RequestMethod.GET)
96 public void getHealthReady(HttpServletResponse response) {
97 logger.debug("getHealthReady");
98 healthApi.getHealthReady();
99 response.setStatus(healthApi.getApiClient().getStatusCode().value());
102 @ApiOperation(value = "Query NCRT of all cells, all or one gNB(s)", response = NeighborCellRelationTable.class)
103 @RequestMapping(value = "/cell", method = RequestMethod.GET)
104 public NeighborCellRelationTable getNcrtInfo( //
105 @RequestParam(name = GGNBID, required = false) String ggnbId, //
106 @RequestParam(name = START_INDEX, required = false) String startIndex, //
107 @RequestParam(name = LIMIT, required = false) Integer limit) {
108 logger.debug("queryNcrtAllCells: ggnbid {}, startIndex {} limit {}", ggnbId, startIndex, limit);
109 return ncrtApi.getNcrtInfo(ggnbId, startIndex, limit);
112 @ApiOperation(value = "Query NCRT of a single serving cell", response = NeighborCellRelationTable.class)
113 @RequestMapping(value = "/cell/" + CELL_ID + "/{" + CELL_ID + "}", method = RequestMethod.GET)
114 public NeighborCellRelationTable getCellNcrtInfo(@PathVariable(CELL_ID) String cellIdentifier, //
115 @RequestParam(name = START_INDEX, required = false) String startIndex, //
116 @RequestParam(name = LIMIT, required = false) Integer limit,
117 @RequestParam(name = NRPCI, required = false) String nrpci,
118 @RequestParam(name = NRCGI, required = false) String nrcgi) {
119 logger.debug("queryNcrtAllCells: cellIdentifier {}, startIndex {} limit {} nrpci {} nrcgi {}", cellIdentifier,
120 startIndex, limit, nrpci, nrcgi);
121 return ncrtApi.getCellNcrtInfo(cellIdentifier, startIndex, limit, nrpci, nrcgi);
124 @ApiOperation(value = "Modify neighbor cell relation based on Source Cell NR CGI and Target Cell NR PCI / NR CGI")
125 @RequestMapping(value = "/cell/" + CELL_ID + "/{" + CELL_ID + "}", method = RequestMethod.PUT)
126 public void modifyNcrt(@PathVariable(CELL_ID) String cellIdentifier, //
127 @RequestBody NeighborCellRelationModTable ncrtModTable, //
128 HttpServletResponse response) {
129 logger.debug("modifyNcrt: cellIdentifier {} modTable {}", cellIdentifier, ncrtModTable);
130 ncrtApi.modifyNcrt(cellIdentifier, ncrtModTable);
131 response.setStatus(healthApi.getApiClient().getStatusCode().value());
135 * TODO: DELETE should not have a body - the path should identify the resource to be deleted.
137 @ApiOperation(value = "Delete neighbor cell relation based on Source Cell NR CGI and Target Cell NR PCI / NR CGI")
138 @RequestMapping(value = "/cell/" + CELL_ID + "/{" + CELL_ID + "}", method = RequestMethod.DELETE)
139 public void deleteNcrt(@PathVariable(CELL_ID) String cellIdentifier, //
140 @RequestBody NeighborCellRelationDelTable ncrtDelTable, //
141 HttpServletResponse response) {
142 logger.debug("modifyNcrt: cellIdentifier {} delTable {}", cellIdentifier, ncrtDelTable);
143 ncrtApi.deleteNcrt(cellIdentifier, ncrtDelTable);
144 response.setStatus(healthApi.getApiClient().getStatusCode().value());