-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclients.go
More file actions
51 lines (41 loc) · 887 Bytes
/
clients.go
File metadata and controls
51 lines (41 loc) · 887 Bytes
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
package cwhydra
type Client struct {
Api Api
}
type ClientInterface interface {
List() ([]OAuth2Client, error)
Create(client OAuth2Client) (OAuth2Client, error)
Delete(id string) error
}
func ClientManager(a Api) Client {
return Client{
Api: a,
}
}
func (c Client) Create(client OAuth2Client) (OAuth2Client, error) {
var res OAuth2Client
err := c.Api.Post("/clients", client, &res)
if err != nil {
return res, err
}
return res, nil
}
func (c Client) Delete(id string) error {
return c.Api.Del("/clients/"+id, nil, nil)
}
func (c Client) List() ([]OAuth2Client, error) {
var res []OAuth2Client
err := c.Api.Get("/clients", &res)
if err != nil {
return res, err
}
return res, nil
}
func (c Client) Get(id string) (OAuth2Client, error) {
var res OAuth2Client
err := c.Api.Get("/clients/"+id, &res)
if err != nil {
return res, err
}
return res, err
}