github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/cloud/pkg/client/clientset/versioned/clientset.go (about)

     1  /*
     2  Copyright 2020 The KubeEdge 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  
    23  	devicesv1alpha1 "github.com/kubeedge/kubeedge/cloud/pkg/client/clientset/versioned/typed/devices/v1alpha1"
    24  	reliablesyncsv1alpha1 "github.com/kubeedge/kubeedge/cloud/pkg/client/clientset/versioned/typed/reliablesyncs/v1alpha1"
    25  	discovery "k8s.io/client-go/discovery"
    26  	rest "k8s.io/client-go/rest"
    27  	flowcontrol "k8s.io/client-go/util/flowcontrol"
    28  )
    29  
    30  type Interface interface {
    31  	Discovery() discovery.DiscoveryInterface
    32  	DevicesV1alpha1() devicesv1alpha1.DevicesV1alpha1Interface
    33  	ReliablesyncsV1alpha1() reliablesyncsv1alpha1.ReliablesyncsV1alpha1Interface
    34  }
    35  
    36  // Clientset contains the clients for groups. Each group has exactly one
    37  // version included in a Clientset.
    38  type Clientset struct {
    39  	*discovery.DiscoveryClient
    40  	devicesV1alpha1       *devicesv1alpha1.DevicesV1alpha1Client
    41  	reliablesyncsV1alpha1 *reliablesyncsv1alpha1.ReliablesyncsV1alpha1Client
    42  }
    43  
    44  // DevicesV1alpha1 retrieves the DevicesV1alpha1Client
    45  func (c *Clientset) DevicesV1alpha1() devicesv1alpha1.DevicesV1alpha1Interface {
    46  	return c.devicesV1alpha1
    47  }
    48  
    49  // ReliablesyncsV1alpha1 retrieves the ReliablesyncsV1alpha1Client
    50  func (c *Clientset) ReliablesyncsV1alpha1() reliablesyncsv1alpha1.ReliablesyncsV1alpha1Interface {
    51  	return c.reliablesyncsV1alpha1
    52  }
    53  
    54  // Discovery retrieves the DiscoveryClient
    55  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    56  	if c == nil {
    57  		return nil
    58  	}
    59  	return c.DiscoveryClient
    60  }
    61  
    62  // NewForConfig creates a new Clientset for the given config.
    63  // If config's RateLimiter is not set and QPS and Burst are acceptable,
    64  // NewForConfig will generate a rate-limiter in configShallowCopy.
    65  func NewForConfig(c *rest.Config) (*Clientset, error) {
    66  	configShallowCopy := *c
    67  	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
    68  		if configShallowCopy.Burst <= 0 {
    69  			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")
    70  		}
    71  		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
    72  	}
    73  	var cs Clientset
    74  	var err error
    75  	cs.devicesV1alpha1, err = devicesv1alpha1.NewForConfig(&configShallowCopy)
    76  	if err != nil {
    77  		return nil, err
    78  	}
    79  	cs.reliablesyncsV1alpha1, err = reliablesyncsv1alpha1.NewForConfig(&configShallowCopy)
    80  	if err != nil {
    81  		return nil, err
    82  	}
    83  
    84  	cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
    85  	if err != nil {
    86  		return nil, err
    87  	}
    88  	return &cs, nil
    89  }
    90  
    91  // NewForConfigOrDie creates a new Clientset for the given config and
    92  // panics if there is an error in the config.
    93  func NewForConfigOrDie(c *rest.Config) *Clientset {
    94  	var cs Clientset
    95  	cs.devicesV1alpha1 = devicesv1alpha1.NewForConfigOrDie(c)
    96  	cs.reliablesyncsV1alpha1 = reliablesyncsv1alpha1.NewForConfigOrDie(c)
    97  
    98  	cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
    99  	return &cs
   100  }
   101  
   102  // New creates a new Clientset for the given RESTClient.
   103  func New(c rest.Interface) *Clientset {
   104  	var cs Clientset
   105  	cs.devicesV1alpha1 = devicesv1alpha1.New(c)
   106  	cs.reliablesyncsV1alpha1 = reliablesyncsv1alpha1.New(c)
   107  
   108  	cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
   109  	return &cs
   110  }