mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
Add Delete Interface
This commit is contained in:
parent
7121c46a74
commit
61ae805305
2 changed files with 25 additions and 7 deletions
|
@ -8,27 +8,35 @@ import (
|
|||
"nfsense.net/nfsense/internal/interfaces"
|
||||
)
|
||||
|
||||
type GetInterfacesParameters struct {
|
||||
}
|
||||
|
||||
type GetInterfacesResult struct {
|
||||
Interfaces map[string]definitions.Interface
|
||||
}
|
||||
|
||||
func (f *Network) GetInterfaces(ctx context.Context, params GetInterfacesParameters) (GetInterfacesResult, error) {
|
||||
func (f *Network) GetInterfaces(ctx context.Context, params struct{}) (GetInterfacesResult, error) {
|
||||
return GetInterfacesResult{
|
||||
Interfaces: f.Conf.Network.Interfaces,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ApplyInterfacesParameters struct {
|
||||
type DeleteInterfaceParameters struct {
|
||||
Interface string
|
||||
}
|
||||
|
||||
func (f *Network) DeleteInterface(ctx context.Context, params DeleteInterfaceParameters) (struct{}, error) {
|
||||
_, ok := f.Conf.Network.Interfaces[params.Interface]
|
||||
if !ok {
|
||||
return struct{}{}, fmt.Errorf("Interface does not Exist")
|
||||
}
|
||||
|
||||
delete(f.Conf.Network.Interfaces, params.Interface)
|
||||
return struct{}{}, nil
|
||||
}
|
||||
|
||||
type ApplyInterfacesResult struct {
|
||||
Log string
|
||||
}
|
||||
|
||||
func (f *Network) ApplyInterfaces(ctx context.Context, params ApplyInterfacesParameters) (ApplyInterfacesResult, error) {
|
||||
func (f *Network) ApplyInterfaces(ctx context.Context, params struct{}) (ApplyInterfacesResult, error) {
|
||||
data, err := interfaces.GenerateInterfacesFile(*f.Conf)
|
||||
if err != nil {
|
||||
return ApplyInterfacesResult{}, fmt.Errorf("Generating Interfaces File: %w", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue