1
16
17
18
19 package v1beta1
20
21 import (
22 "context"
23 json "encoding/json"
24 "fmt"
25 "time"
26
27 v1beta1 "k8s.io/api/flowcontrol/v1beta1"
28 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29 types "k8s.io/apimachinery/pkg/types"
30 watch "k8s.io/apimachinery/pkg/watch"
31 flowcontrolv1beta1 "k8s.io/client-go/applyconfigurations/flowcontrol/v1beta1"
32 scheme "k8s.io/client-go/kubernetes/scheme"
33 rest "k8s.io/client-go/rest"
34 )
35
36
37
38 type FlowSchemasGetter interface {
39 FlowSchemas() FlowSchemaInterface
40 }
41
42
43 type FlowSchemaInterface interface {
44 Create(ctx context.Context, flowSchema *v1beta1.FlowSchema, opts v1.CreateOptions) (*v1beta1.FlowSchema, error)
45 Update(ctx context.Context, flowSchema *v1beta1.FlowSchema, opts v1.UpdateOptions) (*v1beta1.FlowSchema, error)
46 UpdateStatus(ctx context.Context, flowSchema *v1beta1.FlowSchema, opts v1.UpdateOptions) (*v1beta1.FlowSchema, 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) (*v1beta1.FlowSchema, error)
50 List(ctx context.Context, opts v1.ListOptions) (*v1beta1.FlowSchemaList, 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 *v1beta1.FlowSchema, err error)
53 Apply(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.FlowSchema, err error)
54 ApplyStatus(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.FlowSchema, err error)
55 FlowSchemaExpansion
56 }
57
58
59 type flowSchemas struct {
60 client rest.Interface
61 }
62
63
64 func newFlowSchemas(c *FlowcontrolV1beta1Client) *flowSchemas {
65 return &flowSchemas{
66 client: c.RESTClient(),
67 }
68 }
69
70
71 func (c *flowSchemas) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.FlowSchema, err error) {
72 result = &v1beta1.FlowSchema{}
73 err = c.client.Get().
74 Resource("flowschemas").
75 Name(name).
76 VersionedParams(&options, scheme.ParameterCodec).
77 Do(ctx).
78 Into(result)
79 return
80 }
81
82
83 func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.FlowSchemaList, err error) {
84 var timeout time.Duration
85 if opts.TimeoutSeconds != nil {
86 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
87 }
88 result = &v1beta1.FlowSchemaList{}
89 err = c.client.Get().
90 Resource("flowschemas").
91 VersionedParams(&opts, scheme.ParameterCodec).
92 Timeout(timeout).
93 Do(ctx).
94 Into(result)
95 return
96 }
97
98
99 func (c *flowSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
100 var timeout time.Duration
101 if opts.TimeoutSeconds != nil {
102 timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
103 }
104 opts.Watch = true
105 return c.client.Get().
106 Resource("flowschemas").
107 VersionedParams(&opts, scheme.ParameterCodec).
108 Timeout(timeout).
109 Watch(ctx)
110 }
111
112
113 func (c *flowSchemas) Create(ctx context.Context, flowSchema *v1beta1.FlowSchema, opts v1.CreateOptions) (result *v1beta1.FlowSchema, err error) {
114 result = &v1beta1.FlowSchema{}
115 err = c.client.Post().
116 Resource("flowschemas").
117 VersionedParams(&opts, scheme.ParameterCodec).
118 Body(flowSchema).
119 Do(ctx).
120 Into(result)
121 return
122 }
123
124
125 func (c *flowSchemas) Update(ctx context.Context, flowSchema *v1beta1.FlowSchema, opts v1.UpdateOptions) (result *v1beta1.FlowSchema, err error) {
126 result = &v1beta1.FlowSchema{}
127 err = c.client.Put().
128 Resource("flowschemas").
129 Name(flowSchema.Name).
130 VersionedParams(&opts, scheme.ParameterCodec).
131 Body(flowSchema).
132 Do(ctx).
133 Into(result)
134 return
135 }
136
137
138
139 func (c *flowSchemas) UpdateStatus(ctx context.Context, flowSchema *v1beta1.FlowSchema, opts v1.UpdateOptions) (result *v1beta1.FlowSchema, err error) {
140 result = &v1beta1.FlowSchema{}
141 err = c.client.Put().
142 Resource("flowschemas").
143 Name(flowSchema.Name).
144 SubResource("status").
145 VersionedParams(&opts, scheme.ParameterCodec).
146 Body(flowSchema).
147 Do(ctx).
148 Into(result)
149 return
150 }
151
152
153 func (c *flowSchemas) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
154 return c.client.Delete().
155 Resource("flowschemas").
156 Name(name).
157 Body(&opts).
158 Do(ctx).
159 Error()
160 }
161
162
163 func (c *flowSchemas) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
164 var timeout time.Duration
165 if listOpts.TimeoutSeconds != nil {
166 timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
167 }
168 return c.client.Delete().
169 Resource("flowschemas").
170 VersionedParams(&listOpts, scheme.ParameterCodec).
171 Timeout(timeout).
172 Body(&opts).
173 Do(ctx).
174 Error()
175 }
176
177
178 func (c *flowSchemas) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.FlowSchema, err error) {
179 result = &v1beta1.FlowSchema{}
180 err = c.client.Patch(pt).
181 Resource("flowschemas").
182 Name(name).
183 SubResource(subresources...).
184 VersionedParams(&opts, scheme.ParameterCodec).
185 Body(data).
186 Do(ctx).
187 Into(result)
188 return
189 }
190
191
192 func (c *flowSchemas) Apply(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.FlowSchema, err error) {
193 if flowSchema == nil {
194 return nil, fmt.Errorf("flowSchema provided to Apply must not be nil")
195 }
196 patchOpts := opts.ToPatchOptions()
197 data, err := json.Marshal(flowSchema)
198 if err != nil {
199 return nil, err
200 }
201 name := flowSchema.Name
202 if name == nil {
203 return nil, fmt.Errorf("flowSchema.Name must be provided to Apply")
204 }
205 result = &v1beta1.FlowSchema{}
206 err = c.client.Patch(types.ApplyPatchType).
207 Resource("flowschemas").
208 Name(*name).
209 VersionedParams(&patchOpts, scheme.ParameterCodec).
210 Body(data).
211 Do(ctx).
212 Into(result)
213 return
214 }
215
216
217
218 func (c *flowSchemas) ApplyStatus(ctx context.Context, flowSchema *flowcontrolv1beta1.FlowSchemaApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.FlowSchema, err error) {
219 if flowSchema == nil {
220 return nil, fmt.Errorf("flowSchema provided to Apply must not be nil")
221 }
222 patchOpts := opts.ToPatchOptions()
223 data, err := json.Marshal(flowSchema)
224 if err != nil {
225 return nil, err
226 }
227
228 name := flowSchema.Name
229 if name == nil {
230 return nil, fmt.Errorf("flowSchema.Name must be provided to Apply")
231 }
232
233 result = &v1beta1.FlowSchema{}
234 err = c.client.Patch(types.ApplyPatchType).
235 Resource("flowschemas").
236 Name(*name).
237 SubResource("status").
238 VersionedParams(&patchOpts, scheme.ParameterCodec).
239 Body(data).
240 Do(ctx).
241 Into(result)
242 return
243 }
244
View as plain text