From 4fd5dedc7f48646b6feb9762a4a23a593ff7712f Mon Sep 17 00:00:00 2001 From: ross-p-smith Date: Wed, 11 Oct 2023 00:44:37 +0100 Subject: [PATCH] Fixed up ARM References --- .../v1api20220801/api_types_gen.go | 157 +++++++++++------- .../v1api20220801/api_types_gen_test.go | 3 - .../service_api_spec_arm_types_gen.go | 14 +- .../apimanagement/v1api20220801/structure.txt | 6 +- .../v1api20220801/zz_generated.deepcopy.go | 22 +-- .../v1api20220801storage/api_types_gen.go | 46 ++--- .../api_types_gen_test.go | 3 - .../v1api20220801storage/structure.txt | 6 +- .../zz_generated.deepcopy.go | 22 +-- v2/azure-arm.yaml | 6 +- .../crd_apimanagement_20220801_test.go | 20 ++- .../v1api20220801/v1api20220801_api.yaml | 6 +- .../v1api20220801/v1api20220801_service.yaml | 1 + 13 files changed, 179 insertions(+), 133 deletions(-) diff --git a/v2/api/apimanagement/v1api20220801/api_types_gen.go b/v2/api/apimanagement/v1api20220801/api_types_gen.go index 24b1eef2da4..a7379ae8212 100644 --- a/v2/api/apimanagement/v1api20220801/api_types_gen.go +++ b/v2/api/apimanagement/v1api20220801/api_types_gen.go @@ -346,8 +346,8 @@ type Service_Api_Spec struct { // ApiVersionSet: Version set details ApiVersionSet *ApiVersionSetContractDetails `json:"apiVersionSet,omitempty"` - // ApiVersionSetId: A resource identifier for the related ApiVersionSet. - ApiVersionSetId *string `json:"apiVersionSetId,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"` @@ -401,8 +401,8 @@ type Service_Api_Spec struct { // ServiceUrl: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. ServiceUrl *string `json:"serviceUrl,omitempty"` - // SourceApiId: API identifier of the source API. - SourceApiId *string `json:"sourceApiId,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"` @@ -446,7 +446,7 @@ func (serviceApi *Service_Api_Spec) ConvertToARM(resolved genruntime.ConvertToAR serviceApi.ApiType != nil || serviceApi.ApiVersionDescription != nil || serviceApi.ApiVersionSet != nil || - serviceApi.ApiVersionSetId != nil || + serviceApi.ApiVersionSetReference != nil || serviceApi.AuthenticationSettings != nil || serviceApi.Contact != nil || serviceApi.Description != nil || @@ -457,7 +457,7 @@ func (serviceApi *Service_Api_Spec) ConvertToARM(resolved genruntime.ConvertToAR serviceApi.Path != nil || serviceApi.Protocols != nil || serviceApi.ServiceUrl != nil || - serviceApi.SourceApiId != nil || + serviceApi.SourceApiReference != nil || serviceApi.SubscriptionKeyParameterNames != nil || serviceApi.SubscriptionRequired != nil || serviceApi.TermsOfServiceUrl != nil || @@ -495,8 +495,12 @@ func (serviceApi *Service_Api_Spec) ConvertToARM(resolved genruntime.ConvertToAR apiVersionSet := *apiVersionSet_ARM.(*ApiVersionSetContractDetails_ARM) result.Properties.ApiVersionSet = &apiVersionSet } - if serviceApi.ApiVersionSetId != nil { - apiVersionSetId := *serviceApi.ApiVersionSetId + 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 { @@ -550,8 +554,12 @@ func (serviceApi *Service_Api_Spec) ConvertToARM(resolved genruntime.ConvertToAR serviceUrl := *serviceApi.ServiceUrl result.Properties.ServiceUrl = &serviceUrl } - if serviceApi.SourceApiId != nil { - sourceApiId := *serviceApi.SourceApiId + 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 { @@ -664,14 +672,7 @@ func (serviceApi *Service_Api_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } } - // Set property "ApiVersionSetId": - // copying flattened property: - if typedInput.Properties != nil { - if typedInput.Properties.ApiVersionSetId != nil { - apiVersionSetId := *typedInput.Properties.ApiVersionSetId - serviceApi.ApiVersionSetId = &apiVersionSetId - } - } + // no assignment for property "ApiVersionSetReference" // Set property "AuthenticationSettings": // copying flattened property: @@ -786,14 +787,7 @@ func (serviceApi *Service_Api_Spec) PopulateFromARM(owner genruntime.ArbitraryOw } } - // Set property "SourceApiId": - // copying flattened property: - if typedInput.Properties != nil { - if typedInput.Properties.SourceApiId != nil { - sourceApiId := *typedInput.Properties.SourceApiId - serviceApi.SourceApiId = &sourceApiId - } - } + // no assignment for property "SourceApiReference" // Set property "SubscriptionKeyParameterNames": // copying flattened property: @@ -977,8 +971,13 @@ func (serviceApi *Service_Api_Spec) AssignProperties_From_Service_Api_Spec(sourc serviceApi.ApiVersionSet = nil } - // ApiVersionSetId - serviceApi.ApiVersionSetId = genruntime.ClonePointerToString(source.ApiVersionSetId) + // ApiVersionSetReference + if source.ApiVersionSetReference != nil { + apiVersionSetReference := source.ApiVersionSetReference.Copy() + serviceApi.ApiVersionSetReference = &apiVersionSetReference + } else { + serviceApi.ApiVersionSetReference = nil + } // AuthenticationSettings if source.AuthenticationSettings != nil { @@ -1083,8 +1082,13 @@ func (serviceApi *Service_Api_Spec) AssignProperties_From_Service_Api_Spec(sourc serviceApi.ServiceUrl = nil } - // SourceApiId - serviceApi.SourceApiId = genruntime.ClonePointerToString(source.SourceApiId) + // SourceApiReference + if source.SourceApiReference != nil { + sourceApiReference := source.SourceApiReference.Copy() + serviceApi.SourceApiReference = &sourceApiReference + } else { + serviceApi.SourceApiReference = nil + } // SubscriptionKeyParameterNames if source.SubscriptionKeyParameterNames != nil { @@ -1201,8 +1205,13 @@ func (serviceApi *Service_Api_Spec) AssignProperties_To_Service_Api_Spec(destina destination.ApiVersionSet = nil } - // ApiVersionSetId - destination.ApiVersionSetId = genruntime.ClonePointerToString(serviceApi.ApiVersionSetId) + // ApiVersionSetReference + if serviceApi.ApiVersionSetReference != nil { + apiVersionSetReference := serviceApi.ApiVersionSetReference.Copy() + destination.ApiVersionSetReference = &apiVersionSetReference + } else { + destination.ApiVersionSetReference = nil + } // AuthenticationSettings if serviceApi.AuthenticationSettings != nil { @@ -1310,8 +1319,13 @@ func (serviceApi *Service_Api_Spec) AssignProperties_To_Service_Api_Spec(destina destination.ServiceUrl = nil } - // SourceApiId - destination.SourceApiId = genruntime.ClonePointerToString(serviceApi.SourceApiId) + // SourceApiReference + if serviceApi.SourceApiReference != nil { + sourceApiReference := serviceApi.SourceApiReference.Copy() + destination.SourceApiReference = &sourceApiReference + } else { + destination.SourceApiReference = nil + } // SubscriptionKeyParameterNames if serviceApi.SubscriptionKeyParameterNames != nil { @@ -1425,8 +1439,13 @@ func (serviceApi *Service_Api_Spec) Initialize_From_Service_Api_STATUS(source *S serviceApi.ApiVersionSet = nil } - // ApiVersionSetId - serviceApi.ApiVersionSetId = genruntime.ClonePointerToString(source.ApiVersionSetId) + // ApiVersionSetReference + if source.ApiVersionSetId != nil { + apiVersionSetReference := genruntime.CreateResourceReferenceFromARMID(*source.ApiVersionSetId) + serviceApi.ApiVersionSetReference = &apiVersionSetReference + } else { + serviceApi.ApiVersionSetReference = nil + } // AuthenticationSettings if source.AuthenticationSettings != nil { @@ -1513,8 +1532,13 @@ func (serviceApi *Service_Api_Spec) Initialize_From_Service_Api_STATUS(source *S serviceApi.ServiceUrl = nil } - // SourceApiId - serviceApi.SourceApiId = genruntime.ClonePointerToString(source.SourceApiId) + // SourceApiReference + if source.SourceApiId != nil { + sourceApiReference := genruntime.CreateResourceReferenceFromARMID(*source.SourceApiId) + serviceApi.SourceApiReference = &sourceApiReference + } else { + serviceApi.SourceApiReference = nil + } // SubscriptionKeyParameterNames if source.SubscriptionKeyParameterNames != nil { @@ -2838,12 +2862,12 @@ type ApiVersionSetContractDetails struct { // Description: Description of API Version Set. Description *string `json:"description,omitempty"` - // Id: Identifier for existing API Version Set. Omit this value to create a new Version Set. - Id *string `json:"id,omitempty"` - // Name: The display Name of the API Version Set. Name *string `json:"name,omitempty"` + // Reference: Identifier for existing API Version Set. Omit this value to create a new Version Set. + Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"` + // VersionHeaderName: Name of HTTP header parameter that indicates the API Version if versioningScheme is set to `header`. VersionHeaderName *string `json:"versionHeaderName,omitempty"` @@ -2870,9 +2894,13 @@ func (details *ApiVersionSetContractDetails) ConvertToARM(resolved genruntime.Co } // Set property "Id": - if details.Id != nil { - id := *details.Id - result.Id = &id + if details.Reference != nil { + referenceARMID, err := resolved.ResolvedReferences.Lookup(*details.Reference) + if err != nil { + return nil, err + } + reference := referenceARMID + result.Id = &reference } // Set property "Name": @@ -2919,18 +2947,14 @@ func (details *ApiVersionSetContractDetails) PopulateFromARM(owner genruntime.Ar details.Description = &description } - // Set property "Id": - if typedInput.Id != nil { - id := *typedInput.Id - details.Id = &id - } - // Set property "Name": if typedInput.Name != nil { name := *typedInput.Name details.Name = &name } + // no assignment for property "Reference" + // Set property "VersionHeaderName": if typedInput.VersionHeaderName != nil { versionHeaderName := *typedInput.VersionHeaderName @@ -2959,12 +2983,17 @@ func (details *ApiVersionSetContractDetails) AssignProperties_From_ApiVersionSet // Description details.Description = genruntime.ClonePointerToString(source.Description) - // Id - details.Id = genruntime.ClonePointerToString(source.Id) - // Name details.Name = genruntime.ClonePointerToString(source.Name) + // Reference + if source.Reference != nil { + reference := source.Reference.Copy() + details.Reference = &reference + } else { + details.Reference = nil + } + // VersionHeaderName details.VersionHeaderName = genruntime.ClonePointerToString(source.VersionHeaderName) @@ -2991,12 +3020,17 @@ func (details *ApiVersionSetContractDetails) AssignProperties_To_ApiVersionSetCo // Description destination.Description = genruntime.ClonePointerToString(details.Description) - // Id - destination.Id = genruntime.ClonePointerToString(details.Id) - // Name destination.Name = genruntime.ClonePointerToString(details.Name) + // Reference + if details.Reference != nil { + reference := details.Reference.Copy() + destination.Reference = &reference + } else { + destination.Reference = nil + } + // VersionHeaderName destination.VersionHeaderName = genruntime.ClonePointerToString(details.VersionHeaderName) @@ -3028,12 +3062,17 @@ func (details *ApiVersionSetContractDetails) Initialize_From_ApiVersionSetContra // Description details.Description = genruntime.ClonePointerToString(source.Description) - // Id - details.Id = genruntime.ClonePointerToString(source.Id) - // Name details.Name = genruntime.ClonePointerToString(source.Name) + // Reference + if source.Id != nil { + reference := genruntime.CreateResourceReferenceFromARMID(*source.Id) + details.Reference = &reference + } else { + details.Reference = nil + } + // VersionHeaderName details.VersionHeaderName = genruntime.ClonePointerToString(source.VersionHeaderName) diff --git a/v2/api/apimanagement/v1api20220801/api_types_gen_test.go b/v2/api/apimanagement/v1api20220801/api_types_gen_test.go index eb053a56543..6f3c23d8dfe 100644 --- a/v2/api/apimanagement/v1api20220801/api_types_gen_test.go +++ b/v2/api/apimanagement/v1api20220801/api_types_gen_test.go @@ -281,7 +281,6 @@ func AddIndependentPropertyGeneratorsForService_Api_Spec(gens map[string]gopter. ApiCreateOrUpdateProperties_ApiType_Soap, ApiCreateOrUpdateProperties_ApiType_Websocket)) gens["ApiVersionDescription"] = gen.PtrOf(gen.AlphaString()) - gens["ApiVersionSetId"] = gen.PtrOf(gen.AlphaString()) gens["AzureName"] = gen.AlphaString() gens["Description"] = gen.PtrOf(gen.AlphaString()) gens["DisplayName"] = gen.PtrOf(gen.AlphaString()) @@ -305,7 +304,6 @@ func AddIndependentPropertyGeneratorsForService_Api_Spec(gens map[string]gopter. ApiCreateOrUpdateProperties_Protocols_Ws, ApiCreateOrUpdateProperties_Protocols_Wss)) gens["ServiceUrl"] = gen.PtrOf(gen.AlphaString()) - gens["SourceApiId"] = gen.PtrOf(gen.AlphaString()) gens["SubscriptionRequired"] = gen.PtrOf(gen.Bool()) gens["TermsOfServiceUrl"] = gen.PtrOf(gen.AlphaString()) gens["TranslateRequiredQueryParameters"] = gen.PtrOf(gen.OneConstOf(ApiCreateOrUpdateProperties_TranslateRequiredQueryParameters_Query, ApiCreateOrUpdateProperties_TranslateRequiredQueryParameters_Template)) @@ -1096,7 +1094,6 @@ func ApiVersionSetContractDetailsGenerator() gopter.Gen { // AddIndependentPropertyGeneratorsForApiVersionSetContractDetails is a factory method for creating gopter generators func AddIndependentPropertyGeneratorsForApiVersionSetContractDetails(gens map[string]gopter.Gen) { gens["Description"] = gen.PtrOf(gen.AlphaString()) - gens["Id"] = gen.PtrOf(gen.AlphaString()) gens["Name"] = gen.PtrOf(gen.AlphaString()) gens["VersionHeaderName"] = gen.PtrOf(gen.AlphaString()) gens["VersionQueryName"] = gen.PtrOf(gen.AlphaString()) diff --git a/v2/api/apimanagement/v1api20220801/service_api_spec_arm_types_gen.go b/v2/api/apimanagement/v1api20220801/service_api_spec_arm_types_gen.go index 6b6a6a437d8..e63ead57a71 100644 --- a/v2/api/apimanagement/v1api20220801/service_api_spec_arm_types_gen.go +++ b/v2/api/apimanagement/v1api20220801/service_api_spec_arm_types_gen.go @@ -51,10 +51,8 @@ type ApiCreateOrUpdateProperties_ARM struct { ApiVersionDescription *string `json:"apiVersionDescription,omitempty"` // ApiVersionSet: Version set details - ApiVersionSet *ApiVersionSetContractDetails_ARM `json:"apiVersionSet,omitempty"` - - // ApiVersionSetId: A resource identifier for the related ApiVersionSet. - ApiVersionSetId *string `json:"apiVersionSetId,omitempty"` + ApiVersionSet *ApiVersionSetContractDetails_ARM `json:"apiVersionSet,omitempty"` + ApiVersionSetId *string `json:"apiVersionSetId,omitempty"` // AuthenticationSettings: Collection of authentication settings included into this API. AuthenticationSettings *AuthenticationSettingsContract_ARM `json:"authenticationSettings,omitempty"` @@ -86,9 +84,7 @@ type ApiCreateOrUpdateProperties_ARM struct { Protocols []ApiCreateOrUpdateProperties_Protocols `json:"protocols,omitempty"` // ServiceUrl: Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. - ServiceUrl *string `json:"serviceUrl,omitempty"` - - // SourceApiId: API identifier of the source API. + ServiceUrl *string `json:"serviceUrl,omitempty"` SourceApiId *string `json:"sourceApiId,omitempty"` // SubscriptionKeyParameterNames: Protocols over which API is made available. @@ -147,9 +143,7 @@ type ApiLicenseInformation_ARM struct { type ApiVersionSetContractDetails_ARM struct { // Description: Description of API Version Set. Description *string `json:"description,omitempty"` - - // Id: Identifier for existing API Version Set. Omit this value to create a new Version Set. - Id *string `json:"id,omitempty"` + Id *string `json:"id,omitempty"` // Name: The display Name of the API Version Set. Name *string `json:"name,omitempty"` diff --git a/v2/api/apimanagement/v1api20220801/structure.txt b/v2/api/apimanagement/v1api20220801/structure.txt index 9c25f7c5d8f..b14435e6626 100644 --- a/v2/api/apimanagement/v1api20220801/structure.txt +++ b/v2/api/apimanagement/v1api20220801/structure.txt @@ -21,15 +21,15 @@ github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20220801 │ │ │ └── Rule 0: MaxLength: 256 │ │ ├── ApiVersionSet: *Object (6 properties) │ │ │ ├── Description: *string -│ │ │ ├── Id: *string │ │ │ ├── Name: *string +│ │ │ ├── Reference: *genruntime.ResourceReference │ │ │ ├── VersionHeaderName: *string │ │ │ ├── VersionQueryName: *string │ │ │ └── VersioningScheme: *Enum (3 values) │ │ │ ├── "Header" │ │ │ ├── "Query" │ │ │ └── "Segment" -│ │ ├── ApiVersionSetId: *string +│ │ ├── ApiVersionSetReference: *genruntime.ResourceReference │ │ ├── AuthenticationSettings: *Object (4 properties) │ │ │ ├── OAuth2: *Object (2 properties) │ │ │ │ ├── AuthorizationServerId: *string @@ -87,7 +87,7 @@ github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20220801 │ │ ├── ServiceUrl: Validated<*string> (2 rules) │ │ │ ├── Rule 0: MaxLength: 2000 │ │ │ └── Rule 1: MinLength: 0 -│ │ ├── SourceApiId: *string +│ │ ├── SourceApiReference: *genruntime.ResourceReference │ │ ├── SubscriptionKeyParameterNames: *Object (2 properties) │ │ │ ├── Header: *string │ │ │ └── Query: *string diff --git a/v2/api/apimanagement/v1api20220801/zz_generated.deepcopy.go b/v2/api/apimanagement/v1api20220801/zz_generated.deepcopy.go index 6c354c53cc8..2284cffd9cd 100644 --- a/v2/api/apimanagement/v1api20220801/zz_generated.deepcopy.go +++ b/v2/api/apimanagement/v1api20220801/zz_generated.deepcopy.go @@ -1446,16 +1446,16 @@ func (in *ApiVersionSetContractDetails) DeepCopyInto(out *ApiVersionSetContractD *out = new(string) **out = **in } - if in.Id != nil { - in, out := &in.Id, &out.Id - *out = new(string) - **out = **in - } if in.Name != nil { in, out := &in.Name, &out.Name *out = new(string) **out = **in } + if in.Reference != nil { + in, out := &in.Reference, &out.Reference + *out = new(genruntime.ResourceReference) + **out = **in + } if in.VersionHeaderName != nil { in, out := &in.VersionHeaderName, &out.VersionHeaderName *out = new(string) @@ -4951,9 +4951,9 @@ func (in *Service_Api_Spec) DeepCopyInto(out *Service_Api_Spec) { *out = new(ApiVersionSetContractDetails) (*in).DeepCopyInto(*out) } - if in.ApiVersionSetId != nil { - in, out := &in.ApiVersionSetId, &out.ApiVersionSetId - *out = new(string) + if in.ApiVersionSetReference != nil { + in, out := &in.ApiVersionSetReference, &out.ApiVersionSetReference + *out = new(genruntime.ResourceReference) **out = **in } if in.AuthenticationSettings != nil { @@ -5011,9 +5011,9 @@ func (in *Service_Api_Spec) DeepCopyInto(out *Service_Api_Spec) { *out = new(string) **out = **in } - if in.SourceApiId != nil { - in, out := &in.SourceApiId, &out.SourceApiId - *out = new(string) + if in.SourceApiReference != nil { + in, out := &in.SourceApiReference, &out.SourceApiReference + *out = new(genruntime.ResourceReference) **out = **in } if in.SubscriptionKeyParameterNames != nil { diff --git a/v2/api/apimanagement/v1api20220801storage/api_types_gen.go b/v2/api/apimanagement/v1api20220801storage/api_types_gen.go index 3111d34153b..f99cb500b19 100644 --- a/v2/api/apimanagement/v1api20220801storage/api_types_gen.go +++ b/v2/api/apimanagement/v1api20220801storage/api_types_gen.go @@ -135,13 +135,15 @@ const APIVersion_Value = APIVersion("2022-08-01") // Storage version of v1api20220801.Service_Api_Spec type Service_Api_Spec struct { - APIVersion *string `json:"apiVersion,omitempty"` - ApiRevision *string `json:"apiRevision,omitempty"` - ApiRevisionDescription *string `json:"apiRevisionDescription,omitempty"` - ApiType *string `json:"apiType,omitempty"` - ApiVersionDescription *string `json:"apiVersionDescription,omitempty"` - ApiVersionSet *ApiVersionSetContractDetails `json:"apiVersionSet,omitempty"` - ApiVersionSetId *string `json:"apiVersionSetId,omitempty"` + APIVersion *string `json:"apiVersion,omitempty"` + ApiRevision *string `json:"apiRevision,omitempty"` + ApiRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + ApiType *string `json:"apiType,omitempty"` + ApiVersionDescription *string `json:"apiVersionDescription,omitempty"` + ApiVersionSet *ApiVersionSetContractDetails `json:"apiVersionSet,omitempty"` + + // ApiVersionSetReference: A resource identifier for the related ApiVersionSet. + ApiVersionSetReference *genruntime.ResourceReference `armReference:"ApiVersionSetId" json:"apiVersionSetReference,omitempty"` AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` // +kubebuilder:validation:MaxLength=256 @@ -162,12 +164,14 @@ type Service_Api_Spec struct { // 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"` - Path *string `json:"path,omitempty"` - PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` - Protocols []string `json:"protocols,omitempty"` - ServiceUrl *string `json:"serviceUrl,omitempty"` - SourceApiId *string `json:"sourceApiId,omitempty"` + Owner *genruntime.KnownResourceReference `group:"apimanagement.azure.com" json:"owner,omitempty" kind:"Service"` + Path *string `json:"path,omitempty"` + PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` + Protocols []string `json:"protocols,omitempty"` + ServiceUrl *string `json:"serviceUrl,omitempty"` + + // SourceApiReference: API identifier of the source API. + SourceApiReference *genruntime.ResourceReference `armReference:"SourceApiId" json:"sourceApiReference,omitempty"` SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` TermsOfServiceUrl *string `json:"termsOfServiceUrl,omitempty"` @@ -291,13 +295,15 @@ type ApiLicenseInformation_STATUS struct { // Storage version of v1api20220801.ApiVersionSetContractDetails // An API Version Set contains the common configuration for a set of API Versions relating type ApiVersionSetContractDetails struct { - Description *string `json:"description,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` - VersionHeaderName *string `json:"versionHeaderName,omitempty"` - VersionQueryName *string `json:"versionQueryName,omitempty"` - VersioningScheme *string `json:"versioningScheme,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + PropertyBag genruntime.PropertyBag `json:"$propertyBag,omitempty"` + + // Reference: Identifier for existing API Version Set. Omit this value to create a new Version Set. + Reference *genruntime.ResourceReference `armReference:"Id" json:"reference,omitempty"` + VersionHeaderName *string `json:"versionHeaderName,omitempty"` + VersionQueryName *string `json:"versionQueryName,omitempty"` + VersioningScheme *string `json:"versioningScheme,omitempty"` } // Storage version of v1api20220801.ApiVersionSetContractDetails_STATUS diff --git a/v2/api/apimanagement/v1api20220801storage/api_types_gen_test.go b/v2/api/apimanagement/v1api20220801storage/api_types_gen_test.go index 295e82567e5..ac598dc6138 100644 --- a/v2/api/apimanagement/v1api20220801storage/api_types_gen_test.go +++ b/v2/api/apimanagement/v1api20220801storage/api_types_gen_test.go @@ -149,7 +149,6 @@ func AddIndependentPropertyGeneratorsForService_Api_Spec(gens map[string]gopter. gens["ApiRevisionDescription"] = gen.PtrOf(gen.AlphaString()) gens["ApiType"] = gen.PtrOf(gen.AlphaString()) gens["ApiVersionDescription"] = gen.PtrOf(gen.AlphaString()) - gens["ApiVersionSetId"] = gen.PtrOf(gen.AlphaString()) gens["AzureName"] = gen.AlphaString() gens["Description"] = gen.PtrOf(gen.AlphaString()) gens["DisplayName"] = gen.PtrOf(gen.AlphaString()) @@ -159,7 +158,6 @@ func AddIndependentPropertyGeneratorsForService_Api_Spec(gens map[string]gopter. gens["Path"] = gen.PtrOf(gen.AlphaString()) gens["Protocols"] = gen.SliceOf(gen.AlphaString()) gens["ServiceUrl"] = gen.PtrOf(gen.AlphaString()) - gens["SourceApiId"] = gen.PtrOf(gen.AlphaString()) gens["SubscriptionRequired"] = gen.PtrOf(gen.Bool()) gens["TermsOfServiceUrl"] = gen.PtrOf(gen.AlphaString()) gens["TranslateRequiredQueryParameters"] = gen.PtrOf(gen.AlphaString()) @@ -644,7 +642,6 @@ func ApiVersionSetContractDetailsGenerator() gopter.Gen { // AddIndependentPropertyGeneratorsForApiVersionSetContractDetails is a factory method for creating gopter generators func AddIndependentPropertyGeneratorsForApiVersionSetContractDetails(gens map[string]gopter.Gen) { gens["Description"] = gen.PtrOf(gen.AlphaString()) - gens["Id"] = gen.PtrOf(gen.AlphaString()) gens["Name"] = gen.PtrOf(gen.AlphaString()) gens["VersionHeaderName"] = gen.PtrOf(gen.AlphaString()) gens["VersionQueryName"] = gen.PtrOf(gen.AlphaString()) diff --git a/v2/api/apimanagement/v1api20220801storage/structure.txt b/v2/api/apimanagement/v1api20220801storage/structure.txt index 7688585be01..1f58bb68ee8 100644 --- a/v2/api/apimanagement/v1api20220801storage/structure.txt +++ b/v2/api/apimanagement/v1api20220801storage/structure.txt @@ -12,13 +12,13 @@ github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20220801storag │ │ ├── ApiVersionDescription: *string │ │ ├── ApiVersionSet: *Object (7 properties) │ │ │ ├── Description: *string -│ │ │ ├── Id: *string │ │ │ ├── Name: *string │ │ │ ├── PropertyBag: genruntime.PropertyBag +│ │ │ ├── Reference: *genruntime.ResourceReference │ │ │ ├── VersionHeaderName: *string │ │ │ ├── VersionQueryName: *string │ │ │ └── VersioningScheme: *string -│ │ ├── ApiVersionSetId: *string +│ │ ├── ApiVersionSetReference: *genruntime.ResourceReference │ │ ├── AuthenticationSettings: *Object (5 properties) │ │ │ ├── OAuth2: *Object (3 properties) │ │ │ │ ├── AuthorizationServerId: *string @@ -60,7 +60,7 @@ github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20220801storag │ │ ├── PropertyBag: genruntime.PropertyBag │ │ ├── Protocols: string[] │ │ ├── ServiceUrl: *string -│ │ ├── SourceApiId: *string +│ │ ├── SourceApiReference: *genruntime.ResourceReference │ │ ├── SubscriptionKeyParameterNames: *Object (3 properties) │ │ │ ├── Header: *string │ │ │ ├── PropertyBag: genruntime.PropertyBag diff --git a/v2/api/apimanagement/v1api20220801storage/zz_generated.deepcopy.go b/v2/api/apimanagement/v1api20220801storage/zz_generated.deepcopy.go index 39edfa0fa90..d0bfe5557b3 100644 --- a/v2/api/apimanagement/v1api20220801storage/zz_generated.deepcopy.go +++ b/v2/api/apimanagement/v1api20220801storage/zz_generated.deepcopy.go @@ -587,11 +587,6 @@ func (in *ApiVersionSetContractDetails) DeepCopyInto(out *ApiVersionSetContractD *out = new(string) **out = **in } - if in.Id != nil { - in, out := &in.Id, &out.Id - *out = new(string) - **out = **in - } if in.Name != nil { in, out := &in.Name, &out.Name *out = new(string) @@ -604,6 +599,11 @@ func (in *ApiVersionSetContractDetails) DeepCopyInto(out *ApiVersionSetContractD (*out)[key] = val } } + if in.Reference != nil { + in, out := &in.Reference, &out.Reference + *out = new(genruntime.ResourceReference) + **out = **in + } if in.VersionHeaderName != nil { in, out := &in.VersionHeaderName, &out.VersionHeaderName *out = new(string) @@ -2611,9 +2611,9 @@ func (in *Service_Api_Spec) DeepCopyInto(out *Service_Api_Spec) { *out = new(ApiVersionSetContractDetails) (*in).DeepCopyInto(*out) } - if in.ApiVersionSetId != nil { - in, out := &in.ApiVersionSetId, &out.ApiVersionSetId - *out = new(string) + if in.ApiVersionSetReference != nil { + in, out := &in.ApiVersionSetReference, &out.ApiVersionSetReference + *out = new(genruntime.ResourceReference) **out = **in } if in.AuthenticationSettings != nil { @@ -2678,9 +2678,9 @@ func (in *Service_Api_Spec) DeepCopyInto(out *Service_Api_Spec) { *out = new(string) **out = **in } - if in.SourceApiId != nil { - in, out := &in.SourceApiId, &out.SourceApiId - *out = new(string) + if in.SourceApiReference != nil { + in, out := &in.SourceApiReference, &out.SourceApiReference + *out = new(genruntime.ResourceReference) **out = **in } if in.SubscriptionKeyParameterNames != nil { diff --git a/v2/azure-arm.yaml b/v2/azure-arm.yaml index ea4adad880a..ef0d0b5cfb2 100644 --- a/v2/azure-arm.yaml +++ b/v2/azure-arm.yaml @@ -700,10 +700,12 @@ objectModelConfiguration: $armReference: true ApiCreateOrUpdateProperties: ApiVersionSetId: - $armReference: false + $armReference: true + SourceApiId: + $armReference: true ApiVersionSetContractDetails: Id: - $armReference: false + $armReference: true ApiManagementServiceProperties: PublicIpAddressId: $armReference: true diff --git a/v2/internal/controllers/crd_apimanagement_20220801_test.go b/v2/internal/controllers/crd_apimanagement_20220801_test.go index 70aa9c26cbe..bf4906374c8 100644 --- a/v2/internal/controllers/crd_apimanagement_20220801_test.go +++ b/v2/internal/controllers/crd_apimanagement_20220801_test.go @@ -14,6 +14,7 @@ import ( apim "github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20220801" "github.com/Azure/azure-service-operator/v2/internal/testcommon" "github.com/Azure/azure-service-operator/v2/internal/util/to" + "github.com/Azure/azure-service-operator/v2/pkg/genruntime" ) func Test_ApiManagement_20220801_CRUD(t *testing.T) { @@ -25,10 +26,10 @@ func Test_ApiManagement_20220801_CRUD(t *testing.T) { tc := globalTestContext.ForTest(t) - // We don't want to delete the resource group at the end of the test as APIM - // takes a long time to provision. We'll clean it up manually + // If you don't want to delete the resource group at the end of the test as APIM + // takes a long time to provision; comment out the delete lines at the end of the test. rg := tc.NewTestResourceGroup() - tc.CreateResourceAndWaitWithoutCleanup(rg) + tc.CreateResourceAndWait(rg) // There will be a New v2 SKU released 5/10/2023 which will have a much quicker start up // time. Move to that when it's available (BasicV2 or StandardV2 SKU) @@ -51,9 +52,7 @@ func Test_ApiManagement_20220801_CRUD(t *testing.T) { }, } - // TODO: When you are debugging, you can use this to create the APIM service once and not delete it tc.CreateResourceAndWaitWithoutCleanup(&service) - // tc.CreateResourceAndWait(&service) tc.Expect(service.Status.Id).ToNot(BeNil()) @@ -109,6 +108,11 @@ func Test_ApiManagement_20220801_CRUD(t *testing.T) { }, }, ) + + // Whilst developing APIM tests, you can comment these two lines + // out to keep the APIM instance + tc.DeleteResourceAndWait(&service) + tc.DeleteResourceAndWait(rg) } func APIM_Subscription_CRUD(tc *testcommon.KubePerTestContext, service client.Object) { @@ -263,6 +267,10 @@ func APIM_Api_CRUD(tc *testcommon.KubePerTestContext, service client.Object) { tc.T.Log("creating apim version set") tc.CreateResourceAndWait(&versionSet) + versionSetReference := genruntime.ResourceReference{ + ARMID: *versionSet.Status.Id, + } + // Add a simple Api api := apim.Api{ ObjectMeta: tc.MakeObjectMetaWithName(tc.Namer.GenerateName("api")), @@ -271,7 +279,7 @@ func APIM_Api_CRUD(tc *testcommon.KubePerTestContext, service client.Object) { ApiRevision: to.Ptr("v1"), ApiRevisionDescription: to.Ptr("First Revision"), ApiVersionDescription: to.Ptr("Second Version"), - ApiVersionSetId: versionSet.Status.Id, + ApiVersionSetReference: &versionSetReference, Description: to.Ptr("A Description about the api"), DisplayName: to.Ptr("account-api"), Owner: testcommon.AsOwner(service), diff --git a/v2/samples/apimanagement/v1api20220801/v1api20220801_api.yaml b/v2/samples/apimanagement/v1api20220801/v1api20220801_api.yaml index a8feca84e73..21c2ff23078 100644 --- a/v2/samples/apimanagement/v1api20220801/v1api20220801_api.yaml +++ b/v2/samples/apimanagement/v1api20220801/v1api20220801_api.yaml @@ -8,8 +8,10 @@ spec: apiRevision: "2" apiRevisionDescription: Second Revision apiVersionDescription: August 2020 - apiVersionSet: - id: /apiVersionSets/sampleapimversionset + ApiVersionSetReference: + group: apimanagement.azure.com + kind: VersionSet + name: sampleapimversionset displayName: account-api description: Description about the API subscriptionRequired: false diff --git a/v2/samples/apimanagement/v1api20220801/v1api20220801_service.yaml b/v2/samples/apimanagement/v1api20220801/v1api20220801_service.yaml index 8fcab20dd1d..10e8c9c61de 100644 --- a/v2/samples/apimanagement/v1api20220801/v1api20220801_service.yaml +++ b/v2/samples/apimanagement/v1api20220801/v1api20220801_service.yaml @@ -12,3 +12,4 @@ spec: name: aso-sample-rg publisherEmail: ASO@testing.com publisherName: ASOTesting + restore: true # The service may have been soft-deleted previously, so we need to restore it