k8s.io/client-go@v0.22.2/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 "time" 26 27 v1beta2 "k8s.io/api/apps/v1beta2" 28 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 types "k8s.io/apimachinery/pkg/types" 30 watch "k8s.io/apimachinery/pkg/watch" 31 appsv1beta2 "k8s.io/client-go/applyconfigurations/apps/v1beta2" 32 scheme "k8s.io/client-go/kubernetes/scheme" 33 rest "k8s.io/client-go/rest" 34 ) 35 36 // StatefulSetsGetter has a method to return a StatefulSetInterface. 37 // A group's client should implement this interface. 38 type StatefulSetsGetter interface { 39 StatefulSets(namespace string) StatefulSetInterface 40 } 41 42 // StatefulSetInterface has methods to work with StatefulSet resources. 43 type StatefulSetInterface interface { 44 Create(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.CreateOptions) (*v1beta2.StatefulSet, error) 45 Update(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.UpdateOptions) (*v1beta2.StatefulSet, error) 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 ApplyStatus(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error) 55 GetScale(ctx context.Context, statefulSetName string, options v1.GetOptions) (*v1beta2.Scale, error) 56 UpdateScale(ctx context.Context, statefulSetName string, scale *v1beta2.Scale, opts v1.UpdateOptions) (*v1beta2.Scale, error) 57 ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (*v1beta2.Scale, error) 58 59 StatefulSetExpansion 60 } 61 62 // statefulSets implements StatefulSetInterface 63 type statefulSets struct { 64 client rest.Interface 65 ns string 66 } 67 68 // newStatefulSets returns a StatefulSets 69 func newStatefulSets(c *AppsV1beta2Client, namespace string) *statefulSets { 70 return &statefulSets{ 71 client: c.RESTClient(), 72 ns: namespace, 73 } 74 } 75 76 // Get takes name of the statefulSet, and returns the corresponding statefulSet object, and an error if there is any. 77 func (c *statefulSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.StatefulSet, err error) { 78 result = &v1beta2.StatefulSet{} 79 err = c.client.Get(). 80 Namespace(c.ns). 81 Resource("statefulsets"). 82 Name(name). 83 VersionedParams(&options, scheme.ParameterCodec). 84 Do(ctx). 85 Into(result) 86 return 87 } 88 89 // List takes label and field selectors, and returns the list of StatefulSets that match those selectors. 90 func (c *statefulSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.StatefulSetList, err error) { 91 var timeout time.Duration 92 if opts.TimeoutSeconds != nil { 93 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 94 } 95 result = &v1beta2.StatefulSetList{} 96 err = c.client.Get(). 97 Namespace(c.ns). 98 Resource("statefulsets"). 99 VersionedParams(&opts, scheme.ParameterCodec). 100 Timeout(timeout). 101 Do(ctx). 102 Into(result) 103 return 104 } 105 106 // Watch returns a watch.Interface that watches the requested statefulSets. 107 func (c *statefulSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { 108 var timeout time.Duration 109 if opts.TimeoutSeconds != nil { 110 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 111 } 112 opts.Watch = true 113 return c.client.Get(). 114 Namespace(c.ns). 115 Resource("statefulsets"). 116 VersionedParams(&opts, scheme.ParameterCodec). 117 Timeout(timeout). 118 Watch(ctx) 119 } 120 121 // Create takes the representation of a statefulSet and creates it. Returns the server's representation of the statefulSet, and an error, if there is any. 122 func (c *statefulSets) Create(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.CreateOptions) (result *v1beta2.StatefulSet, err error) { 123 result = &v1beta2.StatefulSet{} 124 err = c.client.Post(). 125 Namespace(c.ns). 126 Resource("statefulsets"). 127 VersionedParams(&opts, scheme.ParameterCodec). 128 Body(statefulSet). 129 Do(ctx). 130 Into(result) 131 return 132 } 133 134 // Update takes the representation of a statefulSet and updates it. Returns the server's representation of the statefulSet, and an error, if there is any. 135 func (c *statefulSets) Update(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.UpdateOptions) (result *v1beta2.StatefulSet, err error) { 136 result = &v1beta2.StatefulSet{} 137 err = c.client.Put(). 138 Namespace(c.ns). 139 Resource("statefulsets"). 140 Name(statefulSet.Name). 141 VersionedParams(&opts, scheme.ParameterCodec). 142 Body(statefulSet). 143 Do(ctx). 144 Into(result) 145 return 146 } 147 148 // UpdateStatus was generated because the type contains a Status member. 149 // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 150 func (c *statefulSets) UpdateStatus(ctx context.Context, statefulSet *v1beta2.StatefulSet, opts v1.UpdateOptions) (result *v1beta2.StatefulSet, err error) { 151 result = &v1beta2.StatefulSet{} 152 err = c.client.Put(). 153 Namespace(c.ns). 154 Resource("statefulsets"). 155 Name(statefulSet.Name). 156 SubResource("status"). 157 VersionedParams(&opts, scheme.ParameterCodec). 158 Body(statefulSet). 159 Do(ctx). 160 Into(result) 161 return 162 } 163 164 // Delete takes name of the statefulSet and deletes it. Returns an error if one occurs. 165 func (c *statefulSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { 166 return c.client.Delete(). 167 Namespace(c.ns). 168 Resource("statefulsets"). 169 Name(name). 170 Body(&opts). 171 Do(ctx). 172 Error() 173 } 174 175 // DeleteCollection deletes a collection of objects. 176 func (c *statefulSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { 177 var timeout time.Duration 178 if listOpts.TimeoutSeconds != nil { 179 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second 180 } 181 return c.client.Delete(). 182 Namespace(c.ns). 183 Resource("statefulsets"). 184 VersionedParams(&listOpts, scheme.ParameterCodec). 185 Timeout(timeout). 186 Body(&opts). 187 Do(ctx). 188 Error() 189 } 190 191 // Patch applies the patch and returns the patched statefulSet. 192 func (c *statefulSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.StatefulSet, err error) { 193 result = &v1beta2.StatefulSet{} 194 err = c.client.Patch(pt). 195 Namespace(c.ns). 196 Resource("statefulsets"). 197 Name(name). 198 SubResource(subresources...). 199 VersionedParams(&opts, scheme.ParameterCodec). 200 Body(data). 201 Do(ctx). 202 Into(result) 203 return 204 } 205 206 // Apply takes the given apply declarative configuration, applies it and returns the applied statefulSet. 207 func (c *statefulSets) Apply(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error) { 208 if statefulSet == nil { 209 return nil, fmt.Errorf("statefulSet provided to Apply must not be nil") 210 } 211 patchOpts := opts.ToPatchOptions() 212 data, err := json.Marshal(statefulSet) 213 if err != nil { 214 return nil, err 215 } 216 name := statefulSet.Name 217 if name == nil { 218 return nil, fmt.Errorf("statefulSet.Name must be provided to Apply") 219 } 220 result = &v1beta2.StatefulSet{} 221 err = c.client.Patch(types.ApplyPatchType). 222 Namespace(c.ns). 223 Resource("statefulsets"). 224 Name(*name). 225 VersionedParams(&patchOpts, scheme.ParameterCodec). 226 Body(data). 227 Do(ctx). 228 Into(result) 229 return 230 } 231 232 // ApplyStatus was generated because the type contains a Status member. 233 // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). 234 func (c *statefulSets) ApplyStatus(ctx context.Context, statefulSet *appsv1beta2.StatefulSetApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.StatefulSet, err error) { 235 if statefulSet == nil { 236 return nil, fmt.Errorf("statefulSet provided to Apply must not be nil") 237 } 238 patchOpts := opts.ToPatchOptions() 239 data, err := json.Marshal(statefulSet) 240 if err != nil { 241 return nil, err 242 } 243 244 name := statefulSet.Name 245 if name == nil { 246 return nil, fmt.Errorf("statefulSet.Name must be provided to Apply") 247 } 248 249 result = &v1beta2.StatefulSet{} 250 err = c.client.Patch(types.ApplyPatchType). 251 Namespace(c.ns). 252 Resource("statefulsets"). 253 Name(*name). 254 SubResource("status"). 255 VersionedParams(&patchOpts, scheme.ParameterCodec). 256 Body(data). 257 Do(ctx). 258 Into(result) 259 return 260 } 261 262 // GetScale takes name of the statefulSet, and returns the corresponding v1beta2.Scale object, and an error if there is any. 263 func (c *statefulSets) GetScale(ctx context.Context, statefulSetName string, options v1.GetOptions) (result *v1beta2.Scale, err error) { 264 result = &v1beta2.Scale{} 265 err = c.client.Get(). 266 Namespace(c.ns). 267 Resource("statefulsets"). 268 Name(statefulSetName). 269 SubResource("scale"). 270 VersionedParams(&options, scheme.ParameterCodec). 271 Do(ctx). 272 Into(result) 273 return 274 } 275 276 // 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. 277 func (c *statefulSets) UpdateScale(ctx context.Context, statefulSetName string, scale *v1beta2.Scale, opts v1.UpdateOptions) (result *v1beta2.Scale, err error) { 278 result = &v1beta2.Scale{} 279 err = c.client.Put(). 280 Namespace(c.ns). 281 Resource("statefulsets"). 282 Name(statefulSetName). 283 SubResource("scale"). 284 VersionedParams(&opts, scheme.ParameterCodec). 285 Body(scale). 286 Do(ctx). 287 Into(result) 288 return 289 } 290 291 // ApplyScale takes top resource name and the apply declarative configuration for scale, 292 // applies it and returns the applied scale, and an error, if there is any. 293 func (c *statefulSets) ApplyScale(ctx context.Context, statefulSetName string, scale *appsv1beta2.ScaleApplyConfiguration, opts v1.ApplyOptions) (result *v1beta2.Scale, err error) { 294 if scale == nil { 295 return nil, fmt.Errorf("scale provided to ApplyScale must not be nil") 296 } 297 patchOpts := opts.ToPatchOptions() 298 data, err := json.Marshal(scale) 299 if err != nil { 300 return nil, err 301 } 302 303 result = &v1beta2.Scale{} 304 err = c.client.Patch(types.ApplyPatchType). 305 Namespace(c.ns). 306 Resource("statefulsets"). 307 Name(statefulSetName). 308 SubResource("scale"). 309 VersionedParams(&patchOpts, scheme.ParameterCodec). 310 Body(data). 311 Do(ctx). 312 Into(result) 313 return 314 }