Add Create and Update Interface Backend

This commit is contained in:
Samuel Lorch 2023-04-01 01:10:32 +02:00
parent 9568adbd8e
commit f1d7f63079

View file

@ -18,6 +18,36 @@ func (f *Network) GetInterfaces(ctx context.Context, params struct{}) (GetInterf
}, nil
}
type CreateInterfaceParameters struct {
Name string
Interface definitions.Interface
}
func (f *Network) CreateInterface(ctx context.Context, params CreateInterfaceParameters) (struct{}, error) {
_, ok := f.Conf.Network.Interfaces[params.Name]
if ok {
return struct{}{}, fmt.Errorf("Interface already Exists")
}
f.Conf.Network.Interfaces[params.Name] = params.Interface
return struct{}{}, nil
}
type UpdateInterfaceParameters struct {
Name string
Interface definitions.Interface
}
func (f *Network) UpdateInterface(ctx context.Context, params CreateInterfaceParameters) (struct{}, error) {
_, ok := f.Conf.Network.Interfaces[params.Name]
if !ok {
return struct{}{}, fmt.Errorf("Interface does not Exist")
}
f.Conf.Network.Interfaces[params.Name] = params.Interface
return struct{}{}, nil
}
type DeleteInterfaceParameters struct {
Name string
}