...

Source file src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/rolebinding.go

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

     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  // RoleBindingsGetter has a method to return a RoleBindingInterface.
    37  // A group's client should implement this interface.
    38  type RoleBindingsGetter interface {
    39  	RoleBindings(namespace string) RoleBindingInterface
    40  }
    41  
    42  // RoleBindingInterface has methods to work with RoleBinding resources.
    43  type RoleBindingInterface interface {
    44  	Create(ctx context.Context, roleBinding *v1alpha1.RoleBinding, opts v1.CreateOptions) (*v1alpha1.RoleBinding, error)
    45  	Update(ctx context.Context, roleBinding *v1alpha1.RoleBinding, opts v1.UpdateOptions) (*v1alpha1.RoleBinding, 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.RoleBinding, error)
    49  	List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RoleBindingList, 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.RoleBinding, err error)
    52  	Apply(ctx context.Context, roleBinding *rbacv1alpha1.RoleBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.RoleBinding, err error)
    53  	RoleBindingExpansion
    54  }
    55  
    56  // roleBindings implements RoleBindingInterface
    57  type roleBindings struct {
    58  	client rest.Interface
    59  	ns     string
    60  }
    61  
    62  // newRoleBindings returns a RoleBindings
    63  func newRoleBindings(c *RbacV1alpha1Client, namespace string) *roleBindings {
    64  	return &roleBindings{
    65  		client: c.RESTClient(),
    66  		ns:     namespace,
    67  	}
    68  }
    69  
    70  // Get takes name of the roleBinding, and returns the corresponding roleBinding object, and an error if there is any.
    71  func (c *roleBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.RoleBinding, err error) {
    72  	result = &v1alpha1.RoleBinding{}
    73  	err = c.client.Get().
    74  		Namespace(c.ns).
    75  		Resource("rolebindings").
    76  		Name(name).
    77  		VersionedParams(&options, scheme.ParameterCodec).
    78  		Do(ctx).
    79  		Into(result)
    80  	return
    81  }
    82  
    83  // List takes label and field selectors, and returns the list of RoleBindings that match those selectors.
    84  func (c *roleBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RoleBindingList, err error) {
    85  	var timeout time.Duration
    86  	if opts.TimeoutSeconds != nil {
    87  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
    88  	}
    89  	result = &v1alpha1.RoleBindingList{}
    90  	err = c.client.Get().
    91  		Namespace(c.ns).
    92  		Resource("rolebindings").
    93  		VersionedParams(&opts, scheme.ParameterCodec).
    94  		Timeout(timeout).
    95  		Do(ctx).
    96  		Into(result)
    97  	return
    98  }
    99  
   100  // Watch returns a watch.Interface that watches the requested roleBindings.
   101  func (c *roleBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
   102  	var timeout time.Duration
   103  	if opts.TimeoutSeconds != nil {
   104  		timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
   105  	}
   106  	opts.Watch = true
   107  	return c.client.Get().
   108  		Namespace(c.ns).
   109  		Resource("rolebindings").
   110  		VersionedParams(&opts, scheme.ParameterCodec).
   111  		Timeout(timeout).
   112  		Watch(ctx)
   113  }
   114  
   115  // Create takes the representation of a roleBinding and creates it.  Returns the server's representation of the roleBinding, and an error, if there is any.
   116  func (c *roleBindings) Create(ctx context.Context, roleBinding *v1alpha1.RoleBinding, opts v1.CreateOptions) (result *v1alpha1.RoleBinding, err error) {
   117  	result = &v1alpha1.RoleBinding{}
   118  	err = c.client.Post().
   119  		Namespace(c.ns).
   120  		Resource("rolebindings").
   121  		VersionedParams(&opts, scheme.ParameterCodec).
   122  		Body(roleBinding).
   123  		Do(ctx).
   124  		Into(result)
   125  	return
   126  }
   127  
   128  // Update takes the representation of a roleBinding and updates it. Returns the server's representation of the roleBinding, and an error, if there is any.
   129  func (c *roleBindings) Update(ctx context.Context, roleBinding *v1alpha1.RoleBinding, opts v1.UpdateOptions) (result *v1alpha1.RoleBinding, err error) {
   130  	result = &v1alpha1.RoleBinding{}
   131  	err = c.client.Put().
   132  		Namespace(c.ns).
   133  		Resource("rolebindings").
   134  		Name(roleBinding.Name).
   135  		VersionedParams(&opts, scheme.ParameterCodec).
   136  		Body(roleBinding).
   137  		Do(ctx).
   138  		Into(result)
   139  	return
   140  }
   141  
   142  // Delete takes name of the roleBinding and deletes it. Returns an error if one occurs.
   143  func (c *roleBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
   144  	return c.client.Delete().
   145  		Namespace(c.ns).
   146  		Resource("rolebindings").
   147  		Name(name).
   148  		Body(&opts).
   149  		Do(ctx).
   150  		Error()
   151  }
   152  
   153  // DeleteCollection deletes a collection of objects.
   154  func (c *roleBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
   155  	var timeout time.Duration
   156  	if listOpts.TimeoutSeconds != nil {
   157  		timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
   158  	}
   159  	return c.client.Delete().
   160  		Namespace(c.ns).
   161  		Resource("rolebindings").
   162  		VersionedParams(&listOpts, scheme.ParameterCodec).
   163  		Timeout(timeout).
   164  		Body(&opts).
   165  		Do(ctx).
   166  		Error()
   167  }
   168  
   169  // Patch applies the patch and returns the patched roleBinding.
   170  func (c *roleBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.RoleBinding, err error) {
   171  	result = &v1alpha1.RoleBinding{}
   172  	err = c.client.Patch(pt).
   173  		Namespace(c.ns).
   174  		Resource("rolebindings").
   175  		Name(name).
   176  		SubResource(subresources...).
   177  		VersionedParams(&opts, scheme.ParameterCodec).
   178  		Body(data).
   179  		Do(ctx).
   180  		Into(result)
   181  	return
   182  }
   183  
   184  // Apply takes the given apply declarative configuration, applies it and returns the applied roleBinding.
   185  func (c *roleBindings) Apply(ctx context.Context, roleBinding *rbacv1alpha1.RoleBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.RoleBinding, err error) {
   186  	if roleBinding == nil {
   187  		return nil, fmt.Errorf("roleBinding provided to Apply must not be nil")
   188  	}
   189  	patchOpts := opts.ToPatchOptions()
   190  	data, err := json.Marshal(roleBinding)
   191  	if err != nil {
   192  		return nil, err
   193  	}
   194  	name := roleBinding.Name
   195  	if name == nil {
   196  		return nil, fmt.Errorf("roleBinding.Name must be provided to Apply")
   197  	}
   198  	result = &v1alpha1.RoleBinding{}
   199  	err = c.client.Patch(types.ApplyPatchType).
   200  		Namespace(c.ns).
   201  		Resource("rolebindings").
   202  		Name(*name).
   203  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   204  		Body(data).
   205  		Do(ctx).
   206  		Into(result)
   207  	return
   208  }
   209  

View as plain text