Change name of policy ID in API

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>
diff --git a/docs/policy-agent-api.rst b/docs/policy-agent-api.rst
index e3354e4..8a46fc7 100644
--- a/docs/policy-agent-api.rst
+++ b/docs/policy-agent-api.rst
@@ -634,12 +634,12 @@
   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 @@
           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 @@
 
     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 @@
 
     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 @@
   "*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 @@
 
     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 @@
   "*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 @@
 
     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 @@
   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:**
 
diff --git a/policy-agent/docs/api.yaml b/policy-agent/docs/api.yaml
index 5800f0f..3ea913d 100644
--- a/policy-agent/docs/api.yaml
+++ b/policy-agent/docs/api.yaml
@@ -64,9 +64,9 @@
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
       responses:
@@ -91,9 +91,9 @@
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
         - in: body
@@ -147,9 +147,9 @@
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
       responses:
@@ -281,9 +281,9 @@
       produces:
         - '*/*'
       parameters:
-        - name: instance
+        - name: id
           in: query
-          description: instance
+          description: id
           required: true
           type: string
       responses:
diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
index 5ae54ef..0991605 100644
--- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
+++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java
@@ -155,9 +155,9 @@
             @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 @@
             @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 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 @@
             @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)) //
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java b/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
index b7e9a4b..1784fea 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
@@ -247,9 +247,9 @@
 
     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 @@
         // 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 @@
 
     @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 @@
         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 @@
         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);
     }
 
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/ConcurrencyTestRunnable.java b/policy-agent/src/test/java/org/oransc/policyagent/ConcurrencyTestRunnable.java
index 26e2091..f3aaa24 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/ConcurrencyTestRunnable.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/ConcurrencyTestRunnable.java
@@ -115,12 +115,12 @@
     }
 
     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);
     }