Repository navigation
Description
Currently we just have the one config API endpoint, POST /rest/system/config to replace the whole thing. This isn't optimally easy to use from API clients that just want to change an option or two as you need a while get/change/post and there is also an inherent race condition.
It would be nice to have an API that can twiddle parts of the config easier and safer. From the outside it could look something like this:
PUT /rest/system/config/devices/5Y62GZS-...creates or replaces a single device in its entiretyDELETE /rest/system/config/folders/defaultdeletes the default folderPATCH /rest/system/config/devices/5Y62GZS-...overwrites the properties present in the given object only, which could be something like{"name": "Unused for now", "paused": true}.PUT /rest/system/config/options/localAnnounceEnabledoverwrites the named field in the config, in this case the JSON in the body needs to a boolean likefalse.- ... and so on
Implementation wise we can mostly just take the current config, JSON serialize it, traverse the resulting object according to the request path, and then remove, replace or unmarshal on top of the resulting leaf object, then commit. (Folders and devices handled specifically as they are arrays in the config object and not dicts.) This would happen while holding the API config lock, so it's atomic from an API perspective.
Activity
lib/api: Add /rest/config endpoint (fixes syncthing#6540)
lib/api: Add /rest/config endpoint (fixes #6540) (#7001)
Merge tag 'v1.12.0' into ios_try_syncthing-1.12