Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance conditional updates for merge/PATCH to specify different conditions for parts of the patch #1927

Open
thjaeckle opened this issue Apr 19, 2024 · 0 comments

Comments

@thjaeckle
Copy link
Member

thjaeckle commented Apr 19, 2024

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 conditions 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)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant