k8s.io/client-go@v0.22.2/kubernetes/typed/policy/v1/policy_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  	v1 "k8s.io/api/policy/v1"
    23  	"k8s.io/client-go/kubernetes/scheme"
    24  	rest "k8s.io/client-go/rest"
    25  )
    26  
    27  type PolicyV1Interface interface {
    28  	RESTClient() rest.Interface
    29  	EvictionsGetter
    30  	PodDisruptionBudgetsGetter
    31  }
    32  
    33  // PolicyV1Client is used to interact with features provided by the policy group.
    34  type PolicyV1Client struct {
    35  	restClient rest.Interface
    36  }
    37  
    38  func (c *PolicyV1Client) Evictions(namespace string) EvictionInterface {
    39  	return newEvictions(c, namespace)
    40  }
    41  
    42  func (c *PolicyV1Client) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface {
    43  	return newPodDisruptionBudgets(c, namespace)
    44  }
    45  
    46  // NewForConfig creates a new PolicyV1Client for the given config.
    47  func NewForConfig(c *rest.Config) (*PolicyV1Client, error) {
    48  	config := *c
    49  	if err := setConfigDefaults(&config); err != nil {
    50  		return nil, err
    51  	}
    52  	client, err := rest.RESTClientFor(&config)
    53  	if err != nil {
    54  		return nil, err
    55  	}
    56  	return &PolicyV1Client{client}, nil
    57  }
    58  
    59  // NewForConfigOrDie creates a new PolicyV1Client for the given config and
    60  // panics if there is an error in the config.
    61  func NewForConfigOrDie(c *rest.Config) *PolicyV1Client {
    62  	client, err := NewForConfig(c)
    63  	if err != nil {
    64  		panic(err)
    65  	}
    66  	return client
    67  }
    68  
    69  // New creates a new PolicyV1Client for the given RESTClient.
    70  func New(c rest.Interface) *PolicyV1Client {
    71  	return &PolicyV1Client{c}
    72  }
    73  
    74  func setConfigDefaults(config *rest.Config) error {
    75  	gv := v1.SchemeGroupVersion
    76  	config.GroupVersion = &gv
    77  	config.APIPath = "/apis"
    78  	config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
    79  
    80  	if config.UserAgent == "" {
    81  		config.UserAgent = rest.DefaultKubernetesUserAgent()
    82  	}
    83  
    84  	return nil
    85  }
    86  
    87  // RESTClient returns a RESTClient that is used to communicate
    88  // with API server by this client implementation.
    89  func (c *PolicyV1Client) RESTClient() rest.Interface {
    90  	if c == nil {
    91  		return nil
    92  	}
    93  	return c.restClient
    94  }