...

Source file src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrolebinding.go

Documentation: k8s.io/client-go/kubernetes/typed/rbac/v1

     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 v1
    20  
    21  import (
    22  	"context"
    23  	json "encoding/json"
    24  	"fmt"
    25  	"time"
    26  
    27  	v1 "k8s.io/api/rbac/v1"
    28  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    29  	types "k8s.io/apimachinery/pkg/types"
    30  	watch "k8s.io/apimachinery/pkg/watch"
    31  	rbacv1 "k8s.io/client-go/applyconfigurations/rbac/v1"
    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.
    38  type ClusterRoleBindingsGetter interface {
    39  	ClusterRoleBindings() ClusterRoleBindingInterface
    40  }
    41  
    42  // ClusterRoleBindingInterface has methods to work with ClusterRoleBinding resources.
    43  type ClusterRoleBindingInterface interface {
    44  	Create(ctx context.Context, clusterRoleBinding *v1.ClusterRoleBinding, opts metav1.CreateOptions) (*v1.ClusterRoleBinding, error)
    45  	Update(ctx context.Context, clusterRoleBinding *v1.ClusterRoleBinding, opts metav1.UpdateOptions) (*v1.ClusterRoleBinding, error)
    46  	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
    47  	DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
    48  	Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.ClusterRoleBinding, error)
    49  	List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterRoleBindingList, error)
    50  	Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
    51  	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterRoleBinding, err error)
    52  	Apply(ctx context.Context, clusterRoleBinding *rbacv1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ClusterRoleBinding, err error)
    53  	ClusterRoleBindingExpansion
    54  }
    55  
    56  // clusterRoleBindings implements ClusterRoleBindingInterface
    57  type clusterRoleBindings struct {
    58  	client rest.Interface
    59  }
    60  
    61  // newClusterRoleBindings returns a ClusterRoleBindings
    62  func newClusterRoleBindings(c *RbacV1Client) *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.
    69  func (c *clusterRoleBindings) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ClusterRoleBinding, err error) {
    70  	result = &v1.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.
    81  func (c *clusterRoleBindings) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterRoleBindingList, err error) {
    82  	var timeout time.Duration
    83  	if opts.TimeoutSeconds != nil {
    84  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
    85  	}
    86  	result = &v1.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.
    97  func (c *clusterRoleBindings) Watch(ctx context.Context, opts metav1.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.
   111  func (c *clusterRoleBindings) Create(ctx context.Context, clusterRoleBinding *v1.ClusterRoleBinding, opts metav1.CreateOptions) (result *v1.ClusterRoleBinding, err error) {
   112  	result = &v1.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.
   123  func (c *clusterRoleBindings) Update(ctx context.Context, clusterRoleBinding *v1.ClusterRoleBinding, opts metav1.UpdateOptions) (result *v1.ClusterRoleBinding, err error) {
   124  	result = &v1.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.
   136  func (c *clusterRoleBindings) Delete(ctx context.Context, name string, opts metav1.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.
   146  func (c *clusterRoleBindings) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.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.
   161  func (c *clusterRoleBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ClusterRoleBinding, err error) {
   162  	result = &v1.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.
   175  func (c *clusterRoleBindings) Apply(ctx context.Context, clusterRoleBinding *rbacv1.ClusterRoleBindingApplyConfiguration, opts metav1.ApplyOptions) (result *v1.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 = &v1.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  

View as plain text