diff --git a/.chronus/changes/remove-restrictions-armresourcelist-2024-9-11-10-42-44.md b/.chronus/changes/remove-restrictions-armresourcelist-2024-9-11-10-42-44.md new file mode 100644 index 0000000000..d113bf389b --- /dev/null +++ b/.chronus/changes/remove-restrictions-armresourcelist-2024-9-11-10-42-44.md @@ -0,0 +1,8 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Remove restrictions requiring Foundation.Resource in ArmResourceListByParent. This will allow using the template for non-standard resources / collection actions that return a list. +As part of the change, the response can now return any type. This will be specified in the response section using a new `ResourceListCustomResult` model. diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 4eebcf31d3..2c86ffa9b9 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -728,6 +728,27 @@ model Foo is TrackedResource { | ----- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | kind? | `string` | Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. | +### `ResourceListCustomResult` {#Azure.ResourceManager.ResourceListCustomResult} + +Paged response containing results + +```typespec +model Azure.ResourceManager.ResourceListCustomResult +``` + +#### Template Parameters + +| Name | Description | +| ------ | ----------------------------------------------------- | +| Result | The type of the values returned in the paged response | + +#### Properties + +| Name | Type | Description | +| --------- | ---------------- | ---------------------------------- | +| value | `Array` | The items on this page | +| nextLink? | `string` | The link to the next page of items | + ### `ResourceListResult` {#Azure.ResourceManager.ResourceListResult} Paged response containing resources diff --git a/docs/libraries/azure-resource-manager/reference/index.mdx b/docs/libraries/azure-resource-manager/reference/index.mdx index 7e2090e96a..9cd18c7660 100644 --- a/docs/libraries/azure-resource-manager/reference/index.mdx +++ b/docs/libraries/azure-resource-manager/reference/index.mdx @@ -150,6 +150,7 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`ResourceGroupLocationResource`](./data-types.md#Azure.ResourceManager.ResourceGroupLocationResource) - [`ResourceInstanceParameters`](./data-types.md#Azure.ResourceManager.ResourceInstanceParameters) - [`ResourceKindProperty`](./data-types.md#Azure.ResourceManager.ResourceKindProperty) +- [`ResourceListCustomResult`](./data-types.md#Azure.ResourceManager.ResourceListCustomResult) - [`ResourceListResult`](./data-types.md#Azure.ResourceManager.ResourceListResult) - [`ResourceNameParameter`](./data-types.md#Azure.ResourceManager.ResourceNameParameter) - [`ResourceParentParameters`](./data-types.md#Azure.ResourceManager.ResourceParentParameters) diff --git a/packages/typespec-azure-resource-manager/lib/models.tsp b/packages/typespec-azure-resource-manager/lib/models.tsp index 564079ee93..f59be03064 100644 --- a/packages/typespec-azure-resource-manager/lib/models.tsp +++ b/packages/typespec-azure-resource-manager/lib/models.tsp @@ -295,6 +295,23 @@ model ResourceKindProperty { @friendlyName("{name}ListResult", Resource) model ResourceListResult is Azure.Core.Page; +/** + * Paged response containing results + * @template Result The type of the values returned in the paged response + */ +@doc("The custom response of a list operation.") +@friendlyName("{name}ListResult", Result) +@pagedResult +model ResourceListCustomResult { + /** The items on this page */ + @items + value: Result[]; + + /** The link to the next page of items */ + @nextLink + nextLink?: string; +} + #deprecated "`ResourcePlan` will be deprecated. Please use `ResourcePlanProperty` instead." alias ResourcePlan = ResourcePlanProperty; /**