Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added back logic to keep doc unchanged #1146

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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,7 @@
---
changeKind: breaking
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Moved `@armRenameListByOperation` into `Azure.ResourceManager.Private` namespace. Adding back original listByParent doc resolution logic to keep swagger changes to minimal.
20 changes: 0 additions & 20 deletions docs/libraries/azure-resource-manager/reference/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,6 @@ property to the type of the Azure Resource Manager resource.

None

### `@armRenameListByOperation` {#@Azure.ResourceManager.armRenameListByOperation}

Marks the operation as being a collection action

```typespec
@Azure.ResourceManager.armRenameListByOperation(resourceType: Model, parentTypeName?: valueof string, parentFriendlyTypeName?: valueof string)
```

#### Target

`Operation`

#### Parameters

| Name | Type | Description |
| ---------------------- | ---------------- | ------------------------- |
| resourceType | `Model` | Resource |
| parentTypeName | `valueof string` | : Parent type name. |
| parentFriendlyTypeName | `valueof string` | Friendly name for parent. |

### `@armResourceAction` {#@Azure.ResourceManager.armResourceAction}

```typespec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager
- [`@armLibraryNamespace`](./decorators.md#@Azure.ResourceManager.armLibraryNamespace)
- [`@armProviderNamespace`](./decorators.md#@Azure.ResourceManager.armProviderNamespace)
- [`@armProviderNameValue`](./decorators.md#@Azure.ResourceManager.armProviderNameValue)
- [`@armRenameListByOperation`](./decorators.md#@Azure.ResourceManager.armRenameListByOperation)
- [`@armResourceAction`](./decorators.md#@Azure.ResourceManager.armResourceAction)
- [`@armResourceCollectionAction`](./decorators.md#@Azure.ResourceManager.armResourceCollectionAction)
- [`@armResourceCreateOrUpdate`](./decorators.md#@Azure.ResourceManager.armResourceCreateOrUpdate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@
"tags": [
"Tracked2Operations"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List TestTrackedResource2 resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"tags": [
"Widgets"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List WidgetResource resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"tags": [
"Widgets"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List WidgetResource resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"tags": [
"Widgets"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List WidgetResource resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"tags": [
"Widgets"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List WidgetResource resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"tags": [
"RoleAssignments"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List RoleAssignment resources by parent",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by Location",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down Expand Up @@ -399,7 +399,7 @@
"tags": [
"Dependents"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Dependent resources by Employee",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by tenant",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by resource group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"tags": [
"Employees"
],
"description": "A resource list operation, at the scope of the resource's parent",
"description": "List Employee resources by Group",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
Expand Down
21 changes: 0 additions & 21 deletions packages/typespec-azure-resource-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Available ruleSets:
- [`@armLibraryNamespace`](#@armlibrarynamespace)
- [`@armProviderNamespace`](#@armprovidernamespace)
- [`@armProviderNameValue`](#@armprovidernamevalue)
- [`@armRenameListByOperation`](#@armrenamelistbyoperation)
- [`@armResourceAction`](#@armresourceaction)
- [`@armResourceCollectionAction`](#@armresourcecollectionaction)
- [`@armResourceCreateOrUpdate`](#@armresourcecreateorupdate)
Expand Down Expand Up @@ -178,26 +177,6 @@ property to the type of the Azure Resource Manager resource.

None

#### `@armRenameListByOperation`

Marks the operation as being a collection action

```typespec
@Azure.ResourceManager.armRenameListByOperation(resourceType: Model, parentTypeName?: valueof string, parentFriendlyTypeName?: valueof string)
```

##### Target

`Operation`

##### Parameters

| Name | Type | Description |
| ---------------------- | ---------------- | ------------------------- |
| resourceType | `Model` | Resource |
| parentTypeName | `valueof string` | : Parent type name. |
| parentFriendlyTypeName | `valueof string` | Friendly name for parent. |

#### `@armResourceAction`

```typespec
Expand Down
13 changes: 0 additions & 13 deletions packages/typespec-azure-resource-manager/lib/decorators.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,6 @@ extern dec armProviderNameValue(target: Operation | Model);
*/
extern dec armResourceCollectionAction(target: Operation);

