1fb9cc7e6cd6d961d39ea5dcfb06c156953eed80
[nonrtric/plt/rappmanager.git] /
1 package org.oransc.ran.nssmf.simulator.controller;
2
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import com.fasterxml.jackson.databind.SerializationFeature;
5 import org.oransc.ran.nssmf.simulator.dto.*;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8 import org.springframework.http.ResponseEntity;
9 import org.springframework.web.bind.annotation.GetMapping;
10 import org.springframework.web.bind.annotation.PathVariable;
11 import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.RestController;
13
14 import java.util.Arrays;
15 import java.util.List;
16
17
18 @RestController
19 @RequestMapping("/3GPPManagement/ProvMnS/${mns.fileDataReporting.version}") // Example version
20 public class NetworkSliceSubnetController {
21
22     private static final Logger logger = LoggerFactory.getLogger(NetworkSliceSubnetController.class);
23
24     private static final ObjectMapper objectMapper;
25
26     static {
27         objectMapper = new ObjectMapper();
28         objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
29     }
30
31     /**
32      * Retrieves an existing Network Slice Subnet by its ID.
33      *
34      * @param subnetId The unique identifier of the Network Slice Subnet to be retrieved.
35      * @return A ResponseEntity with HTTP status 200 (OK) and the NetworkSliceSubnetDTO,
36      *         or 404 (Not Found) if no such subnet exists.
37      */
38     @GetMapping("/NetworkSliceSubnets/{subnetId}")
39     public ResponseEntity<NetworkSliceSubnetDTO> getNetworkSliceSubnet(@PathVariable String subnetId) {
40         logger.info("Get request received for subnetId: {}", subnetId);
41         NetworkSliceSubnetDTO responseDto = new NetworkSliceSubnetDTO();
42         responseDto.setId(subnetId);
43
44         NetworkSliceSubnetAttributesDTO attributes = new NetworkSliceSubnetAttributesDTO();
45         attributes.setOperationalState("enabled");
46         attributes.setAdministrativeState("UNLOCKED");
47         attributes.setNetworkSliceSubnetType("RAN_SLICESUBNET");
48         attributes.setManagedFunctionRef(Arrays.asList(
49                 "2c000978-15e3-4393-984e-a20d32c96004-AUPF_200000",
50                 "2c000978-15e3-4393-984e-a20d32c96004-DU_200000",
51                 "2c000978-15e3-4393-984e-a20d32c96004-ACPF_200000"
52         ));
53         attributes.setNetworkSliceSubnetRef(List.of());
54
55         SliceProfileItemDTO sliceProfileItem = new SliceProfileItemDTO();
56         SliceProfileExtensionsDTO extensions = new SliceProfileExtensionsDTO();
57         extensions.setState("IN_SERVICE");
58         sliceProfileItem.setExtensions(extensions);
59
60         PlmnInfoListDTO plmnInfo = new PlmnInfoListDTO();
61         PlmnIdDTO plmnId = new PlmnIdDTO();
62         plmnId.setMcc("330");
63         plmnId.setMnc("220");
64         plmnInfo.setPLMNId(plmnId);
65
66         SnssaiDTO snssai = new SnssaiDTO();
67         plmnInfo.setSNSSAI(snssai);
68         sliceProfileItem.setPLMNInfoList(List.of(plmnInfo));
69
70         RanSliceSubnetProfileDTO ranProfile = new RanSliceSubnetProfileDTO();
71         ranProfile.setCoverageAreaTAList(Arrays.asList(1, 2));
72         ranProfile.setResourceSharingLevel("shared");
73
74         switch (subnetId) {
75             case "9090d36f-6af5-4cfd-8bda-7a3c88fa82fa":
76                 sliceProfileItem.setSliceProfileId("2f1ca17d-5c44-4355-bfed-e9800a2996c1");
77                 snssai.setSst(1);
78                 snssai.setSd("000001");
79                 break;
80             case "9090d36f-6af5-4cfd-8bda-7a3c88fa82fb":
81                 sliceProfileItem.setSliceProfileId("2f1ca17d-5c44-4355-bfed-e9800a2996c2");
82                 snssai.setSst(1);
83                 snssai.setSd("000002");
84                 ranProfile.setRRU_PrbDl(1024);
85                 ranProfile.setRRU_PrbUl(3096);
86                 break;
87             case "9090d36f-6af5-4cfd-8bda-7a3c88fa82fc":
88                 sliceProfileItem.setSliceProfileId("2f1ca17d-5c44-4355-bfed-e9800a2996c3");
89                 snssai.setSst(2);
90                 snssai.setSd("000003");
91                 break;
92             case "9090d36f-6af5-4cfd-8bda-7a3c88fa82fd":
93                 sliceProfileItem.setSliceProfileId("2f1ca17d-5c44-4355-bfed-e9800a2996c4");
94                 snssai.setSst(2);
95                 snssai.setSd("000004");
96                 ranProfile.setRRU_PrbDl(256);
97                 ranProfile.setRRU_PrbUl(512);
98                 break;
99             case "9090d36f-6af5-4cfd-8bda-7a3c88fa82fe":
100                 sliceProfileItem.setSliceProfileId("2f1ca17d-5c44-4355-bfed-e9800a2996c5");
101                 snssai.setSst(3);
102                 snssai.setSd("000005");
103                 break;
104             case "9090d36f-6af5-4cfd-8bda-7a3c88fa82ff":
105                 sliceProfileItem.setSliceProfileId("2f1ca17d-5c44-4355-bfed-e9800a2996c6");
106                 snssai.setSst(1);
107                 snssai.setSd("000006");
108                 ranProfile.setRRU_PrbDl(2048);
109                 ranProfile.setRRU_PrbUl(4096);
110                 break;
111             default:
112                 return ResponseEntity.notFound().build();
113         }
114
115         sliceProfileItem.setRANSliceSubnetProfile(ranProfile);
116         attributes.setSliceProfileList(List.of(sliceProfileItem));
117         responseDto.setAttributes(attributes);
118
119         return ResponseEntity.ok(responseDto);
120     }
121 }