forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subjectaccessreview.go
60 lines (50 loc) · 2.24 KB
/
subjectaccessreview.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
package client
import (
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
)
// SubjectAccessReviewsNamespacer has methods to work with SubjectAccessReview resources in a namespace
type SubjectAccessReviewsNamespacer interface {
SubjectAccessReviews(namespace string) SubjectAccessReviewInterface
}
// ClusterSubjectAccessReviews has methods to work with SubjectAccessReview resources in the cluster scope
type ClusterSubjectAccessReviews interface {
ClusterSubjectAccessReviews() SubjectAccessReviewInterface
}
// SubjectAccessReviewInterface exposes methods on SubjectAccessReview resources.
type SubjectAccessReviewInterface interface {
Create(policy *authorizationapi.SubjectAccessReview) (*authorizationapi.SubjectAccessReviewResponse, error)
}
// subjectAccessReviews implements SubjectAccessReviewsNamespacer interface
type subjectAccessReviews struct {
r *Client
ns string
}
// newSubjectAccessReviews returns a subjectAccessReviews
func newSubjectAccessReviews(c *Client, namespace string) *subjectAccessReviews {
return &subjectAccessReviews{
r: c,
ns: namespace,
}
}
// Create creates new policy. Returns the server's representation of the policy and error if one occurs.
func (c *subjectAccessReviews) Create(policy *authorizationapi.SubjectAccessReview) (result *authorizationapi.SubjectAccessReviewResponse, err error) {
result = &authorizationapi.SubjectAccessReviewResponse{}
err = c.r.Post().Namespace(c.ns).Resource("subjectAccessReviews").Body(policy).Do().Into(result)
return
}
// clusterSubjectAccessReviews implements ClusterSubjectAccessReviews interface
type clusterSubjectAccessReviews struct {
r *Client
}
// newClusterSubjectAccessReviews returns a clusterSubjectAccessReviews
func newClusterSubjectAccessReviews(c *Client) *clusterSubjectAccessReviews {
return &clusterSubjectAccessReviews{
r: c,
}
}
// Create creates new policy. Returns the server's representation of the policy and error if one occurs.
func (c *clusterSubjectAccessReviews) Create(policy *authorizationapi.SubjectAccessReview) (result *authorizationapi.SubjectAccessReviewResponse, err error) {
result = &authorizationapi.SubjectAccessReviewResponse{}
err = c.r.Post().Resource("subjectAccessReviews").Body(policy).Do().Into(result)
return
}