Versions Compared

Key

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

Objective 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 ChangesComments
URL: http://<IP:PORT>/v1/dataspaces/{dataspace-name}/anchors/{anchor-name}/node?xpath=/&include-
decendents
descendants=true&depth=1
  1. depth is an optional query
parameter 
  1. 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-
decendents
descendents=true&depth=1
depth is an optional query parameter 

...







Implementations: 


changes files changes/notesDecision
cpsData.yml
nodeByDataspaceAndAnchor:
get:
description:
 
Get
 
a
 
node
 
with an option to retrieve all the children for a given anchor and dataspace
tags:
- cps-data
summary: Get a node
operationId: getNodeByDataspaceAndAnchor
parameters:
- $ref: 'components
.
yml#/components/parameters/dataspaceNameInPath'
- $ref: 'components
.
yml#/components/parameters/anchorNameInPath'
- $ref: 'components
.
yml#/components/parameters/xpathInQuery'
      - $ref: 'components.yml#/components/parameters/
includeDescendantsOptionInQuery'
- $ref: 'components.yml#/components/parameters/
depthInQuery'
...

cpsQuery.yml
nodesByDataspaceAndAnchorAndCpsPath:
get
:
description: Query data nodes for the given dataspace and anchor using CPS path
tags
:
   
-
 
cps-query
summary: Query data nodes
operationId: getNodesByDataspaceAndAnchorAndCpsPath
parameters:
- $ref: 'components.yml#/components/parameters/dataspaceNameInPath'
- $ref: 'components
.
yml#/components/parameters/anchorNameInPath'
- $ref: 'components
.
yml#/components/parameters/cpsPathInQuery'
- $ref: 'components
.
yml#/components/parameters/includeDescendantsOptionInQuery'

- $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.  
CpsDataPersistenceServiceImpl.java
change in "queryDataNodes" method