Skip to content

Commit

Permalink
Fix ArmResourcePatch templates and incorporate common-types updates Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
markcowl authored Jul 15, 2024
1 parent b4df7c5 commit 685d6ef
Show file tree
Hide file tree
Showing 21 changed files with 661 additions and 281 deletions.
8 changes: 8 additions & 0 deletions .chronus/changes/fix-patch-2024-5-13-3-36-28.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@azure-tools/typespec-autorest"
---

Fix patch models for common-types
8 changes: 8 additions & 0 deletions .chronus/changes/resource-patch-2024-5-27-2-24-51.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Fix ArmResourcePatch templates and incorporate common-types updates
6 changes: 6 additions & 0 deletions docs/emitters/typespec-autorest/reference/emitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,9 @@ Determine whether and how to emit x-ms-long-running-operation-options for lro re
**Type:** `boolean`

Back-compat flag. If true, continue to emit `x-ms-client-flatten` in for some of the ARM resource properties.

### `emit-common-types-schema`

**Type:** `"never" | "for-visibility-changes"`

Determine whether and how to emit schemas for common-types rather than referencing them
4 changes: 2 additions & 2 deletions docs/libraries/azure-resource-manager/reference/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ op Azure.ResourceManager.ArmResourceListByParent(provider: "Microsoft.ThisWillBe
### `ArmResourcePatchAsync` {#Azure.ResourceManager.ArmResourcePatchAsync}

```typespec
op Azure.ResourceManager.ArmResourcePatchAsync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel<Resource, Properties>): Azure.ResourceManager.ArmResponse<ResponseBody> | Azure.ResourceManager.ArmAcceptedLroResponse<Description, LroHeaders> | Azure.ResourceManager.CommonTypes.ErrorResponse
op Azure.ResourceManager.ArmResourcePatchAsync(provider: "Microsoft.ThisWillBeReplaced", properties: Resource): Azure.ResourceManager.ArmResponse<ResponseBody> | Azure.ResourceManager.ArmAcceptedLroResponse<Description, LroHeaders> | Azure.ResourceManager.CommonTypes.ErrorResponse
```

#### Template Parameters
Expand All @@ -986,7 +986,7 @@ op Azure.ResourceManager.ArmResourcePatchAsync(provider: "Microsoft.ThisWillBeRe
### `ArmResourcePatchSync` {#Azure.ResourceManager.ArmResourcePatchSync}

```typespec
op Azure.ResourceManager.ArmResourcePatchSync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel<Resource, Properties>): Azure.ResourceManager.ArmResponse<ResponseBody> | Azure.ResourceManager.CommonTypes.ErrorResponse
op Azure.ResourceManager.ArmResourcePatchSync(provider: "Microsoft.ThisWillBeReplaced", properties: Resource): Azure.ResourceManager.ArmResponse<ResponseBody> | Azure.ResourceManager.CommonTypes.ErrorResponse
```

#### Template Parameters
Expand Down
4 changes: 4 additions & 0 deletions eng/scripts/lint-resourcemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const suppressedErrors = [
id: "D5001",
code: "XmsExamplesRequired",
},
{
id: "R2026",
code: "AvoidAnonymousTypes",
},
];

async function lintInternal(swagger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@
"description": "The resource properties to be updated.",
"required": true,
"schema": {
"$ref": "#/definitions/TestTrackedResource2Update"
"$ref": "#/definitions/Microsoft.OperationsTest.TestTrackedResource2Update"
}
}
],
Expand Down Expand Up @@ -1729,15 +1729,15 @@
"description": "The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource."
},
"plan": {
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/Plan",
"$ref": "#/definitions/Azure.ResourceManager.CommonTypes.PlanUpdate",
"description": "Details of the resource plan."
},
"sku": {
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/Sku",
"$ref": "#/definitions/Azure.ResourceManager.CommonTypes.SkuUpdate",
"description": "The SKU (Stock Keeping Unit) assigned to this resource."
},
"identity": {
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/managedidentity.json#/definitions/ManagedServiceIdentity",
"$ref": "#/definitions/Azure.ResourceManager.CommonTypes.ManagedServiceIdentityUpdate",
"description": "The managed service identities assigned to this resource."
},
"tags": {
Expand Down Expand Up @@ -1765,6 +1765,100 @@
}
}
},
"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityUpdate": {
"type": "object",
"description": "Managed service identity (system assigned and/or user assigned identities)",
"properties": {
"type": {
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/managedidentity.json#/definitions/ManagedServiceIdentityType",
"description": "The type of managed identity assigned to this resource."
},
"userAssignedIdentities": {
"type": "object",
"description": "The identities assigned to this resource by the user.",
"additionalProperties": {
"allOf": [
{
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/managedidentity.json#/definitions/UserAssignedIdentity"
}
],
"type": "object",
"x-nullable": true
}
}
}
},
"Azure.ResourceManager.CommonTypes.PlanUpdate": {
"type": "object",
"description": "Plan for the resource.",
"properties": {
"name": {
"type": "string",
"description": "A user defined name of the 3rd Party Artifact that is being procured."
},
"publisher": {
"type": "string",
"description": "The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic"
},
"product": {
"type": "string",
"description": "The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding."
},
"promotionCode": {
"type": "string",
"description": "A publisher provided promotion code as provisioned in Data Market for the said product/artifact."
},
"version": {
"type": "string",
"description": "The version of the desired product/artifact."
}
}
},
"Azure.ResourceManager.CommonTypes.SkuUpdate": {
"type": "object",
"description": "The resource model definition representing SKU",
"properties": {
"name": {
"type": "string",
"description": "The name of the SKU. Ex - P3. It is typically a letter+number code"
},
"tier": {
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/SkuTier",
"description": "This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT."
},
"size": {
"type": "string",
"description": "The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code."
},
"family": {
"type": "string",
"description": "If the service has different generations of hardware, for the same SKU, then that can be captured here."
},
"capacity": {
"type": "integer",
"format": "int32",
"description": "If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted."
}
}
},
"Azure.ResourceManager.CommonTypes.TrackedResourceUpdate": {
"type": "object",
"description": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'",
"properties": {
"tags": {
"type": "object",
"description": "Resource tags.",
"additionalProperties": {
"type": "string"
}
}
},
"allOf": [
{
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/Resource"
}
]
},
"Azure.ResourceManager.ResourceProvisioningState": {
"type": "string",
"description": "The provisioning state of a resource type.",
Expand Down Expand Up @@ -1962,6 +2056,22 @@
}
]
},
"Microsoft.OperationsTest.TestTrackedResource2Update": {
"type": "object",
"description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.",
"properties": {
"properties": {
"$ref": "#/definitions/Microsoft.OperationsTest.TestTrackedProperties2",
"description": "The resource-specific properties for this resource.",
"x-ms-client-flatten": true
}
},
"allOf": [
{
"$ref": "#/definitions/Azure.ResourceManager.CommonTypes.TrackedResourceUpdate"
}
]
},
"SystemEnvelopeProvisioningState": {
"type": "string",
"description": "Envelope provisioning state",
Expand Down Expand Up @@ -2127,35 +2237,6 @@
"value"
]
},
"TestTrackedResource2Update": {
"type": "object",
"description": "The type used for update operations of the TestTrackedResource2.",
"properties": {
"tags": {
"type": "object",
"description": "Resource tags.",
"additionalProperties": {
"type": "string"
}
},
"properties": {
"$ref": "#/definitions/TestTrackedResource2UpdateProperties",
"description": "The resource-specific properties for this resource.",
"x-ms-client-flatten": true
}
}
},
"TestTrackedResource2UpdateProperties": {
"type": "object",
"description": "The updatable properties of the TestTrackedResource2.",
"properties": {
"displayName": {
"type": "string",
"description": "Name of the resource",
"default": "default"
}
}
},
"TestTrackedResourceListResult": {
"type": "object",
"description": "The response of a TestTrackedResource list operation.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,24 @@
}
},
"definitions": {
"Azure.ResourceManager.CommonTypes.TrackedResourceUpdate": {
"type": "object",
"description": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'",
"properties": {
"tags": {
"type": "object",
"description": "Resource tags.",
"additionalProperties": {
"type": "string"
}
}
},
"allOf": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/Resource"
}
]
},
"Employee": {
"type": "object",
"description": "A ContosoProviderHub resource",
Expand Down Expand Up @@ -645,41 +663,19 @@
},
"EmployeeUpdate": {
"type": "object",
"description": "The type used for update operations of the Employee.",
"description": "A ContosoProviderHub resource",
"properties": {
"tags": {
"type": "object",
"description": "Resource tags.",
"additionalProperties": {
"type": "string"
}
},
"properties": {
"$ref": "#/definitions/EmployeeUpdateProperties",
"$ref": "#/definitions/EmployeeProperties",
"description": "The resource-specific properties for this resource.",
"x-ms-client-flatten": true
}
}
},
"EmployeeUpdateProperties": {
"type": "object",
"description": "The updatable properties of the Employee.",
"properties": {
"age": {
"type": "integer",
"format": "int32",
"description": "Age of employee"
},
"city": {
"type": "string",
"description": "City of employee"
},
"profile": {
"type": "string",
"format": "base64url",
"description": "Profile of employee"
},
"allOf": [
{
"$ref": "#/definitions/Azure.ResourceManager.CommonTypes.TrackedResourceUpdate"
}
}
]
},
"ProvisioningState": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,25 +450,19 @@
},
"RoleAssignmentUpdate": {
"type": "object",
"description": "The type used for update operations of the RoleAssignment.",
"description": "A ContosoProviderHub resource",
"properties": {
"properties": {
"$ref": "#/definitions/RoleAssignmentUpdateProperties",
"$ref": "#/definitions/RoleAssignmentProperties",
"description": "The resource-specific properties for this resource.",
"x-ms-client-flatten": true
}
}
},
"RoleAssignmentUpdateProperties": {
"type": "object",
"description": "The updatable properties of the RoleAssignment.",
"properties": {
"profile": {
"type": "string",
"format": "base64url",
"description": "Profile of roleAssignment"
},
"allOf": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ProxyResource"
}
}
]
}
},
"parameters": {
Expand Down
Loading

0 comments on commit 685d6ef

Please sign in to comment.