aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-08-19 15:17:56 +0100
committertragait <rahul.tyagi@est.tech>2021-08-20 15:31:31 +0100
commit888dcd495ecb63bf678e7234e9dc34e0743cb412 (patch)
tree65e1208beacc9a11eeb08985a1d4b28a90f3864c /cps-ncmp-rest
parentdc5ed75c841da857611713bceed8bf9988204d3d (diff)
Get resource data from pass through running (Ncmp impl.)
Issue-ID: CPS-580 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: I6dc37d9516078c87efc3f0c5bbd2b7b8a7155d48
Diffstat (limited to 'cps-ncmp-rest')
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml25
-rwxr-xr-xcps-ncmp-rest/docs/openapi/openapi.yml3
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java28
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy25
4 files changed, 76 insertions, 5 deletions
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index ede0ec62f0..b2e14d714a 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -225,4 +225,29 @@ getResourceDataForPassthroughOperational:
403:
$ref: 'components.yaml#/components/responses/Forbidden'
404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+
+resourceDataForPassthroughRunning:
+ get:
+ tags:
+ - network-cm-proxy
+ summary: Get resource data from pass-through running for cm handle
+ description: Get resource data from pass-through running for given cm handle
+ operationId: getResourceDataRunningForCmHandle
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+ - $ref: 'components.yaml#/components/parameters/resourceIdentifierInPath'
+ - $ref: 'components.yaml#/components/parameters/acceptParamInHeader'
+ - $ref: 'components.yaml#/components/parameters/fieldsParamInQuery'
+ - $ref: 'components.yaml#/components/parameters/depthParamInQuery'
+ responses:
+ 200:
+ $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 5b7c8d205b..0dfe3c83a7 100755
--- a/cps-ncmp-rest/docs/openapi/openapi.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi.yml
@@ -43,4 +43,5 @@ paths:
/v1/ch/{cm-handle}/data/ds/ncmp-datastore:passthrough-operational/{resourceIdentifier}:
$ref: 'ncmproxy.yml#/getResourceDataForPassthroughOperational'
- \ No newline at end of file
+ /v1/ch/{cm-handle}/data/ds/ncmp-datastore:passthrough-running/{resourceIdentifier}:
+ $ref: 'ncmproxy.yml#/resourceDataForPassthroughRunning' \ No newline at end of file
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 b35b245aab..587787e2df 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
@@ -153,7 +153,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
}
/**
- * Get resource data for for operational datastore.
+ * Get resource data from operational datastore.
*
* @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier
@@ -168,7 +168,31 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final String accept,
final @Valid String fields,
final @Min(1) @Valid Integer depth) {
- final var responseObject = networkCmProxyDataService.getResourceDataOperationalFoCmHandle(cmHandle,
+ final Object responseObject = networkCmProxyDataService.getResourceDataOperationalForCmHandle(cmHandle,
+ resourceIdentifier,
+ accept,
+ fields,
+ depth);
+ return ResponseEntity.ok(responseObject);
+ }
+
+ /**
+ * Get resource data from pass-through running datastore.
+ *
+ * @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier
+ * @param accept accept header parameter
+ * @param fields fields query parameter
+ * @param depth depth query parameter
+ * @return {@code ResponseEntity} response from dmi plugin
+ */
+ @Override
+ public ResponseEntity<Object> getResourceDataRunningForCmHandle(final String cmHandle,
+ final String resourceIdentifier,
+ final String accept,
+ final @Valid String fields,
+ final @Min(1) @Valid Integer depth) {
+ final Object responseObject = networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier,
accept,
fields,
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 b2a060c278..a7fa309013 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
@@ -206,8 +206,8 @@ class NetworkCmProxyControllerSpec extends Specification {
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_VALUE)
).andReturn().response
- then: 'the NCMP data service is called with getResourceDataOperationalFoCmHandle'
- 1 * mockNetworkCmProxyDataService.getResourceDataOperationalFoCmHandle('testCmHandle',
+ then: 'the NCMP data service is called with getResourceDataOperationalForCmHandle'
+ 1 * mockNetworkCmProxyDataService.getResourceDataOperationalForCmHandle('testCmHandle',
'testResourceIdentifier',
'application/json',
'testFields',
@@ -216,5 +216,26 @@ class NetworkCmProxyControllerSpec extends Specification {
response.status == HttpStatus.OK.value()
}
+ def 'Get Resource Data from pass-through running.' () {
+ given: 'resource data url'
+ def getUrl = "$basePath/v1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ "/testResourceIdentifier?fields=testFields&depth=5"
+ and: 'ncmp service returns json object'
+ mockNetworkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'testResourceIdentifier',
+ 'application/json',
+ 'testFields',
+ 5) >> '{valid-json}'
+ when: 'get data resource request is performed'
+ def response = mvc.perform(
+ get(getUrl)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON_VALUE)
+ ).andReturn().response
+ then: 'response status is Ok'
+ response.status == HttpStatus.OK.value()
+ and: 'response contains valid object body'
+ response.getContentAsString() == '{valid-json}'
+ }
}