mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Add GetService API Method
This commit is contained in:
parent
ab7656c8ca
commit
74fc3b0b8c
1 changed files with 21 additions and 0 deletions
|
@ -7,6 +7,27 @@ import (
|
|||
"nfsense.net/nfsense/internal/definitions/object"
|
||||
)
|
||||
|
||||
type GetServiceParameters struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
type GetServiceResult struct {
|
||||
Name string `json:"name"`
|
||||
object.Service
|
||||
}
|
||||
|
||||
func (f *Object) GetService(ctx context.Context, params GetServiceParameters) (GetServiceResult, error) {
|
||||
_, ok := f.ConfigManager.GetPendingConfig().Object.Services[params.ID]
|
||||
if !ok {
|
||||
return GetServiceResult{}, fmt.Errorf("Service does not Exist")
|
||||
}
|
||||
|
||||
return GetServiceResult{
|
||||
Name: params.ID,
|
||||
Service: f.ConfigManager.GetPendingConfig().Object.Services[params.ID],
|
||||
}, nil
|
||||
}
|
||||
|
||||
type GetServicesResult struct {
|
||||
Services map[string]object.Service
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue