forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identities.go
70 lines (59 loc) · 2.23 KB
/
identities.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
70
package client
import (
kapi "k8s.io/kubernetes/pkg/api"
userapi "github.com/openshift/origin/pkg/user/api"
)
// IdentitiesInterface has methods to work with Identity resources
type IdentitiesInterface interface {
Identities() IdentityInterface
}
// IdentityInterface exposes methods on identity resources.
type IdentityInterface interface {
List(opts kapi.ListOptions) (*userapi.IdentityList, error)
Get(name string) (*userapi.Identity, error)
Create(identity *userapi.Identity) (*userapi.Identity, error)
Update(identity *userapi.Identity) (*userapi.Identity, error)
Delete(name string) error
}
// identities implements IdentityInterface interface
type identities struct {
r *Client
}
// newIdentities returns an identities client
func newIdentities(c *Client) *identities {
return &identities{
r: c,
}
}
// List returns a list of identities that match the label and field selectors.
func (c *identities) List(opts kapi.ListOptions) (result *userapi.IdentityList, err error) {
result = &userapi.IdentityList{}
err = c.r.Get().
Resource("identities").
VersionedParams(&opts, kapi.ParameterCodec).
Do().
Into(result)
return
}
// Get returns information about a particular identity or an error
func (c *identities) Get(name string) (result *userapi.Identity, err error) {
result = &userapi.Identity{}
err = c.r.Get().Resource("identities").Name(name).Do().Into(result)
return
}
// Create creates a new identity. Returns the server's representation of the identity and error if one occurs.
func (c *identities) Create(identity *userapi.Identity) (result *userapi.Identity, err error) {
result = &userapi.Identity{}
err = c.r.Post().Resource("identities").Body(identity).Do().Into(result)
return
}
// Update updates the identity on server. Returns the server's representation of the identity and error if one occurs.
func (c *identities) Update(identity *userapi.Identity) (result *userapi.Identity, err error) {
result = &userapi.Identity{}
err = c.r.Put().Resource("identities").Name(identity.Name).Body(identity).Do().Into(result)
return
}
// Delete deletes the identity on server. Returns an error if one occurs.
func (c *identities) Delete(name string) (err error) {
return c.r.Delete().Resource("identities").Name(name).Do().Error()
}