fleet/server/service_appconfig.go
Victor Vrantchan 26b1e70ac3 App config api (#223)
Add GET and PATCH endpoints for /kolide/config to get/update current app configuration
2016-09-21 20:45:57 -04:00

47 lines
910 B
Go

package server
import (
"context"
"github.com/kolide/kolide-ose/kolide"
)
func (svc service) NewOrgInfo(ctx context.Context, p kolide.OrgInfoPayload) (*kolide.OrgInfo, error) {
info := &kolide.OrgInfo{}
if p.OrgName != nil {
info.OrgName = *p.OrgName
}
if p.OrgLogoURL != nil {
info.OrgLogoURL = *p.OrgLogoURL
}
info, err := svc.ds.NewOrgInfo(info)
if err != nil {
return nil, err
}
return info, nil
}
func (svc service) OrgInfo(ctx context.Context) (*kolide.OrgInfo, error) {
return svc.ds.OrgInfo()
}
func (svc service) ModifyOrgInfo(ctx context.Context, p kolide.OrgInfoPayload) (*kolide.OrgInfo, error) {
info, err := svc.ds.OrgInfo()
if err != nil {
return nil, err
}
if p.OrgName != nil {
info.OrgName = *p.OrgName
}
if p.OrgLogoURL != nil {
info.OrgLogoURL = *p.OrgLogoURL
}
err = svc.ds.SaveOrgInfo(info)
if err != nil {
return nil, err
}
return info, nil
}