/
api_types_gen.go
4200 lines (3514 loc) · 150 KB
/
api_types_gen.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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package v1api20230501preview
import (
"fmt"
v20230501ps "github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20230501preview/storage"
"github.com/Azure/azure-service-operator/v2/internal/reflecthelpers"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/conditions"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/conversion"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="Severity",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].severity"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].reason"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].message"
// Generator information:
// - Generated from: /apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-05-01-preview/apimapis.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}
type Api struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec Service_Api_Spec `json:"spec,omitempty"`
Status Service_Api_STATUS `json:"status,omitempty"`
}
var _ conditions.Conditioner = &Api{}
// GetConditions returns the conditions of the resource
func (api *Api) GetConditions() conditions.Conditions {
return api.Status.Conditions
}
// SetConditions sets the conditions on the resource status
func (api *Api) SetConditions(conditions conditions.Conditions) { api.Status.Conditions = conditions }
var _ conversion.Convertible = &Api{}
// ConvertFrom populates our Api from the provided hub Api
func (api *Api) ConvertFrom(hub conversion.Hub) error {
// intermediate variable for conversion
var source v20230501ps.Api
err := source.ConvertFrom(hub)
if err != nil {
return errors.Wrap(err, "converting from hub to source")
}
err = api.AssignProperties_From_Api(&source)
if err != nil {
return errors.Wrap(err, "converting from source to api")
}
return nil
}
// ConvertTo populates the provided hub Api from our Api
func (api *Api) ConvertTo(hub conversion.Hub) error {
// intermediate variable for conversion
var destination v20230501ps.Api
err := api.AssignProperties_To_Api(&destination)
if err != nil {
return errors.Wrap(err, "converting to destination from api")
}
err = destination.ConvertTo(hub)
if err != nil {
return errors.Wrap(err, "converting from destination to hub")
}
return nil
}
// +kubebuilder:webhook:path=/mutate-apimanagement-azure-com-v1api20230501preview-api,mutating=true,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=apimanagement.azure.com,resources=apis,verbs=create;update,versions=v1api20230501preview,name=default.v1api20230501preview.apis.apimanagement.azure.com,admissionReviewVersions=v1
var _ admission.Defaulter = &Api{}
// Default applies defaults to the Api resource
func (api *Api) Default() {
api.defaultImpl()
var temp any = api
if runtimeDefaulter, ok := temp.(genruntime.Defaulter); ok {
runtimeDefaulter.CustomDefault()
}
}
// defaultAzureName defaults the Azure name of the resource to the Kubernetes name
func (api *Api) defaultAzureName() {
if api.Spec.AzureName == "" {
api.Spec.AzureName = api.Name
}
}
// defaultImpl applies the code generated defaults to the Api resource
func (api *Api) defaultImpl() { api.defaultAzureName() }
var _ genruntime.KubernetesResource = &Api{}
// AzureName returns the Azure name of the resource
func (api *Api) AzureName() string {
return api.Spec.AzureName
}
// GetAPIVersion returns the ARM API version of the resource. This is always "2023-05-01-preview"
func (api Api) GetAPIVersion() string {
return string(APIVersion_Value)
}
// GetResourceScope returns the scope of the resource
func (api *Api) GetResourceScope() genruntime.ResourceScope {
return genruntime.ResourceScopeResourceGroup
}
// GetSpec returns the specification of this resource
func (api *Api) GetSpec() genruntime.ConvertibleSpec {
return &api.Spec
}
// GetStatus returns the status of this resource
func (api *Api) GetStatus() genruntime.ConvertibleStatus {
return &api.Status
}
// GetSupportedOperations returns the operations supported by the resource
func (api *Api) GetSupportedOperations() []genruntime.ResourceOperation {
return []genruntime.ResourceOperation{
genruntime.ResourceOperationDelete,
genruntime.ResourceOperationGet,
genruntime.ResourceOperationHead,
genruntime.ResourceOperationPut,
}
}
// GetType returns the ARM Type of the resource. This is always "Microsoft.ApiManagement/service/apis"
func (api *Api) GetType() string {
return "Microsoft.ApiManagement/service/apis"
}
// NewEmptyStatus returns a new empty (blank) status
func (api *Api) NewEmptyStatus() genruntime.ConvertibleStatus {
return &Service_Api_STATUS{}
}
// Owner returns the ResourceReference of the owner
func (api *Api) Owner() *genruntime.ResourceReference {
group, kind := genruntime.LookupOwnerGroupKind(api.Spec)
return api.Spec.Owner.AsResourceReference(group, kind)
}
// SetStatus sets the status of this resource
func (api *Api) SetStatus(status genruntime.ConvertibleStatus) error {
// If we have exactly the right type of status, assign it
if st, ok := status.(*Service_Api_STATUS); ok {
api.Status = *st
return nil
}
// Convert status to required version
var st Service_Api_STATUS
err := status.ConvertStatusTo(&st)
if err != nil {
return errors.Wrap(err, "failed to convert status")
}
api.Status = st
return nil
}
// +kubebuilder:webhook:path=/validate-apimanagement-azure-com-v1api20230501preview-api,mutating=false,sideEffects=None,matchPolicy=Exact,failurePolicy=fail,groups=apimanagement.azure.com,resources=apis,verbs=create;update,versions=v1api20230501preview,name=validate.v1api20230501preview.apis.apimanagement.azure.com,admissionReviewVersions=v1
var _ admission.Validator = &Api{}
// ValidateCreate validates the creation of the resource
func (api *Api) ValidateCreate() (admission.Warnings, error) {
validations := api.createValidations()
var temp any = api
if runtimeValidator, ok := temp.(genruntime.Validator); ok {
validations = append(validations, runtimeValidator.CreateValidations()...)
}
return genruntime.ValidateCreate(validations)
}
// ValidateDelete validates the deletion of the resource
func (api *Api) ValidateDelete() (admission.Warnings, error) {
validations := api.deleteValidations()
var temp any = api
if runtimeValidator, ok := temp.(genruntime.Validator); ok {
validations = append(validations, runtimeValidator.DeleteValidations()...)
}
return genruntime.ValidateDelete(validations)
}
// ValidateUpdate validates an update of the resource
func (api *Api) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
validations := api.updateValidations()
var temp any = api
if runtimeValidator, ok := temp.(genruntime.Validator); ok {
validations = append(validations, runtimeValidator.UpdateValidations()...)
}
return genruntime.ValidateUpdate(old, validations)
}
// createValidations validates the creation of the resource
func (api *Api) createValidations() []func() (admission.Warnings, error) {
return []func() (admission.Warnings, error){api.validateResourceReferences, api.validateOwnerReference}
}
// deleteValidations validates the deletion of the resource
func (api *Api) deleteValidations() []func() (admission.Warnings, error) {
return nil
}
// updateValidations validates the update of the resource
func (api *Api) updateValidations() []func(old runtime.Object) (admission.Warnings, error) {
return []func(old runtime.Object) (admission.Warnings, error){
func(old runtime.Object) (admission.Warnings, error) {
return api.validateResourceReferences()
},
api.validateWriteOnceProperties,
func(old runtime.Object) (admission.Warnings, error) {
return api.validateOwnerReference()
},
}
}
// validateOwnerReference validates the owner field
func (api *Api) validateOwnerReference() (admission.Warnings, error) {
return genruntime.ValidateOwner(api)
}
// validateResourceReferences validates all resource references
func (api *Api) validateResourceReferences() (admission.Warnings, error) {
refs, err := reflecthelpers.FindResourceReferences(&api.Spec)
if err != nil {
return nil, err
}
return genruntime.ValidateResourceReferences(refs)
}
// validateWriteOnceProperties validates all WriteOnce properties
func (api *Api) validateWriteOnceProperties(old runtime.Object) (admission.Warnings, error) {
oldObj, ok := old.(*Api)
if !ok {
return nil, nil
}
return genruntime.ValidateWriteOnceProperties(oldObj, api)
}
// AssignProperties_From_Api populates our Api from the provided source Api
func (api *Api) AssignProperties_From_Api(source *v20230501ps.Api) error {
// ObjectMeta
api.ObjectMeta = *source.ObjectMeta.DeepCopy()
// Spec
var spec Service_Api_Spec
err := spec.AssignProperties_From_Service_Api_Spec(&source.Spec)
if err != nil {
return errors.Wrap(err, "calling AssignProperties_From_Service_Api_Spec() to populate field Spec")
}
api.Spec = spec
// Status
var status Service_Api_STATUS
err = status.AssignProperties_From_Service_Api_STATUS(&source.Status)
if err != nil {
return errors.Wrap(err, "calling AssignProperties_From_Service_Api_STATUS() to populate field Status")
}
api.Status = status
// No error
return nil
}
// AssignProperties_To_Api populates the provided destination Api from our Api
func (api *Api) AssignProperties_To_Api(destination *v20230501ps.Api) error {
// ObjectMeta
destination.ObjectMeta = *api.ObjectMeta.DeepCopy()
// Spec
var spec v20230501ps.Service_Api_Spec
err := api.Spec.AssignProperties_To_Service_Api_Spec(&spec)
if err != nil {
return errors.Wrap(err, "calling AssignProperties_To_Service_Api_Spec() to populate field Spec")
}
destination.Spec = spec
// Status
var status v20230501ps.Service_Api_STATUS
err = api.Status.AssignProperties_To_Service_Api_STATUS(&status)
if err != nil {
return errors.Wrap(err, "calling AssignProperties_To_Service_Api_STATUS() to populate field Status")
}
destination.Status = status
// No error
return nil
}
// OriginalGVK returns a GroupValueKind for the original API version used to create the resource
func (api *Api) OriginalGVK() *schema.GroupVersionKind {
return &schema.GroupVersionKind{
Group: GroupVersion.Group,
Version: api.Spec.OriginalVersion(),
Kind: "Api",
}
}
// +kubebuilder:object:root=true
// Generator information:
// - Generated from: /apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-05-01-preview/apimapis.json
// - ARM URI: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}
type ApiList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Api `json:"items"`
}
// +kubebuilder:validation:Enum={"2023-05-01-preview"}
type APIVersion string
const APIVersion_Value = APIVersion("2023-05-01-preview")
type Service_Api_Spec struct {
// +kubebuilder:validation:MaxLength=100
// APIVersion: Indicates the version identifier of the API if the API is versioned
APIVersion *string `json:"apiVersion,omitempty"`
// +kubebuilder:validation:MaxLength=100
// +kubebuilder:validation:MinLength=1
// ApiRevision: Describes the revision of the API. If no value is provided, default revision 1 is created
ApiRevision *string `json:"apiRevision,omitempty"`
// +kubebuilder:validation:MaxLength=256
// ApiRevisionDescription: Description of the API Revision.
ApiRevisionDescription *string `json:"apiRevisionDescription,omitempty"`
// ApiType: Type of API to create.
// * `http` creates a REST API
// * `soap` creates a SOAP pass-through API
// * `websocket` creates websocket API
// * `graphql` creates GraphQL API.
// New types can be added in the future.
ApiType *ApiCreateOrUpdateProperties_ApiType `json:"apiType,omitempty"`
// +kubebuilder:validation:MaxLength=256
// ApiVersionDescription: Description of the API Version.
ApiVersionDescription *string `json:"apiVersionDescription,omitempty"`
// ApiVersionSet: Version set details
ApiVersionSet *ApiVersionSetContractDetails `json:"apiVersionSet,omitempty"`
// ApiVersionSetReference: A resource identifier for the related ApiVersionSet.
ApiVersionSetReference *genruntime.ResourceReference `armReference:"ApiVersionSetId" json:"apiVersionSetReference,omitempty"`
// AuthenticationSettings: Collection of authentication settings included into this API.
AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"`
// +kubebuilder:validation:MaxLength=256
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern="^[^*#&+:<>?]+$"
// AzureName: The name of the resource in Azure. This is often the same as the name of the resource in Kubernetes but it
// doesn't have to be.
AzureName string `json:"azureName,omitempty"`
// Contact: Contact information for the API.
Contact *ApiContactInformation `json:"contact,omitempty"`
// Description: Description of the API. May include HTML formatting tags.
Description *string `json:"description,omitempty"`
// +kubebuilder:validation:MaxLength=300
// +kubebuilder:validation:MinLength=1
// DisplayName: API name. Must be 1 to 300 characters long.
DisplayName *string `json:"displayName,omitempty"`
// Format: Format of the Content in which the API is getting imported. New formats can be added in the future
Format *ApiCreateOrUpdateProperties_Format `json:"format,omitempty"`
// IsCurrent: Indicates if API revision is current api revision.
IsCurrent *bool `json:"isCurrent,omitempty"`
// License: License information for the API.
License *ApiLicenseInformation `json:"license,omitempty"`
// +kubebuilder:validation:Required
// Owner: The owner of the resource. The owner controls where the resource goes when it is deployed. The owner also
// controls the resources lifecycle. When the owner is deleted the resource will also be deleted. Owner is expected to be a
// reference to a apimanagement.azure.com/Service resource
Owner *genruntime.KnownResourceReference `group:"apimanagement.azure.com" json:"owner,omitempty" kind:"Service"`
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=400
// +kubebuilder:validation:MinLength=0
// Path: Relative URL uniquely identifying this API and all of its resource paths within the API Management service
// instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public
// URL for this API.
Path *string `json:"path,omitempty"`
// Protocols: Describes on which protocols the operations in this API can be invoked.
Protocols []ApiCreateOrUpdateProperties_Protocols `json:"protocols,omitempty"`
// +kubebuilder:validation:MaxLength=2000
// +kubebuilder:validation:MinLength=0
// ServiceUrl: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long.
ServiceUrl *string `json:"serviceUrl,omitempty"`
// SourceApiReference: API identifier of the source API.
SourceApiReference *genruntime.ResourceReference `armReference:"SourceApiId" json:"sourceApiReference,omitempty"`
// SubscriptionKeyParameterNames: Protocols over which API is made available.
SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"`
// SubscriptionRequired: Specifies whether an API or Product subscription is required for accessing the API.
SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"`
// TermsOfServiceUrl: A URL to the Terms of Service for the API. MUST be in the format of a URL.
TermsOfServiceUrl *string `json:"termsOfServiceUrl,omitempty"`
// TranslateRequiredQueryParameters: Strategy of translating required query parameters to template ones. By default has
// value 'template'. Possible values: 'template', 'query'
TranslateRequiredQueryParameters *ApiCreateOrUpdateProperties_TranslateRequiredQueryParameters `json:"translateRequiredQueryParameters,omitempty"`
// Type: Type of API.
Type *ApiCreateOrUpdateProperties_Type `json:"type,omitempty"`
// Value: Content value when Importing an API.
Value *string `json:"value,omitempty"`
// WsdlSelector: Criteria to limit import of WSDL to a subset of the document.
WsdlSelector *ApiCreateOrUpdateProperties_WsdlSelector `json:"wsdlSelector,omitempty"`
}
var _ genruntime.ARMTransformer = &Service_Api_Spec{}
// ConvertToARM converts from a Kubernetes CRD object to an ARM object
func (serviceApi *Service_Api_Spec) ConvertToARM(resolved genruntime.ConvertToARMResolvedDetails) (interface{}, error) {
if serviceApi == nil {
return nil, nil
}
result := &Service_Api_Spec_ARM{}
// Set property "Name":
result.Name = resolved.Name
// Set property "Properties":
if serviceApi.APIVersion != nil ||
serviceApi.ApiRevision != nil ||
serviceApi.ApiRevisionDescription != nil ||
serviceApi.ApiType != nil ||
serviceApi.ApiVersionDescription != nil ||
serviceApi.ApiVersionSet != nil ||
serviceApi.ApiVersionSetReference != nil ||
serviceApi.AuthenticationSettings != nil ||
serviceApi.Contact != nil ||
serviceApi.Description != nil ||
serviceApi.DisplayName != nil ||
serviceApi.Format != nil ||
serviceApi.IsCurrent != nil ||
serviceApi.License != nil ||
serviceApi.Path != nil ||
serviceApi.Protocols != nil ||
serviceApi.ServiceUrl != nil ||
serviceApi.SourceApiReference != nil ||
serviceApi.SubscriptionKeyParameterNames != nil ||
serviceApi.SubscriptionRequired != nil ||
serviceApi.TermsOfServiceUrl != nil ||
serviceApi.TranslateRequiredQueryParameters != nil ||
serviceApi.Type != nil ||
serviceApi.Value != nil ||
serviceApi.WsdlSelector != nil {
result.Properties = &ApiCreateOrUpdateProperties_ARM{}
}
if serviceApi.APIVersion != nil {
apiVersion := *serviceApi.APIVersion
result.Properties.APIVersion = &apiVersion
}
if serviceApi.ApiRevision != nil {
apiRevision := *serviceApi.ApiRevision
result.Properties.ApiRevision = &apiRevision
}
if serviceApi.ApiRevisionDescription != nil {
apiRevisionDescription := *serviceApi.ApiRevisionDescription
result.Properties.ApiRevisionDescription = &apiRevisionDescription
}
if serviceApi.ApiType != nil {
apiType := *serviceApi.ApiType
result.Properties.ApiType = &apiType
}
if serviceApi.ApiVersionDescription != nil {
apiVersionDescription := *serviceApi.ApiVersionDescription
result.Properties.ApiVersionDescription = &apiVersionDescription
}
if serviceApi.ApiVersionSet != nil {
apiVersionSet_ARM, err := (*serviceApi.ApiVersionSet).ConvertToARM(resolved)
if err != nil {
return nil, err
}
apiVersionSet := *apiVersionSet_ARM.(*ApiVersionSetContractDetails_ARM)
result.Properties.ApiVersionSet = &apiVersionSet
}
if serviceApi.ApiVersionSetReference != nil {
apiVersionSetIdARMID, err := resolved.ResolvedReferences.Lookup(*serviceApi.ApiVersionSetReference)
if err != nil {
return nil, err
}
apiVersionSetId := apiVersionSetIdARMID
result.Properties.ApiVersionSetId = &apiVersionSetId
}
if serviceApi.AuthenticationSettings != nil {
authenticationSettings_ARM, err := (*serviceApi.AuthenticationSettings).ConvertToARM(resolved)
if err != nil {
return nil, err
}
authenticationSettings := *authenticationSettings_ARM.(*AuthenticationSettingsContract_ARM)
result.Properties.AuthenticationSettings = &authenticationSettings
}
if serviceApi.Contact != nil {
contact_ARM, err := (*serviceApi.Contact).ConvertToARM(resolved)
if err != nil {
return nil, err
}
contact := *contact_ARM.(*ApiContactInformation_ARM)
result.Properties.Contact = &contact
}
if serviceApi.Description != nil {
description := *serviceApi.Description
result.Properties.Description = &description
}
if serviceApi.DisplayName != nil {
displayName := *serviceApi.DisplayName
result.Properties.DisplayName = &displayName
}
if serviceApi.Format != nil {
format := *serviceApi.Format
result.Properties.Format = &format
}
if serviceApi.IsCurrent != nil {
isCurrent := *serviceApi.IsCurrent
result.Properties.IsCurrent = &isCurrent
}
if serviceApi.License != nil {
license_ARM, err := (*serviceApi.License).ConvertToARM(resolved)
if err != nil {
return nil, err
}
license := *license_ARM.(*ApiLicenseInformation_ARM)
result.Properties.License = &license
}
if serviceApi.Path != nil {
path := *serviceApi.Path
result.Properties.Path = &path
}
for _, item := range serviceApi.Protocols {
result.Properties.Protocols = append(result.Properties.Protocols, item)
}
if serviceApi.ServiceUrl != nil {
serviceUrl := *serviceApi.ServiceUrl
result.Properties.ServiceUrl = &serviceUrl
}
if serviceApi.SourceApiReference != nil {
sourceApiIdARMID, err := resolved.ResolvedReferences.Lookup(*serviceApi.SourceApiReference)
if err != nil {
return nil, err
}
sourceApiId := sourceApiIdARMID
result.Properties.SourceApiId = &sourceApiId
}
if serviceApi.SubscriptionKeyParameterNames != nil {
subscriptionKeyParameterNames_ARM, err := (*serviceApi.SubscriptionKeyParameterNames).ConvertToARM(resolved)
if err != nil {
return nil, err
}
subscriptionKeyParameterNames := *subscriptionKeyParameterNames_ARM.(*SubscriptionKeyParameterNamesContract_ARM)
result.Properties.SubscriptionKeyParameterNames = &subscriptionKeyParameterNames
}
if serviceApi.SubscriptionRequired != nil {
subscriptionRequired := *serviceApi.SubscriptionRequired
result.Properties.SubscriptionRequired = &subscriptionRequired
}
if serviceApi.TermsOfServiceUrl != nil {
termsOfServiceUrl := *serviceApi.TermsOfServiceUrl
result.Properties.TermsOfServiceUrl = &termsOfServiceUrl
}
if serviceApi.TranslateRequiredQueryParameters != nil {
translateRequiredQueryParameters := *serviceApi.TranslateRequiredQueryParameters
result.Properties.TranslateRequiredQueryParameters = &translateRequiredQueryParameters
}
if serviceApi.Type != nil {
typeVar := *serviceApi.Type
result.Properties.Type = &typeVar
}
if serviceApi.Value != nil {
value := *serviceApi.Value
result.Properties.Value = &value
}
if serviceApi.WsdlSelector != nil {
wsdlSelector_ARM, err := (*serviceApi.WsdlSelector).ConvertToARM(resolved)
if err != nil {
return nil, err
}
wsdlSelector := *wsdlSelector_ARM.(*ApiCreateOrUpdateProperties_WsdlSelector_ARM)
result.Properties.WsdlSelector = &wsdlSelector
}
return result, nil
}
// NewEmptyARMValue returns an empty ARM value suitable for deserializing into
func (serviceApi *Service_Api_Spec) NewEmptyARMValue() genruntime.ARMResourceStatus {
return &Service_Api_Spec_ARM{}
}
// PopulateFromARM populates a Kubernetes CRD object from an Azure ARM object
func (serviceApi *Service_Api_Spec) PopulateFromARM(owner genruntime.ArbitraryOwnerReference, armInput interface{}) error {
typedInput, ok := armInput.(Service_Api_Spec_ARM)
if !ok {
return fmt.Errorf("unexpected type supplied for PopulateFromARM() function. Expected Service_Api_Spec_ARM, got %T", armInput)
}
// Set property "APIVersion":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.APIVersion != nil {
apiVersion := *typedInput.Properties.APIVersion
serviceApi.APIVersion = &apiVersion
}
}
// Set property "ApiRevision":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.ApiRevision != nil {
apiRevision := *typedInput.Properties.ApiRevision
serviceApi.ApiRevision = &apiRevision
}
}
// Set property "ApiRevisionDescription":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.ApiRevisionDescription != nil {
apiRevisionDescription := *typedInput.Properties.ApiRevisionDescription
serviceApi.ApiRevisionDescription = &apiRevisionDescription
}
}
// Set property "ApiType":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.ApiType != nil {
apiType := *typedInput.Properties.ApiType
serviceApi.ApiType = &apiType
}
}
// Set property "ApiVersionDescription":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.ApiVersionDescription != nil {
apiVersionDescription := *typedInput.Properties.ApiVersionDescription
serviceApi.ApiVersionDescription = &apiVersionDescription
}
}
// Set property "ApiVersionSet":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.ApiVersionSet != nil {
var apiVersionSet1 ApiVersionSetContractDetails
err := apiVersionSet1.PopulateFromARM(owner, *typedInput.Properties.ApiVersionSet)
if err != nil {
return err
}
apiVersionSet := apiVersionSet1
serviceApi.ApiVersionSet = &apiVersionSet
}
}
// no assignment for property "ApiVersionSetReference"
// Set property "AuthenticationSettings":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.AuthenticationSettings != nil {
var authenticationSettings1 AuthenticationSettingsContract
err := authenticationSettings1.PopulateFromARM(owner, *typedInput.Properties.AuthenticationSettings)
if err != nil {
return err
}
authenticationSettings := authenticationSettings1
serviceApi.AuthenticationSettings = &authenticationSettings
}
}
// Set property "AzureName":
serviceApi.SetAzureName(genruntime.ExtractKubernetesResourceNameFromARMName(typedInput.Name))
// Set property "Contact":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.Contact != nil {
var contact1 ApiContactInformation
err := contact1.PopulateFromARM(owner, *typedInput.Properties.Contact)
if err != nil {
return err
}
contact := contact1
serviceApi.Contact = &contact
}
}
// Set property "Description":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.Description != nil {
description := *typedInput.Properties.Description
serviceApi.Description = &description
}
}
// Set property "DisplayName":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.DisplayName != nil {
displayName := *typedInput.Properties.DisplayName
serviceApi.DisplayName = &displayName
}
}
// Set property "Format":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.Format != nil {
format := *typedInput.Properties.Format
serviceApi.Format = &format
}
}
// Set property "IsCurrent":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.IsCurrent != nil {
isCurrent := *typedInput.Properties.IsCurrent
serviceApi.IsCurrent = &isCurrent
}
}
// Set property "License":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.License != nil {
var license1 ApiLicenseInformation
err := license1.PopulateFromARM(owner, *typedInput.Properties.License)
if err != nil {
return err
}
license := license1
serviceApi.License = &license
}
}
// Set property "Owner":
serviceApi.Owner = &genruntime.KnownResourceReference{
Name: owner.Name,
ARMID: owner.ARMID,
}
// Set property "Path":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.Path != nil {
path := *typedInput.Properties.Path
serviceApi.Path = &path
}
}
// Set property "Protocols":
// copying flattened property:
if typedInput.Properties != nil {
for _, item := range typedInput.Properties.Protocols {
serviceApi.Protocols = append(serviceApi.Protocols, item)
}
}
// Set property "ServiceUrl":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.ServiceUrl != nil {
serviceUrl := *typedInput.Properties.ServiceUrl
serviceApi.ServiceUrl = &serviceUrl
}
}
// no assignment for property "SourceApiReference"
// Set property "SubscriptionKeyParameterNames":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.SubscriptionKeyParameterNames != nil {
var subscriptionKeyParameterNames1 SubscriptionKeyParameterNamesContract
err := subscriptionKeyParameterNames1.PopulateFromARM(owner, *typedInput.Properties.SubscriptionKeyParameterNames)
if err != nil {
return err
}
subscriptionKeyParameterNames := subscriptionKeyParameterNames1
serviceApi.SubscriptionKeyParameterNames = &subscriptionKeyParameterNames
}
}
// Set property "SubscriptionRequired":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.SubscriptionRequired != nil {
subscriptionRequired := *typedInput.Properties.SubscriptionRequired
serviceApi.SubscriptionRequired = &subscriptionRequired
}
}
// Set property "TermsOfServiceUrl":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.TermsOfServiceUrl != nil {
termsOfServiceUrl := *typedInput.Properties.TermsOfServiceUrl
serviceApi.TermsOfServiceUrl = &termsOfServiceUrl
}
}
// Set property "TranslateRequiredQueryParameters":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.TranslateRequiredQueryParameters != nil {
translateRequiredQueryParameters := *typedInput.Properties.TranslateRequiredQueryParameters
serviceApi.TranslateRequiredQueryParameters = &translateRequiredQueryParameters
}
}
// Set property "Type":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.Type != nil {
typeVar := *typedInput.Properties.Type
serviceApi.Type = &typeVar
}
}
// Set property "Value":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.Value != nil {
value := *typedInput.Properties.Value
serviceApi.Value = &value
}
}
// Set property "WsdlSelector":
// copying flattened property:
if typedInput.Properties != nil {
if typedInput.Properties.WsdlSelector != nil {
var wsdlSelector1 ApiCreateOrUpdateProperties_WsdlSelector
err := wsdlSelector1.PopulateFromARM(owner, *typedInput.Properties.WsdlSelector)
if err != nil {
return err
}
wsdlSelector := wsdlSelector1
serviceApi.WsdlSelector = &wsdlSelector
}
}
// No error
return nil
}
var _ genruntime.ConvertibleSpec = &Service_Api_Spec{}
// ConvertSpecFrom populates our Service_Api_Spec from the provided source
func (serviceApi *Service_Api_Spec) ConvertSpecFrom(source genruntime.ConvertibleSpec) error {
src, ok := source.(*v20230501ps.Service_Api_Spec)
if ok {
// Populate our instance from source
return serviceApi.AssignProperties_From_Service_Api_Spec(src)
}
// Convert to an intermediate form
src = &v20230501ps.Service_Api_Spec{}
err := src.ConvertSpecFrom(source)
if err != nil {
return errors.Wrap(err, "initial step of conversion in ConvertSpecFrom()")
}
// Update our instance from src
err = serviceApi.AssignProperties_From_Service_Api_Spec(src)
if err != nil {
return errors.Wrap(err, "final step of conversion in ConvertSpecFrom()")
}
return nil
}
// ConvertSpecTo populates the provided destination from our Service_Api_Spec
func (serviceApi *Service_Api_Spec) ConvertSpecTo(destination genruntime.ConvertibleSpec) error {
dst, ok := destination.(*v20230501ps.Service_Api_Spec)
if ok {
// Populate destination from our instance
return serviceApi.AssignProperties_To_Service_Api_Spec(dst)
}
// Convert to an intermediate form
dst = &v20230501ps.Service_Api_Spec{}
err := serviceApi.AssignProperties_To_Service_Api_Spec(dst)
if err != nil {
return errors.Wrap(err, "initial step of conversion in ConvertSpecTo()")
}
// Update dst from our instance
err = dst.ConvertSpecTo(destination)
if err != nil {
return errors.Wrap(err, "final step of conversion in ConvertSpecTo()")
}
return nil
}
// AssignProperties_From_Service_Api_Spec populates our Service_Api_Spec from the provided source Service_Api_Spec
func (serviceApi *Service_Api_Spec) AssignProperties_From_Service_Api_Spec(source *v20230501ps.Service_Api_Spec) error {
// APIVersion
if source.APIVersion != nil {
apiVersion := *source.APIVersion
serviceApi.APIVersion = &apiVersion
} else {
serviceApi.APIVersion = nil
}
// ApiRevision
if source.ApiRevision != nil {
apiRevision := *source.ApiRevision
serviceApi.ApiRevision = &apiRevision
} else {
serviceApi.ApiRevision = nil
}
// ApiRevisionDescription
if source.ApiRevisionDescription != nil {
apiRevisionDescription := *source.ApiRevisionDescription
serviceApi.ApiRevisionDescription = &apiRevisionDescription
} else {
serviceApi.ApiRevisionDescription = nil
}
// ApiType
if source.ApiType != nil {
apiType := *source.ApiType
apiTypeTemp := genruntime.ToEnum(apiType, apiCreateOrUpdateProperties_ApiType_Values)
serviceApi.ApiType = &apiTypeTemp
} else {
serviceApi.ApiType = nil
}
// ApiVersionDescription
if source.ApiVersionDescription != nil {
apiVersionDescription := *source.ApiVersionDescription
serviceApi.ApiVersionDescription = &apiVersionDescription
} else {
serviceApi.ApiVersionDescription = nil
}
// ApiVersionSet
if source.ApiVersionSet != nil {
var apiVersionSet ApiVersionSetContractDetails
err := apiVersionSet.AssignProperties_From_ApiVersionSetContractDetails(source.ApiVersionSet)
if err != nil {
return errors.Wrap(err, "calling AssignProperties_From_ApiVersionSetContractDetails() to populate field ApiVersionSet")
}
serviceApi.ApiVersionSet = &apiVersionSet
} else {
serviceApi.ApiVersionSet = nil
}
// ApiVersionSetReference
if source.ApiVersionSetReference != nil {
apiVersionSetReference := source.ApiVersionSetReference.Copy()
serviceApi.ApiVersionSetReference = &apiVersionSetReference
} else {
serviceApi.ApiVersionSetReference = nil
}
// AuthenticationSettings
if source.AuthenticationSettings != nil {
var authenticationSetting AuthenticationSettingsContract
err := authenticationSetting.AssignProperties_From_AuthenticationSettingsContract(source.AuthenticationSettings)