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

Compare with Current View Page History

Version 1 Next »

Overview

The second API proposed under the Delta feature is to generate a delta between configuration stored under an Anchor and JSON payload provided by the user. All the responses and exceptions thrown by this API will be similar to the API to generate delta between 2 anchors to maintain consistency between the API's.

Issues & Decisions

Questions/IssuesDecisions/Answers
Should the "descendants" option be provided as part of the API? The JSON payload may or may not contain all the child nodes. Hence there is always the uncertainty. So, would it be a better approach to fetch all descendants always?

HTTP response codes for Delta between Anchor and Payload API

The proposed API will be part of the CPS Data Interface. The following response codes will be returned by the API:

#Sub InterfaceMethodScenario

HTTP Response codes

to be implemented

Notes
1Data

Proposed API:

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

Proposed method name:  getDeltaByDataspaceAnchorAndPayload()

Generate a delta report between an anchor and JSON payload

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

Request parameters:

Parameter nameInRequiredDescription
dataspace-namePathYesDataspace name
anchor1QueryYesFirst Anchor Name/Reference Anchor
anchor2QueryYesSecond Anchor Name
xpathQueryYesxpath of the node
descendantsQueryNoLevel of descendants for delta comparison. 

Response Body/Delta Report Format

Response body should contain anchors delta report (added/deleted/modified configuration) as below.
[
  {
    "action": "ADD",
    "xpath": "/bookstore/categories/[@code=3]",
    "payload": {
      "code": 3,
      "name": "kidz"
    }
  },
  {
    "action": "DELETE",
    "xpath": "/bookstore/categories/[@code=1]",
    "payload": {
      "code": 1,
      "name": "Fiction"
    }
  },
  {
    "action": "UPDATE",
    "xpath": "/bookstore/categories/[@code=2]",
    "payload": {
      "name": "Comic"
    }
  }
]

Mechanism for Delta generation between Anchor and Payload

  • No labels