blob: 47f52dc6709746566725bc89f2bde251da9b25d0 [file] [log] [blame]
Arpit Singhc45db422024-01-30 10:51:28 +05301.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
Arpit Singhc45db422024-01-30 10:51:28 +05303.. Copyright (C) 2024 TechMahindra Ltd.
4.. _cpsDeltaEndpoints:
5
Arpit Singhc45db422024-01-30 10:51:28 +05306CPS Delta Endpoints
7###################
8
Arpit Singh04094542024-05-06 20:12:52 +05309The CPS Delta feature provides two endpoints:
Arpit Singhc45db422024-01-30 10:51:28 +053010
Arpit Singh04094542024-05-06 20:12:52 +0530111. GET /v2/dataspaces/{dataspace-name}/anchors/{source-anchor-name}/delta
122. POST /v2/dataspaces/{dataspace-name}/anchors/{source-anchor-name}/delta
Arpit Singhc45db422024-01-30 10:51:28 +053013
Arpit Singh04094542024-05-06 20:12:52 +053014Common Parameters of both the endpoints
15---------------------------------------
16Common Path Parameters
17^^^^^^^^^^^^^^^^^^^^^^
18The following parameters are common inputs between the two endpoints:
19 - **dataspace-name:** name of dataspace where the anchor(s) to be used for delta generation are stored.
20 - **source-anchor-name:** the source anchor name, the data under this anchor will be the reference data for delta report generation
Arpit Singhc45db422024-01-30 10:51:28 +053021
Arpit Singh04094542024-05-06 20:12:52 +053022Common Query Parameter
23^^^^^^^^^^^^^^^^^^^^^^
24Both the endpoint need the following query parameters as input:
25 - **xpath:** the xpath to a particular data node.
26 - Example: /bookstore/categories[@code='1']
Arpit Singhc45db422024-01-30 10:51:28 +053027
Arpit Singh04094542024-05-06 20:12:52 +053028Description of API 1: Delta between 2 Anchors
29---------------------------------------------
30This API performs a GET operation, which allows the user to find the delta between configurations stored under two anchors within the same dataspace. The API has following input parameters:
31
32Specific Query Parameters
33^^^^^^^^^^^^^^^^^^^^^^^^^
34The endpoint takes following additional/specific query parameters as input:
35 - **target-anchor-name:** the data retrieved from target anchor is compared against the data retrieved from source anchor
Arpit Singhc45db422024-01-30 10:51:28 +053036 - **descendants:** specifies the number of descendants to query.
37
Arpit Singh04094542024-05-06 20:12:52 +053038Description of API 2: Delta between Anchor and JSON payload
39-----------------------------------------------------------
40This API performs a POST operation, which allows the user to find the delta between configurations stored under an anchors and a JSON payload provided as part of the request. The API has the following input parameters:
41
42Request Body for Endpoint 2
43^^^^^^^^^^^^^^^^^^^^^^^^^^^
44The endpoint accepts a **multipart/form-data** input as part of request body. This allows the user to provide the following inputs as part of request body:
45 - **JSON payload:** this field accepts a valid JSON string as an input. The data provided as part of this JSON will be parsed using the schema, the schema is either retrieved using the anchor name or it can be provided as part of request body using the optional parameter of request body defined below. Once the JSON is parsed and validated, it is compared to the data fetched from the source anchor and the delta report is generated.
46 - **schema-context:** this is an optional parameter and allows the user to provide the schema of the JSON payload, as a yang or zip file, and this schema can be used to parse the JSON string in case the schema of JSON differs from the schema associated with source anchor. If the schema of JSON payload is similar to the schema associated with the anchor then this parameter can be left empty.
47
Arpit Singhc45db422024-01-30 10:51:28 +053048Sample Delta Report
49-------------------
Arpit Singh04094542024-05-06 20:12:52 +053050Both the APIs have the same format for the delta report. The format is as follows:
Arpit Singhc45db422024-01-30 10:51:28 +053051
52.. code-block:: json
53
54 [
55 {
Arpit Singh3c8539c2024-09-04 11:02:06 +053056 "action": "create",
Arpit Singhc45db422024-01-30 10:51:28 +053057 "xpath": "/bookstore/categories/[@code=3]",
58 "target-data": {
59 "code": "3,",
60 "name": "kidz"
61 }
62 },
63 {
Arpit Singh3c8539c2024-09-04 11:02:06 +053064 "action": "remove",
Arpit Singhc45db422024-01-30 10:51:28 +053065 "xpath": "/bookstore/categories/[@code=1]",
66 "source-data": {
67 "code": "1,",
68 "name": "Fiction"
69 }
70 },
71 {
Arpit Singh3c8539c2024-09-04 11:02:06 +053072 "action": "replace",
Arpit Singhc45db422024-01-30 10:51:28 +053073 "xpath": "/bookstore/categories/[@code=2]",
74 "source-data": {
75 "name": "Funny"
76 },
77 "target-data": {
78 "name": "Comic"
79 }
80 }
81 ]