k8s.io/client-go@v0.31.1/kubernetes/typed/rbac/v1/rbac_client.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 v1
    20  
    21  import (
    22  	"net/http"
    23  
    24  	v1 "k8s.io/api/rbac/v1"
    25  	"k8s.io/client-go/kubernetes/scheme"
    26  	rest "k8s.io/client-go/rest"
    27  )
    28  
    29  type RbacV1Interface interface {
    30  	RESTClient() rest.Interface
    31  	ClusterRolesGetter
    32  	ClusterRoleBindingsGetter
    33  	RolesGetter
    34  	RoleBindingsGetter
    35  }
    36  
    37  // RbacV1Client is used to interact with features provided by the rbac.authorization.k8s.io group.
    38  type RbacV1Client struct {
    39  	restClient rest.Interface
    40  }
    41  
    42  func (c *RbacV1Client) ClusterRoles() ClusterRoleInterface {
    43  	return newClusterRoles(c)
    44  }
    45  
    46  func (c *RbacV1Client) ClusterRoleBindings() ClusterRoleBindingInterface {
    47  	return newClusterRoleBindings(c)
    48  }
    49  
    50  func (c *RbacV1Client) Roles(namespace string) RoleInterface {
    51  	return newRoles(c, namespace)
    52  }
    53  
    54  func (c *RbacV1Client) RoleBindings(namespace string) RoleBindingInterface {
    55  	return newRoleBindings(c, namespace)
    56  }
    57  
    58  // NewForConfig creates a new RbacV1Client for the given config.
    59  // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
    60  // where httpClient was generated with rest.HTTPClientFor(c).
    61  func NewForConfig(c *rest.Config) (*RbacV1Client, error) {
    62  	config := *c
    63  	if err := setConfigDefaults(&config); err != nil {
    64  		return nil, err
    65  	}
    66  	httpClient, err := rest.HTTPClientFor(&config)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  	return NewForConfigAndClient(&config, httpClient)
    71  }
    72  
    73  // NewForConfigAndClient creates a new RbacV1Client for the given config and http client.
    74  // Note the http client provided takes precedence over the configured transport values.
    75  func NewForConfigAndClient(c *rest.Config, h *http.Client) (*RbacV1Client, error) {
    76  	config := *c
    77  	if err := setConfigDefaults(&config); err != nil {
    78  		return nil, err
    79  	}
    80  	client, err := rest.RESTClientForConfigAndClient(&config, h)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  	return &RbacV1Client{client}, nil
    85  }
    86  
    87  // NewForConfigOrDie creates a new RbacV1Client for the given config and
    88  // panics if there is an error in the config.
    89  func NewForConfigOrDie(c *rest.Config) *RbacV1Client {
    90  	client, err := NewForConfig(c)
    91  	if err != nil {
    92  		panic(err)
    93  	}
    94  	return client
    95  }
    96  
    97  // New creates a new RbacV1Client for the given RESTClient.
    98  func New(c rest.Interface) *RbacV1Client {
    99  	return &RbacV1Client{c}
   100  }
   101  
   102  func setConfigDefaults(config *rest.Config) error {
   103  	gv := v1.SchemeGroupVersion
   104  	config.GroupVersion = &gv
   105  	config.APIPath = "/apis"
   106  	config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
   107  
   108  	if config.UserAgent == "" {
   109  		config.UserAgent = rest.DefaultKubernetesUserAgent()
   110  	}
   111  
   112  	return nil
   113  }
   114  
   115  // RESTClient returns a RESTClient that is used to communicate
   116  // with API server by this client implementation.
   117  func (c *RbacV1Client) RESTClient() rest.Interface {
   118  	if c == nil {
   119  		return nil
   120  	}
   121  	return c.restClient
   122  }