Add Relationship Base Type - #4892
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8a6e07d6-3bd4-4373-b9a2-88ad69127fcf
| * Applies the Relationship base type decorator automatically. | ||
| * @template Properties RP-specific properties for the relationship (must extend RelationshipProperties) | ||
| */ | ||
| @azureBaseType(#{ baseType: "Relationship", version: "2024-06-01" }) |
There was a problem hiding this comment.
Just thinking more about the baseType value and keeping a note for me. Assuming 'Relationship' also becomes the canonical base type, I would consider defining baseType as a constrained enum set having 'Relationship' & 'Agent'. Currently that is modeled as string which allows any string for the baseType. An open-ended string contract may introduce divergence across producers and consumers, making dependency tracking, and long-term schema governance significantly more challenging. I can do this once your PR gets merged.
There was a problem hiding this comment.
One question, is it possible for a resource to be an Agent and a Relationship?
The decorator allows this, but we should provide an example if this is a real scenario
There was a problem hiding this comment.
IMO, I do not think it is a real scenario. A single resource can't be an Agent (tracked type) and Relationship (extension type).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bd00581e-a610-4edb-8426-dfc6dd89cedb
|
All changed packages have been documented.
Show changes
|
commit: |
|
You can try these changes here
|
markcowl
left a comment
There was a problem hiding this comment.
I also wonder if we want a resource type for this, especially if it is required to be an extension.
| * Applies the Relationship base type decorator automatically. | ||
| * @template Properties RP-specific properties for the relationship (must extend RelationshipProperties) | ||
| */ | ||
| @azureBaseType(#{ baseType: "Relationship", version: "2024-06-01" }) |
There was a problem hiding this comment.
One question, is it possible for a resource to be an Agent and a Relationship?
The decorator allows this, but we should provide an example if this is a real scenario
| } | ||
|
|
||
| const missing = [ | ||
| "sourceId", |
There was a problem hiding this comment.
I think we should either create templates for these types, or we should have a type that defines the required properties and a decorator that indicates what is required (property exists, optionality, etc.) and use this to drive the linting rule
There was a problem hiding this comment.
Essentially, if we have a `@baseTypeProperty decorator, which took a base type kind and version, we could have an internal-only type (or a set of them) that defined the required properties.
@markcowl, can you please explain what you mean by this? |
| - "@azure-tools/typespec-azure-rulesets" | ||
| --- | ||
|
|
||
| Add the experimental Relationship base type for Azure Resource Manager extension resources, including flat relationship properties and lint validation for Relationship base type conformance. |
There was a problem hiding this comment.
We should add a short example of usage here - this will go into the release notes and the release blog post
| sourceTenant: string; | ||
|
|
||
| /** The relationship target identifier. */ | ||
| targetId: string; |
There was a problem hiding this comment.
In the Agent types, we split these into Appliance and UserDefined templates, with the appliance type having readOnly properties. If we are considering making some of these readOnly, it is easiest to make this part of the Appliance template
| @@ -0,0 +1,41 @@ | |||
| --- | |||
| title: arm-relationship-base-type-required-properties | |||
There was a problem hiding this comment.
To follow guidelines, we should rename this rule and type to use-relationship-required-properties
| import { AzureBaseTypeInfo, getAzureBaseTypes } from "../base-types.js"; | ||
| import { getArmResources } from "../resource.js"; | ||
|
|
||
| export const armRelationshipBaseTypeRequiredPropertiesRule = createRule({ |
There was a problem hiding this comment.
will need to change this name as well
This PR introduces a base type for namespace Microsoft.Relationships. Relationships are extension resources used to establish a connection between a source ARM resource and target ARM resource.
Notably, two relationship types exist in a public preview state in ARM today: serviceGroupMember and dependencyOf.
The implementation of the Microsoft.Relationships base type is heavily inspired by the only other existing base type current: agent.
The relationship type is meant to be a lightweight ARM resources (meaning the resource payload has minimal properties and only really carries references to other ARM resources), however implementations of the relationship base type can new metadata about a relationship through extending the RelationshipMetadata model
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Copilot-Session: 8a6e07d6-3bd4-4373-b9a2-88ad69127fcf