1/* 2Copyright The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17// Code generated by client-gen. DO NOT EDIT. 18 19package v1 20 21import ( 22 "context" 23 "time" 24 25 v1 "k8s.io/api/core/v1" 26 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 27 types "k8s.io/apimachinery/pkg/types" 28 watch "k8s.io/apimachinery/pkg/watch" 29 scheme "k8s.io/client-go/deprecated/scheme" 30 rest "k8s.io/client-go/rest" 31) 32 33// ServicesGetter has a method to return a ServiceInterface. 34// A group's client should implement this interface. 35type ServicesGetter interface { 36 Services(namespace string) ServiceInterface 37} 38 39// ServiceInterface has methods to work with Service resources. 40type ServiceInterface interface { 41 Create(*v1.Service) (*v1.Service, error) 42 Update(*v1.Service) (*v1.Service, error) 43 UpdateStatus(*v1.Service) (*v1.Service, error) 44 Delete(name string, options *metav1.DeleteOptions) error 45 Get(name string, options metav1.GetOptions) (*v1.Service, error) 46 List(opts metav1.ListOptions) (*v1.ServiceList, error) 47 Watch(opts metav1.ListOptions) (watch.Interface, error) 48 Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Service, err error) 49 ServiceExpansion 50} 51 52// services implements ServiceInterface 53type services struct { 54 client rest.Interface 55 ns string 56} 57 58// newServices returns a Services 59func newServices(c *CoreV1Client, namespace string) *services { 60 return &services{ 61 client: c.RESTClient(), 62 ns: namespace, 63 } 64} 65 66// Get takes name of the service, and returns the corresponding service object, and an error if there is any. 67func (c *services) Get(name string, options metav1.GetOptions) (result *v1.Service, err error) { 68 result = &v1.Service{} 69 err = c.client.Get(). 70 Namespace(c.ns). 71 Resource("services"). 72 Name(name). 73 VersionedParams(&options, scheme.ParameterCodec). 74 Do(context.TODO()). 75 Into(result) 76 return 77} 78 79// List takes label and field selectors, and returns the list of Services that match those selectors. 80func (c *services) List(opts metav1.ListOptions) (result *v1.ServiceList, err error) { 81 var timeout time.Duration 82 if opts.TimeoutSeconds != nil { 83 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second 84 } 85 result = &v1.ServiceList{} 86 err = c.client.Get(). 87 Namespace(c.ns). 88 Resource("services"). 89 VersionedParams(&opts, scheme.ParameterCodec). 90 Timeout(timeout). 91 Do(context.TODO()). 92 Into(result) 93 return 94} 95 96// Watch returns a watch.Interface that watches the requested services. 97func (c *services) Watch(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 Namespace(c.ns). 105 Resource("services"). 106 VersionedParams(&opts, scheme.ParameterCodec). 107 Timeout(timeout). 108 Watch(context.TODO()) 109} 110 111// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. 112func (c *services) Create(service *v1.Service) (result *v1.Service, err error) { 113 result = &v1.Service{} 114 err = c.client.Post(). 115 Namespace(c.ns). 116 Resource("services"). 117 Body(service). 118 Do(context.TODO()). 119 Into(result) 120 return 121} 122 123// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. 124func (c *services) Update(service *v1.Service) (result *v1.Service, err error) { 125 result = &v1.Service{} 126 err = c.client.Put(). 127 Namespace(c.ns). 128 Resource("services"). 129 Name(service.Name). 130 Body(service). 131 Do(context.TODO()). 132 Into(result) 133 return 134} 135 136// UpdateStatus was generated because the type contains a Status member. 137// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). 138 139func (c *services) UpdateStatus(service *v1.Service) (result *v1.Service, err error) { 140 result = &v1.Service{} 141 err = c.client.Put(). 142 Namespace(c.ns). 143 Resource("services"). 144 Name(service.Name). 145 SubResource("status"). 146 Body(service). 147 Do(context.TODO()). 148 Into(result) 149 return 150} 151 152// Delete takes name of the service and deletes it. Returns an error if one occurs. 153func (c *services) Delete(name string, options *metav1.DeleteOptions) error { 154 return c.client.Delete(). 155 Namespace(c.ns). 156 Resource("services"). 157 Name(name). 158 Body(options). 159 Do(context.TODO()). 160 Error() 161} 162 163// Patch applies the patch and returns the patched service. 164func (c *services) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Service, err error) { 165 result = &v1.Service{} 166 err = c.client.Patch(pt). 167 Namespace(c.ns). 168 Resource("services"). 169 SubResource(subresources...). 170 Name(name). 171 Body(data). 172 Do(context.TODO()). 173 Into(result) 174 return 175} 176