X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fcontrollers%2FRicRepositoryController.java;h=6b413b2ff3716fb8b2efff072abbe85d9fc872fa;hb=4891734864ae374cf6ff357f41cc840c4f685300;hp=960532a05e1a42976df035aa11228f6739c0f148;hpb=8831a02bce715562f3cacce1691bf4d9d3af206b;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicRepositoryController.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicRepositoryController.java index 960532a0..6b413b2f 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicRepositoryController.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/RicRepositoryController.java @@ -23,6 +23,7 @@ package org.oransc.policyagent.controllers; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; @@ -42,6 +43,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController +@Api(value = "RIC Management API") public class RicRepositoryController { private final ApplicationConfig appConfig; @@ -62,7 +64,7 @@ public class RicRepositoryController { * Example: http://localhost:8080/rics?managedElementId=kista_1 */ @GetMapping("/ric") - @ApiOperation(value = "Returns the name of a RIC managing one Mananged Element") + @ApiOperation(value = "Returns the name of a RIC managing one Mananged Element", response = String.class) @ApiResponses( value = { // @ApiResponse(code = 200, message = "RIC is fond"), // @@ -85,18 +87,25 @@ public class RicRepositoryController { * Example: http://localhost:8080/ric */ @GetMapping("/rics") - @ApiOperation(value = "Returns defined NearRT RIC:s as Json") + @ApiOperation(value = "Returns defined NearRT RIC:s as Json", response = RicInfo.class) @ApiResponses( value = { // - @ApiResponse(code = 200, message = "OK") // + @ApiResponse(code = 200, message = "OK", response = RicInfo.class) // }) - public ResponseEntity getRics() { + public ResponseEntity getRics( + @RequestParam(name = "policyType", required = false) String supportingPolicyType) { + Vector result = new Vector<>(); - for (Ric ric : rics.getRics()) { - result.add(ImmutableRicInfo.builder() // - .name(ric.name()) // - .nodeNames(ric.getManagedNodes()) // - .build()); + synchronized (rics) { + for (Ric ric : rics.getRics()) { + if (supportingPolicyType == null || ric.isSupportingType(supportingPolicyType)) { + result.add(ImmutableRicInfo.builder() // + .name(ric.name()) // + .managedElementIds(ric.getManagedElementIds()) // + .policyTypes(ric.getSupportedPolicyTypeNames()) // + .build()); + } + } } return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);