volcano.sh/apis@v1.8.2/pkg/client/clientset/versioned/clientset.go (about)

     1  /*
     2  Copyright 2021 The Volcano 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  // Code generated by client-gen. DO NOT EDIT.
    17  
    18  package versioned
    19  
    20  import (
    21  	"fmt"
    22  	"net/http"
    23  
    24  	discovery "k8s.io/client-go/discovery"
    25  	rest "k8s.io/client-go/rest"
    26  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    27  	batchv1alpha1 "volcano.sh/apis/pkg/client/clientset/versioned/typed/batch/v1alpha1"
    28  	busv1alpha1 "volcano.sh/apis/pkg/client/clientset/versioned/typed/bus/v1alpha1"
    29  	flowv1alpha1 "volcano.sh/apis/pkg/client/clientset/versioned/typed/flow/v1alpha1"
    30  	nodeinfov1alpha1 "volcano.sh/apis/pkg/client/clientset/versioned/typed/nodeinfo/v1alpha1"
    31  	schedulingv1beta1 "volcano.sh/apis/pkg/client/clientset/versioned/typed/scheduling/v1beta1"
    32  )
    33  
    34  type Interface interface {
    35  	Discovery() discovery.DiscoveryInterface
    36  	BatchV1alpha1() batchv1alpha1.BatchV1alpha1Interface
    37  	BusV1alpha1() busv1alpha1.BusV1alpha1Interface
    38  	FlowV1alpha1() flowv1alpha1.FlowV1alpha1Interface
    39  	NodeinfoV1alpha1() nodeinfov1alpha1.NodeinfoV1alpha1Interface
    40  	SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface
    41  }
    42  
    43  // Clientset contains the clients for groups. Each group has exactly one
    44  // version included in a Clientset.
    45  type Clientset struct {
    46  	*discovery.DiscoveryClient
    47  	batchV1alpha1     *batchv1alpha1.BatchV1alpha1Client
    48  	busV1alpha1       *busv1alpha1.BusV1alpha1Client
    49  	flowV1alpha1      *flowv1alpha1.FlowV1alpha1Client
    50  	nodeinfoV1alpha1  *nodeinfov1alpha1.NodeinfoV1alpha1Client
    51  	schedulingV1beta1 *schedulingv1beta1.SchedulingV1beta1Client
    52  }
    53  
    54  // BatchV1alpha1 retrieves the BatchV1alpha1Client
    55  func (c *Clientset) BatchV1alpha1() batchv1alpha1.BatchV1alpha1Interface {
    56  	return c.batchV1alpha1
    57  }
    58  
    59  // BusV1alpha1 retrieves the BusV1alpha1Client
    60  func (c *Clientset) BusV1alpha1() busv1alpha1.BusV1alpha1Interface {
    61  	return c.busV1alpha1
    62  }
    63  
    64  // FlowV1alpha1 retrieves the FlowV1alpha1Client
    65  func (c *Clientset) FlowV1alpha1() flowv1alpha1.FlowV1alpha1Interface {
    66  	return c.flowV1alpha1
    67  }
    68  
    69  // NodeinfoV1alpha1 retrieves the NodeinfoV1alpha1Client
    70  func (c *Clientset) NodeinfoV1alpha1() nodeinfov1alpha1.NodeinfoV1alpha1Interface {
    71  	return c.nodeinfoV1alpha1
    72  }
    73  
    74  // SchedulingV1beta1 retrieves the SchedulingV1beta1Client
    75  func (c *Clientset) SchedulingV1beta1() schedulingv1beta1.SchedulingV1beta1Interface {
    76  	return c.schedulingV1beta1
    77  }
    78  
    79  // Discovery retrieves the DiscoveryClient
    80  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    81  	if c == nil {
    82  		return nil
    83  	}
    84  	return c.DiscoveryClient
    85  }
    86  
    87  // NewForConfig creates a new Clientset for the given config.
    88  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    89  // NewForConfig will generate a rate-limiter in configShallowCopy.
    90  // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
    91  // where httpClient was generated with rest.HTTPClientFor(c).
    92  func NewForConfig(c *rest.Config) (*Clientset, error) {
    93  	configShallowCopy := *c
    94  
    95  	// share the transport between all clients
    96  	httpClient, err := rest.HTTPClientFor(&configShallowCopy)
    97  	if err != nil {
    98  		return nil, err
    99  	}
   100  
   101  	return NewForConfigAndClient(&configShallowCopy, httpClient)
   102  }
   103  
   104  // NewForConfigAndClient creates a new Clientset for the given config and http client.
   105  // Note the http client provided takes precedence over the configured transport values.
   106  // If config's RateLimiter is not set and QPS and Burst are acceptable,
   107  // NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
   108  func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
   109  	configShallowCopy := *c
   110  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
   111  		if configShallowCopy.Burst <= 0 {
   112  			return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
   113  		}
   114  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
   115  	}
   116  
   117  	var cs Clientset
   118  	var err error
   119  	cs.batchV1alpha1, err = batchv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
   120  	if err != nil {
   121  		return nil, err
   122  	}
   123  	cs.busV1alpha1, err = busv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  	cs.flowV1alpha1, err = flowv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
   128  	if err != nil {
   129  		return nil, err
   130  	}
   131  	cs.nodeinfoV1alpha1, err = nodeinfov1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
   132  	if err != nil {
   133  		return nil, err
   134  	}
   135  	cs.schedulingV1beta1, err = schedulingv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient)
   136  	if err != nil {
   137  		return nil, err
   138  	}
   139  
   140  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
   141  	if err != nil {
   142  		return nil, err
   143  	}
   144  	return &cs, nil
   145  }
   146  
   147  // NewForConfigOrDie creates a new Clientset for the given config and
   148  // panics if there is an error in the config.
   149  func NewForConfigOrDie(c *rest.Config) *Clientset {
   150  	cs, err := NewForConfig(c)
   151  	if err != nil {
   152  		panic(err)
   153  	}
   154  	return cs
   155  }
   156  
   157  // New creates a new Clientset for the given RESTClient.
   158  func New(c rest.Interface) *Clientset {
   159  	var cs Clientset
   160  	cs.batchV1alpha1 = batchv1alpha1.New(c)
   161  	cs.busV1alpha1 = busv1alpha1.New(c)
   162  	cs.flowV1alpha1 = flowv1alpha1.New(c)
   163  	cs.nodeinfoV1alpha1 = nodeinfov1alpha1.New(c)
   164  	cs.schedulingV1beta1 = schedulingv1beta1.New(c)
   165  
   166  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
   167  	return &cs
   168  }