Skip to content
Snippets Groups Projects
Commit 605315e6 authored by Malte Bauch's avatar Malte Bauch Committed by Matthias Feyll
Browse files

Add case for API_OPERATION_REPLACE within plugins ValidateChange method

See merge request !968
parent 44603c37
No related branches found
No related tags found
1 merge request!1005Draft: feature-ui-361_setup-project
...@@ -241,13 +241,21 @@ func (d *DeviceModel) ValidateChange(operation mnepb.ApiOperation, path *gpb.Pat ...@@ -241,13 +241,21 @@ func (d *DeviceModel) ValidateChange(operation mnepb.ApiOperation, path *gpb.Pat
d.mu.RUnlock() d.mu.RUnlock()
switch operation { switch operation {
case mnepb.ApiOperation_API_OPERATION_UPDATE, mnepb.ApiOperation_API_OPERATION_REPLACE: case mnepb.ApiOperation_API_OPERATION_DELETE:
if err := ytypes.DeleteNode(d.schema.RootSchema(), modelCopy, path); err != nil {
return nil, err
}
case mnepb.ApiOperation_API_OPERATION_REPLACE:
if err := ytypes.DeleteNode(d.schema.RootSchema(), modelCopy, path); err != nil {
return nil, err
}
opts := []ytypes.SetNodeOpt{&ytypes.InitMissingElements{}, &ytypes.TolerateJSONInconsistencies{}, &ytypes.IgnoreExtraFields{}} opts := []ytypes.SetNodeOpt{&ytypes.InitMissingElements{}, &ytypes.TolerateJSONInconsistencies{}, &ytypes.IgnoreExtraFields{}}
if err := ytypes.SetNode(d.schema.RootSchema(), modelCopy, path, value, opts...); err != nil { if err := ytypes.SetNode(d.schema.RootSchema(), modelCopy, path, value, opts...); err != nil {
return nil, err return nil, err
} }
case mnepb.ApiOperation_API_OPERATION_DELETE: case mnepb.ApiOperation_API_OPERATION_UPDATE:
if err := ytypes.DeleteNode(d.schema.RootSchema(), modelCopy, path); err != nil { opts := []ytypes.SetNodeOpt{&ytypes.InitMissingElements{}, &ytypes.TolerateJSONInconsistencies{}, &ytypes.IgnoreExtraFields{}}
if err := ytypes.SetNode(d.schema.RootSchema(), modelCopy, path, value, opts...); err != nil {
return nil, err return nil, err
} }
default: default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment