Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-azure-resource-manager"
- "@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should add a short example of usage here - this will go into the release notes and the release blog post

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import "@typespec/rest";
import "@typespec/versioning";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

using Http;
using Rest;
using Versioning;
using Azure.ResourceManager;
using Azure.ResourceManager.BaseTypes.Relationships;

/** Contoso Relationships Resource Provider management API. */
@armProviderNamespace
@service(#{ title: "ContosoRelationshipsClient" })
@versioned(Versions)
namespace Microsoft.ContosoRelationships;

/** Contoso Relationships API versions */
enum Versions {
/** 2024-06-01 version */
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
`2024-06-01`,
}

interface Operations extends Azure.ResourceManager.Operations {}

/** Metadata for a Contoso dependency relationship. */
alias DependencyOfMetadata = RelationshipMetadata & {
/** A human-readable relationship description. */
description?: string;
};

/** Provisioning state values for a Contoso dependency relationship async flow. */
@Azure.Core.lroStatus
union DependencyOfProvisioningState {
/** Include standard terminal provisioning states. */
ResourceProvisioningState,

/** The dependency relationship creation has been accepted. */
Accepted: "Accepted",

/** The dependency relationship is being provisioned. */
Provisioning: "Provisioning",

/** The dependency relationship is being deleted. */
Deleting: "Deleting",

string,
}

/** Properties for a Contoso dependency relationship. */
model DependencyOfProperties is RelationshipProperties<
Metadata = DependencyOfMetadata,
ProvisioningState = DependencyOfProvisioningState
>;

/**
* A dependency relationship between a source scope and target entity.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/basetypes-experimental" "Experimental BaseTypes"
model DependencyOf is Relationship<DependencyOfProperties> {
...ResourceNameParameter<
Resource = DependencyOf,
KeyName = "relationshipName",
SegmentName = "dependencyOf",
NamePattern = "^[a-zA-Z0-9_.-]{1,64}$"
>;
}

/** Defines dependency relationship operations for a source scope. */
interface DependencyOfOps<Scope extends Azure.ResourceManager.Foundations.SimpleResource> {
get is Extension.Read<Scope, DependencyOf>;
create is Extension.CreateOrReplaceAsync<Scope, DependencyOf>;
update is Extension.CustomPatchAsync<
Scope,
DependencyOf,
Azure.ResourceManager.Foundations.ResourceUpdateModel<DependencyOf, DependencyOfProperties>
>;
delete is Extension.DeleteWithoutOkAsync<Scope, DependencyOf>;
list is Extension.ListByTarget<Scope, DependencyOf>;
}

/**
* Operations over any source scope.
* Routes at: {scope}/providers/Microsoft.ContosoRelationships/dependencyOf/{relationshipName}
*/
@armResourceOperations
interface DependencyOfRelationships extends DependencyOfOps<Extension.ScopeParameter> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Relationship Base Type
description: Sample specification for a resource implementing the Relationship base type.

llmstxt: false
playground: false

order: 9
Loading
Loading