fleet/server/service/service_hosts.go
Zachary Wasserman fcb8418b2f Add fleetctl get host capability to get single host with labels
Getting a single host with `fleetctl get host foobar` will look up the
host with the matching hostname, uuid, osquery identifier, or node key,
and provide the full host details along with the labels the host is a
member of.
2020-07-21 14:05:46 -07:00

36 lines
917 B
Go

package service
import (
"context"
"github.com/kolide/fleet/server/kolide"
)
func (svc service) ListHosts(ctx context.Context, opt kolide.HostListOptions) ([]*kolide.Host, error) {
return svc.ds.ListHosts(opt)
}
func (svc service) GetHost(ctx context.Context, id uint) (*kolide.Host, error) {
return svc.ds.Host(id)
}
func (svc service) HostByIdentifier(ctx context.Context, identifier string) (*kolide.Host, error) {
return svc.ds.HostByIdentifier(identifier)
}
func (svc service) GetHostSummary(ctx context.Context) (*kolide.HostSummary, error) {
online, offline, mia, new, err := svc.ds.GenerateHostStatusStatistics(svc.clock.Now())
if err != nil {
return nil, err
}
return &kolide.HostSummary{
OnlineCount: online,
OfflineCount: offline,
MIACount: mia,
NewCount: new,
}, nil
}
func (svc service) DeleteHost(ctx context.Context, id uint) error {
return svc.ds.DeleteHost(id)
}