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.GgNodeBTable;
29 import org.oransc.ric.anrxapp.client.model.NeighborCellRelationMod;
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());
61 private static final String QP_NODEB = "ggnodeb";
62 private static final String QP_SERVING = "servingCellNrcgi";
63 private static final String QP_NEIGHBOR = "neighborCellNrpci";
65 private static final String PP_SERVING = "servingcells";
66 private static final String PP_NEIGHBOR = "neighborcells";
68 // Populated by the autowired constructor
69 private final HealthApi healthApi;
70 private final NcrtApi ncrtApi;
73 public AnrXappController(final HealthApi healthApi, final NcrtApi ncrtApi) {
74 Assert.notNull(healthApi, "API must not be null");
75 Assert.notNull(ncrtApi, "API must not be null");
76 this.healthApi = healthApi;
77 this.ncrtApi = ncrtApi;
80 @ApiOperation(value = "Gets the ANR client library MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class)
81 @RequestMapping(value = DashboardConstants.VERSION_PATH, method = RequestMethod.GET)
82 public SuccessTransport getAnrXappClientVersion() {
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 getAnrXappHealthAlive(HttpServletResponse response) {
89 healthApi.getHealthAlive();
90 response.setStatus(healthApi.getApiClient().getStatusCode().value());
93 @ApiOperation(value = "Performs a readiness probe on the ANR xApp, result expressed as the response code.")
94 @RequestMapping(value = "/health/ready", method = RequestMethod.GET)
95 public void getAnrXappHealthReady(HttpServletResponse response) {
96 healthApi.getHealthReady();
97 response.setStatus(healthApi.getApiClient().getStatusCode().value());
100 @ApiOperation(value = "Returns list of gNodeB IDs based on NCRT in ANR", response = GgNodeBTable.class)
101 @RequestMapping(value = "/gnodebs", method = RequestMethod.GET)
102 public GgNodeBTable getGnodebs() {
103 return ncrtApi.getgNodeB();
106 @ApiOperation(value = "Returns neighbor cell relation table for all gNodeBs or based on query parameters", response = NeighborCellRelationTable.class)
107 @RequestMapping(value = "/ncrt", method = RequestMethod.GET)
108 public NeighborCellRelationTable getNcrt( //
109 @RequestParam(name = QP_NODEB, required = false) String ggnbId, //
110 @RequestParam(name = QP_SERVING, required = false) String servingCellNrcgi, //
111 @RequestParam(name = QP_NEIGHBOR, required = false) String neighborCellNrpci) {
112 logger.debug("getNcrt: ggnbid {}, servingCellNrpci {}, neighborCellNrcgi {}", ggnbId, servingCellNrcgi,
114 return ncrtApi.getNcrt(ggnbId, servingCellNrcgi, neighborCellNrpci);
117 // /ncrt/servingcells/{servCellNrcgi}/neighborcells/{neighCellNrpci} :
118 @ApiOperation(value = "Modify neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI")
119 @RequestMapping(value = "/ncrt/" + PP_SERVING + "/{" + PP_SERVING + "}/" + PP_NEIGHBOR + "/{" + PP_NEIGHBOR
120 + "}", method = RequestMethod.PUT)
121 public void modifyNcrt(@PathVariable(PP_SERVING) String servingCellNrcgi, //
122 @PathVariable(PP_NEIGHBOR) String neighborCellNrpci, //
123 @RequestBody NeighborCellRelationMod ncrMod, HttpServletResponse response) {
124 logger.debug("modifyNcrt: servingCellNrcgi {}, neighborCellNrpci {}, ncrMod {}", servingCellNrcgi,
125 neighborCellNrpci, ncrMod);
126 ncrtApi.modifyNcrt(servingCellNrcgi, neighborCellNrpci, ncrMod);
127 response.setStatus(healthApi.getApiClient().getStatusCode().value());
130 @ApiOperation(value = "Delete neighbor cell relation based on Serving Cell NRCGI and Neighbor Cell NRPCI")
131 @RequestMapping(value = "/ncrt/" + PP_SERVING + "/{" + PP_SERVING + "}/" + PP_NEIGHBOR + "/{" + PP_NEIGHBOR
132 + "}", method = RequestMethod.DELETE)
133 public void deleteNcrt(@PathVariable(PP_SERVING) String servingCellNrcgi, //
134 @PathVariable(PP_NEIGHBOR) String neighborCellNrpci, //
135 HttpServletResponse response) {
136 logger.debug("deleteNcrt: servingCellNrcgi {}, neighborCellNrpci {}", servingCellNrcgi, neighborCellNrpci);
137 ncrtApi.deleteNcrt(servingCellNrcgi, neighborCellNrpci);
138 response.setStatus(healthApi.getApiClient().getStatusCode().value());