1/* 2Copyright The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17// Code generated by client-gen. DO NOT EDIT. 18 19package v1alpha1 20 21import ( 22 "context" 23 json "encoding/json" 24 "fmt" 25 "time" 26 27 v1alpha1 "k8s.io/api/rbac/v1alpha1" 28 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 types "k8s.io/apimachinery/pkg/types" 30 watch "k8s.io/apimachinery/pkg/watch" 31 rbacv1alpha1 "k8s.io/client-go/applyconfigurations/rbac/v1alpha1" 32 scheme "k8s.io/client-go/kubernetes/scheme" 33 rest "k8s.io/client-go/rest" 34) 35 36// ClusterRoleBindingsGetter has a method to return a ClusterRoleBindingInterface. 37// A group's client should implement this interface. 38type ClusterRoleBindingsGetter interface { 39 ClusterRoleBindings() ClusterRoleBindingInterface 40} 41 42// ClusterRoleBindingInterface has methods to work with ClusterRoleBinding resources. 43type ClusterRoleBindingInterface interface { 44 Create(ctx context.Context, clusterRoleBinding *v1alpha1.ClusterRoleBinding, opts v1.CreateOptions) (*v1alpha1.ClusterRoleBinding, error) 45 Update(ctx context.Context, clusterRoleBinding *v1alpha1.ClusterRoleBinding, opts v1.UpdateOptions) (*v1alpha1.ClusterRoleBinding, error) 46 Delete(ctx context.Context, name string, opts v1.DeleteOptions) error 47 DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error 48 Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterRoleBinding, error) 49 List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterRoleBindingList, error) 50 Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) 51 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error) 52 Apply(ctx context.Context, clusterRoleBinding *rbacv1alpha1.ClusterRoleBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ClusterRoleBinding, err error) 53 ClusterRoleBindingExpansion 54} 55 56// clusterRoleBindings implements ClusterRoleBindingInterface 57type clusterRoleBindings struct { 58 client rest.Interface 59} 60 61// newClusterRoleBindings returns a ClusterRoleBindings 62func newClusterRoleBindings(c *RbacV1alpha1Client) *clusterRoleBindings { 63 return &clusterRoleBindings{ 64 client: c.RESTClient(), 65 } 66} 67 68// Get takes name of the clusterRoleBinding, and returns the corresponding clusterRoleBinding object, and an error if there is any. 69func (c *clusterRoleBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterRoleBinding, err error) { 70 result = &v1alpha1.ClusterRoleBinding{} 71 err = c.client.Get(). 72 Resource("clusterrolebindings"). 73 Name(name). 74 VersionedParams(&options, scheme.ParameterCodec). 75 Do(ctx). 76 Into(result) 77 return 78} 79 80// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. 81func (c *clusterRoleBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterRoleBindingList, err error) { 82 var timeout time.Duration 83 if opts.TimeoutSeconds != nil { 84 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 85 } 86 result = &v1alpha1.ClusterRoleBindingList{} 87 err = c.client.Get(). 88 Resource("clusterrolebindings"). 89 VersionedParams(&opts, scheme.ParameterCodec). 90 Timeout(timeout). 91 Do(ctx). 92 Into(result) 93 return 94} 95 96// Watch returns a watch.Interface that watches the requested clusterRoleBindings. 97func (c *clusterRoleBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { 98 var timeout time.Duration 99 if opts.TimeoutSeconds != nil { 100 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 101 } 102 opts.Watch = true 103 return c.client.Get(). 104 Resource("clusterrolebindings"). 105 VersionedParams(&opts, scheme.ParameterCodec). 106 Timeout(timeout). 107 Watch(ctx) 108} 109 110// Create takes the representation of a clusterRoleBinding and creates it. Returns the server's representation of the clusterRoleBinding, and an error, if there is any. 111func (c *clusterRoleBindings) Create(ctx context.Context, clusterRoleBinding *v1alpha1.ClusterRoleBinding, opts v1.CreateOptions) (result *v1alpha1.ClusterRoleBinding, err error) { 112 result = &v1alpha1.ClusterRoleBinding{} 113 err = c.client.Post(). 114 Resource("clusterrolebindings"). 115 VersionedParams(&opts, scheme.ParameterCodec). 116 Body(clusterRoleBinding). 117 Do(ctx). 118 Into(result) 119 return 120} 121 122// Update takes the representation of a clusterRoleBinding and updates it. Returns the server's representation of the clusterRoleBinding, and an error, if there is any. 123func (c *clusterRoleBindings) Update(ctx context.Context, clusterRoleBinding *v1alpha1.ClusterRoleBinding, opts v1.UpdateOptions) (result *v1alpha1.ClusterRoleBinding, err error) { 124 result = &v1alpha1.ClusterRoleBinding{} 125 err = c.client.Put(). 126 Resource("clusterrolebindings"). 127 Name(clusterRoleBinding.Name). 128 VersionedParams(&opts, scheme.ParameterCodec). 129 Body(clusterRoleBinding). 130 Do(ctx). 131 Into(result) 132 return 133} 134 135// Delete takes name of the clusterRoleBinding and deletes it. Returns an error if one occurs. 136func (c *clusterRoleBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { 137 return c.client.Delete(). 138 Resource("clusterrolebindings"). 139 Name(name). 140 Body(&opts). 141 Do(ctx). 142 Error() 143} 144 145// DeleteCollection deletes a collection of objects. 146func (c *clusterRoleBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { 147 var timeout time.Duration 148 if listOpts.TimeoutSeconds != nil { 149 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second 150 } 151 return c.client.Delete(). 152 Resource("clusterrolebindings"). 153 VersionedParams(&listOpts, scheme.ParameterCodec). 154 Timeout(timeout). 155 Body(&opts). 156 Do(ctx). 157 Error() 158} 159 160// Patch applies the patch and returns the patched clusterRoleBinding. 161func (c *clusterRoleBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error) { 162 result = &v1alpha1.ClusterRoleBinding{} 163 err = c.client.Patch(pt). 164 Resource("clusterrolebindings"). 165 Name(name). 166 SubResource(subresources...). 167 VersionedParams(&opts, scheme.ParameterCodec). 168 Body(data). 169 Do(ctx). 170 Into(result) 171 return 172} 173 174// Apply takes the given apply declarative configuration, applies it and returns the applied clusterRoleBinding. 175func (c *clusterRoleBindings) Apply(ctx context.Context, clusterRoleBinding *rbacv1alpha1.ClusterRoleBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ClusterRoleBinding, err error) { 176 if clusterRoleBinding == nil { 177 return nil, fmt.Errorf("clusterRoleBinding provided to Apply must not be nil") 178 } 179 patchOpts := opts.ToPatchOptions() 180 data, err := json.Marshal(clusterRoleBinding) 181 if err != nil { 182 return nil, err 183 } 184 name := clusterRoleBinding.Name 185 if name == nil { 186 return nil, fmt.Errorf("clusterRoleBinding.Name must be provided to Apply") 187 } 188 result = &v1alpha1.ClusterRoleBinding{} 189 err = c.client.Patch(types.ApplyPatchType). 190 Resource("clusterrolebindings"). 191 Name(*name). 192 VersionedParams(&patchOpts, scheme.ParameterCodec). 193 Body(data). 194 Do(ctx). 195 Into(result) 196 return 197} 198