2016-09-26 18:48:55 +00:00
|
|
|
package service
|
2016-09-06 21:28:07 +00:00
|
|
|
|
|
|
|
import (
|
2017-02-01 17:20:50 +00:00
|
|
|
"github.com/kolide/kolide/server/kolide"
|
2016-09-06 21:28:07 +00:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-10-13 18:21:47 +00:00
|
|
|
func (svc service) ListHosts(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Host, error) {
|
2016-10-14 15:59:27 +00:00
|
|
|
return svc.ds.ListHosts(opt)
|
2016-09-06 21:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (svc service) GetHost(ctx context.Context, id uint) (*kolide.Host, error) {
|
|
|
|
return svc.ds.Host(id)
|
|
|
|
}
|
|
|
|
|
2017-01-04 21:16:17 +00:00
|
|
|
func (svc service) GetHostSummary(ctx context.Context) (*kolide.HostSummary, error) {
|
2017-01-20 13:57:47 +00:00
|
|
|
online, offline, mia, new, err := svc.ds.GenerateHostStatusStatistics(svc.clock.Now())
|
2017-01-04 21:16:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2016-10-12 21:41:35 +00:00
|
|
|
}
|
2017-01-04 21:16:17 +00:00
|
|
|
return &kolide.HostSummary{
|
|
|
|
OnlineCount: online,
|
|
|
|
OfflineCount: offline,
|
|
|
|
MIACount: mia,
|
2017-01-20 13:57:47 +00:00
|
|
|
NewCount: new,
|
2017-01-04 21:16:17 +00:00
|
|
|
}, nil
|
2016-10-12 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 21:28:07 +00:00
|
|
|
func (svc service) DeleteHost(ctx context.Context, id uint) error {
|
2017-01-04 18:18:21 +00:00
|
|
|
return svc.ds.DeleteHost(id)
|
2016-09-06 21:28:07 +00:00
|
|
|
}
|