-
Notifications
You must be signed in to change notification settings - Fork 346
/
client.go
69 lines (60 loc) · 1.8 KB
/
client.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package depsync
import (
"net/url"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/log"
httptransport "github.com/go-kit/kit/transport/http"
"github.com/micromdm/micromdm/pkg/httputil"
)
func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) {
u, err := url.Parse(instance)
if err != nil {
return nil, err
}
var syncNowEndpoint endpoint.Endpoint
{
syncNowEndpoint = httptransport.NewClient(
"PUT",
httputil.CopyURL(u, "/v1/dep/autoassign"),
httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest),
decodeEmptyResponse,
opts...,
).Endpoint()
}
var applyAutoAssignerEndpoint endpoint.Endpoint
{
applyAutoAssignerEndpoint = httptransport.NewClient(
"POST",
httputil.CopyURL(u, "/v1/dep/autoassigners"),
httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest),
decodeApplyAutoAssignerResponse,
opts...,
).Endpoint()
}
var getAutoAssignersEndpoint endpoint.Endpoint
{
getAutoAssignersEndpoint = httptransport.NewClient(
"GET",
httputil.CopyURL(u, "/v1/dep/autoassigners"),
httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest),
decodeGetAutoAssignersResponse,
opts...,
).Endpoint()
}
var removeAutoAssignerEndpoint endpoint.Endpoint
{
removeAutoAssignerEndpoint = httptransport.NewClient(
"DELETE",
httputil.CopyURL(u, "/v1/dep/autoassigners"),
httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest),
decodeRemoveAutoAssignerResponse,
opts...,
).Endpoint()
}
return Endpoints{
SyncNowEndpoint: syncNowEndpoint,
ApplyAutoAssignerEndpoint: applyAutoAssignerEndpoint,
GetAutoAssignersEndpoint: getAutoAssignersEndpoint,
RemoveAutoAssignerEndpoint: removeAutoAssignerEndpoint,
}, nil
}