Skip to content

Commit

Permalink
Initial commit of ARM bug fix and rename/reorg (#762)
Browse files Browse the repository at this point in the history
This change contains following changes:

- Updated `extendedLocation` with optional and READ, CREATE
- Renamed base common types to be consistent with ARM common type,
included backcompat aliases with #deprecate
  - ArmResource -> Resource
  - TrackResourceBase -> TrackResource
  - ProxyResourceBase -> ProxyResource
  - ExtensionResourceBase -> ExtensionResource
  - ResourceSku -> Sku
  - ResourcePlan -> Plan

Note: both the `#deprecated alias` and in some cases `TrackResource<T>`
and `Foundations.TrackResource` may cause spec break.
`rest-api-specs/typespec-next` will be checked and updated if this is
approved.

---------

Co-authored-by: Timothee Guerin <[email protected]>
  • Loading branch information
allenjzhang and timotheeguerin authored May 7, 2024
1 parent 7cf57c6 commit 079aa68
Show file tree
Hide file tree
Showing 22 changed files with 405 additions and 201 deletions.
20 changes: 20 additions & 0 deletions .chronus/changes/azhang_armReorg-2024-3-29-17-13-46.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
changeKind: deprecation
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Renaming internal TypeSpec ARM foundation model names to be consistent with ARM common-type definitions.
However, these are `Azure.Resource.Manager.Foundations` models that would not normally be used directly in service specs.

- Deprecate `Foundations.ArmResource`. `Foundations.Resource` should be used instead.

- Deprecate `Foundations.ResourceSkuType`. `Foundations.Sku` should be used instead.

- Deprecate `Foundations.ResourcePlanType`. `Foundations.Plan` should be used instead.

- Deprecate `Foundations.TrackedResourceBase`. `Foundations.TrackedResource` should be used instead.

- Deprecate `Foundations.ProxyResourceBase`. `Foundations.ProxyResource` should be used instead.

- Deprecate `Foundations.ExtensionResourceBase`. `Foundations.ExtensionResource` should be used instead.
160 changes: 81 additions & 79 deletions docs/libraries/azure-resource-manager/reference/data-types.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/libraries/azure-resource-manager/reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,16 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager

### Models

- [`ArmResource`](./data-types.md#Azure.ResourceManager.Foundations.ArmResource)
- [`ArmResourceBase`](./data-types.md#Azure.ResourceManager.Foundations.ArmResourceBase)
- [`ArmTagsProperty`](./data-types.md#Azure.ResourceManager.Foundations.ArmTagsProperty)
- [`AzureEntityResource`](./data-types.md#Azure.ResourceManager.Foundations.AzureEntityResource)
- [`CheckNameAvailabilityRequest`](./data-types.md#Azure.ResourceManager.Foundations.CheckNameAvailabilityRequest)
- [`CheckNameAvailabilityResponse`](./data-types.md#Azure.ResourceManager.Foundations.CheckNameAvailabilityResponse)
- [`DefaultBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.DefaultBaseParameters)
- [`ErrorAdditionalInfo`](./data-types.md#Azure.ResourceManager.Foundations.ErrorAdditionalInfo)
- [`ErrorDetail`](./data-types.md#Azure.ResourceManager.Foundations.ErrorDetail)
- [`ExtendedLocation`](./data-types.md#Azure.ResourceManager.Foundations.ExtendedLocation)
- [`ExtensionBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionBaseParameters)
- [`ExtensionResourceBase`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionResourceBase)
- [`ExtensionResource`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionResource)
- [`ExtensionScope`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionScope)
- [`LocationBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.LocationBaseParameters)
- [`LocationScope`](./data-types.md#Azure.ResourceManager.Foundations.LocationScope)
Expand All @@ -210,21 +209,22 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager
- [`OperationIdParameter`](./data-types.md#Azure.ResourceManager.Foundations.OperationIdParameter)
- [`OperationListResult`](./data-types.md#Azure.ResourceManager.Foundations.OperationListResult)
- [`OperationStatusResult`](./data-types.md#Azure.ResourceManager.Foundations.OperationStatusResult)
- [`ProxyResourceBase`](./data-types.md#Azure.ResourceManager.Foundations.ProxyResourceBase)
- [`Plan`](./data-types.md#Azure.ResourceManager.Foundations.Plan)
- [`ProxyResource`](./data-types.md#Azure.ResourceManager.Foundations.ProxyResource)
- [`ProxyResourceUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.ProxyResourceUpdateModel)
- [`Resource`](./data-types.md#Azure.ResourceManager.Foundations.Resource)
- [`ResourceGroupBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.ResourceGroupBaseParameters)
- [`ResourceGroupScope`](./data-types.md#Azure.ResourceManager.Foundations.ResourceGroupScope)
- [`ResourcePlanType`](./data-types.md#Azure.ResourceManager.Foundations.ResourcePlanType)
- [`ResourceSkuType`](./data-types.md#Azure.ResourceManager.Foundations.ResourceSkuType)
- [`ResourceUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.ResourceUpdateModel)
- [`ResourceUpdateModelProperties`](./data-types.md#Azure.ResourceManager.Foundations.ResourceUpdateModelProperties)
- [`Sku`](./data-types.md#Azure.ResourceManager.Foundations.Sku)
- [`SubscriptionBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.SubscriptionBaseParameters)
- [`SubscriptionScope`](./data-types.md#Azure.ResourceManager.Foundations.SubscriptionScope)
- [`SystemAssignedServiceIdentity`](./data-types.md#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentity)
- [`SystemData`](./data-types.md#Azure.ResourceManager.Foundations.SystemData)
- [`TagsUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.TagsUpdateModel)
- [`TenantBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.TenantBaseParameters)
- [`TenantScope`](./data-types.md#Azure.ResourceManager.Foundations.TenantScope)
- [`TrackedResourceBase`](./data-types.md#Azure.ResourceManager.Foundations.TrackedResourceBase)
- [`TrackedResource`](./data-types.md#Azure.ResourceManager.Foundations.TrackedResource)
- [`UserAssignedIdentities`](./data-types.md#Azure.ResourceManager.Foundations.UserAssignedIdentities)
- [`UserAssignedIdentity`](./data-types.md#Azure.ResourceManager.Foundations.UserAssignedIdentity)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.ResourceManager;
using Azure.ResourceManager.Foundations;
using Autorest;

@armProviderNamespace
Expand Down Expand Up @@ -164,7 +163,7 @@ interface MarketplaceAgreements extends ResourceListBySubscription<ConfluentAgre
@doc("Create a new marketplace agreement.")
@armResourceCreateOrUpdate(ConfluentAgreementResource)
create(
...SubscriptionScope<ConfluentAgreementResource>,
...Foundations.SubscriptionScope<ConfluentAgreementResource>,
...KeysOf<ConfluentAgreementResource>,

@doc("The agreement details.")
Expand Down
25 changes: 13 additions & 12 deletions packages/typespec-azure-resource-manager/lib/arm.foundations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ enum ResourceHome {
*
* @template Resource The type of the resource.
*/
alias BaseParameters<Resource extends ArmResourceBase> = DefaultBaseParameters<Resource>;
alias BaseParameters<Resource extends {}> = DefaultBaseParameters<Resource>;

/**
* Base parameters for a resource.
* @template Resource The type of the resource.
*/
@resourceBaseParametersOf(Resource)
model DefaultBaseParameters<Resource extends ArmResourceBase> {
model DefaultBaseParameters<Resource extends {}> {
...ApiVersionParameter;

// unless tenant or extension
Expand Down Expand Up @@ -97,7 +97,7 @@ model ExtensionBaseParameters is TenantBaseParameters {
@doc("The updatable properties of the {name}.", Resource)
@friendlyName("{name}UpdateProperties", Resource)
model ResourceUpdateModelProperties<
Resource extends ArmResource,
Resource extends Foundations.Resource,
Properties extends TypeSpec.Reflection.Model
> is OptionalProperties<UpdateableProperties<Properties>>;

Expand All @@ -111,7 +111,7 @@ model ResourceUpdateModelProperties<
@friendlyName("{name}Update", Resource)
@omitIfEmpty("properties")
model ResourceUpdateModel<
Resource extends ArmResource,
Resource extends Foundations.Resource,
Properties extends TypeSpec.Reflection.Model
> is OptionalProperties<UpdateableProperties<OmitProperties<Resource, "Name" | "name">>> {
@extension("x-ms-client-flatten", true)
Expand All @@ -124,47 +124,48 @@ model ResourceUpdateModel<
*/
@doc("The type used for updating tags in {name} resources.", Resource)
@friendlyName("{name}TagsUpdate", Resource)
model TagsUpdateModel<Resource extends ArmResource> {
model TagsUpdateModel<Resource extends Foundations.Resource> {
...ArmTagsProperty;
}

// Tenant resource operation definitions

alias TenantParentScope<Resource extends ArmResource> = TenantScope<Resource>;
alias TenantParentScope<Resource extends Foundations.Resource> = TenantScope<Resource>;

/**
* Parameter model for listing a resource at the tenant scope
* @template Resource The type of the resource.
*/
model TenantScope<Resource extends ArmResource>
model TenantScope<Resource extends Foundations.Resource>
is ResourceParentParameters<Resource, TenantBaseParameters>;

/**
* Parameter model for listing a resource at the subscription scope
* @template Resource The type of the resource.
*/
model SubscriptionScope<Resource extends ArmResource>
model SubscriptionScope<Resource extends Foundations.Resource>
is ResourceParentParameters<Resource, SubscriptionBaseParameters>;

/**
* Parameter model for listing a resource at the location scope
* @template Resource The type of the resource.
*/
model LocationScope<Resource extends ArmResource>
model LocationScope<Resource extends Foundations.Resource>
is ResourceParentParameters<Resource, LocationBaseParameters>;

/**
* Parameter model for listing an extension resource
* @template Resource The type of the resource.
*/
model ExtensionScope<Resource extends ArmResource>
model ExtensionScope<Resource extends Foundations.Resource>
is ResourceParentParameters<Resource, ExtensionBaseParameters>;

/**
* Parameter model for listing a resource at the resource group scope
* @template Resource The type of the resource.
*/
model ResourceGroupScope<Resource extends ArmResource> is ResourceParentParameters<Resource>;
model ResourceGroupScope<Resource extends Foundations.Resource>
is ResourceParentParameters<Resource>;

/**
* The type used for update operations of the resource.
Expand All @@ -174,7 +175,7 @@ model ResourceGroupScope<Resource extends ArmResource> is ResourceParentParamete
@doc("The type used for update operations of the {name}.", Resource)
@friendlyName("{name}Update", Resource)
model ProxyResourceUpdateModel<
Resource extends ArmResource,
Resource extends Foundations.Resource,
Properties extends TypeSpec.Reflection.Model
> {
@extension("x-ms-client-flatten", true)
Expand Down
1 change: 1 addition & 0 deletions packages/typespec-azure-resource-manager/lib/arm.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "@azure-tools/typespec-azure-core";

import "./arm.foundations.tsp";
import "./common-types/common-types.tsp";
import "./common-types/backcompat.tsp";
import "./common-types/types.tsp";
import "./common-types/managed-identity.tsp";
import "./common-types/private-links.tsp";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Azure.ResourceManager.Foundations;

#deprecated "Please use Foundations.Resource instead of Foundations.ArmResource"
alias ArmResource = Resource;

#deprecated "Please use Foundations.TrackedResource instead of Foundations.TrackedResourceBase"
alias TrackedResourceBase = TrackedResource;

#deprecated "Please use Foundations.ProxyResource instead of Foundations.ProxyResourceBase"
alias ProxyResourceBase = ProxyResource;

#deprecated "Please use Foundations.ProxyResource instead of Foundations.ExtensionResourceBase"
alias ExtensionResourceBase = ExtensionResource;

#deprecated "Please use Foundations.Sku instead of Foundations.ResourceSkuType"
alias ResourceSkuType = Sku;

#deprecated "Please use Foundations.Plan instead of Foundations.ResourcePlanType"
alias ResourcePlanType = Plan;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ model PrivateEndpoint {
}

/** The private endpoint connection resource */
model PrivateEndpointConnection extends Azure.ResourceManager.Foundations.ProxyResourceBase {
model PrivateEndpointConnection extends Azure.ResourceManager.Foundations.ProxyResource {
/** The private endpoint connection properties */
properties?: PrivateEndpointConnectionProperties;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ union PrivateEndpointServiceConnectionStatus {
string,
}

model PrivateLinkResource extends Azure.ResourceManager.Foundations.ProxyResourceBase {
model PrivateLinkResource extends Azure.ResourceManager.Foundations.ProxyResource {
/** Properties of the private link resource. */
properties?: PrivateLinkResourceProperties;
}
Expand Down
34 changes: 21 additions & 13 deletions packages/typespec-azure-resource-manager/lib/common-types/types.tsp
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
using TypeSpec.Http;
using TypeSpec.OpenAPI;
using Azure.Core;
using Azure.ResourceManager.Private;

namespace Azure.ResourceManager.Foundations;

/** Base class used for type definitions */
model ArmResourceBase {}

/**
* Base model that defines common properties for all Azure Resource Manager resources.
*/
@doc("Common properties for all Azure Resource Manager resources.")
model ArmResource extends ArmResourceBase {
model Resource {
@doc("Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}")
@visibility("read")
id: string;
id?: string;

@doc("The name of the resource")
@visibility("read")
name: string;
name?: string;

@doc("The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"")
@visibility("read")
type: string;
type?: string;

@doc("Azure Resource Manager metadata containing createdBy and modifiedBy information.")
@visibility("read")
systemData?: SystemData;
}

/** The resource model definition for an Azure Resource Manager resource with an etag. */
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v5)
model AzureEntityResource extends Resource {
/** Resource Etag. */
@visibility("read")
etag: string;
}

/**
* Standard type definition for Azure Resource Manager Tags property.
*
Expand All @@ -46,8 +54,8 @@ model ArmTagsProperty {
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v5)
@doc("The resource model definition for an Azure Resource Manager tracked top level resource")
model TrackedResourceBase extends ArmResource {
@doc("The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'")
model TrackedResource extends Resource {
@doc("The geo-location where the resource lives")
@visibility("read", "create")
location: string;
Expand All @@ -62,7 +70,7 @@ model TrackedResourceBase extends ArmResource {
@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v5)
model ProxyResourceBase extends ArmResource {}
model ProxyResource extends Resource {}

/**
* The base extension resource.
Expand All @@ -72,7 +80,7 @@ model ProxyResourceBase extends ArmResource {}
@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v5)
model ExtensionResourceBase extends ArmResource {}
model ExtensionResource extends Resource {}

/**
* The SKU (Stock Keeping Unit) assigned to this resource.
Expand All @@ -81,7 +89,7 @@ model ExtensionResourceBase extends ArmResource {}
@armCommonDefinition("Sku", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("Sku", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("Sku", Azure.ResourceManager.CommonTypes.Versions.v5)
model ResourceSkuType {
model Sku {
@doc("The name of the SKU, usually a combination of letters and numbers, for example, 'P3'")
name: string;

Expand Down Expand Up @@ -379,7 +387,7 @@ union createdByType {
@armCommonDefinition("Plan", Azure.ResourceManager.CommonTypes.Versions.v3)
@armCommonDefinition("Plan", Azure.ResourceManager.CommonTypes.Versions.v4)
@armCommonDefinition("Plan", Azure.ResourceManager.CommonTypes.Versions.v5)
model ResourcePlanType {
model Plan {
@doc("A user defined name of the 3rd Party Artifact that is being procured.")
name: string;

Expand Down
Loading

0 comments on commit 079aa68

Please sign in to comment.