+ this.a1ClientFactory = a1ClientFactory;
+ }
+
+ @GetMapping("/policy_schemas")
+ @ApiOperation(value = "Returns policy type schema definitions")
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = 200, message = "Policy schemas", response = String.class, responseContainer = "List")})
+ 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<String>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
+ } else {
+ try {
+ Collection<PolicyType> types = rics.getRic(ricName).getSupportedPolicyTypes();
+ return new ResponseEntity<String>(toPolicyTypeSchemasJson(types), HttpStatus.OK);
+ } catch (ServiceException e) {
+ return new ResponseEntity<String>(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)})
+ public ResponseEntity<String> getPolicySchema(@RequestParam(name = "id", required = true) String id) {
+ try {
+ PolicyType type = policyTypes.getType(id);
+ return new ResponseEntity<String>(type.schema(), HttpStatus.OK);
+ } catch (ServiceException e) {
+ return new ResponseEntity<String>(e.toString(), HttpStatus.NOT_FOUND);
+ }
+ }
+
+ @GetMapping("/policy_types")
+ @ApiOperation(value = "Returns policy types")
+ @ApiResponses(
+ value = {@ApiResponse(
+ code = 200,
+ message = "Policy type names",
+ response = String.class,
+ responseContainer = "List")})
+ 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<String>(toPolicyTypeIdsJson(types), HttpStatus.OK);
+ } else {
+ try {
+ Collection<PolicyType> types = rics.getRic(ricName).getSupportedPolicyTypes();
+ return new ResponseEntity<String>(toPolicyTypeIdsJson(types), HttpStatus.OK);
+ } catch (ServiceException e) {
+ return new ResponseEntity<String>(e.toString(), HttpStatus.NOT_FOUND);
+ }
+ }
+ }