1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Wipro Limited.
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=========================================================
20 *******************************************************************************/
21 package org.onap.slice.analysis.ms.configdb;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
28 import org.onap.slice.analysis.ms.models.Configuration;
29 import org.onap.slice.analysis.ms.models.configdb.CellsModel;
30 import org.onap.slice.analysis.ms.models.configdb.NetworkFunctionModel;
31 import org.onap.slice.analysis.ms.restclients.ConfigDbRestClient;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.core.ParameterizedTypeReference;
34 import org.springframework.http.ResponseEntity;
35 import org.springframework.stereotype.Service;
39 * Service for config db interfaces
43 public class ConfigDbInterfaceService implements IConfigDbService {
46 private ConfigDbRestClient restclient;
47 private String configDbBaseUrl = Configuration.getInstance().getConfigDbService();
50 * Fetches the current configuration of an S-NSSAI from config DB
52 public Map<String, Integer> fetchCurrentConfigurationOfSlice(String snssai){
53 Map<String,Integer> responseMap = null;
54 String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/profile-config/"+snssai;
56 ResponseEntity<Map<String,Integer>> response=restclient.sendGetRequest(reqUrl,new ParameterizedTypeReference<Map<String, Integer>>() {
58 responseMap=response.getBody();
63 * Fetches the current configuration of RIC from config DB
65 public Map<String,Map<String,Object>> fetchCurrentConfigurationOfRIC(String snssai){
66 String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/slice-config/"+snssai;
67 ResponseEntity<Map<String,Map<String,Object>>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,Map<String,Object>>>() {
69 return response.getBody();
73 * Fetches all the network functions of an S-NSSAI from config DB
75 public List<String> fetchNetworkFunctionsOfSnssai(String snssai){
76 List<String> responseList=new ArrayList<>();
77 String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-list/"+snssai;
78 ResponseEntity<List<NetworkFunctionModel>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<List<NetworkFunctionModel>>() {
80 for(NetworkFunctionModel networkFn:response.getBody()) {
81 responseList.add(networkFn.getgNBDUId());
87 * Fetches the RICS of an S-NSSAI from config DB
89 public Map<String, List<String>> fetchRICsOfSnssai(String snssai){
90 Map<String,List<String>> responseMap=new HashMap<>();
91 String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-cell-list/"+snssai;
92 ResponseEntity<Map<String,List<CellsModel>>> response = restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,List<CellsModel>>>() {
95 for (Map.Entry<String, List<CellsModel>> entry : response.getBody().entrySet()) {
96 List<String> cellslist=new ArrayList<>();
97 for(CellsModel cellmodel:entry.getValue()) {
98 cellslist.add(cellmodel.getCellLocalId());
100 responseMap.put(entry.getKey(), cellslist);
106 * Fetches the details of a service
108 public Map<String,String> fetchServiceDetails(String snssai){
109 String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/subscriber-details/"+snssai;
110 ResponseEntity<Map<String,String>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,String>>() {
112 return response.getBody();