Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add armResourceType scalar in typespec-azure-core #1272

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

ArcturusZhang
Copy link
Member

Fixes #1268

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jul 31, 2024

All changed packages have been documented.

  • @azure-tools/typespec-azure-core
  • @azure-tools/typespec-azure-resource-manager
Show changes

@azure-tools/typespec-azure-core - feature ✏️

Add armResourceType scalar, and changed some properties to be armResourceType instead of string

@azure-tools/typespec-azure-resource-manager - feature ✏️

Add armResourceType scalar, and changed some properties to be armResourceType instead of string

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

@tadelesh
Copy link
Member

@allenjzhang could you help to review?

Copy link
Member

@timotheeguerin timotheeguerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should go through some design discussion to approve this new type

@ArcturusZhang
Copy link
Member Author

We should go through some design discussion to approve this new type

Yeah I assume we should go through design discussions before we could merge this. What is the process of that?

@timotheeguerin
Copy link
Member

We can talk about it tomorrow in dpg meeting(or later one if we can't) don't think this needs to be brought up to the Wednesday one

@ArcturusZhang
Copy link
Member Author

@timotheeguerin any update on this?

* Microsoft.Network/virtualNetworks/subnets
* ```
*/
scalar resourceType extends string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was OOF the last 2 weeks, has there been agreement we needed this and this was the name we wanted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh - I do not know. Do we need to bring up this topic in one of our typespec sync up meeting or your internal typespec sync up meeting?
In those meetings that I have participated in, this has not been a topic there.
Or maybe we could put this as an agenda in our next typespec sync up meeting on your wednesday night.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah would be good, do you need this for this release?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably need to differentiate this as we did with armResourceIdentifier - armResourceType.

There is definitely use for this in ARM, and since the type is needed to properly specify the allowedResourceType in armResourceIdentifier, it seems appropriate to put this here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree the name should be armResourceType which makes more sense.
The second part is that you suggest we add a generic argument for allowed resource type? like this?

scalar armResourceType<AllowedResourceTypes extends ArmResourceIdentifierAllowedResource[] = never> extends string {}

I think this looks weird because this type is modeling the resource type of myself, if there is a limited list of resource types that this field is supporting, should we define a extensible enum based on resource type like this?

union SupportedResourceType extends armResourceType {
	"Microsoft.Compute/virtualMachines"
}

Well but I could see values for this because we could update the definition of Resource and TrackedResource to let them accept another argument of resource type like this:

model TrackedResource<Properties extends Model, ResourceType extends ArmResourceIdentifierAllowedResource> {
id: armResourceIdentifier;
type: armResourceType<ResourceType>;

properties: Properties;
}

so that we finally have explicitly defined resource type on resources, currently arm resources could have resource types but they are implicitly - we can infer them from the uri paths we built for resource related operations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think using a union here instead to be more precise makes more sense instead of the armREsourceIdentifier which does that for a subset of the value.

and +1 on the name being armResourceType

@ArcturusZhang ArcturusZhang changed the title add resource type scalar in typespec-azure-core add armResourceType scalar in typespec-azure-core Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add resourceType scalar in typespec-azure-core library
5 participants