k8s.io/client-go@v0.22.2/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.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 "time" 26 27 v1 "k8s.io/api/admissionregistration/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 admissionregistrationv1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1" 32 scheme "k8s.io/client-go/kubernetes/scheme" 33 rest "k8s.io/client-go/rest" 34 ) 35 36 // ValidatingWebhookConfigurationsGetter has a method to return a ValidatingWebhookConfigurationInterface. 37 // A group's client should implement this interface. 38 type ValidatingWebhookConfigurationsGetter interface { 39 ValidatingWebhookConfigurations() ValidatingWebhookConfigurationInterface 40 } 41 42 // ValidatingWebhookConfigurationInterface has methods to work with ValidatingWebhookConfiguration resources. 43 type ValidatingWebhookConfigurationInterface interface { 44 Create(ctx context.Context, validatingWebhookConfiguration *v1.ValidatingWebhookConfiguration, opts metav1.CreateOptions) (*v1.ValidatingWebhookConfiguration, error) 45 Update(ctx context.Context, validatingWebhookConfiguration *v1.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (*v1.ValidatingWebhookConfiguration, error) 46 Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error 47 DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error 48 Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.ValidatingWebhookConfiguration, error) 49 List(ctx context.Context, opts metav1.ListOptions) (*v1.ValidatingWebhookConfigurationList, error) 50 Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) 51 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ValidatingWebhookConfiguration, err error) 52 Apply(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1.ValidatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ValidatingWebhookConfiguration, err error) 53 ValidatingWebhookConfigurationExpansion 54 } 55 56 // validatingWebhookConfigurations implements ValidatingWebhookConfigurationInterface 57 type validatingWebhookConfigurations struct { 58 client rest.Interface 59 } 60 61 // newValidatingWebhookConfigurations returns a ValidatingWebhookConfigurations 62 func newValidatingWebhookConfigurations(c *AdmissionregistrationV1Client) *validatingWebhookConfigurations { 63 return &validatingWebhookConfigurations{ 64 client: c.RESTClient(), 65 } 66 } 67 68 // Get takes name of the validatingWebhookConfiguration, and returns the corresponding validatingWebhookConfiguration object, and an error if there is any. 69 func (c *validatingWebhookConfigurations) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ValidatingWebhookConfiguration, err error) { 70 result = &v1.ValidatingWebhookConfiguration{} 71 err = c.client.Get(). 72 Resource("validatingwebhookconfigurations"). 73 Name(name). 74 VersionedParams(&options, scheme.ParameterCodec). 75 Do(ctx). 76 Into(result) 77 return 78 } 79 80 // List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. 81 func (c *validatingWebhookConfigurations) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingWebhookConfigurationList, err error) { 82 var timeout time.Duration 83 if opts.TimeoutSeconds != nil { 84 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 85 } 86 result = &v1.ValidatingWebhookConfigurationList{} 87 err = c.client.Get(). 88 Resource("validatingwebhookconfigurations"). 89 VersionedParams(&opts, scheme.ParameterCodec). 90 Timeout(timeout). 91 Do(ctx). 92 Into(result) 93 return 94 } 95 96 // Watch returns a watch.Interface that watches the requested validatingWebhookConfigurations. 97 func (c *validatingWebhookConfigurations) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { 98 var timeout time.Duration 99 if opts.TimeoutSeconds != nil { 100 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 101 } 102 opts.Watch = true 103 return c.client.Get(). 104 Resource("validatingwebhookconfigurations"). 105 VersionedParams(&opts, scheme.ParameterCodec). 106 Timeout(timeout). 107 Watch(ctx) 108 } 109 110 // Create takes the representation of a validatingWebhookConfiguration and creates it. Returns the server's representation of the validatingWebhookConfiguration, and an error, if there is any. 111 func (c *validatingWebhookConfigurations) Create(ctx context.Context, validatingWebhookConfiguration *v1.ValidatingWebhookConfiguration, opts metav1.CreateOptions) (result *v1.ValidatingWebhookConfiguration, err error) { 112 result = &v1.ValidatingWebhookConfiguration{} 113 err = c.client.Post(). 114 Resource("validatingwebhookconfigurations"). 115 VersionedParams(&opts, scheme.ParameterCodec). 116 Body(validatingWebhookConfiguration). 117 Do(ctx). 118 Into(result) 119 return 120 } 121 122 // Update takes the representation of a validatingWebhookConfiguration and updates it. Returns the server's representation of the validatingWebhookConfiguration, and an error, if there is any. 123 func (c *validatingWebhookConfigurations) Update(ctx context.Context, validatingWebhookConfiguration *v1.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (result *v1.ValidatingWebhookConfiguration, err error) { 124 result = &v1.ValidatingWebhookConfiguration{} 125 err = c.client.Put(). 126 Resource("validatingwebhookconfigurations"). 127 Name(validatingWebhookConfiguration.Name). 128 VersionedParams(&opts, scheme.ParameterCodec). 129 Body(validatingWebhookConfiguration). 130 Do(ctx). 131 Into(result) 132 return 133 } 134 135 // Delete takes name of the validatingWebhookConfiguration and deletes it. Returns an error if one occurs. 136 func (c *validatingWebhookConfigurations) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { 137 return c.client.Delete(). 138 Resource("validatingwebhookconfigurations"). 139 Name(name). 140 Body(&opts). 141 Do(ctx). 142 Error() 143 } 144 145 // DeleteCollection deletes a collection of objects. 146 func (c *validatingWebhookConfigurations) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { 147 var timeout time.Duration 148 if listOpts.TimeoutSeconds != nil { 149 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second 150 } 151 return c.client.Delete(). 152 Resource("validatingwebhookconfigurations"). 153 VersionedParams(&listOpts, scheme.ParameterCodec). 154 Timeout(timeout). 155 Body(&opts). 156 Do(ctx). 157 Error() 158 } 159 160 // Patch applies the patch and returns the patched validatingWebhookConfiguration. 161 func (c *validatingWebhookConfigurations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ValidatingWebhookConfiguration, err error) { 162 result = &v1.ValidatingWebhookConfiguration{} 163 err = c.client.Patch(pt). 164 Resource("validatingwebhookconfigurations"). 165 Name(name). 166 SubResource(subresources...). 167 VersionedParams(&opts, scheme.ParameterCodec). 168 Body(data). 169 Do(ctx). 170 Into(result) 171 return 172 } 173 174 // Apply takes the given apply declarative configuration, applies it and returns the applied validatingWebhookConfiguration. 175 func (c *validatingWebhookConfigurations) Apply(ctx context.Context, validatingWebhookConfiguration *admissionregistrationv1.ValidatingWebhookConfigurationApplyConfiguration, opts metav1.ApplyOptions) (result *v1.ValidatingWebhookConfiguration, err error) { 176 if validatingWebhookConfiguration == nil { 177 return nil, fmt.Errorf("validatingWebhookConfiguration provided to Apply must not be nil") 178 } 179 patchOpts := opts.ToPatchOptions() 180 data, err := json.Marshal(validatingWebhookConfiguration) 181 if err != nil { 182 return nil, err 183 } 184 name := validatingWebhookConfiguration.Name 185 if name == nil { 186 return nil, fmt.Errorf("validatingWebhookConfiguration.Name must be provided to Apply") 187 } 188 result = &v1.ValidatingWebhookConfiguration{} 189 err = c.client.Patch(types.ApplyPatchType). 190 Resource("validatingwebhookconfigurations"). 191 Name(*name). 192 VersionedParams(&patchOpts, scheme.ParameterCodec). 193 Body(data). 194 Do(ctx). 195 Into(result) 196 return 197 }