You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Background : we want to include limit/depth/pagination in CPS-Core query APIs where output size is large. it will allow user to limit query outputs.

It was discussed on 11th Nov 2022 in weekly meeting to use 'depth' parameter to limit large outputs.


Implementation


'depth' query parameter added in below URLsNotesDecision
URL: http://<IP:PORT>/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/node?xpath=/&include-descendants=true&depth=1
  1. depth is an optional query parameter or mandatory 
  2. how to handle include-descendants query parameter? can we remove this parameter and use only depth parameter.  depth = -1 is same as include-descendants= true 
  3. depth values treated as below
    1. -1 : all descendants 
    2. 0 : no descendants
    3. 1, 2, 3, ... : number or descendants  

URL: http://<IP:PORT>/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes/query?cps-path=/&include-descendents=true&depth=1




Implementations: 

changes files changes/notesDecision
cpsData.yml
nodeByDataspaceAndAnchor:
get:
...
      - $ref: 'components.yml#/components/parameters/depthInQuery'
...

cpsQuery.yml
nodesByDataspaceAndAnchorAndCpsPath:
get:
...
- $ref: 'components.yml#/components/parameters/depthInQuery'
...

components.yml
depthInQuery:
name: depth
in: query
description: depth parameter for large query outputs
required: false
schema:
type: string
default: all
example: 1

FetchDescendantsOption.java

We Need to change this class to accept for any other depth values except -1, 0 and 1.  

Do we need to change FetchDescendantsOption to support multiple depths or add depth as separate argument along with FetchDescendantsOption


CpsDataPersistenceServiceImpl.java
change in "queryDataNodes" method 
  • No labels