Add GetService API Method

This commit is contained in:
Samuel Lorch 2023-05-13 22:11:41 +02:00
parent ab7656c8ca
commit 74fc3b0b8c

View file

@ -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
}