Skip to content

Commit 90b54dd

Browse files
committed
Update to show how to use the cloud diff and patch
1 parent 216e3a2 commit 90b54dd

File tree

1 file changed

+31
-7
lines changed
  • src/app/docs/json-diff-and-patch

1 file changed

+31
-7
lines changed

src/app/docs/json-diff-and-patch/page.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,45 @@ A **patch** applies a diff to two objects to obtain a new object with any differ
2727

2828
## Public Endpoint
2929

30-
Use our public endpoints for each operation:
30+
The diff and patch endpoints can be used directly as an API without data products, using the [dfrnt.com](https://dfrnt.com/hypergraph-content-studio/) cloud hosting.
3131

32-
**JSON Diff**
32+
Use our endpoints for each operation, get your API token ready to run below commands.
3333

34-
```text
35-
https://cloud.terminusdb.com/jsondiff
34+
**JSON Diff example **
35+
36+
Have a token and your username that can be found in the profile section to use with the below example where the cloud diff and patch operations are used.
37+
38+
```bash
39+
TOKEN=01234567-0123-0123-0123...
40+
DFRNT_USER=00000000-0000-0000...
41+
curl -H "Authorization: Token $TOKEN" -X POST -H "Content-Type: application/json" "https://dfrnt.com/api/hosted/${DFRNT_USER}/api/diff" -d \
42+
'{ "before" : { "asdf" : "foo", "fdsa" : "bar"}, "after" : { "asdf" : "bar", "fdsa" : "bar"}, "keep" : { "fdsa" : true}}'
43+
```
44+
45+
Result:
46+
```json
47+
{"asdf": {"@after":"bar", "@before":"foo", "@op":"SwapValue"},"fdsa":"bar"}
3648
```
3749

3850
**JSON Patch**
3951

40-
```text
41-
https://cloud.terminusdb.com/jsonpatch
52+
Have a token and your username that can be found in the profile section to use with the below example where the cloud diff and patch operations are used.
53+
54+
```bash
55+
TOKEN=01234567-0123-0123-0123...
56+
DFRNT_USER=00000000-0000-0000...
57+
curl -H "Authorization: Token $TOKEN" -X POST -H "Content-Type: application/json" "https://dfrnt.com/api/hosted/${DFRNT_USER}/api/patch" -d \
58+
'{ "before" : { "alpha" : 1, "asdf" : { "fdsa" : "quux"}}, "patch" : {
59+
"asdf": {"fdsa": {"@after":"quuz", "@before":"quux", "@op":"SwapValue"}}
60+
}}'
61+
```
62+
63+
Result:
64+
```json
65+
{"alpha":1, "asdf": {"fdsa":"quuz"}}
4266
```
4367

44-
See [Diff and Patch Endpoints](#diffandpatchendpoints) for more information, and examples of [diff](#diffexamplesusingcurl) and [patch](#patchexamplesusingcurl) using curl.
68+
See [Diff and Patch Endpoints](#diffandpatchendpoints) for more information, and examples of [diff](#diffexamplesusingcurl) and [patch](#patchexamplesusingcurl) using curl for more examples.
4569

4670
## Diff & Patch with Client
4771

0 commit comments

Comments
 (0)