/**
* Marks the operation as being a collection action
* @param resourceType Resource
* @param parentTypeName: Parent type name.
* @param parentFriendlyTypeName Friendly name for parent.
*/
extern dec armRenameListByOperation(
target: Operation,
resourceType: Model,
parentTypeName?: valueof string,
parentFriendlyTypeName?: valueof string
);

/**
* @param resourceType Resource model
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ interface ResourceListByParent<
* @template ParentName The name of the parent resource
* @template ParentFriendlyName The friendly name of the parent resource
*/
@armRenameListByOperation(Resource, ParentName, ParentFriendlyName) // This must come before @armResourceList!
@Private.armRenameListByOperation(Resource, ParentName, ParentFriendlyName) // This must come before @armResourceList!
listByParent is ArmResourceListByParent<Resource, BaseParameters, ParentName, ParentFriendlyName>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ op ArmListBySubscription<
@segmentOf(Resource)
@armResourceList(Resource)
@Private.enforceConstraint(Resource, Foundations.Resource)
@Private.defaultListByOperationDoc(Resource)
op ArmResourceListByParent<
Resource extends Foundations.Resource,
BaseParameters = DefaultBaseParameters<Resource>,
Expand All @@ -69,7 +70,7 @@ op ArmResourceListByParent<
@autoRoute
@listsResource(Resource)
@segmentOf(Resource)
@armRenameListByOperation(Resource) // This must come before @armResourceList!
@Private.armRenameListByOperation(Resource) // This must come before @armResourceList!
@armResourceList(Resource)
@Private.enforceConstraint(Resource, Foundations.Resource)
op ArmResourceListAtScope<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,21 @@ extern dec defaultResourceKeySegmentName(
* Note, this is intended for internal use only for now.
*/
extern dec enforceConstraint(target: Operation | Model, sourceType: Model, constraintType: Model);

/**
* Provides default doc for ArmResourceListByParent operation for back compat.
*/
extern dec defaultListByOperationDoc(target: Operation, resource: Model);

/**
* Marks the operation as being a collection action
* @param resourceType Resource
* @param parentTypeName: Parent type name.
* @param parentFriendlyTypeName Friendly name for parent.
*/
extern dec armRenameListByOperation(
allenjzhang marked this conversation as resolved.
Show resolved Hide resolved
target: Operation,
resourceType: Model,
parentTypeName?: valueof string,
parentFriendlyTypeName?: valueof string
);
15 changes: 9 additions & 6 deletions packages/typespec-azure-resource-manager/src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@ export function $armResourceList(
operations.lists[target.name] = operation as ArmResourceOperation;
}

export function $armRenameListByOperation(
export function armRenameListByOperationInternal(
context: DecoratorContext,
entity: Operation,
resourceType: Model,
updateOperationName: boolean = true,
parentTypeName?: string,
parentFriendlyTypeName?: string
) {
Expand Down Expand Up @@ -244,11 +245,13 @@ export function $armRenameListByOperation(
undefined as any
);

// Set the operation name
entity.name =
parentTypeName === "Extension" || parentTypeName === undefined || parentTypeName.length < 1
? "list"
: `listBy${parentTypeName}`;
if (updateOperationName) {
// Set the operation name
entity.name =
parentTypeName === "Extension" || parentTypeName === undefined || parentTypeName.length < 1
? "list"
: `listBy${parentTypeName}`;
}
}

function getArmParentName(program: Program, resource: Model): string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { camelCase } from "change-case";
import pluralize from "pluralize";
import { reportDiagnostic } from "./lib.js";
import { getArmProviderNamespace, isArmLibraryNamespace } from "./namespace.js";
import { armRenameListByOperationInternal } from "./operations.js";
import {
ArmResourceDetails,
ResourceBaseType,
Expand Down Expand Up @@ -350,3 +351,28 @@ function hasProperty(program: Program, model: Model): boolean {
if (model.baseModel) return hasProperty(program, model.baseModel);
return false;
}

export function $defaultListByOperationDoc(
context: DecoratorContext,
entity: Operation,
resource: Model
) {
armRenameListByOperationInternal(context, entity, resource, false);
}

export function $armRenameListByOperation(
context: DecoratorContext,
entity: Operation,
resourceType: Model,
parentTypeName?: string,
parentFriendlyTypeName?: string
) {
armRenameListByOperationInternal(
context,
entity,
resourceType,
true,
parentTypeName,
parentFriendlyTypeName
);
}
Loading