mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Add Get Interface API
This commit is contained in:
parent
69066f0ad2
commit
34c4b9b87e
1 changed files with 22 additions and 1 deletions
|
@ -22,6 +22,27 @@ func (f *Network) GetLinks(ctx context.Context, params struct{}) (GetLinksResult
|
|||
}, nil
|
||||
}
|
||||
|
||||
type GetInterfaceParameters struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
type GetInterfaceResult struct {
|
||||
Name string `json:"name"`
|
||||
definitions.Interface
|
||||
}
|
||||
|
||||
func (f *Network) GetInterface(ctx context.Context, params GetInterfaceParameters) (GetInterfaceResult, error) {
|
||||
_, ok := f.ConfigManager.GetPendingConfig().Network.Interfaces[params.ID]
|
||||
if !ok {
|
||||
return GetInterfaceResult{}, fmt.Errorf("Interface does not Exist")
|
||||
}
|
||||
|
||||
return GetInterfaceResult{
|
||||
Name: params.ID,
|
||||
Interface: f.ConfigManager.GetPendingConfig().Network.Interfaces[params.ID],
|
||||
}, nil
|
||||
}
|
||||
|
||||
type GetInterfacesResult struct {
|
||||
Interfaces map[string]definitions.Interface
|
||||
}
|
||||
|
@ -33,7 +54,7 @@ func (f *Network) GetInterfaces(ctx context.Context, params struct{}) (GetInterf
|
|||
}
|
||||
|
||||
type CreateInterfaceParameters struct {
|
||||
Name string
|
||||
Name string `json:"name"`
|
||||
definitions.Interface
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue