Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 API Mapper CPS-TBDMT service.


2. Architecture

Drawio
bordertrue
diagramNamemapper service arch
simpleViewerfalse
width
linksauto
tbstyletop
lboxtrue
diagramWidth447
revision12
 

3. API definition guide

Swagger file: CPS-TBDMT-swagger.yaml

Template CRUD operations

Create xpath template

Interface definitionDescription
Content-Typeapplication/json
OperationPOST
URI/api/v1/templates

Request Body

AttributeRequiredTypeDescription
idtemplateIdYStringIdentifier for the template
schema-setmodelYStringschema set on which xpath query should be executed
requestTypeYStringrequest type(get, post ..)
xpathTemplateYStringxpath template
includeDescendantsYbooleaninclude descendants
multipleQueryTemplateIdNStringxpath templatemultiple query template Id
transformParamNStringtranformation format("param1, param2")

Response Codes

CodeDescription
201Template created successfully
400Bad Request (Error in request attributes)
500Internal server error

List all xpath template

Interface definitionDescription
Content-Typeapplication/json
OperationGET
URI/api/v1/templates

Response Codes

CodeDescription
200Templates returned successfully
404No templates found
500Internal server error

Response Body

AttributeRequiredTypeDescription
templatesYListList of template objects

Template Object

xpath
AttributeRequiredTypeDescription
idtemplateIdYStringIdentifier for the template
schema-setmodelYStringschema set on which xpath query should be executed
requestTypeYStringrequest type(get, post ..)
xpathTemplateYStringxpath template
includeDescendantsYbooleaninclude descendants
multipleQueryTemplateIdNStringmultiple query template Id
transformParamNStringtranformation format("param1, param2")


Get a xpath template by id

Interface definitionDescription
Content-Typeapplication/json
OperationGET
URI/api/v1/templates/{schema-set}/{id}

Response Codes

CodeDescription
200Template found and returned
404Template not found
500Internal server error

Response Body

Same as template Object

Delete xpath template

Interface definitionDescription
Content-Typeapplication/json
OperationDELETE
URI/api/v1/templates/{schema-set}/{id}

Response Codes

CodeDescription
200Template deleted successfully
400Bad Request (Error in request attributes)
500Internal server error

Execute template

Interface definitionDescription
Content-Typeapplication/json
OperationPOST
URI/api/v1/execute/{schema-setmodel}/{id}

Request Body

AttributeRequiredTypeDescription
InputinputParametersYJSON blobInput dictionary to be applied to the template
payloadNJSON blobPayload to be used during edit/patch

Response Codes

CodeDescription
200Template executed successfully
400Bad Request (Error in request attributes)
404Template Not  found
500Internal server error

Response Body

AttributeRequiredTypeDescription
resultYJSON BlobResult of the xpath query as JSON object

4. Dependencies

Definition of templates

Sample xpath query

/NearRTRIC[idNearRTRIC=11]/GNBDUFunction[idGNBDUFunction=1]/NRCellDU[idNRCellDU=15296]/attributes/RRMPolicyRatio[id=123]

...

/NearRTRIC[idNearRTRIC={{nearrtric_id}}]/GNBDUFunction[idGNBDUFunction={{gnbdu_id}}]/NRCellDU[idNRCellDU={{nrcelldu_id}}]/attributes/RRMPolicyRatio[id={{rrmpolicy_id}}]

Sample API for the above template

Elite soft json viewer
{
   "inputinputParameters": {
      "nearrtric_id": 11,
      "gnbdu_id": 1,
      "nrcelldu_id": 15296,
      "rrmpolicy_id": 123
   }
}


Response Object


Elite soft json viewer
{
   "result": {
      "key": "value"
   }
}

5. Output Transformation Template Example

   

curl --location --request POST 'http://localhost:8080/templates' --header 'Content-Type: application/json' --data-raw '{
"templateId": "get-ric",
"model": "ns-schemaset",
"requestType": "get",
"xpathTemplate": "/",
"includeDescendants": true,
"transformParam":"NearRTRIC,GNBDUFunction,NRCellDU,idNRCellDU"
}'


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

Response: 

["Left","Right"]

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

Responses
//get-all-data
["Left","Right"]
//get-branch
[["Owl","Raven","Crow"]], [["Robin","Sparrow","Finch"]]

6. Supported requestTypes:

  1. get (/anchors/{anchor}/node?xpath=)
  2. query (/anchors/{anchor}/nodes/query?xpath)
  3. query-cps-path (/anchors/{anchor}/nodes/query?cps-path)
  4. post (/anchors/{anchor}/nodes?xpath=)
  5. put (/anchors/{anchor}/nodes?xpath=)
  6. patch (/anchors/{anchor}/nodes?xpath=)
  7. post-list-node (/anchors/{anchor}/list-node?xpath=)


7. Deployment aspects

...

To be updated

  1. git clone "https://gerrit.onap.org/r/cps/cps-tbdmt
  2. cd cps-tbdmt/
  3. mvn clean install
  4. cd docker-compose/
  5. update cps & ncmp ip-address in application.yml
  6. docker-compose up (use the image built using the above steps in the docker-compose file)