-
Notifications
You must be signed in to change notification settings - Fork 7
/
user_client.go
43 lines (35 loc) · 1.01 KB
/
user_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
package users
import (
"errors"
"net/http"
"github.com/IBM/satcon-client-go/client/auth"
"github.com/IBM/satcon-client-go/client/types"
"github.com/IBM/satcon-client-go/client/web"
)
// UserService is the interface used to perform all user-centric actions.
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 . UserService
type UserService interface {
Me() (*types.User, error)
}
// Client is an implementation of a satcon client.
type Client struct {
web.SatConClient
}
// NewClient returns a configured instance of ClusterService which can then be used
// to perform cluster queries against Satellite Config.
func NewClient(endpointURL string, httpClient web.HTTPClient, authClient auth.AuthClient) (UserService, error) {
if endpointURL == "" {
return nil, errors.New("Must supply a valid endpoint URL")
}
s := web.SatConClient{
Endpoint: endpointURL,
HTTPClient: http.DefaultClient,
AuthClient: authClient,
}
if httpClient != nil {
s.HTTPClient = httpClient
}
return &Client{
s,
}, nil
}