clusterrolebindings.go 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package unversioned
  14. import (
  15. "k8s.io/kubernetes/pkg/api"
  16. "k8s.io/kubernetes/pkg/apis/rbac"
  17. "k8s.io/kubernetes/pkg/watch"
  18. )
  19. // ClusterRoleBindings has methods to work with ClusterRoleBinding resources in a namespace
  20. type ClusterRoleBindings interface {
  21. ClusterRoleBindings() ClusterRoleBindingInterface
  22. }
  23. // ClusterRoleBindingInterface has methods to work with ClusterRoleBinding resources.
  24. type ClusterRoleBindingInterface interface {
  25. List(opts api.ListOptions) (*rbac.ClusterRoleBindingList, error)
  26. Get(name string) (*rbac.ClusterRoleBinding, error)
  27. Delete(name string, options *api.DeleteOptions) error
  28. Create(clusterRoleBinding *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error)
  29. Update(clusterRoleBinding *rbac.ClusterRoleBinding) (*rbac.ClusterRoleBinding, error)
  30. Watch(opts api.ListOptions) (watch.Interface, error)
  31. }
  32. // clusterRoleBindings implements ClusterRoleBindingsNamespacer interface
  33. type clusterRoleBindings struct {
  34. client *RbacClient
  35. }
  36. // newClusterRoleBindings returns a clusterRoleBindings
  37. func newClusterRoleBindings(c *RbacClient) *clusterRoleBindings {
  38. return &clusterRoleBindings{
  39. client: c,
  40. }
  41. }
  42. // List takes label and field selectors, and returns the list of clusterRoleBindings that match those selectors.
  43. func (c *clusterRoleBindings) List(opts api.ListOptions) (result *rbac.ClusterRoleBindingList, err error) {
  44. result = &rbac.ClusterRoleBindingList{}
  45. err = c.client.Get().Resource("clusterrolebindings").VersionedParams(&opts, api.ParameterCodec).Do().Into(result)
  46. return
  47. }
  48. // Get takes the name of the clusterRoleBinding, and returns the corresponding ClusterRoleBinding object, and an error if it occurs
  49. func (c *clusterRoleBindings) Get(name string) (result *rbac.ClusterRoleBinding, err error) {
  50. result = &rbac.ClusterRoleBinding{}
  51. err = c.client.Get().Resource("clusterrolebindings").Name(name).Do().Into(result)
  52. return
  53. }
  54. // Delete takes the name of the clusterRoleBinding and deletes it. Returns an error if one occurs.
  55. func (c *clusterRoleBindings) Delete(name string, options *api.DeleteOptions) error {
  56. return c.client.Delete().Resource("clusterrolebindings").Name(name).Body(options).Do().Error()
  57. }
  58. // Create takes the representation of a clusterRoleBinding and creates it. Returns the server's representation of the clusterRoleBinding, and an error, if it occurs.
  59. func (c *clusterRoleBindings) Create(clusterRoleBinding *rbac.ClusterRoleBinding) (result *rbac.ClusterRoleBinding, err error) {
  60. result = &rbac.ClusterRoleBinding{}
  61. err = c.client.Post().Resource("clusterrolebindings").Body(clusterRoleBinding).Do().Into(result)
  62. return
  63. }
  64. // Update takes the representation of a clusterRoleBinding and updates it. Returns the server's representation of the clusterRoleBinding, and an error, if it occurs.
  65. func (c *clusterRoleBindings) Update(clusterRoleBinding *rbac.ClusterRoleBinding) (result *rbac.ClusterRoleBinding, err error) {
  66. result = &rbac.ClusterRoleBinding{}
  67. err = c.client.Put().Resource("clusterrolebindings").Name(clusterRoleBinding.Name).Body(clusterRoleBinding).Do().Into(result)
  68. return
  69. }
  70. // Watch returns a watch.Interface that watches the requested clusterRoleBindings.
  71. func (c *clusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) {
  72. return c.client.Get().
  73. Prefix("watch").
  74. Resource("clusterrolebindings").
  75. VersionedParams(&opts, api.ParameterCodec).
  76. Watch()
  77. }