+ @Autowired
+ private Rics rics;
+ @Autowired
+ private PolicyTypes policyTypes;
+ @Autowired
+ private Policies policies;
+ @Autowired
+ private A1ClientFactory a1ClientFactory;
+ @Autowired
+ private Services services;
+
+ private static Gson gson = new GsonBuilder() //
+ .serializeNulls() //
+ .create(); //
+
+ @GetMapping("/policy_schemas")
+ @ApiOperation(value = "Returns policy type schema definitions")
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = 200, message = "Policy schemas", response = Object.class, responseContainer = "List"), //
+ @ApiResponse(code = 404, message = "RIC is not found", response = String.class)})
+ public ResponseEntity<String> getPolicySchemas(@RequestParam(name = "ric", required = false) String ricName) {
+ synchronized (this.policyTypes) {
+ if (ricName == null) {
+ Collection<PolicyType> types = this.policyTypes.getAll();
+ return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
+ } else {
+ try {
+ Collection<PolicyType> types = rics.getRic(ricName).getSupportedPolicyTypes();
+ return new ResponseEntity<>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
+ } catch (ServiceException e) {
+ return new ResponseEntity<>(e.toString(), HttpStatus.NOT_FOUND);
+ }
+ }
+ }
+ }
+
+ @GetMapping("/policy_schema")
+ @ApiOperation(value = "Returns one policy type schema definition")
+ @ApiResponses(
+ value = { //
+ @ApiResponse(code = 200, message = "Policy schema", response = Object.class),
+ @ApiResponse(code = 404, message = "RIC is not found", response = String.class)})
+ public ResponseEntity<String> getPolicySchema(@RequestParam(name = "id", required = true) String id) {
+ try {
+ PolicyType type = policyTypes.getType(id);
+ return new ResponseEntity<>(type.schema(), HttpStatus.OK);
+ } catch (ServiceException e) {
+ return new ResponseEntity<>(e.toString(), HttpStatus.NOT_FOUND);
+ }
+ }
+
+ @GetMapping("/policy_types")
+ @ApiOperation(value = "Query policy type names")
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "Policy type names",
+ response = String.class,
+ responseContainer = "List"),
+ @ApiResponse(code = 404, message = "RIC is not found", response = String.class)})
+ public ResponseEntity<String> getPolicyTypes(@RequestParam(name = "ric", required = false) String ricName) {
+ synchronized (this.policyTypes) {
+ if (ricName == null) {
+ Collection<PolicyType> types = this.policyTypes.getAll();
+ return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK);
+ } else {
+ try {
+ Collection<PolicyType> types = rics.getRic(ricName).getSupportedPolicyTypes();
+ return new ResponseEntity<>(toPolicyTypeIdsJson(types), HttpStatus.OK);
+ } catch (ServiceException e) {
+ return new ResponseEntity<>(e.toString(), HttpStatus.NOT_FOUND);
+ }
+ }
+ }
+ }
+