Versions Compared

Key

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

With recent developments in the CPS core API's a few inconsistencies that were observed with the Get Data Node API. The goal of this wiki is to provide the analysis of these inconsistencies, how these functional inconsistencies compare against the Query API and some possible solutions to them.

Table of Contents

Issues & Decisions

NotesDecisions

 

  • As per discussion with Lukasz Rajewski the following decisions were made:
    • The approach to have a custom logic to retrieve all the list items seems to be most appropriate to make Get Data Node API consistent with Query API
    • The approach to use a special character, asterisk(*) does not address the problem of inconsistency. As we would like to have the xpath in request consistent with that in Query API
      • Example: 

        Code Block
        /v2/dataspaces/my-dataspace/anchors/multipleTop/node?xpath=/bookstore/categories&descendants=3


    • The approach to Redirect the request to Query API does not seem to be a feasible approach.

 

After discussion in the CPS-sub team, following conclusions were made:

  • Use correct Error Code and Response Message, when updating multiple data nodes
  • As per CPS Exceptions and REST APIs HTTP Response Codes, the response code was set to 400 with appropriate message.
  • Update for single data node with root node xpath remains as it is.

Inconsistent response when retrieving data nodes.

...

Similarly, when the comparing the Get Data Node API to Query API, it was observed that when a Query is performed on a List data node then all the list items are returned, but when the same operation is performed using Get Data Node API it returns 404 Not Found as response.

Requesting an entire List using Query API

Code Block
titleRequesting entire List using Query API and xPath
/v2/dataspaces/my-dataspace/anchors/multipleTop/nodes/query?cps-path=/bookstore/categories&descendants=3

...

In the above table we can see that the the individual list items of the list "Categories" are stored with respect to their unique xpaths and no xPath such as /bookstore/categories exists in the DB.

Possible Solutions

Implement a logic to retrieve all data nodes when a list is requested

One approach could be to implement logic to retrieve all the list items when a List data node is queried, similar to the approach taken in Query API.

This would require a custom logic in Get Data Node API which would fetch all the list items when a xpath for a list data node is sent in the get request. This would make the Get Data node API consistent with the Query API.

A sample request in this case would look something like:

Code Block
/v2/dataspaces/my-dataspace/anchors/multipleTop/node?xpath=/bookstore/categories&descendants=3

Using a special character in the xPath for Get Data Node API

...

Note: The problem with this approach is to identify whether the request data node is a list or not, by using the xpath provided in the Get request.

Implement a logic to retrieve all data nodes when a list is requested

Another approach could be to implement logic to retrieve all the list items when a List data node is queried, similar to the approach taken in Also it is not feasible to redirect the request to Query API.