-
Notifications
You must be signed in to change notification settings - Fork 349
/
service.go
41 lines (34 loc) · 1.28 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package dep
import (
"context"
"sync"
"github.com/micromdm/micromdm/dep"
"github.com/micromdm/micromdm/platform/pubsub"
)
type Service interface {
DefineProfile(ctx context.Context, p *dep.Profile) (*dep.ProfileResponse, error)
AssignProfile(ctx context.Context, uuid string, serials ...string) (*dep.ProfileResponse, error)
RemoveProfile(ctx context.Context, serials ...string) (map[string]string, error)
GetAccountInfo(ctx context.Context) (*dep.Account, error)
GetDeviceDetails(ctx context.Context, serials []string) (*dep.DeviceDetailsResponse, error)
FetchProfile(ctx context.Context, uuid string) (*dep.Profile, error)
}
type DEPClient interface {
DefineProfile(*dep.Profile) (*dep.ProfileResponse, error)
AssignProfile(string, ...string) (*dep.ProfileResponse, error)
RemoveProfile(...string) (map[string]string, error)
FetchProfile(string) (*dep.Profile, error)
Account() (*dep.Account, error)
DeviceDetails(...string) (*dep.DeviceDetailsResponse, error)
}
type DEPService struct {
mtx sync.RWMutex
client DEPClient
subscriber pubsub.Subscriber
}
func (svc *DEPService) Run() error {
return svc.watchTokenUpdates(svc.subscriber)
}
func New(client DEPClient, subscriber pubsub.Subscriber) *DEPService {
return &DEPService{client: client, subscriber: subscriber}
}