Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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"
---

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<type>` model.
21 changes: 21 additions & 0 deletions docs/libraries/azure-resource-manager/reference/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,27 @@ model Foo is TrackedResource<FooProperties> {
| ----- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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<Result>
```

#### Template Parameters

| Name | Description |
| ------ | ----------------------------------------------------- |
| Result | The type of the values returned in the paged response |

#### Properties

| Name | Type | Description |
| --------- | ---------------- | ---------------------------------- |
| value | `Array<Element>` | The items on this page |
| nextLink? | `string` | The link to the next page of items |

### `ResourceListResult` {#Azure.ResourceManager.ResourceListResult}

Paged response containing resources
Expand Down
2 changes: 2 additions & 0 deletions docs/libraries/azure-resource-manager/reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager

- [`ArmCustomPatchAsync`](./interfaces.md#Azure.ResourceManager.ArmCustomPatchAsync)
- [`ArmCustomPatchSync`](./interfaces.md#Azure.ResourceManager.ArmCustomPatchSync)
- [`ArmCustomReadOperation`](./interfaces.md#Azure.ResourceManager.ArmCustomReadOperation)
- [`ArmListBySubscription`](./interfaces.md#Azure.ResourceManager.ArmListBySubscription)
- [`ArmProviderActionAsync`](./interfaces.md#Azure.ResourceManager.ArmProviderActionAsync)
- [`ArmProviderActionSync`](./interfaces.md#Azure.ResourceManager.ArmProviderActionSync)
Expand Down Expand Up @@ -150,6 +151,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)
Expand Down
14 changes: 14 additions & 0 deletions docs/libraries/azure-resource-manager/reference/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,20 @@ op Azure.ResourceManager.ArmCustomPatchSync(provider: "Microsoft.ThisWillBeRepla
| Response | Optional. The success response for the patch operation |
| Error | Optional. The error response, if non-standard. |

### `ArmCustomReadOperation` {#Azure.ResourceManager.ArmCustomReadOperation}

```typespec
op Azure.ResourceManager.ArmCustomReadOperation(): Response | ErrorResponse
```

#### Template Parameters

| Name | Description |
| ------------- | ----------- |
| Parameters | |
| Response | |
| ErrorResponse | |

### `ArmListBySubscription` {#Azure.ResourceManager.ArmListBySubscription}

A resource list operation, at the subscription scope
Expand Down
17 changes: 17 additions & 0 deletions packages/typespec-azure-resource-manager/lib/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,23 @@ model ResourceKindProperty {
@friendlyName("{name}ListResult", Resource)
model ResourceListResult<Resource extends Foundations.Resource> is Azure.Core.Page<Resource>;

/**
* 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<Result> {
/** 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;
/**
Expand Down
14 changes: 12 additions & 2 deletions packages/typespec-azure-resource-manager/lib/operations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,24 @@ op ArmResourceListByParent<
ParentName extends valueof string = "",
ParentFriendlyName extends valueof string = "",
Parameters extends {} = {},
Response extends {} = ArmResponse<ResourceListResult<Resource>>,
Response = ArmResponse<ResourceListResult<Resource>>,
Error extends {} = ErrorResponse
> is ArmReadOperation<
> is ArmCustomReadOperation<
ResourceParentParameters<Resource, BaseParameters> & Parameters,
Response,
Error
>;

/**
* @dev Template for Azure Resource Manager GET and HEAD Operations.
* @param Parameters The parameter object for the operation.
* @param Response The response or union of responses for success, it can be any type.
* @param ErrorResponse The error response.
*/
op ArmCustomReadOperation<Parameters extends {}, Response, ErrorResponse extends {}>(
Comment thread
AlitzelMendez marked this conversation as resolved.
Outdated
...Parameters,
): Response | ErrorResponse;

/**
* A resource list operation, with scope determined by BaseParameters
* @template Resource the resource being patched
Expand Down