2016-10-03 03:14:35 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/kolide/kolide-ose/server/kolide"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-10-13 18:21:47 +00:00
|
|
|
func (svc service) ListLabels(ctx context.Context, opt kolide.ListOptions) ([]*kolide.Label, error) {
|
2016-10-14 15:59:27 +00:00
|
|
|
return svc.ds.ListLabels(opt)
|
2016-10-03 03:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (svc service) GetLabel(ctx context.Context, id uint) (*kolide.Label, error) {
|
|
|
|
return svc.ds.Label(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (svc service) NewLabel(ctx context.Context, p kolide.LabelPayload) (*kolide.Label, error) {
|
|
|
|
label := &kolide.Label{}
|
|
|
|
|
|
|
|
if p.Name == nil {
|
|
|
|
return nil, newInvalidArgumentError("name", "missing required argument")
|
|
|
|
}
|
|
|
|
label.Name = *p.Name
|
|
|
|
|
2016-11-03 01:17:23 +00:00
|
|
|
if p.Query == nil {
|
|
|
|
return nil, newInvalidArgumentError("query", "missing required argument")
|
2016-10-03 03:14:35 +00:00
|
|
|
}
|
2016-11-03 01:17:23 +00:00
|
|
|
label.Query = *p.Query
|
2016-10-03 03:14:35 +00:00
|
|
|
|
2016-11-03 01:17:23 +00:00
|
|
|
if p.Platform != nil {
|
|
|
|
label.Platform = *p.Platform
|
2016-10-03 03:14:35 +00:00
|
|
|
}
|
|
|
|
|
2016-11-03 01:17:23 +00:00
|
|
|
if p.Description != nil {
|
|
|
|
label.Description = *p.Description
|
2016-10-03 03:14:35 +00:00
|
|
|
}
|
|
|
|
|
2016-11-03 01:17:23 +00:00
|
|
|
label, err := svc.ds.NewLabel(label)
|
2016-10-03 03:14:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return label, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (svc service) DeleteLabel(ctx context.Context, id uint) error {
|
|
|
|
return svc.ds.DeleteLabel(id)
|
|
|
|
}
|