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