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

Add case for API_OPERATION_REPLACE within plugins ValidateChange method

See merge request !968
parent 486fe09e
Branches
No related tags found
1 merge request!968Add case for API_OPERATION_REPLACE within plugins ValidateChange method
Pipeline #218375 passed
...@@ -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