Change name of policy ID in API 29/3129/4
authorelinuxhenrik <henrik.b.andersson@est.tech>
Fri, 3 Apr 2020 07:24:52 +0000 (09:24 +0200)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 7 Apr 2020 06:17:34 +0000 (08:17 +0200)
In some methods the policy ID parameter was named "instance". It is
changed to "id".

Change-Id: Id267fba84e62a2e6d3ff52ffb3d728561178b337
Issue-ID: NONRTRIC-152
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
docs/policy-agent-api.rst
policy-agent/docs/api.yaml
policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
policy-agent/src/test/java/org/oransc/policyagent/ConcurrencyTestRunnable.java

index e3354e4..8a46fc7 100644 (file)
@@ -634,12 +634,12 @@ GET
   Returns a policy configuration.
 
   **URL path:**
-    /policy?instance=<name-of-policy>
+    /policy?id=<policy-id>
 
   **Parameters:**
 
-    instance: (*Required*)
-      The ID/name of the policy instance.
+    id: (*Required*)
+      The ID of the policy instance.
 
   **Responses:**
 
@@ -647,7 +647,7 @@ GET
           JSON object containing policy information. ::
 
             {
-              "id": "string",                  (ID/name of policy)
+              "id": "string",                  (ID of policy)
               "json": "object",                (JSON with policy data speified by the type)
               "ownerServiceName": "string",    (Name of the service that created the policy)
               "ric": "string",                 (Name of the Near |nbh| RT |nbsp| RIC where the policy resides)
@@ -662,7 +662,7 @@ GET
 
     Call: ::
 
-      curl -X GET "http://localhost:8081/policy?instance=Policy 1"
+      curl -X GET "http://localhost:8081/policy?id=Policy 1"
 
     Result:
       200: ::
@@ -696,7 +696,7 @@ GET
 
     Call: ::
 
-      curl -X GET "http://localhost:8081/policy?instance=nonexistent"
+      curl -X GET "http://localhost:8081/policy?id=nonexistent"
 
     Result:
        404: ::
@@ -710,12 +710,12 @@ PUT
   "*Keep Alive Interval*" registered.
 
   **URL path:**
-    /policy?instance=<name-of-policy>&ric=<name-of-ric>&service=<name-of-service>&type=<name-of-policy-type>
+    /policy?id=<policy-id>&ric=<name-of-ric>&service=<name-of-service>&type=<name-of-policy-type>
 
   **Parameters:**
 
-    instance: (*Required*)
-      The ID/name of the policy instance.
+    id: (*Required*)
+      The ID of the policy instance.
 
     ric: (*Required*)
       The name of the Near |nbh| RT |nbsp| RIC where the policy will be created.
@@ -747,7 +747,7 @@ PUT
 
     Call: ::
 
-      curl -X PUT "http://localhost:8081/policy?instance=Policy%201&ric=ric1&service=Service%201&type=STD_PolicyModelUnconstrained_0.2.0"
+      curl -X PUT "http://localhost:8081/policy?id=Policy%201&ric=ric1&service=Service%201&type=STD_PolicyModelUnconstrained_0.2.0"
         -H  "Content-Type: application/json"
         -d "{
               \"scope\": {
@@ -779,12 +779,12 @@ DELETE
   "*Keep Alive Interval*" registered.
 
   **URL path:**
-    /policy?instance=<name-of-policy>
+    /policy?id=<policy-id>
 
   **Parameters:**
 
-    instance: (*Required*)
-      The ID/name of the policy instance.
+    id: (*Required*)
+      The ID of the policy instance.
 
   **Responses:**
 
@@ -798,7 +798,7 @@ DELETE
 
     Call: ::
 
-      curl -X DELETE "http://localhost:8081/policy?instance=Policy 1"
+      curl -X DELETE "http://localhost:8081/policy?id=Policy 1"
 
     Result:
       204
@@ -866,12 +866,12 @@ GET
   Returns the status of a policy.
 
   **URL path:**
-    /policy_status?instance=<name-of-policy>
+    /policy_status?id=<policy-id>
 
   **Parameters:**
 
-    instance: (*Required*)
-      The ID/name of the policy.
+    id: (*Required*)
+      The ID of the policy.
 
   **Responses:**
 
index 5800f0f..3ea913d 100644 (file)
@@ -64,9 +64,9 @@ paths:
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
       responses:
@@ -91,9 +91,9 @@ paths:
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
         - in: body
@@ -147,9 +147,9 @@ paths:
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
       responses:
@@ -281,9 +281,9 @@ paths:
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
       responses:
index 5ae54ef..0991605 100644 (file)
@@ -155,9 +155,9 @@ public class PolicyController {
             @ApiResponse(code = 404, message = "Policy is not found")} //
     )
     public ResponseEntity<String> getPolicy( //
-        @RequestParam(name = "instance", required = true) String instance) {
+        @RequestParam(name = "id", required = true) String id) {
         try {
-            Policy p = policies.getPolicy(instance);
+            Policy p = policies.getPolicy(id);
             return new ResponseEntity<>(p.json(), HttpStatus.OK);
         } catch (ServiceException e) {
             return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
@@ -172,7 +172,7 @@ public class PolicyController {
             @ApiResponse(code = 404, message = "Policy is not found", response = String.class),
             @ApiResponse(code = 423, message = "RIC is not operational", response = String.class)})
     public Mono<ResponseEntity<Object>> deletePolicy( //
-        @RequestParam(name = "instance", required = true) String id) {
+        @RequestParam(name = "id", required = true) String id) {
         try {
             Policy policy = policies.getPolicy(id);
             keepServiceAlive(policy.ownerServiceName());
@@ -202,7 +202,7 @@ public class PolicyController {
         })
     public Mono<ResponseEntity<Object>> putPolicy( //
         @RequestParam(name = "type", required = false, defaultValue = "") String typeName, //
-        @RequestParam(name = "instance", required = true) String instanceId, //
+        @RequestParam(name = "id", required = true) String instanceId, //
         @RequestParam(name = "ric", required = true) String ricName, //
         @RequestParam(name = "service", required = true) String service, //
         @RequestBody Object jsonBody) {
@@ -328,9 +328,9 @@ public class PolicyController {
             @ApiResponse(code = 404, message = "Policy is not found", response = String.class)} //
     )
     public Mono<ResponseEntity<String>> getPolicyStatus( //
-        @RequestParam(name = "instance", required = true) String instance) {
+        @RequestParam(name = "id", required = true) String id) {
         try {
-            Policy policy = policies.getPolicy(instance);
+            Policy policy = policies.getPolicy(id);
 
             return a1ClientFactory.createA1Client(policy.ric()) //
                 .flatMap(client -> client.getPolicyStatus(policy)) //
index b7e9a4b..1784fea 100644 (file)
@@ -247,9 +247,9 @@ public class ApplicationTest {
 
     private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId) {
         if (policyTypeName.isEmpty()) {
-            return "/policy?instance=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName;
+            return "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName;
         } else {
-            return "/policy?instance=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type="
+            return "/policy?id=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type="
                 + policyTypeName;
         }
     }
@@ -320,17 +320,17 @@ public class ApplicationTest {
         // DELETE POLICY
         this.addPolicy("instance1", "type1", "service1", "ric1");
         doReturn(Mono.error(a1Exception)).when(a1Client).deletePolicy(any());
-        testErrorCode(restClient().delete("/policy?instance=instance1"), httpStatus, responseBody);
+        testErrorCode(restClient().delete("/policy?id=instance1"), httpStatus, responseBody);
 
         // GET STATUS
         this.addPolicy("instance1", "type1", "service1", "ric1");
         doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
-        testErrorCode(restClient().get("/policy_status?instance=instance1"), httpStatus, responseBody);
+        testErrorCode(restClient().get("/policy_status?id=instance1"), httpStatus, responseBody);
 
         // Check that empty response body is OK
         a1Exception = new WebClientResponseException(httpStatus.value(), "", null, null, null, null);
         doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
-        testErrorCode(restClient().get("/policy_status?instance=instance1"), httpStatus);
+        testErrorCode(restClient().get("/policy_status?id=instance1"), httpStatus);
     }
 
     @Test
@@ -363,7 +363,7 @@ public class ApplicationTest {
 
     @Test
     public void testGetPolicy() throws Exception {
-        String url = "/policy?instance=id";
+        String url = "/policy?id=id";
         Policy policy = addPolicy("id", "typeName", "service1", "ric1");
         {
             String rsp = restClient().get(url).block();
@@ -380,7 +380,7 @@ public class ApplicationTest {
         addPolicy("id", "typeName", "service1", "ric1");
         assertThat(policies.size()).isEqualTo(1);
 
-        String url = "/policy?instance=id";
+        String url = "/policy?id=id";
         ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
 
         assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
@@ -584,12 +584,12 @@ public class ApplicationTest {
         addPolicy("id", "typeName", "service1", "ric1");
         assertThat(policies.size()).isEqualTo(1);
 
-        String url = "/policy_status?instance=id";
+        String url = "/policy_status?id=id";
         String rsp = restClient().get(url).block();
         assertThat(rsp.equals("OK")).isTrue();
 
         // GET non existing policy status
-        url = "/policy_status?instance=XXX";
+        url = "/policy_status?id=XXX";
         testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
     }
 
index 26e2091..f3aaa24 100644 (file)
@@ -115,12 +115,12 @@ class ConcurrencyTestRunnable implements Runnable {
     }
 
     private void putPolicy(String name) {
-        String putUrl = baseUrl + "/policy?type=type1&instance=" + name + "&ric=ric&service=service1";
+        String putUrl = baseUrl + "/policy?type=type1&id=" + name + "&ric=ric&service=service1";
         restTemplate.put(putUrl, createJsonHttpEntity("{}"));
     }
 
     private void deletePolicy(String name) {
-        String deleteUrl = baseUrl + "/policy?instance=" + name;
+        String deleteUrl = baseUrl + "/policy?id=" + name;
         restTemplate.delete(deleteUrl);
     }