summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmp.yml28
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java10
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy17
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiRequestBody.java3
4 files changed, 57 insertions, 1 deletions
diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml
index 611e84e01e..fdad1f56db 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp.yml
@@ -289,6 +289,34 @@ resourceDataForPassthroughRunning:
404:
$ref: 'components.yaml#/components/responses/NotFound'
+ patch:
+ tags:
+ - network-cm-proxy
+ summary: Patch resource data from pass-through running
+ description: Patch resource data from pass-through running for the given cm handle
+ operationId: patchResourceDataRunningForCmHandle
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+ - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
+ - $ref: 'components.yaml#/components/parameters/contentParamInHeader'
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ 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'
+
fetchModuleReferencesByCmHandle:
get:
description: fetch all module references (name and revision) for a given cm handle
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 222957c9f4..f95d4a2f52 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
@@ -23,6 +23,7 @@
package org.onap.cps.ncmp.rest.controller;
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.CREATE;
+import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.PATCH;
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE;
import com.google.gson.Gson;
@@ -189,6 +190,15 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return ResponseEntity.ok(responseObject);
}
+ @Override
+ public ResponseEntity<Object> patchResourceDataRunningForCmHandle(final String resourceIdentifier,
+ final String cmHandle,
+ final Object requestBody, final String contentType) {
+ networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ resourceIdentifier, PATCH, requestBody.toString(), contentType);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
/**
* Create resource data in datastore pass through running for given cm-handle.
*
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 436f22b327..4186bcd1bf 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
@@ -25,6 +25,7 @@ package org.onap.cps.ncmp.rest.controller
import org.onap.cps.TestUtils
import org.onap.cps.spi.model.ModuleReference
+import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.PATCH
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
@@ -301,5 +302,21 @@ class NetworkCmProxyControllerSpec extends Specification {
response.contentAsString == '{"cmHandles":[]}'
}
+ def 'Patch resource data in passthrough-running datastore.' () {
+ given: 'patch resource data url'
+ def url = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ "?resourceIdentifier=parent/child"
+ when: 'patch data resource request is performed'
+ def response = mvc.perform(
+ patch(url)
+ .contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON).content('{"some-key" : "some-value"}')
+ ).andReturn().response
+ then: 'ncmp service method to update resource is called'
+ 1 * mockNetworkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'parent/child', PATCH, '{some-key=some-value}', 'application/json;charset=UTF-8')
+ and: 'the response status is OK'
+ response.status == HttpStatus.OK.value()
+ }
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiRequestBody.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiRequestBody.java
index 13cfdcefe4..a635f0bc89 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiRequestBody.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiRequestBody.java
@@ -37,7 +37,8 @@ public class DmiRequestBody {
public enum OperationEnum {
READ("read"),
CREATE("create"),
- UPDATE("update");
+ UPDATE("update"),
+ PATCH("patch");
private String value;
OperationEnum(final String value) {