Skip to content
Snippets Groups Projects
Commit 14d1235f authored by Malte Bauch's avatar Malte Bauch
Browse files

Add case for API_OPERATION_REPLACE within plugins ValidateChange method

parent 486fe09e
No related branches found
No related tags found
1 merge request!968Add case for API_OPERATION_REPLACE within plugins ValidateChange method
Pipeline #218247 passed
......@@ -241,13 +241,21 @@ func (d *DeviceModel) ValidateChange(operation mnepb.ApiOperation, path *gpb.Pat
d.mu.RUnlock()
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{}}
if err := ytypes.SetNode(d.schema.RootSchema(), modelCopy, path, value, opts...); err != nil {
return nil, err
}
case mnepb.ApiOperation_API_OPERATION_DELETE:
if err := ytypes.DeleteNode(d.schema.RootSchema(), modelCopy, path); err != nil {
case mnepb.ApiOperation_API_OPERATION_UPDATE:
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
}
default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment