k8s.io/client-go@v0.31.1/kubernetes/typed/apps/v1beta2/statefulset.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  	"context"
    23  	json "encoding/json"
    24  	"fmt"
    25  
    26  	v1beta2 "k8s.io/api/apps/v1beta2"
    27  	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    28  	types "k8s.io/apimachinery/pkg/types"
    29  	watch "k8s.io/apimachinery/pkg/watch"
    30  	appsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2"
    31  	gentype "k8s.io/client-go/gentype"
    32  	scheme "k8s.io/client-go/kubernetes/scheme"
    33  )
    34  
    35  // StatefulSetsGetter has a method to return a StatefulSetInterface.
    36  // A group's client should implement this interface.
    37  type StatefulSetsGetter interface {
    38  	StatefulSets(namespace string) StatefulSetInterface
    39  }
    40  
    41  // StatefulSetInterface has methods to work with StatefulSet resources.
    42  type StatefulSetInterface interface {
    43  	Create(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.CreateOptions) (*v1beta2.StatefulSet, error)
    44  	Update(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.UpdateOptions) (*v1beta2.StatefulSet, error)
    45  	// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
    46  	UpdateStatus(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.UpdateOptions) (*v1beta2.StatefulSet, error)
    47  	Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
    48  	DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
    49  	Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta2.StatefulSet, error)
    50  	List(ctx context.Context, opts v1.ListOptions) (*v1beta2.StatefulSetList, error)
    51  	Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
    52  	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.StatefulSet, err error)
    53  	Apply(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error)
    54  	// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
    55  	ApplyStatus(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error)
    56  	GetScale(ctx context.Context, statefulSetName string, options v1.GetOptions) (*v1beta2.Scale, error)
    57  	UpdateScale(ctx context.Context, statefulSetName string, scale *v1beta2.Scale, opts v1.UpdateOptions) (*v1beta2.Scale, error)
    58  	ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta2.Scale, error)
    59  
    60  	StatefulSetExpansion
    61  }
    62  
    63  // statefulSets implements StatefulSetInterface
    64  type statefulSets struct {
    65  	*gentype.ClientWithListAndApply[*v1beta2.StatefulSet, *v1beta2.StatefulSetList, *appsv1beta2.StatefulSetApplyConfiguration]
    66  }
    67  
    68  // newStatefulSets returns a StatefulSets
    69  func newStatefulSets(c *AppsV1beta2Client, namespace string) *statefulSets {
    70  	return &statefulSets{
    71  		gentype.NewClientWithListAndApply[*v1beta2.StatefulSet, *v1beta2.StatefulSetList, *appsv1beta2.StatefulSetApplyConfiguration](
    72  			"statefulsets",
    73  			c.RESTClient(),
    74  			scheme.ParameterCodec,
    75  			namespace,
    76  			func() *v1beta2.StatefulSet { return &v1beta2.StatefulSet{} },
    77  			func() *v1beta2.StatefulSetList { return &v1beta2.StatefulSetList{} }),
    78  	}
    79  }
    80  
    81  // GetScale takes name of the statefulSet, and returns the corresponding v1beta2.Scale object, and an error if there is any.
    82  func (c *statefulSets) GetScale(ctx context.Context, statefulSetName string, options v1.GetOptions) (result *v1beta2.Scale, err error) {
    83  	result = &v1beta2.Scale{}
    84  	err = c.GetClient().Get().
    85  		Namespace(c.GetNamespace()).
    86  		Resource("statefulsets").
    87  		Name(statefulSetName).
    88  		SubResource("scale").
    89  		VersionedParams(&options, scheme.ParameterCodec).
    90  		Do(ctx).
    91  		Into(result)
    92  	return
    93  }
    94  
    95  // UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
    96  func (c *statefulSets) UpdateScale(ctx context.Context, statefulSetName string, scale *v1beta2.Scale, opts v1.UpdateOptions) (result *v1beta2.Scale, err error) {
    97  	result = &v1beta2.Scale{}
    98  	err = c.GetClient().Put().
    99  		Namespace(c.GetNamespace()).
   100  		Resource("statefulsets").
   101  		Name(statefulSetName).
   102  		SubResource("scale").
   103  		VersionedParams(&opts, scheme.ParameterCodec).
   104  		Body(scale).
   105  		Do(ctx).
   106  		Into(result)
   107  	return
   108  }
   109  
   110  // ApplyScale takes top resource name and the apply declarative configuration for scale,
   111  // applies it and returns the applied scale, and an error, if there is any.
   112  func (c *statefulSets) ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.Scale, err error) {
   113  	if scale == nil {
   114  		return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
   115  	}
   116  	patchOpts := opts.ToPatchOptions()
   117  	data, err := json.Marshal(scale)
   118  	if err != nil {
   119  		return nil, err
   120  	}
   121  
   122  	result = &v1beta2.Scale{}
   123  	err = c.GetClient().Patch(types.ApplyPatchType).
   124  		Namespace(c.GetNamespace()).
   125  		Resource("statefulsets").
   126  		Name(statefulSetName).
   127  		SubResource("scale").
   128  		VersionedParams(&patchOpts, scheme.ParameterCodec).
   129  		Body(data).
   130  		Do(ctx).
   131  		Into(result)
   132  	return
   133  }