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