1. Overview
This service shall be used to map the erstwhile Config-DB-like REST APIs to appropriate CPS API calls. The purpose of this service is to abstract the details of (possibly multiple, and complex) XPath queries from the users of CPS. It enables CPS-users to continue using simple REST API calls that are intuitive and easy-to-understand and implement. The mapping to appropriate queries to CPS (including mapping of one API call to many Xpath queries) shall be done in a generic way by the CPS-TBDMT service.
...
6. Multiple query Example
Example test-tree model:
{"branch":[{"name":"Right","nest":{"name":"Big","birds":["Owl","Raven","Crow"]}},{"name":"Left","nest":{"name":"Small","birds":["Robin","Sparrow","Finch"]}}]}
Get-all-data
curl --location --request POST 'http://localhost:8080/templates' --header 'Content-Type: application/json' --data-raw '{
"templateId": "get-all-data",
"model": "CSIT-SchemaSet",
"requestType": "get",
"xpathTemplate": "/test-tree",
"includeDescendants": true,
"transformParam":"branch,name"
}' -i
curl --location --request POST 'http://localhost:8080/execute/CSIT-SchemaSet/get-all-data' --header 'Content-Type: application/json' --data-raw '{
"inputParameters": {
}
}' -i
...
The above response will be inserted ({{name}}) in the below template and will be executed twice(First "/test-tree/branch[@name='Left']/nest" and then "/test-tree/branch[@name='Right']/nest") to give collective output.
Get-branch
curl --location --request POST 'http://localhost:8080/templates' --header 'Content-Type: application/json' --data-raw '{
"templateId": "get-branch",
"model": "CSIT-SchemaSet",
"requestType": "get",
"xpathTemplate": "/test-tree/branch[@name='\''{{name}}'\'']/nest",
"includeDescendants": true,
"multipleQueryTemplateId":"get-all-data",
"transformParam":"birds"
}' -i
6. Supported requestTypes:
- get (/anchors/{anchor}/node?xpath=)
- query (/anchors/{anchor}/nodes/query?xpath)
- query-cps-path (/anchors/{anchor}/nodes/query?cps-path)
- post (/anchors/{anchor}/nodes?xpath=)
- put (/anchors/{anchor}/nodes?xpath=)
- patch (/anchors/{anchor}/nodes?xpath=)
- post-list-node (/anchors/{anchor}/list-node?xpath=)
7. Deployment aspects1.
- git clone "https://gerrit.onap.org/r/cps/cps-tbdmt"
...
- cd cps-tbdmt/
...
- mvn clean install
...
- cd docker-compose/
...
- update cps & ncmp ip-address in application.yml
...
- docker-compose up (use the image built using the above steps in the docker-compose file)