k8s.io/client-go@v0.22.2/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.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 v2beta2 20 21 import ( 22 "context" 23 json "encoding/json" 24 "fmt" 25 "time" 26 27 v2beta2 "k8s.io/api/autoscaling/v2beta2" 28 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 29 types "k8s.io/apimachinery/pkg/types" 30 watch "k8s.io/apimachinery/pkg/watch" 31 autoscalingv2beta2 "k8s.io/client-go/applyconfigurations/autoscaling/v2beta2" 32 scheme "k8s.io/client-go/kubernetes/scheme" 33 rest "k8s.io/client-go/rest" 34 ) 35 36 // HorizontalPodAutoscalersGetter has a method to return a HorizontalPodAutoscalerInterface. 37 // A group's client should implement this interface. 38 type HorizontalPodAutoscalersGetter interface { 39 HorizontalPodAutoscalers(namespace string) HorizontalPodAutoscalerInterface 40 } 41 42 // HorizontalPodAutoscalerInterface has methods to work with HorizontalPodAutoscaler resources. 43 type HorizontalPodAutoscalerInterface interface { 44 Create(ctx context.Context, horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler, opts v1.CreateOptions) (*v2beta2.HorizontalPodAutoscaler, error) 45 Update(ctx context.Context, horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler, opts v1.UpdateOptions) (*v2beta2.HorizontalPodAutoscaler, error) 46 UpdateStatus(ctx context.Context, horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler, opts v1.UpdateOptions) (*v2beta2.HorizontalPodAutoscaler, 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) (*v2beta2.HorizontalPodAutoscaler, error) 50 List(ctx context.Context, opts v1.ListOptions) (*v2beta2.HorizontalPodAutoscalerList, 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 *v2beta2.HorizontalPodAutoscaler, err error) 53 Apply(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) 54 ApplyStatus(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) 55 HorizontalPodAutoscalerExpansion 56 } 57 58 // horizontalPodAutoscalers implements HorizontalPodAutoscalerInterface 59 type horizontalPodAutoscalers struct { 60 client rest.Interface 61 ns string 62 } 63 64 // newHorizontalPodAutoscalers returns a HorizontalPodAutoscalers 65 func newHorizontalPodAutoscalers(c *AutoscalingV2beta2Client, namespace string) *horizontalPodAutoscalers { 66 return &horizontalPodAutoscalers{ 67 client: c.RESTClient(), 68 ns: namespace, 69 } 70 } 71 72 // Get takes name of the horizontalPodAutoscaler, and returns the corresponding horizontalPodAutoscaler object, and an error if there is any. 73 func (c *horizontalPodAutoscalers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) { 74 result = &v2beta2.HorizontalPodAutoscaler{} 75 err = c.client.Get(). 76 Namespace(c.ns). 77 Resource("horizontalpodautoscalers"). 78 Name(name). 79 VersionedParams(&options, scheme.ParameterCodec). 80 Do(ctx). 81 Into(result) 82 return 83 } 84 85 // List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. 86 func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.HorizontalPodAutoscalerList, err error) { 87 var timeout time.Duration 88 if opts.TimeoutSeconds != nil { 89 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 90 } 91 result = &v2beta2.HorizontalPodAutoscalerList{} 92 err = c.client.Get(). 93 Namespace(c.ns). 94 Resource("horizontalpodautoscalers"). 95 VersionedParams(&opts, scheme.ParameterCodec). 96 Timeout(timeout). 97 Do(ctx). 98 Into(result) 99 return 100 } 101 102 // Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers. 103 func (c *horizontalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { 104 var timeout time.Duration 105 if opts.TimeoutSeconds != nil { 106 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 107 } 108 opts.Watch = true 109 return c.client.Get(). 110 Namespace(c.ns). 111 Resource("horizontalpodautoscalers"). 112 VersionedParams(&opts, scheme.ParameterCodec). 113 Timeout(timeout). 114 Watch(ctx) 115 } 116 117 // Create takes the representation of a horizontalPodAutoscaler and creates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if there is any. 118 func (c *horizontalPodAutoscalers) Create(ctx context.Context, horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler, opts v1.CreateOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) { 119 result = &v2beta2.HorizontalPodAutoscaler{} 120 err = c.client.Post(). 121 Namespace(c.ns). 122 Resource("horizontalpodautoscalers"). 123 VersionedParams(&opts, scheme.ParameterCodec). 124 Body(horizontalPodAutoscaler). 125 Do(ctx). 126 Into(result) 127 return 128 } 129 130 // Update takes the representation of a horizontalPodAutoscaler and updates it. Returns the server's representation of the horizontalPodAutoscaler, and an error, if there is any. 131 func (c *horizontalPodAutoscalers) Update(ctx context.Context, horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler, opts v1.UpdateOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) { 132 result = &v2beta2.HorizontalPodAutoscaler{} 133 err = c.client.Put(). 134 Namespace(c.ns). 135 Resource("horizontalpodautoscalers"). 136 Name(horizontalPodAutoscaler.Name). 137 VersionedParams(&opts, scheme.ParameterCodec). 138 Body(horizontalPodAutoscaler). 139 Do(ctx). 140 Into(result) 141 return 142 } 143 144 // UpdateStatus was generated because the type contains a Status member. 145 // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 146 func (c *horizontalPodAutoscalers) UpdateStatus(ctx context.Context, horizontalPodAutoscaler *v2beta2.HorizontalPodAutoscaler, opts v1.UpdateOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) { 147 result = &v2beta2.HorizontalPodAutoscaler{} 148 err = c.client.Put(). 149 Namespace(c.ns). 150 Resource("horizontalpodautoscalers"). 151 Name(horizontalPodAutoscaler.Name). 152 SubResource("status"). 153 VersionedParams(&opts, scheme.ParameterCodec). 154 Body(horizontalPodAutoscaler). 155 Do(ctx). 156 Into(result) 157 return 158 } 159 160 // Delete takes name of the horizontalPodAutoscaler and deletes it. Returns an error if one occurs. 161 func (c *horizontalPodAutoscalers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { 162 return c.client.Delete(). 163 Namespace(c.ns). 164 Resource("horizontalpodautoscalers"). 165 Name(name). 166 Body(&opts). 167 Do(ctx). 168 Error() 169 } 170 171 // DeleteCollection deletes a collection of objects. 172 func (c *horizontalPodAutoscalers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { 173 var timeout time.Duration 174 if listOpts.TimeoutSeconds != nil { 175 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second 176 } 177 return c.client.Delete(). 178 Namespace(c.ns). 179 Resource("horizontalpodautoscalers"). 180 VersionedParams(&listOpts, scheme.ParameterCodec). 181 Timeout(timeout). 182 Body(&opts). 183 Do(ctx). 184 Error() 185 } 186 187 // Patch applies the patch and returns the patched horizontalPodAutoscaler. 188 func (c *horizontalPodAutoscalers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.HorizontalPodAutoscaler, err error) { 189 result = &v2beta2.HorizontalPodAutoscaler{} 190 err = c.client.Patch(pt). 191 Namespace(c.ns). 192 Resource("horizontalpodautoscalers"). 193 Name(name). 194 SubResource(subresources...). 195 VersionedParams(&opts, scheme.ParameterCodec). 196 Body(data). 197 Do(ctx). 198 Into(result) 199 return 200 } 201 202 // Apply takes the given apply declarative configuration, applies it and returns the applied horizontalPodAutoscaler. 203 func (c *horizontalPodAutoscalers) Apply(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) { 204 if horizontalPodAutoscaler == nil { 205 return nil, fmt.Errorf("horizontalPodAutoscaler provided to Apply must not be nil") 206 } 207 patchOpts := opts.ToPatchOptions() 208 data, err := json.Marshal(horizontalPodAutoscaler) 209 if err != nil { 210 return nil, err 211 } 212 name := horizontalPodAutoscaler.Name 213 if name == nil { 214 return nil, fmt.Errorf("horizontalPodAutoscaler.Name must be provided to Apply") 215 } 216 result = &v2beta2.HorizontalPodAutoscaler{} 217 err = c.client.Patch(types.ApplyPatchType). 218 Namespace(c.ns). 219 Resource("horizontalpodautoscalers"). 220 Name(*name). 221 VersionedParams(&patchOpts, scheme.ParameterCodec). 222 Body(data). 223 Do(ctx). 224 Into(result) 225 return 226 } 227 228 // ApplyStatus was generated because the type contains a Status member. 229 // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). 230 func (c *horizontalPodAutoscalers) ApplyStatus(ctx context.Context, horizontalPodAutoscaler *autoscalingv2beta2.HorizontalPodAutoscalerApplyConfiguration, opts v1.ApplyOptions) (result *v2beta2.HorizontalPodAutoscaler, err error) { 231 if horizontalPodAutoscaler == nil { 232 return nil, fmt.Errorf("horizontalPodAutoscaler provided to Apply must not be nil") 233 } 234 patchOpts := opts.ToPatchOptions() 235 data, err := json.Marshal(horizontalPodAutoscaler) 236 if err != nil { 237 return nil, err 238 } 239 240 name := horizontalPodAutoscaler.Name 241 if name == nil { 242 return nil, fmt.Errorf("horizontalPodAutoscaler.Name must be provided to Apply") 243 } 244 245 result = &v2beta2.HorizontalPodAutoscaler{} 246 err = c.client.Patch(types.ApplyPatchType). 247 Namespace(c.ns). 248 Resource("horizontalpodautoscalers"). 249 Name(*name). 250 SubResource("status"). 251 VersionedParams(&patchOpts, scheme.ParameterCodec). 252 Body(data). 253 Do(ctx). 254 Into(result) 255 return 256 }