k8s.io/client-go@v0.22.2/kubernetes/typed/rbac/v1alpha1/clusterrole.go (about) 1 /* 2 Copyright The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Code generated by client-gen. DO NOT EDIT. 18 19 package v1alpha1 20 21 import ( 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 // ClusterRolesGetter has a method to return a ClusterRoleInterface. 37 // A group's client should implement this interface. 38 type ClusterRolesGetter interface { 39 ClusterRoles() ClusterRoleInterface 40 } 41 42 // ClusterRoleInterface has methods to work with ClusterRole resources. 43 type ClusterRoleInterface interface { 44 Create(ctx context.Context, clusterRole *v1alpha1.ClusterRole, opts v1.CreateOptions) (*v1alpha1.ClusterRole, error) 45 Update(ctx context.Context, clusterRole *v1alpha1.ClusterRole, opts v1.UpdateOptions) (*v1alpha1.ClusterRole, 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.ClusterRole, error) 49 List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterRoleList, 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.ClusterRole, err error) 52 Apply(ctx context.Context, clusterRole *rbacv1alpha1.ClusterRoleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ClusterRole, err error) 53 ClusterRoleExpansion 54 } 55 56 // clusterRoles implements ClusterRoleInterface 57 type clusterRoles struct { 58 client rest.Interface 59 } 60 61 // newClusterRoles returns a ClusterRoles 62 func newClusterRoles(c *RbacV1alpha1Client) *clusterRoles { 63 return &clusterRoles{ 64 client: c.RESTClient(), 65 } 66 } 67 68 // Get takes name of the clusterRole, and returns the corresponding clusterRole object, and an error if there is any. 69 func (c *clusterRoles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterRole, err error) { 70 result = &v1alpha1.ClusterRole{} 71 err = c.client.Get(). 72 Resource("clusterroles"). 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 ClusterRoles that match those selectors. 81 func (c *clusterRoles) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterRoleList, err error) { 82 var timeout time.Duration 83 if opts.TimeoutSeconds != nil { 84 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 85 } 86 result = &v1alpha1.ClusterRoleList{} 87 err = c.client.Get(). 88 Resource("clusterroles"). 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 clusterRoles. 97 func (c *clusterRoles) 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("clusterroles"). 105 VersionedParams(&opts, scheme.ParameterCodec). 106 Timeout(timeout). 107 Watch(ctx) 108 } 109 110 // Create takes the representation of a clusterRole and creates it. Returns the server's representation of the clusterRole, and an error, if there is any. 111 func (c *clusterRoles) Create(ctx context.Context, clusterRole *v1alpha1.ClusterRole, opts v1.CreateOptions) (result *v1alpha1.ClusterRole, err error) { 112 result = &v1alpha1.ClusterRole{} 113 err = c.client.Post(). 114 Resource("clusterroles"). 115 VersionedParams(&opts, scheme.ParameterCodec). 116 Body(clusterRole). 117 Do(ctx). 118 Into(result) 119 return 120 } 121 122 // Update takes the representation of a clusterRole and updates it. Returns the server's representation of the clusterRole, and an error, if there is any. 123 func (c *clusterRoles) Update(ctx context.Context, clusterRole *v1alpha1.ClusterRole, opts v1.UpdateOptions) (result *v1alpha1.ClusterRole, err error) { 124 result = &v1alpha1.ClusterRole{} 125 err = c.client.Put(). 126 Resource("clusterroles"). 127 Name(clusterRole.Name). 128 VersionedParams(&opts, scheme.ParameterCodec). 129 Body(clusterRole). 130 Do(ctx). 131 Into(result) 132 return 133 } 134 135 // Delete takes name of the clusterRole and deletes it. Returns an error if one occurs. 136 func (c *clusterRoles) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { 137 return c.client.Delete(). 138 Resource("clusterroles"). 139 Name(name). 140 Body(&opts). 141 Do(ctx). 142 Error() 143 } 144 145 // DeleteCollection deletes a collection of objects. 146 func (c *clusterRoles) 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("clusterroles"). 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 clusterRole. 161 func (c *clusterRoles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterRole, err error) { 162 result = &v1alpha1.ClusterRole{} 163 err = c.client.Patch(pt). 164 Resource("clusterroles"). 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 clusterRole. 175 func (c *clusterRoles) Apply(ctx context.Context, clusterRole *rbacv1alpha1.ClusterRoleApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.ClusterRole, err error) { 176 if clusterRole == nil { 177 return nil, fmt.Errorf("clusterRole provided to Apply must not be nil") 178 } 179 patchOpts := opts.ToPatchOptions() 180 data, err := json.Marshal(clusterRole) 181 if err != nil { 182 return nil, err 183 } 184 name := clusterRole.Name 185 if name == nil { 186 return nil, fmt.Errorf("clusterRole.Name must be provided to Apply") 187 } 188 result = &v1alpha1.ClusterRole{} 189 err = c.client.Patch(types.ApplyPatchType). 190 Resource("clusterroles"). 191 Name(*name). 192 VersionedParams(&patchOpts, scheme.ParameterCodec). 193 Body(data). 194 Do(ctx). 195 Into(result) 196 return 197 }