Implementation of IS-13 NMOS Annotation API
Current annotation_patch_merger has three arguments:
const nmos::resource& resource- the IS-04 resource that is beingPATCHedweb::json::value& value- contains the annotation properties from that resource, modifiable by the callbackconst web::json::value& patch- contains the body of thePATCHrequest, which is guaranteed valid per the schema
The behaviour is that the callback is expected to update the value with the patch, and then the calling function updates the resource from the updated value.
Passing read-only resource and a writable value ensures that the callback cannot update other properties than label, description and tags, but that it has access to the full resource to determine semantic validity.
However, the implementation is still a bit complicated. The callback might want to proceed to...
- reject the
PATCHrequest completely if it attempts to change to read-only properties e.g. because the whole resource is read-only (Sources and Flows in dynamic Nodes), or because certaintagsare read-only such as BCP-002-02 Asset Distinguishing Information or vendor-specific tags - reject the
PATCHrequest completely if the values are unacceptable for this particular resource, such as being too large for persistent storage or not meeting format for particular tag - merge the
patch - apply default values if the
PATCHrequest removed/reset values that cannot be omitted per spec or particular resource - reject the
PATCHrequest completely if the final values are unacceptable
As @jonathan-r-thorpe suggested, nmos::details::is_read_only_tag is now an overridable predicate, and default values can also be specified declaratively. This is demonstrated by nmos-cpp-node/node_implementation.cpp for the Node and Device tags specified via config.json node_tags and device_tags.
@jonathan-r-thorpe, @lo-simon, I've just attempted to merge master into this rwnode branch, so let's keep an eye on the tests :-)