Skip to content

Commit

Permalink
Convert arm-id m4 type to Bicep strings (Azure#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeskew authored Aug 15, 2022
1 parent d905fa1 commit b040ccf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/autorest.bicep/src/type-generator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { AnySchema, ArraySchema, ByteArraySchema, ChoiceSchema, ConstantSchema, DictionarySchema, ObjectSchema, PrimitiveSchema, Property, Schema, SchemaType, SealedChoiceSchema, StringSchema } from "@autorest/codemodel";
import { AnySchema, ArmIdSchema, ArraySchema, ByteArraySchema, ChoiceSchema, ConstantSchema, DictionarySchema, ObjectSchema, PrimitiveSchema, Property, Schema, SchemaType, SealedChoiceSchema, StringSchema } from "@autorest/codemodel";
import { Channel, AutorestExtensionHost } from "@autorest/extension-base";
import { ArrayType, BuiltInTypeKind, DiscriminatedObjectType, ObjectProperty, ObjectPropertyFlags, ObjectType, ResourceFlags, ResourceFunctionType, ResourceType, StringLiteralType, TypeFactory, TypeReference, UnionType } from "./types";
import { uniq, keys, keyBy, Dictionary, flatMap } from 'lodash';
Expand Down Expand Up @@ -458,6 +458,7 @@ export function generateTypes(host: AutorestExtensionHost, definition: ProviderD
case SchemaType.Uuid:
case SchemaType.Duration:
case SchemaType.Credential:
case SchemaType.ArmId:
return BuiltInTypeKind.String;
default:
logWarning(`Unrecognized known property type: "${schema.type}"`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Test.Rp1/testType1"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/testType1","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"The resource properties."},"tags":{"Type":26,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"TestType1CreateOrUpdatePropertiesOrTestType1Properties","Properties":{"basicString":{"Type":4,"Flags":0,"Description":"Description for a basic string property."},"stringEnum":{"Type":14,"Flags":0,"Description":"Description for a basic enum property."},"skuTier":{"Type":19,"Flags":0,"Description":"This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT."},"encryptionProperties":{"Type":20,"Flags":0,"Description":"TestType1 encryption properties"},"locationData":{"Type":25,"Flags":2,"Description":"Metadata pertaining to the geographic location of the resource."},"base64EncodedBytes":{"Type":4,"Flags":2},"binaryBuffer":{"Type":0,"Flags":2}}}},{"6":{"Value":"Foo"}},{"6":{"Value":"Bar"}},{"5":{"Elements":[12,13,4]}},{"6":{"Value":"Free"}},{"6":{"Value":"Basic"}},{"6":{"Value":"Standard"}},{"6":{"Value":"Premium"}},{"5":{"Elements":[15,16,17,18]}},{"2":{"Name":"EncryptionProperties","Properties":{"status":{"Type":23,"Flags":0,"Description":"Indicates whether or not the encryption is enabled for container registry."},"keyVaultProperties":{"Type":24,"Flags":0,"Description":"Key vault properties."}}}},{"6":{"Value":"enabled"}},{"6":{"Value":"disabled"}},{"5":{"Elements":[21,22,4]}},{"2":{"Name":"KeyVaultProperties","Properties":{"keyIdentifier":{"Type":4,"Flags":0,"Description":"Key vault uri to access the encryption key."},"identity":{"Type":4,"Flags":0,"Description":"The client ID of the identity which will be used to access key vault."}}}},{"2":{"Name":"LocationData","Properties":{"name":{"Type":4,"Flags":1,"Description":"A canonical name for the geographic or physical location."},"city":{"Type":4,"Flags":0,"Description":"The city or locality where the resource is located."},"district":{"Type":4,"Flags":0,"Description":"The district, state, or province where the resource is located."},"countryOrRegion":{"Type":4,"Flags":0,"Description":"The country or region where the resource is located"}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":32,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":37,"Flags":0,"Description":"The type of identity that last modified the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[28,29,30,31,4]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[33,34,35,36,4]}},{"4":{"Name":"Test.Rp1/testType1@2021-10-31","ScopeType":8,"Body":10,"Flags":0}},{"6":{"Value":"constantName"}},{"6":{"Value":"yetAnotherName"}},{"5":{"Elements":[39,40,4]}},{"6":{"Value":"Test.Rp1/splitPutAndGetType"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/splitPutAndGetType","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":41,"Flags":9,"Description":"The resource name"},"type":{"Type":42,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":43,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"The resource properties."},"tags":{"Type":45,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Test.Rp1/splitPutAndGetType@2021-10-31","ScopeType":4,"Body":44,"Flags":0}},{"6":{"Value":"Test.Rp1/partlyReadonlyType"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/partlyReadonlyType","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":47,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":48,"Flags":10,"Description":"The resource api version"},"properties":{"Type":50,"Flags":0},"tags":{"Type":59,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"TestType1Properties","Properties":{"locationData":{"Type":25,"Flags":0,"Description":"Metadata pertaining to the geographic location of the resource."},"base64EncodedBytes":{"Type":4,"Flags":0},"binaryBuffer":{"Type":0,"Flags":0},"basicString":{"Type":4,"Flags":0,"Description":"Description for a basic string property."},"stringEnum":{"Type":53,"Flags":0,"Description":"Description for a basic enum property."},"skuTier":{"Type":58,"Flags":0,"Description":"This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT."},"encryptionProperties":{"Type":20,"Flags":0,"Description":"TestType1 encryption properties"}}}},{"6":{"Value":"Foo"}},{"6":{"Value":"Bar"}},{"5":{"Elements":[51,52,4]}},{"6":{"Value":"Free"}},{"6":{"Value":"Basic"}},{"6":{"Value":"Standard"}},{"6":{"Value":"Premium"}},{"5":{"Elements":[54,55,56,57]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Test.Rp1/partlyReadonlyType@2021-10-31","ScopeType":9,"ReadOnlyScopes":1,"Body":49,"Flags":0}},{"6":{"Value":"Test.Rp1/readOnlyTestType"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/readOnlyTestType","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":61,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":62,"Flags":10,"Description":"The resource api version"},"properties":{"Type":64,"Flags":2},"tags":{"Type":66,"Flags":2,"Description":"Resource tags."},"location":{"Type":4,"Flags":2,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"ReadOnlyTestTypeProperties","Properties":{"plan":{"Type":65,"Flags":0,"Description":"Plan for the resource."}}}},{"2":{"Name":"Plan","Properties":{"name":{"Type":4,"Flags":1,"Description":"A user defined name of the 3rd Party Artifact that is being procured."},"publisher":{"Type":4,"Flags":1,"Description":"The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic"},"product":{"Type":4,"Flags":1,"Description":"The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding."},"promotionCode":{"Type":4,"Flags":0,"Description":"A publisher provided promotion code as provisioned in Data Market for the said product/artifact."},"version":{"Type":4,"Flags":0,"Description":"The version of the desired product/artifact."}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Test.Rp1/readOnlyTestType@2021-10-31","ScopeType":8,"Body":63,"Flags":1}},{"2":{"Name":"FoosRequest","Properties":{"someString":{"Type":4,"Flags":1,"Description":"The foo request string"},"locationData":{"Type":25,"Flags":0,"Description":"Metadata pertaining to the geographic location of the resource."}}}},{"2":{"Name":"FoosResponse","Properties":{"someString":{"Type":4,"Flags":0,"Description":"The foo response string"}}}},{"8":{"Name":"listFoos","ResourceType":"Test.Rp1/testType1","ApiVersion":"2021-10-31","Output":69,"Input":68}},{"3":{"ItemType":69}},{"8":{"Name":"listArrayOfFoos","ResourceType":"Test.Rp1/testType1","ApiVersion":"2021-10-31","Output":71}}]
[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Test.Rp1/testType1"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/testType1","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"The resource properties."},"tags":{"Type":26,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"TestType1CreateOrUpdatePropertiesOrTestType1Properties","Properties":{"basicString":{"Type":4,"Flags":0,"Description":"Description for a basic string property."},"stringEnum":{"Type":14,"Flags":0,"Description":"Description for a basic enum property."},"skuTier":{"Type":19,"Flags":0,"Description":"This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT."},"encryptionProperties":{"Type":20,"Flags":0,"Description":"TestType1 encryption properties"},"locationData":{"Type":25,"Flags":2,"Description":"Metadata pertaining to the geographic location of the resource."},"base64EncodedBytes":{"Type":4,"Flags":2},"binaryBuffer":{"Type":0,"Flags":2},"subnetId":{"Type":4,"Flags":2,"Description":"A fully-qualified resource ID"}}}},{"6":{"Value":"Foo"}},{"6":{"Value":"Bar"}},{"5":{"Elements":[12,13,4]}},{"6":{"Value":"Free"}},{"6":{"Value":"Basic"}},{"6":{"Value":"Standard"}},{"6":{"Value":"Premium"}},{"5":{"Elements":[15,16,17,18]}},{"2":{"Name":"EncryptionProperties","Properties":{"status":{"Type":23,"Flags":0,"Description":"Indicates whether or not the encryption is enabled for container registry."},"keyVaultProperties":{"Type":24,"Flags":0,"Description":"Key vault properties."}}}},{"6":{"Value":"enabled"}},{"6":{"Value":"disabled"}},{"5":{"Elements":[21,22,4]}},{"2":{"Name":"KeyVaultProperties","Properties":{"keyIdentifier":{"Type":4,"Flags":0,"Description":"Key vault uri to access the encryption key."},"identity":{"Type":4,"Flags":0,"Description":"The client ID of the identity which will be used to access key vault."}}}},{"2":{"Name":"LocationData","Properties":{"name":{"Type":4,"Flags":1,"Description":"A canonical name for the geographic or physical location."},"city":{"Type":4,"Flags":0,"Description":"The city or locality where the resource is located."},"district":{"Type":4,"Flags":0,"Description":"The district, state, or province where the resource is located."},"countryOrRegion":{"Type":4,"Flags":0,"Description":"The country or region where the resource is located"}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":32,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":37,"Flags":0,"Description":"The type of identity that last modified the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[28,29,30,31,4]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[33,34,35,36,4]}},{"4":{"Name":"Test.Rp1/testType1@2021-10-31","ScopeType":8,"Body":10,"Flags":0}},{"6":{"Value":"constantName"}},{"6":{"Value":"yetAnotherName"}},{"5":{"Elements":[39,40,4]}},{"6":{"Value":"Test.Rp1/splitPutAndGetType"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/splitPutAndGetType","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":41,"Flags":9,"Description":"The resource name"},"type":{"Type":42,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":43,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"The resource properties."},"tags":{"Type":45,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Test.Rp1/splitPutAndGetType@2021-10-31","ScopeType":4,"Body":44,"Flags":0}},{"6":{"Value":"Test.Rp1/partlyReadonlyType"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/partlyReadonlyType","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":47,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":48,"Flags":10,"Description":"The resource api version"},"properties":{"Type":50,"Flags":0},"tags":{"Type":59,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"TestType1Properties","Properties":{"locationData":{"Type":25,"Flags":0,"Description":"Metadata pertaining to the geographic location of the resource."},"base64EncodedBytes":{"Type":4,"Flags":0},"binaryBuffer":{"Type":0,"Flags":0},"subnetId":{"Type":4,"Flags":0,"Description":"A fully-qualified resource ID"},"basicString":{"Type":4,"Flags":0,"Description":"Description for a basic string property."},"stringEnum":{"Type":53,"Flags":0,"Description":"Description for a basic enum property."},"skuTier":{"Type":58,"Flags":0,"Description":"This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT."},"encryptionProperties":{"Type":20,"Flags":0,"Description":"TestType1 encryption properties"}}}},{"6":{"Value":"Foo"}},{"6":{"Value":"Bar"}},{"5":{"Elements":[51,52,4]}},{"6":{"Value":"Free"}},{"6":{"Value":"Basic"}},{"6":{"Value":"Standard"}},{"6":{"Value":"Premium"}},{"5":{"Elements":[54,55,56,57]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Test.Rp1/partlyReadonlyType@2021-10-31","ScopeType":9,"ReadOnlyScopes":1,"Body":49,"Flags":0}},{"6":{"Value":"Test.Rp1/readOnlyTestType"}},{"6":{"Value":"2021-10-31"}},{"2":{"Name":"Test.Rp1/readOnlyTestType","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":61,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":62,"Flags":10,"Description":"The resource api version"},"properties":{"Type":64,"Flags":2},"tags":{"Type":66,"Flags":2,"Description":"Resource tags."},"location":{"Type":4,"Flags":2,"Description":"The geo-location where the resource lives"},"systemData":{"Type":27,"Flags":2,"Description":"Azure Resource Manager metadata containing createdBy and modifiedBy information."}}}},{"2":{"Name":"ReadOnlyTestTypeProperties","Properties":{"plan":{"Type":65,"Flags":0,"Description":"Plan for the resource."}}}},{"2":{"Name":"Plan","Properties":{"name":{"Type":4,"Flags":1,"Description":"A user defined name of the 3rd Party Artifact that is being procured."},"publisher":{"Type":4,"Flags":1,"Description":"The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic"},"product":{"Type":4,"Flags":1,"Description":"The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding."},"promotionCode":{"Type":4,"Flags":0,"Description":"A publisher provided promotion code as provisioned in Data Market for the said product/artifact."},"version":{"Type":4,"Flags":0,"Description":"The version of the desired product/artifact."}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Test.Rp1/readOnlyTestType@2021-10-31","ScopeType":8,"Body":63,"Flags":1}},{"2":{"Name":"FoosRequest","Properties":{"someString":{"Type":4,"Flags":1,"Description":"The foo request string"},"locationData":{"Type":25,"Flags":0,"Description":"Metadata pertaining to the geographic location of the resource."}}}},{"2":{"Name":"FoosResponse","Properties":{"someString":{"Type":4,"Flags":0,"Description":"The foo response string"}}}},{"8":{"Name":"listFoos","ResourceType":"Test.Rp1/testType1","ApiVersion":"2021-10-31","Output":69,"Input":68}},{"3":{"ItemType":69}},{"8":{"Name":"listArrayOfFoos","ResourceType":"Test.Rp1/testType1","ApiVersion":"2021-10-31","Output":71}}]
Loading

0 comments on commit b040ccf

Please sign in to comment.