Versions Compared

Key

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

Table of Contents

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


HTTP response codes for Delta between Anchor and Payload API

Proposed API

The proposed API will be part of the CPS Data Interface. This API takes multipart form data as request body, using this the user can provide the JSON payload and its corresponding Schema Context in form of a Yang or ZIP file. This file will only be used to generate the data nodes from the JSON payload and will not be persisted in CPS DB. The following response codes will be returned by the API:

#Sub InterfaceMethodScenario

HTTP Response codes

to be implemented

Notes
1Data

Proposed API:

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

Proposed method name:  CpsDataApi.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
anchorPathYesAnchor Name/Reference Anchor
xpathQueryYesxpath of the node
descendantsQueryNoLevel of descendants for delta comparison. Set to INCLUDE_ALL_DESCENDANTS by default.

Request body:

Content-Type: multipart/form-data

...

Code Block
titleResponse body should contain anchors delta report (added/deleted/modified configuration) as below.
collapsetrue
[
  {
    "action": "ADD",
    "xpath": "/bookstore/categories/[@code=3]",
    "target-data": {
      "code": 3,
      "name": "kidz"
    }
  },
  {
    "action": "DELETE",
    "xpath": "/bookstore/categories/[@code=1]",
    "source-data": {
      "code": 1,
      "name": "Fiction"
    }
  },
  {
    "action": "UPDATE",
    "xpath": "/bookstore/categories/[@code=2]",
    "source-data": {
      "name": "Funny"
    },
    "target-data": {
      "name": "Comic"
    }
  }
]

Functional Details about the API

The proposed API will be used to generate a delta between data fetched from an anchor against JSON payload provided by the user. The following are some key functional details about the API:

...