aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml8
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml28
-rwxr-xr-xcps-ncmp-rest/docs/openapi/openapi.yml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java7
-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/NetworkCmProxyDataService.java10
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java5
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/api/impl/NetworkCmProxyDataServiceImplSpec.groovy10
8 files changed, 89 insertions, 0 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index 69c37ad7a7..5ff30994f9 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -1,5 +1,6 @@
# ============LICENSE_START=======================================================
# Modification (C) 2021 Nordix Foundation
+# Modifications Copyright (C) 2021 Pantheon.tech
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -52,6 +53,13 @@ components:
schema:
type: string
default: /
+ requiredXpathInQuery:
+ name: xpath
+ in: query
+ description: xpath
+ required: true
+ schema:
+ type: string
includeDescendantsOptionInQuery:
name: include-descendants
in: query
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index d5358cc5d4..00e0cc78f8 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -142,4 +142,32 @@ nodesByCmHandleAndXpath:
403:
$ref: 'components.yaml#/components/responses/Forbidden'
404:
+ $ref: 'components.yaml#/components/responses/NotFound'
+
+listNodeByCmHandleAndXpath:
+ post:
+ description: Add one or more list-node child elements under existing node for the given CM Handle
+ tags:
+ - network-cm-proxy
+ summary: Add list-node child element(s)
+ operationId: addListNodeElements
+ parameters:
+ - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
+ - $ref: 'components.yaml#/components/parameters/requiredXpathInQuery'
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: string
+ 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/docs/openapi/openapi.yml b/cps-ncmp-rest/docs/openapi/openapi.yml
index 7575022f83..862837ea28 100755
--- a/cps-ncmp-rest/docs/openapi/openapi.yml
+++ b/cps-ncmp-rest/docs/openapi/openapi.yml
@@ -1,5 +1,6 @@
# ============LICENSE_START=======================================================
# Modification (C) 2021 Nordix Foundation
+# Modifications Copyright (C) 2021 Pantheon.tech
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -26,6 +27,9 @@ paths:
/v1/cm-handles/{cm-handle}/node:
$ref: 'ncmproxy.yml#/nodeByCmHandleAndXpath'
+ /v1/cm-handles/{cm-handle}/list-node:
+ $ref: 'ncmproxy.yml#/listNodeByCmHandleAndXpath'
+
/v1/cm-handles/{cm-handle}/nodes/query:
$ref: 'ncmproxy.yml#/nodesByCmHandleAndCpsPath'
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 3c8a04e822..484a21ae65 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
@@ -54,6 +54,13 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
}
@Override
+ public ResponseEntity<String> addListNodeElements(final String jsonData, final String parentNodeXpath,
+ final String cmHandle) {
+ networkCmProxyDataService.addListNodeElements(cmHandle, parentNodeXpath, jsonData);
+ return new ResponseEntity<>(HttpStatus.CREATED);
+ }
+
+ @Override
public ResponseEntity<Object> getNodeByCmHandleAndXpath(final String cmHandle, @Valid final String xpath,
@Valid final Boolean includeDescendants) {
final FetchDescendantsOption fetchDescendantsOption = Boolean.TRUE.equals(includeDescendants)
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 ea3c16d4cb..45e8f11948 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
@@ -105,6 +105,23 @@ class NetworkCmProxyControllerSpec extends Specification {
'parent node xpath' | '/xpath' || '/xpath'
}
+ def 'Add list-node elements.'() {
+ given: 'json data and parent node xpath'
+ def jsonData = 'json data'
+ def parentNodeXpath = 'parent node xpath'
+ when: 'post request is performed'
+ def response = mvc.perform(
+ post("$dataNodeBaseEndpoint/cm-handles/$cmHandle/list-node")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(jsonData)
+ .param('xpath', parentNodeXpath)
+ ).andReturn().response
+ then: 'the service method is invoked once with expected parameters'
+ 1 * mockNetworkCmProxyDataService.addListNodeElements(cmHandle, parentNodeXpath, jsonData)
+ and: 'response status indicates success'
+ response.status == HttpStatus.CREATED.value()
+ }
+
def 'Update data node leaves.'() {
given: 'json data'
def jsonData = 'json data'
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index 8176ea50fa..ccc4e44ccb 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -68,6 +68,16 @@ public interface NetworkCmProxyDataService {
void createDataNode(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
/**
+ * Creates one or more child node elements with descendants under existing node from list-node data fragment.
+ *
+ * @param cmHandle The identifier for a network function, network element, subnetwork or any other cm
+ * object managed by Network CM Proxy
+ * @param parentNodeXpath xpath to parent node
+ * @param jsonData data as JSON string
+ */
+ void addListNodeElements(@NonNull String cmHandle, @NonNull String parentNodeXpath, @NonNull String jsonData);
+
+ /**
* Updates data node for given cm handle using xpath to parent node.
*
* @param cmHandle The identifier for a network function, network element, subnetwork or any other cm object
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 56f4cf8dce..bdb71bf625 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -68,6 +68,11 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
@Override
+ public void addListNodeElements(final String cmHandle, final String parentNodeXpath, final String jsonData) {
+ cpsDataService.saveListNodeData(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
+ }
+
+ @Override
public void updateNodeLeaves(final String cmHandle, final String parentNodeXpath, final String jsonData) {
cpsDataService.updateNodeLeaves(getDataspaceName(), cmHandle, parentNodeXpath, jsonData);
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
index 0a00e34f7b..e67d4ad85d 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
@@ -73,6 +73,16 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
1 * mockcpsDataService.saveData(expectedDataspaceName, cmHandle, xpath, jsonData)
}
+ def 'Add list-node elements.'() {
+ given: 'a cm handle and parent node xpath'
+ def jsonData = 'some json'
+ def xpath = '/test-node'
+ when: 'addListNodeElements is invoked'
+ objectUnderTest.addListNodeElements(cmHandle, xpath, jsonData)
+ then: 'the CPS service method is invoked once with the expected parameters'
+ 1 * mockcpsDataService.saveListNodeData(expectedDataspaceName, cmHandle, xpath, jsonData)
+ }
+
def 'Update data node leaves.'() {
given: 'a cm Handle and a cps path'
def xpath = '/xpath'