Open garethsb opened 1 year ago
Current annotation_patch_merger
has three arguments:
const nmos::resource& resource
- the IS-04 resource that is being PATCH
edweb::json::value& value
- contains the annotation properties from that resource, modifiable by the callbackconst web::json::value& patch
- contains the body of the PATCH
request, which is guaranteed valid per the schemaThe 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...
PATCH
request 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 certain tags
are read-only such as BCP-002-02 Asset Distinguishing Information or vendor-specific tagsPATCH
request completely if the values are unacceptable for this particular resource, such as being too large for persistent storage or not meeting format for particular tagpatch
PATCH
request removed/reset values that cannot be omitted per spec or particular resourcePATCH
request completely if the final values are unacceptableAs @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/nodeimplementation.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 :-)
⚠️ Ink isn't dry on the IS-13 spec, but here's an implementation.