A.6 Partial update of a resource
32.1583GPPDesign rules for REpresentational State Transfer (REST) Solution Sets (SS)Management and orchestrationRelease 17TS
A.6.1 Partial update of a resource with JSON Merge Patch
The first example shows how the attribute "attrA" of the "XyzFunction with the "id" equal to "YXZF1" is changed from "xyz" to "def" using JSON Merge Patch.
|
PATCH /SubNetwork=SN1/ManagedElement=ME1/XyzFunction=XYZF1 HTTP/1.1 Host: example.org Content-Type: application/merge-patch+json { "id": "XYZF1", "attributes": { "attrA": "def" } } |
In the second example the "mcc" attribute field of the "plmnId" attribute is updated to "654". The employed patch method is again JSON Merge Patch.
|
PATCH /SubNetwork=SN1 HTTP/1.1 Host: example.org Content-Type: application/merge-patch+json { "id": "SN1", "attributes": { "plmnId": { "mcc": 654 } } } |
In the third example the item "Metric3" is added to the array "perfMetrics". The value of "perfMetrics" contains the two old items and the new item.
|
PATCH /SubNetwork=SN1/PerfMetricJob=PMJ1 HTTP/1.1 Host: example.org Content-Type: application/merge-patch+json { "id": "PMJ1", "attributes": { "perfMetrics": ["Metric1", "Metric2, Metric3"] } } } |
Also in case the items of an array have an identifier, the complete updated array value needs to be present in the patch request. In the following fourth example in this clause the old first threshold level is deleted, for the old second threshold level the "thresholdValue" is updated from "20" to "22", the old third threshold level is left unchanged, and a new threshold level is appended as last item.
|
PATCH /SubNetwork=SN1/ThresholdMonitor=TM1 HTTP/1.1 Host: example.org Content-Type: application/merge-patch+json { "id": "TM1", "attributes": { "thresholdLevels": [ { "level": "2", "thresholdValue": 22 }, { "level": "3", "thresholdValue": 30 }, { "level": "4", "thresholdValue": 40 } ] } } |
A.6.2 Partial update of a resource with 3GPP JSON Merge Patch
When updating a single resource, there is no difference between JSON Merge Patch (see A.6.1) and 3GPP JSON Merge Patch.
A.6.3 Partial update of a resource with JSON Patch
When JSON Patch is used to request the same changes as the ones described in the four examples in clause A.6.1, the MnS consumer may send
|
PATCH /SubNetwork=SN1/ManagedElement=ME1/XyzFunction=XYZF1 HTTP/1.1 Host: example.org Content-Type: application/json-patch+json [ { "op": "replace", "path": "/attributes/attrA", "value": "def" } ] |
and
|
PATCH /SubNetwork=SN1 HTTP/1.1 Host: example.org Content-Type: application/json-patch+json [ { "op": "replace", "path": "/attributes/plmnId/mcc", "value": 654 } ] |
and
|
PATCH /SubNetwork=SN1/PerfMetricJob=PMJ1 HTTP/1.1 Host: example.org Content-Type: application/json-patch+json [ { "op": "add", "path": "/attributes/perfMetrics/2", "value": "Metric3" } ] |
and
|
PATCH /SubNetwork=SN1/ThresholdMonotor=TM1 HTTP/1.1 Host: example.org Content-Type: application/json-patch+json [ { "op": "remove", "path": "/attributes/thresholdLevels/0" }, { "op": "replace", "path": "/attributes/thresholdLevels/0/thresholdValue", "value": 22 }, { "op": "add", "path": "/attributes/thresholdLevels/-", "value": { "level": "4", "thresholdValue": 40 } } ] |
Note the patch operations are applied sequentially to the "thresholdLevels" array in the order they appear in the patch array. After removing the first array item with the first operation, the resulting array value becomes the target for the second operation. The array index "0" identifies the new first item, which was the second item before applying the first operation of the patch document. Issues with array positions can be avoided by placing "replace" operations at the beginning of the patch document.
In the examples above the value of "value" is always a simple type (scalar value). When multiple attribute fields of an attribute need to be added or replaced, it is often more compact to add or replace the complete attribute with a single patch operation, instead of each attribute field individually. For example, the following patch
|
PATCH /SubNetwork=SN1 HTTP/1.1 Host: example.org Content-Type: application/json-patch+json [ { "op": "add", "path": "/attributes/plmnId/mcc", "value": 456 }, { "op": "add", "path": "/attributes/plmnId/mnc", "value": 789 } ] |
can be replaced by
|
PATCH /SubNetwork=SN1 HTTP/1.1 Host: example.org Content-Type: application/json-patch+json [ { "op": "add", "path": "/attributes/plmnId", "value": { "mcc": 456, "mnc": 789 } } ] |
A.6.4 Partial update of a resource with 3GPP JSON Patch
When 3GPP JSON Patch is used to request the changes described in the first two examples in clause A.6.1 the MnS consumer may send the following
|
PATCH /SubNetwork=SN1/ManagedElement=ME1/XyzFunction=XYZF1 HTTP/1.1 Host: example.org Content-Type: application/3gpp-json-patch+json [ { "op": "replace", "path": "#/attributes/attrA", "value": "def" } ] |
and
|
PATCH /SubNetwork=SN1 HTTP/1.1 Host: example.org Content-Type: application/3gpp-json-patch+json [ { "op": "replace", "path": "#/attributes/plmnId/mcc", "value": 654 } ] |
and
|
PATCH /SubNetwork=SN1/ThresholdMonitor=TM1 HTTP/1.1 Host: example.org Content-Type: application/3gpp-json-patch+json [ { "op": "remove", "path": "#/attributes/thresholdLevels/0" }, { "op": "replace", "path": "#/attributes/thresholdLevels/0/thresholdValue", "value": 22 }, { "op": "add", "path": "#/attributes/thresholdLevels/-", "value": { "level": "4", "thresholdValue": 40 } } ] |
When using 3GPP JSON Patch to update a single resource, the only difference compared to JSON Patch is the presence of "#" in the "path".