blob: 63b4627d33770158e810051aa8260ab3d91cd707 [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 v1alpha1
20
21import (
22 "context"
23 "time"
24
25 v1alpha1 "k8s.io/api/discovery/v1alpha1"
26 v1 "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// EndpointSlicesGetter has a method to return a EndpointSliceInterface.
34// A group's client should implement this interface.
35type EndpointSlicesGetter interface {
36 EndpointSlices(namespace string) EndpointSliceInterface
37}
38
39// EndpointSliceInterface has methods to work with EndpointSlice resources.
40type EndpointSliceInterface interface {
41 Create(ctx context.Context, endpointSlice *v1alpha1.EndpointSlice, opts v1.CreateOptions) (*v1alpha1.EndpointSlice, error)
42 Update(ctx context.Context, endpointSlice *v1alpha1.EndpointSlice, opts v1.UpdateOptions) (*v1alpha1.EndpointSlice, error)
43 Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
44 DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
45 Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.EndpointSlice, error)
46 List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.EndpointSliceList, error)
47 Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
48 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.EndpointSlice, err error)
49 EndpointSliceExpansion
50}
51
52// endpointSlices implements EndpointSliceInterface
53type endpointSlices struct {
54 client rest.Interface
55 ns string
56}
57
58// newEndpointSlices returns a EndpointSlices
59func newEndpointSlices(c *DiscoveryV1alpha1Client, namespace string) *endpointSlices {
60 return &endpointSlices{
61 client: c.RESTClient(),
62 ns: namespace,
63 }
64}
65
66// Get takes name of the endpointSlice, and returns the corresponding endpointSlice object, and an error if there is any.
67func (c *endpointSlices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.EndpointSlice, err error) {
68 result = &v1alpha1.EndpointSlice{}
69 err = c.client.Get().
70 Namespace(c.ns).
71 Resource("endpointslices").
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 EndpointSlices that match those selectors.
80func (c *endpointSlices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.EndpointSliceList, err error) {
81 var timeout time.Duration
82 if opts.TimeoutSeconds != nil {
83 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
84 }
85 result = &v1alpha1.EndpointSliceList{}
86 err = c.client.Get().
87 Namespace(c.ns).
88 Resource("endpointslices").
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 endpointSlices.
97func (c *endpointSlices) Watch(ctx context.Context, opts v1.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("endpointslices").
106 VersionedParams(&opts, scheme.ParameterCodec).
107 Timeout(timeout).
108 Watch(ctx)
109}
110
111// Create takes the representation of a endpointSlice and creates it. Returns the server's representation of the endpointSlice, and an error, if there is any.
112func (c *endpointSlices) Create(ctx context.Context, endpointSlice *v1alpha1.EndpointSlice, opts v1.CreateOptions) (result *v1alpha1.EndpointSlice, err error) {
113 result = &v1alpha1.EndpointSlice{}
114 err = c.client.Post().
115 Namespace(c.ns).
116 Resource("endpointslices").
117 VersionedParams(&opts, scheme.ParameterCodec).
118 Body(endpointSlice).
119 Do(ctx).
120 Into(result)
121 return
122}
123
124// Update takes the representation of a endpointSlice and updates it. Returns the server's representation of the endpointSlice, and an error, if there is any.
125func (c *endpointSlices) Update(ctx context.Context, endpointSlice *v1alpha1.EndpointSlice, opts v1.UpdateOptions) (result *v1alpha1.EndpointSlice, err error) {
126 result = &v1alpha1.EndpointSlice{}
127 err = c.client.Put().
128 Namespace(c.ns).
129 Resource("endpointslices").
130 Name(endpointSlice.Name).
131 VersionedParams(&opts, scheme.ParameterCodec).
132 Body(endpointSlice).
133 Do(ctx).
134 Into(result)
135 return
136}
137
138// Delete takes name of the endpointSlice and deletes it. Returns an error if one occurs.
139func (c *endpointSlices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
140 return c.client.Delete().
141 Namespace(c.ns).
142 Resource("endpointslices").
143 Name(name).
144 Body(&opts).
145 Do(ctx).
146 Error()
147}
148
149// DeleteCollection deletes a collection of objects.
150func (c *endpointSlices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
151 var timeout time.Duration
152 if listOpts.TimeoutSeconds != nil {
153 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
154 }
155 return c.client.Delete().
156 Namespace(c.ns).
157 Resource("endpointslices").
158 VersionedParams(&listOpts, scheme.ParameterCodec).
159 Timeout(timeout).
160 Body(&opts).
161 Do(ctx).
162 Error()
163}
164
165// Patch applies the patch and returns the patched endpointSlice.
166func (c *endpointSlices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.EndpointSlice, err error) {
167 result = &v1alpha1.EndpointSlice{}
168 err = c.client.Patch(pt).
169 Namespace(c.ns).
170 Resource("endpointslices").
171 Name(name).
172 SubResource(subresources...).
173 VersionedParams(&opts, scheme.ParameterCodec).
174 Body(data).
175 Do(ctx).
176 Into(result)
177 return
178}