blob: ddde2ec6c7b26d8340fac65ecec2a36ed1c425d2 [file] [log] [blame]
Matteo Scandoloa4285862020-12-01 18:10:10 -08001/*
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/kubernetes/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(ctx context.Context, service *v1.Service, opts metav1.CreateOptions) (*v1.Service, error)
42 Update(ctx context.Context, service *v1.Service, opts metav1.UpdateOptions) (*v1.Service, error)
43 UpdateStatus(ctx context.Context, service *v1.Service, opts metav1.UpdateOptions) (*v1.Service, error)
44 Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
45 Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Service, error)
46 List(ctx context.Context, opts metav1.ListOptions) (*v1.ServiceList, error)
47 Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
48 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, 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(ctx context.Context, 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(ctx).
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(ctx context.Context, 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(ctx).
92 Into(result)
93 return
94}
95
96// Watch returns a watch.Interface that watches the requested services.
97func (c *services) 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 Namespace(c.ns).
105 Resource("services").
106 VersionedParams(&opts, scheme.ParameterCodec).
107 Timeout(timeout).
108 Watch(ctx)
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(ctx context.Context, service *v1.Service, opts metav1.CreateOptions) (result *v1.Service, err error) {
113 result = &v1.Service{}
114 err = c.client.Post().
115 Namespace(c.ns).
116 Resource("services").
117 VersionedParams(&opts, scheme.ParameterCodec).
118 Body(service).
119 Do(ctx).
120 Into(result)
121 return
122}
123
124// 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.
125func (c *services) Update(ctx context.Context, service *v1.Service, opts metav1.UpdateOptions) (result *v1.Service, err error) {
126 result = &v1.Service{}
127 err = c.client.Put().
128 Namespace(c.ns).
129 Resource("services").
130 Name(service.Name).
131 VersionedParams(&opts, scheme.ParameterCodec).
132 Body(service).
133 Do(ctx).
134 Into(result)
135 return
136}
137
138// UpdateStatus was generated because the type contains a Status member.
139// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
140func (c *services) UpdateStatus(ctx context.Context, service *v1.Service, opts metav1.UpdateOptions) (result *v1.Service, err error) {
141 result = &v1.Service{}
142 err = c.client.Put().
143 Namespace(c.ns).
144 Resource("services").
145 Name(service.Name).
146 SubResource("status").
147 VersionedParams(&opts, scheme.ParameterCodec).
148 Body(service).
149 Do(ctx).
150 Into(result)
151 return
152}
153
154// Delete takes name of the service and deletes it. Returns an error if one occurs.
155func (c *services) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
156 return c.client.Delete().
157 Namespace(c.ns).
158 Resource("services").
159 Name(name).
160 Body(&opts).
161 Do(ctx).
162 Error()
163}
164
165// Patch applies the patch and returns the patched service.
166func (c *services) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Service, err error) {
167 result = &v1.Service{}
168 err = c.client.Patch(pt).
169 Namespace(c.ns).
170 Resource("services").
171 Name(name).
172 SubResource(subresources...).
173 VersionedParams(&opts, scheme.ParameterCodec).
174 Body(data).
175 Do(ctx).
176 Into(result)
177 return
178}