Define an interface to accept collection of cm handles for Get operation. 14/134014/7
authorleventecsanyi <levente.csanyi@est.tech>
Wed, 5 Apr 2023 09:42:30 +0000 (11:42 +0200)
committerleventecsanyi <levente.csanyi@est.tech>
Mon, 17 Apr 2023 10:06:01 +0000 (12:06 +0200)
 - Added REST endpoint (Not Implemented yet)
 - Created unit test

Issue-ID: CPS-1555
Change-Id: I24ce8d663602c08cc207f4657289631439d3fb9e
Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
openapi/components.yml
openapi/openapi.yml
src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy

index 1e35c02..2bddd8b 100644 (file)
@@ -1,5 +1,5 @@
 #  ============LICENSE_START=======================================================
-#  Copyright (C) 2021-2022 Nordix Foundation
+#  Copyright (C) 2021-2023 Nordix Foundation
 #  Modifications Copyright (C) 2022 Bell Canada
 #  ================================================================================
 #  Licensed under the Apache License, Version 2.0 (the "License");
@@ -164,6 +164,16 @@ components:
             status: 500
             message: Internal Server Error
             details: Internal Server Error occured
+    NotImplemented:
+      description: Not Implemented
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/ErrorMessage'
+          example:
+            status: 501
+            message: Not Implemented
+            details: Method Not Implemented
   parameters:
     cmHandleInPath:
       name: cmHandle
index 38d5cef..24854e9 100644 (file)
@@ -119,8 +119,8 @@ paths:
     post:
       tags:
         - dmi-plugin
-      summary: Get resource data from passthrough operational or running for cm handles
-      description: Get resource data from passthrough operational or running for cm handles
+      summary: Get resource data from passthrough operational or running for a cm handle
+      description: Get resource data from passthrough operational or running for a cm handle
       operationId: dataAccessPassthrough
       parameters:
         - $ref: 'components.yml#/components/parameters/datastoreName'
@@ -148,4 +148,34 @@ paths:
         '400':
           $ref: 'components.yml#/components/responses/BadRequest'
         '500':
-          $ref: 'components.yml#/components/responses/ServerError'
\ No newline at end of file
+          $ref: 'components.yml#/components/responses/ServerError'
+
+  /v1/ch/batch/data/ds/{datastore-name}:
+    post:
+      tags:
+        - dmi-plugin
+      summary: Get a collection of CMHandles
+      description: Get a collection of cm handles by datastore (not implemented)
+      operationId: getResourceDataByCmHandles
+      parameters:
+        - $ref: 'components.yml#/components/parameters/datastoreName'
+        - $ref: 'components.yml#/components/parameters/topicParamInQuery'
+      requestBody:
+        description: Contains collection of cm handles with it's private properties and requestId
+        content:
+          application/json:
+            schema:
+              type: object
+    responses:
+      '200':
+        description: OK
+        content:
+          application/json:
+            schema:
+              type: object
+      '400':
+        $ref: 'components.yml#/components/responses/BadRequest'
+      '500':
+        $ref: 'components.yml#/components/responses/ServerError'
+      '501':
+        $ref: 'components.yml#/components/responses/NotImplemented'
\ No newline at end of file
index f952e22..da0ac3e 100644 (file)
@@ -104,6 +104,21 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
         return new ResponseEntity<>("cm-handle registered successfully.", HttpStatus.CREATED);
     }
 
+    /**
+     * This method is not implemented for ONAP DMI plugin.
+     *
+     * @param datastoreName name of the data store
+     * @param body list of cm-handles
+     * @param topic Kafka topic name
+     * @return (@ code ResponseEntity) response entity
+     */
+    @Override
+    public ResponseEntity<Void> getResourceDataByCmHandles(final String datastoreName,
+                                                 final Object body,
+                                                 final String topic) {
+        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
     /**
      * This method fetches the resource for given cm handle using pass through operational or running datastore.
      * It filters the response on the basis of options query parameters and returns response. Passthrough Running
index 2be0b59..acc8b63 100644 (file)
@@ -311,4 +311,19 @@ class DmiRestControllerSpec extends Specification {
             '? needs to be encoded as %3F' | 'idWith%3F'
 
     }
+
+    def 'Get resource data for a collection of cm handles (unimplemented).'() {
+        given: 'an endpoint for adding a batch of cm handle Ids'
+            def url = "$basePathV1/ch/batch/data/ds/test-datastore?topic=test"
+        and: 'a request body'
+            def body = '{"CmHandles": []}'
+        when: 'the endpoint is invoked'
+            def response = mvc.perform(
+                    post(url)
+                            .contentType(MediaType.APPLICATION_JSON)
+                            .content(body)
+            ).andReturn().response
+        then: 'the response status code is 501'
+            assert response.status == 501
+    }
 }