Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
11 stars 37 forks source link

`extensionResource` should be able to assign the resource type of the scope parameter #1270

Open ArcturusZhang opened 1 month ago

ArcturusZhang commented 1 month ago

We have a @extensionResource which allows us to construct a resource uri like:

/{resourceUri}/providers/namespace/do/something

but in real cases the resourceUri might need to specify resource types - some Rp's scope resource could only support some particular resource type.

Also the type of the parameter reduced from this decorator should be armResourceIdentifier - if we made this change, it has the ability to accept a resource type list for validate resource types.

markcowl commented 1 month ago

@ArcturusZhang This is fairly common for extension resources that only apply to VMs, but there are a few extension resource types that can apply to a few selected resources. Do you think using the allowedResourceTypes in the armResourceIdentifier could be used to specify particular resource types for this parameter?

ArcturusZhang commented 1 month ago

@ArcturusZhang This is fairly common for extension resources that only apply to VMs, but there are a few extension resource types that can apply to a few selected resources. Do you think using the allowedResourceTypes in the armResourceIdentifier could be used to specify particular resource types for this parameter?

yeah i am thinking the allowedResourceTypes should allow us to do that.

Also for extension resources that could only apply to one specific resource type they usually are defined very explicitly like this:

/subscriptions/{subsId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.GuestConfigurations/configurations/{name}

How do we write typespec for this case? A real case here: https://github.com/Azure/azure-rest-api-specs/blob/129c4f812edc27a0e4bd27225a1f7e296fadd160/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/guestconfiguration.json#L30

JoseLimaIVD commented 1 month ago

My team would also like to have this feature