summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-rest')
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml27
-rwxr-xr-xcps-ncmp-rest/docs/openapi/openapi.yml5
-rw-r--r--cps-ncmp-rest/pom.xml2
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java8
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy16
5 files changed, 56 insertions, 2 deletions
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index 138337d24e..5e2957f340 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -280,4 +280,31 @@ resourceDataForPassthroughRunning:
403:
$ref: 'components.yaml#/components/responses/Forbidden'
404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+
+fetchModuleReferencesByCmHandle:
+ get:
+ description: fetch all module references (name and revision) for a given cm handle
+ tags:
+ - network-cm-proxy
+ summary: Fetch all module references (name and revision) for a given cm handle
+ operationId: getModuleReferencesByCmHandle
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: string
+ example: [{"moduleName": "nc-notifications", "revision": "2008-07-14"}]
+ $ref: 'components.yaml#/components/responses/Ok'
+ 400:
+ $ref: 'components.yaml#/components/responses/BadRequest'
+ 401:
+ $ref: 'components.yaml#/components/responses/Unauthorized'
+ 403:
+ $ref: 'components.yaml#/components/responses/Forbidden'
+ 404:
$ref: 'components.yaml#/components/responses/NotFound' \ No newline at end of file
diff --git a/cps-ncmp-rest/docs/openapi/openapi.yml b/cps-ncmp-rest/docs/openapi/openapi.yml
index 8d8684a355..12356b5887 100755
--- a/cps-ncmp-rest/docs/openapi/openapi.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi.yml
@@ -45,4 +45,7 @@ paths:
$ref: 'ncmproxy.yml#/getResourceDataForPassthroughOperational'
/v1/ch/{cm-handle}/data/ds/ncmp-datastore:passthrough-running/{resourceIdentifier}:
- $ref: 'ncmproxy.yml#/resourceDataForPassthroughRunning' \ No newline at end of file
+ $ref: 'ncmproxy.yml#/resourceDataForPassthroughRunning'
+
+ /v1/ch/{cm-handle}/modules:
+ $ref: 'ncmproxy.yml#/fetchModuleReferencesByCmHandle' \ No newline at end of file
diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml
index d3de688e23..e77ede50dc 100644
--- a/cps-ncmp-rest/pom.xml
+++ b/cps-ncmp-rest/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index f5ffdbeb92..b78241662e 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -35,6 +35,7 @@ import org.onap.cps.ncmp.rest.api.NetworkCmProxyApi;
import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.model.DataNode;
+import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.utils.DataMapUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -220,6 +221,13 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return new ResponseEntity<>(HttpStatus.CREATED);
}
+ @Override
+ public ResponseEntity<Object> getModuleReferencesByCmHandle(final String cmHandle) {
+ final Collection<ModuleReference>
+ moduleReferences = networkCmProxyDataService.getYangResourcesModuleReferences(cmHandle);
+ return new ResponseEntity<>(new Gson().toJson(moduleReferences), HttpStatus.OK);
+ }
+
private DmiPluginRegistration convertRestObjectToJavaApiObject(
final RestDmiPluginRegistration restDmiPluginRegistration) {
return objectMapper.convertValue(restDmiPluginRegistration, DmiPluginRegistration.class);
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index 73ccd6e3c2..613243e28b 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -22,6 +22,8 @@
package org.onap.cps.ncmp.rest.controller
+import org.onap.cps.spi.model.ModuleReference
+
import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
@@ -246,5 +248,19 @@ class NetworkCmProxyControllerSpec extends Specification {
and: 'resource is created'
response.status == HttpStatus.CREATED.value()
}
+
+ def 'Get module references for the given dataspace and cm handle.' () {
+ given: 'get module references url'
+ def getUrl = "$ncmpBasePathV1/ch/some-cmhandle/modules"
+ when: 'get module resource request is performed'
+ def response =mvc.perform(get(getUrl)).andReturn().response
+ then: 'ncmp service method to get yang resource module references is called'
+ mockNetworkCmProxyDataService.getYangResourcesModuleReferences('some-cmhandle')
+ >> [new ModuleReference(moduleName: 'some-name1',revision: 'some-revision1')]
+ and: 'response contains an array with the module name and revision'
+ response.getContentAsString() == '[{"moduleName":"some-name1","revision":"some-revision1"}]'
+ and: 'response returns an OK http code'
+ response.status == HttpStatus.OK.value()
+ }
}