Enhance conditional updates for merge/PATCH to specify different conditions for parts of the patch
thjaeckle opened this issue · comments
Currently, Ditto supports conditional requests for modifications for all "types" of modifications in the same way.
Types of modifications:
- modify (HTTP PUT)
- merge (HTTP PATCH)
- delete (HTTP DELETE)
There can be one condition
be specified for those commands with the following semantic:
- if the condition (defined as Ditto RQL) evaluates to
true
, then perform the command- e.g. modify the thing/attribute/feature
- e.g. merge (patch) the thing
For the merge however, we encountered that it often is required to define for a single merge (containing e.g. changes to patch several features of the same thing) several conditions
- in order to be able to patch some parts of the thing based on the current value of other parts of the thing
To enable that, we suggest to enhance Ditto condition
s for merge/PATCH commands (e.g. MergeThing
) with a special patch-condition
.
The header/queryParam should be another one than condition
to be able to also combine them - and would e.g. take a "map" of JsonPointers and RQL expressions.
Ditto must then evaluate for each "JsonPointer" of the merge/patch if the provided RQL statement evaluates to true
- and only then "include" it in the merge/patch, otherwise drop it from it.
Example syntax:
patch-condition=
{
"/features/deviceStatus/properties/dimensions/internal/severity": "ge(features/deviceStatus/properties/dimensions/internal/severity/cardinality,20)",
"/attributes/location": "not(exists(attributes/location)"
}