summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
authortragait <rahul.tyagi@est.tech>2021-08-20 15:45:58 +0100
committertragait <rahul.tyagi@est.tech>2021-08-26 12:50:30 +0100
commitc584bf2729bb6eb9229aad9dbacc65beaa5dbc2f (patch)
tree9a44c8563dc73db1a620de7053cb1eace58fefae /cps-ncmp-rest
parent673c6d94830a1677e685cab82a76747a0808d347 (diff)
Post impl for passthrough running (Ncmp impl.)
Issue-ID: CPS-577 Signed-off-by: tragait <rahul.tyagi@est.tech> Change-Id: Ic8983349cf88fb123feb95ce01ec6fdf670469f4
Diffstat (limited to 'cps-ncmp-rest')
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml10
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml30
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java20
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy17
4 files changed, 76 insertions, 1 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index ca1c6ab794..ffb8dde113 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -112,7 +112,7 @@ components:
schema:
type: string
acceptParamInHeader:
- name: accept
+ name: Accept
in: header
required: false
description: Accept parameter for response, if accept parameter is null, that means client can accept any format.
@@ -134,6 +134,14 @@ components:
schema:
type: integer
minimum: 1
+ contentParamInHeader:
+ name: Content-Type
+ in: header
+ required: false
+ description: Content parameter for request, if content parameter is null, default value is application/json.
+ schema:
+ type: string
+ default: application/json
responses:
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index b2e14d714a..8eed9b37b1 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -250,4 +250,34 @@ resourceDataForPassthroughRunning:
403:
$ref: 'components.yaml#/components/responses/Forbidden'
404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+ post:
+ tags:
+ - network-cm-proxy
+ summary: create resource data from pass-through running for cm handle
+ description: create resource data from pass-through running for given cm handle
+ operationId: createResourceDataRunningForCmHandle
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+ - $ref: 'components.yaml#/components/parameters/resourceIdentifierInPath'
+ - $ref: 'components.yaml#/components/parameters/contentParamInHeader'
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ application/yang-data+json:
+ schema:
+ type: object
+ responses:
+ 201:
+ $ref: 'components.yaml#/components/responses/Created'
+ 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/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 587787e2df..d4e842a35a 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
@@ -200,6 +200,26 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return ResponseEntity.ok(responseObject);
}
+ /**
+ * Create resource data in datastore pass through running
+ * for given cm-handle.
+ *
+ * @param cmHandle cm handle identifier
+ * @param resourceIdentifier resource identifier
+ * @param requestBody requestBody
+ * @param contentType content type of body
+ * @return {@code ResponseEntity} response from dmi plugi
+ */
+ @Override
+ public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String cmHandle,
+ final String resourceIdentifier,
+ final Object requestBody,
+ final String contentType) {
+ networkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle(cmHandle,
+ resourceIdentifier, requestBody, contentType);
+ return new ResponseEntity<>(HttpStatus.CREATED);
+ }
+
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 a7fa309013..1a2d3a204f 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
@@ -237,5 +237,22 @@ class NetworkCmProxyControllerSpec extends Specification {
and: 'response contains valid object body'
response.getContentAsString() == '{valid-json}'
}
+
+ def 'Create Resource Data from pass-through running using POST.' () {
+ given: 'resource data url'
+ def getUrl = "$basePath/v1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ "/testResourceIdentifier"
+ when: 'get data resource request is performed'
+ def response = mvc.perform(
+ post(getUrl)
+ .contentType(MediaType.APPLICATION_JSON_VALUE)
+ .accept(MediaType.APPLICATION_JSON_VALUE).content('{"some-json":"value"}')
+ ).andReturn().response
+ then: 'ncmp service method to create resource called'
+ 1 * mockNetworkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'testResourceIdentifier', ['some-json':'value'], 'application/json;charset=UTF-8')
+ and: 'resource is created'
+ response.status == HttpStatus.CREATED.value()
+ }
}