-
Notifications
You must be signed in to change notification settings - Fork 362
/
zz_conversions.go
391 lines (367 loc) · 11.8 KB
/
zz_conversions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
/*
Copyright 2021 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by ack-generate. DO NOT EDIT.
package api
import (
"github.com/aws/aws-sdk-go/aws/awserr"
svcsdk "github.com/aws/aws-sdk-go/service/apigatewayv2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
svcapitypes "github.com/crossplane/provider-aws/apis/apigatewayv2/v1alpha1"
)
// NOTE(muvaf): We return pointers in case the function needs to start with an
// empty object, hence need to return a new pointer.
// GenerateGetApiInput returns input for read
// operation.
func GenerateGetApiInput(cr *svcapitypes.API) *svcsdk.GetApiInput {
res := &svcsdk.GetApiInput{}
if cr.Status.AtProvider.APIID != nil {
res.SetApiId(*cr.Status.AtProvider.APIID)
}
return res
}
// GenerateAPI returns the current state in the form of *svcapitypes.API.
func GenerateAPI(resp *svcsdk.GetApiOutput) *svcapitypes.API {
cr := &svcapitypes.API{}
if resp.ApiEndpoint != nil {
cr.Status.AtProvider.APIEndpoint = resp.ApiEndpoint
} else {
cr.Status.AtProvider.APIEndpoint = nil
}
if resp.ApiGatewayManaged != nil {
cr.Status.AtProvider.APIGatewayManaged = resp.ApiGatewayManaged
} else {
cr.Status.AtProvider.APIGatewayManaged = nil
}
if resp.ApiId != nil {
cr.Status.AtProvider.APIID = resp.ApiId
} else {
cr.Status.AtProvider.APIID = nil
}
if resp.ApiKeySelectionExpression != nil {
cr.Spec.ForProvider.APIKeySelectionExpression = resp.ApiKeySelectionExpression
} else {
cr.Spec.ForProvider.APIKeySelectionExpression = nil
}
if resp.CorsConfiguration != nil {
f4 := &svcapitypes.CORS{}
if resp.CorsConfiguration.AllowCredentials != nil {
f4.AllowCredentials = resp.CorsConfiguration.AllowCredentials
}
if resp.CorsConfiguration.AllowHeaders != nil {
f4f1 := []*string{}
for _, f4f1iter := range resp.CorsConfiguration.AllowHeaders {
var f4f1elem string
f4f1elem = *f4f1iter
f4f1 = append(f4f1, &f4f1elem)
}
f4.AllowHeaders = f4f1
}
if resp.CorsConfiguration.AllowMethods != nil {
f4f2 := []*string{}
for _, f4f2iter := range resp.CorsConfiguration.AllowMethods {
var f4f2elem string
f4f2elem = *f4f2iter
f4f2 = append(f4f2, &f4f2elem)
}
f4.AllowMethods = f4f2
}
if resp.CorsConfiguration.AllowOrigins != nil {
f4f3 := []*string{}
for _, f4f3iter := range resp.CorsConfiguration.AllowOrigins {
var f4f3elem string
f4f3elem = *f4f3iter
f4f3 = append(f4f3, &f4f3elem)
}
f4.AllowOrigins = f4f3
}
if resp.CorsConfiguration.ExposeHeaders != nil {
f4f4 := []*string{}
for _, f4f4iter := range resp.CorsConfiguration.ExposeHeaders {
var f4f4elem string
f4f4elem = *f4f4iter
f4f4 = append(f4f4, &f4f4elem)
}
f4.ExposeHeaders = f4f4
}
if resp.CorsConfiguration.MaxAge != nil {
f4.MaxAge = resp.CorsConfiguration.MaxAge
}
cr.Spec.ForProvider.CORSConfiguration = f4
} else {
cr.Spec.ForProvider.CORSConfiguration = nil
}
if resp.CreatedDate != nil {
cr.Status.AtProvider.CreatedDate = &metav1.Time{*resp.CreatedDate}
} else {
cr.Status.AtProvider.CreatedDate = nil
}
if resp.Description != nil {
cr.Spec.ForProvider.Description = resp.Description
} else {
cr.Spec.ForProvider.Description = nil
}
if resp.DisableExecuteApiEndpoint != nil {
cr.Spec.ForProvider.DisableExecuteAPIEndpoint = resp.DisableExecuteApiEndpoint
} else {
cr.Spec.ForProvider.DisableExecuteAPIEndpoint = nil
}
if resp.DisableSchemaValidation != nil {
cr.Spec.ForProvider.DisableSchemaValidation = resp.DisableSchemaValidation
} else {
cr.Spec.ForProvider.DisableSchemaValidation = nil
}
if resp.ImportInfo != nil {
f9 := []*string{}
for _, f9iter := range resp.ImportInfo {
var f9elem string
f9elem = *f9iter
f9 = append(f9, &f9elem)
}
cr.Status.AtProvider.ImportInfo = f9
} else {
cr.Status.AtProvider.ImportInfo = nil
}
if resp.Name != nil {
cr.Spec.ForProvider.Name = resp.Name
} else {
cr.Spec.ForProvider.Name = nil
}
if resp.ProtocolType != nil {
cr.Spec.ForProvider.ProtocolType = resp.ProtocolType
} else {
cr.Spec.ForProvider.ProtocolType = nil
}
if resp.RouteSelectionExpression != nil {
cr.Spec.ForProvider.RouteSelectionExpression = resp.RouteSelectionExpression
} else {
cr.Spec.ForProvider.RouteSelectionExpression = nil
}
if resp.Tags != nil {
f13 := map[string]*string{}
for f13key, f13valiter := range resp.Tags {
var f13val string
f13val = *f13valiter
f13[f13key] = &f13val
}
cr.Spec.ForProvider.Tags = f13
} else {
cr.Spec.ForProvider.Tags = nil
}
if resp.Version != nil {
cr.Spec.ForProvider.Version = resp.Version
} else {
cr.Spec.ForProvider.Version = nil
}
if resp.Warnings != nil {
f15 := []*string{}
for _, f15iter := range resp.Warnings {
var f15elem string
f15elem = *f15iter
f15 = append(f15, &f15elem)
}
cr.Status.AtProvider.Warnings = f15
} else {
cr.Status.AtProvider.Warnings = nil
}
return cr
}
// GenerateCreateApiInput returns a create input.
func GenerateCreateApiInput(cr *svcapitypes.API) *svcsdk.CreateApiInput {
res := &svcsdk.CreateApiInput{}
if cr.Spec.ForProvider.APIKeySelectionExpression != nil {
res.SetApiKeySelectionExpression(*cr.Spec.ForProvider.APIKeySelectionExpression)
}
if cr.Spec.ForProvider.CORSConfiguration != nil {
f1 := &svcsdk.Cors{}
if cr.Spec.ForProvider.CORSConfiguration.AllowCredentials != nil {
f1.SetAllowCredentials(*cr.Spec.ForProvider.CORSConfiguration.AllowCredentials)
}
if cr.Spec.ForProvider.CORSConfiguration.AllowHeaders != nil {
f1f1 := []*string{}
for _, f1f1iter := range cr.Spec.ForProvider.CORSConfiguration.AllowHeaders {
var f1f1elem string
f1f1elem = *f1f1iter
f1f1 = append(f1f1, &f1f1elem)
}
f1.SetAllowHeaders(f1f1)
}
if cr.Spec.ForProvider.CORSConfiguration.AllowMethods != nil {
f1f2 := []*string{}
for _, f1f2iter := range cr.Spec.ForProvider.CORSConfiguration.AllowMethods {
var f1f2elem string
f1f2elem = *f1f2iter
f1f2 = append(f1f2, &f1f2elem)
}
f1.SetAllowMethods(f1f2)
}
if cr.Spec.ForProvider.CORSConfiguration.AllowOrigins != nil {
f1f3 := []*string{}
for _, f1f3iter := range cr.Spec.ForProvider.CORSConfiguration.AllowOrigins {
var f1f3elem string
f1f3elem = *f1f3iter
f1f3 = append(f1f3, &f1f3elem)
}
f1.SetAllowOrigins(f1f3)
}
if cr.Spec.ForProvider.CORSConfiguration.ExposeHeaders != nil {
f1f4 := []*string{}
for _, f1f4iter := range cr.Spec.ForProvider.CORSConfiguration.ExposeHeaders {
var f1f4elem string
f1f4elem = *f1f4iter
f1f4 = append(f1f4, &f1f4elem)
}
f1.SetExposeHeaders(f1f4)
}
if cr.Spec.ForProvider.CORSConfiguration.MaxAge != nil {
f1.SetMaxAge(*cr.Spec.ForProvider.CORSConfiguration.MaxAge)
}
res.SetCorsConfiguration(f1)
}
if cr.Spec.ForProvider.CredentialsARN != nil {
res.SetCredentialsArn(*cr.Spec.ForProvider.CredentialsARN)
}
if cr.Spec.ForProvider.Description != nil {
res.SetDescription(*cr.Spec.ForProvider.Description)
}
if cr.Spec.ForProvider.DisableExecuteAPIEndpoint != nil {
res.SetDisableExecuteApiEndpoint(*cr.Spec.ForProvider.DisableExecuteAPIEndpoint)
}
if cr.Spec.ForProvider.DisableSchemaValidation != nil {
res.SetDisableSchemaValidation(*cr.Spec.ForProvider.DisableSchemaValidation)
}
if cr.Spec.ForProvider.Name != nil {
res.SetName(*cr.Spec.ForProvider.Name)
}
if cr.Spec.ForProvider.ProtocolType != nil {
res.SetProtocolType(*cr.Spec.ForProvider.ProtocolType)
}
if cr.Spec.ForProvider.RouteKey != nil {
res.SetRouteKey(*cr.Spec.ForProvider.RouteKey)
}
if cr.Spec.ForProvider.RouteSelectionExpression != nil {
res.SetRouteSelectionExpression(*cr.Spec.ForProvider.RouteSelectionExpression)
}
if cr.Spec.ForProvider.Tags != nil {
f10 := map[string]*string{}
for f10key, f10valiter := range cr.Spec.ForProvider.Tags {
var f10val string
f10val = *f10valiter
f10[f10key] = &f10val
}
res.SetTags(f10)
}
if cr.Spec.ForProvider.Target != nil {
res.SetTarget(*cr.Spec.ForProvider.Target)
}
if cr.Spec.ForProvider.Version != nil {
res.SetVersion(*cr.Spec.ForProvider.Version)
}
return res
}
// GenerateUpdateApiInput returns an update input.
func GenerateUpdateApiInput(cr *svcapitypes.API) *svcsdk.UpdateApiInput {
res := &svcsdk.UpdateApiInput{}
if cr.Status.AtProvider.APIID != nil {
res.SetApiId(*cr.Status.AtProvider.APIID)
}
if cr.Spec.ForProvider.APIKeySelectionExpression != nil {
res.SetApiKeySelectionExpression(*cr.Spec.ForProvider.APIKeySelectionExpression)
}
if cr.Spec.ForProvider.CORSConfiguration != nil {
f2 := &svcsdk.Cors{}
if cr.Spec.ForProvider.CORSConfiguration.AllowCredentials != nil {
f2.SetAllowCredentials(*cr.Spec.ForProvider.CORSConfiguration.AllowCredentials)
}
if cr.Spec.ForProvider.CORSConfiguration.AllowHeaders != nil {
f2f1 := []*string{}
for _, f2f1iter := range cr.Spec.ForProvider.CORSConfiguration.AllowHeaders {
var f2f1elem string
f2f1elem = *f2f1iter
f2f1 = append(f2f1, &f2f1elem)
}
f2.SetAllowHeaders(f2f1)
}
if cr.Spec.ForProvider.CORSConfiguration.AllowMethods != nil {
f2f2 := []*string{}
for _, f2f2iter := range cr.Spec.ForProvider.CORSConfiguration.AllowMethods {
var f2f2elem string
f2f2elem = *f2f2iter
f2f2 = append(f2f2, &f2f2elem)
}
f2.SetAllowMethods(f2f2)
}
if cr.Spec.ForProvider.CORSConfiguration.AllowOrigins != nil {
f2f3 := []*string{}
for _, f2f3iter := range cr.Spec.ForProvider.CORSConfiguration.AllowOrigins {
var f2f3elem string
f2f3elem = *f2f3iter
f2f3 = append(f2f3, &f2f3elem)
}
f2.SetAllowOrigins(f2f3)
}
if cr.Spec.ForProvider.CORSConfiguration.ExposeHeaders != nil {
f2f4 := []*string{}
for _, f2f4iter := range cr.Spec.ForProvider.CORSConfiguration.ExposeHeaders {
var f2f4elem string
f2f4elem = *f2f4iter
f2f4 = append(f2f4, &f2f4elem)
}
f2.SetExposeHeaders(f2f4)
}
if cr.Spec.ForProvider.CORSConfiguration.MaxAge != nil {
f2.SetMaxAge(*cr.Spec.ForProvider.CORSConfiguration.MaxAge)
}
res.SetCorsConfiguration(f2)
}
if cr.Spec.ForProvider.CredentialsARN != nil {
res.SetCredentialsArn(*cr.Spec.ForProvider.CredentialsARN)
}
if cr.Spec.ForProvider.Description != nil {
res.SetDescription(*cr.Spec.ForProvider.Description)
}
if cr.Spec.ForProvider.DisableExecuteAPIEndpoint != nil {
res.SetDisableExecuteApiEndpoint(*cr.Spec.ForProvider.DisableExecuteAPIEndpoint)
}
if cr.Spec.ForProvider.DisableSchemaValidation != nil {
res.SetDisableSchemaValidation(*cr.Spec.ForProvider.DisableSchemaValidation)
}
if cr.Spec.ForProvider.Name != nil {
res.SetName(*cr.Spec.ForProvider.Name)
}
if cr.Spec.ForProvider.RouteKey != nil {
res.SetRouteKey(*cr.Spec.ForProvider.RouteKey)
}
if cr.Spec.ForProvider.RouteSelectionExpression != nil {
res.SetRouteSelectionExpression(*cr.Spec.ForProvider.RouteSelectionExpression)
}
if cr.Spec.ForProvider.Target != nil {
res.SetTarget(*cr.Spec.ForProvider.Target)
}
if cr.Spec.ForProvider.Version != nil {
res.SetVersion(*cr.Spec.ForProvider.Version)
}
return res
}
// GenerateDeleteApiInput returns a deletion input.
func GenerateDeleteApiInput(cr *svcapitypes.API) *svcsdk.DeleteApiInput {
res := &svcsdk.DeleteApiInput{}
if cr.Status.AtProvider.APIID != nil {
res.SetApiId(*cr.Status.AtProvider.APIID)
}
return res
}
// IsNotFound returns whether the given error is of type NotFound or not.
func IsNotFound(err error) bool {
awsErr, ok := err.(awserr.Error)
return ok && awsErr.Code() == "NotFoundException"
}