Versions Compared

Key

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

...


SloganNotesDecision
1Which alternativechanged target anchor name to a query parameter Second approach Alternative 2 of having one endpoint capable of performing 2 operations
2


Introduction

Currently CPS Delta Feature provides 2 endpoints as follows:

...

Type

Format

Description

FileYang file/Zip filefile containing the schema details.
Text/StringTarget anchor name or JSON payload as plain text
  • Case 1: target anchor name to fetch the data stored under the specified anchor, which is then compared to source anchor
  • Case 2: json data to be compared to source anchor

Anchor
finalizedApproach
finalizedApproach
Alternative 2:  One Endpoint with Two Operations

In RESTful interface we can have same endpoint for multiple APIs, given they are performing different operations, for example POST and GET.

...

#Existing EndpointUpdated EndpointPath/Query ParametersResponse Codes
1

GET-/v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/deltaAnchorsGET-/v2/dataspaces/{dataspace-name}/anchors/{source-anchor-name}/delta

GET-/v2/dataspaces/{dataspace-name}/anchors/{source-anchor-name}/delta?target-anchor-name={target-anchor-name}&descendants={descendants}&xpath={xpath}


Parameter NameInRequiredDescription
dataspace-namePathYesDataspace name
source-anchor-namePathYesFirst Anchor Name/Reference Anchor
target-anchor-nameQueryYesSecond Anchor Name/Comparand Anchor
descendantsQueryNoLevel of descendants for delta comparison. 
xpathQueryYesxpath of the node


  • 200 (OK)
    • success
  • 400
    • dataspace not found
      DataspaceNotFoundException
    • anchor not found
      AnchorNotFoundException
    • Data node not found
      DataNodeNotFoundException
    • invalid xpath
      CpsPathException
  • 500
    • unexpected error
2

POST- /v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/deltaPayloadPOST- /v2/dataspaces/{dataspace-name}/anchors/{source-anchor-name}/delta

POST- /v2/dataspaces/{dataspace-name}/anchors/{source-anchor-name}/delta?xpath={xpath}

Body

file- yang/zip schema (Optional)

json - JSON payload as String (Mandatory)


Parameter NameInRequiredDescription
dataspace-namePathYesDataspace name
source-anchor-namePathYesFirst Anchor Name/Reference Anchor
xpathQueryYesxpath of the node
FileBody (multipart/form-data TBC)OptionalYang file/Zip file containing the schema details.
Text/StringBody (multipart/form-data)YesJSON payload as plain text


...

  • we have two different ways to generate delta, so we can say the final operation is common that is "delta". So, the idea is to have the common components between the operations as path parameters, i.e. dataspace name and first anchor name
  • remaining components should be in query, that is target anchor name, and fetch descendants' option in first operation and JSON payload and schema in second operation.
  • this approach is also consistent with existing CPS API's such as list-node APIs where a singular endpoint performs different operations while having similar parameters