Skip to content

Commit

Permalink
Add ArmResourceHead operation template (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
allenjzhang authored Mar 2, 2024
1 parent 69e3f7a commit 53cc4de
Show file tree
Hide file tree
Showing 25 changed files with 528 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/azhang_ArmHead-2024-1-20-8-59-26.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Added `ArmResourceHead` operation template
24 changes: 24 additions & 0 deletions docs/libraries/azure-resource-manager/reference/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ model Azure.ResourceManager.ArmResourceCreatedSyncResponse<Resource>
| body | `Resource` | The body type of the operation request or response. |
| statusCode | `201` | The status code. |

### `ArmResourceExistsResponse` {#Azure.ResourceManager.ArmResourceExistsResponse}

```typespec
model Azure.ResourceManager.ArmResourceExistsResponse
```

#### Properties

| Name | Type | Description |
| ---------- | ----- | ---------------- |
| statusCode | `204` | The status code. |

### `ArmResourceNotFoundResponse` {#Azure.ResourceManager.ArmResourceNotFoundResponse}

```typespec
model Azure.ResourceManager.ArmResourceNotFoundResponse
```

#### Properties

| Name | Type | Description |
| ---------- | ----- | ---------------- |
| statusCode | `404` | The status code. |

### `ArmResourceUpdatedResponse` {#Azure.ResourceManager.ArmResourceUpdatedResponse}

```typespec
Expand Down
3 changes: 3 additions & 0 deletions docs/libraries/azure-resource-manager/reference/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager
- [`ArmResourceActionNoContentSync`](./interfaces.md#Azure.ResourceManager.ArmResourceActionNoContentSync)
- [`ArmResourceActionNoResponseContentAsync`](./interfaces.md#Azure.ResourceManager.ArmResourceActionNoResponseContentAsync)
- [`ArmResourceActionSync`](./interfaces.md#Azure.ResourceManager.ArmResourceActionSync)
- [`ArmResourceCheckExistence`](./interfaces.md#Azure.ResourceManager.ArmResourceCheckExistence)
- [`ArmResourceCreateOrReplaceAsync`](./interfaces.md#Azure.ResourceManager.ArmResourceCreateOrReplaceAsync)
- [`ArmResourceCreateOrReplaceSync`](./interfaces.md#Azure.ResourceManager.ArmResourceCreateOrReplaceSync)
- [`ArmResourceCreateOrUpdateAsync`](./interfaces.md#Azure.ResourceManager.ArmResourceCreateOrUpdateAsync)
Expand Down Expand Up @@ -130,6 +131,8 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager
- [`ArmOperationStatus`](./data-types.md#Azure.ResourceManager.ArmOperationStatus)
- [`ArmResourceCreatedResponse`](./data-types.md#Azure.ResourceManager.ArmResourceCreatedResponse)
- [`ArmResourceCreatedSyncResponse`](./data-types.md#Azure.ResourceManager.ArmResourceCreatedSyncResponse)
- [`ArmResourceExistsResponse`](./data-types.md#Azure.ResourceManager.ArmResourceExistsResponse)
- [`ArmResourceNotFoundResponse`](./data-types.md#Azure.ResourceManager.ArmResourceNotFoundResponse)
- [`ArmResourceUpdatedResponse`](./data-types.md#Azure.ResourceManager.ArmResourceUpdatedResponse)
- [`ArmResponse`](./data-types.md#Azure.ResourceManager.ArmResponse)
- [`CustomerManagedKeyEncryption`](./data-types.md#Azure.ResourceManager.CustomerManagedKeyEncryption)
Expand Down
34 changes: 26 additions & 8 deletions docs/libraries/azure-resource-manager/reference/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,24 @@ op Azure.ResourceManager.ArmResourceActionSync(provider: "Microsoft.ThisWillBeRe
| Parameters | Optional. Additional parameters after the path parameters |
| Error | Optional. The error response, if non-standard. |

### `ArmResourceCheckExistence` {#Azure.ResourceManager.ArmResourceCheckExistence}

Check a resource's existence via HEAD operation

```typespec
op Azure.ResourceManager.ArmResourceCheckExistence(provider: "Microsoft.ThisWillBeReplaced"): Response | Error
```

#### Template Parameters

| Name | Description |
| -------------- | --------------------------------------------------------- |
| Resource | the resource being checked |
| BaseParameters | Optional. Allows overriding the operation parameters |
| Parameters | Optional. Additional parameters after the path parameters |
| Response | Optional. The success response for the read operation |
| Error | Optional. The error response, if non-standard. |

### `ArmResourceCreateOrReplaceAsync` {#Azure.ResourceManager.ArmResourceCreateOrReplaceAsync}

```typespec
Expand All @@ -781,7 +799,7 @@ op Azure.ResourceManager.ArmResourceCreateOrReplaceAsync(provider: "Microsoft.Th

| Name | Description |
| -------------- | ----------------------------------------------------------------------- |
| Resource | the resource being patched |
| Resource | the resource being created or replaced |
| BaseParameters | Optional. Allows overriding the operation parameters |
| LroHeaders | Optional. Allows overriding the lro headers returned on resource create |
| Parameters | Optional. Additional parameters after the path parameters |
Expand All @@ -800,7 +818,7 @@ op Azure.ResourceManager.ArmResourceCreateOrReplaceSync(provider: "Microsoft.Thi

| Name | Description |
| -------------- | --------------------------------------------------------------- |
| Resource | the resource being patched |
| Resource | the resource being created or replaced |
| BaseParameters | Optional. Allows overriding the operation parameters |
| Parameters | Optional. Additional parameters after the path parameters |
| Response | Optional. The success response for the createOrUpdate operation |
Expand All @@ -818,7 +836,7 @@ op Azure.ResourceManager.ArmResourceCreateOrUpdateAsync(provider: "Microsoft.Thi

| Name | Description |
| -------------- | ----------------------------------------------------------------------- |
| Resource | the resource being patched |
| Resource | the resource being created or updated |
| BaseParameters | Optional. Allows overriding the operation parameters |
| LroHeaders | Optional. Allows overriding the lro headers returned on resource create |
| Parameters | Optional. Additional parameters after the path parameters |
Expand All @@ -837,7 +855,7 @@ op Azure.ResourceManager.ArmResourceCreateOrUpdateSync(provider: "Microsoft.This

| Name | Description |
| -------------- | --------------------------------------------------------------- |
| Resource | the resource being patched |
| Resource | the resource being created or updated |
| BaseParameters | Optional. Allows overriding the operation parameters |
| Parameters | Optional. Additional parameters after the path parameters |
| Response | Optional. The success response for the createOrUpdate operation |
Expand Down Expand Up @@ -916,7 +934,7 @@ op Azure.ResourceManager.ArmResourceDeleteWithoutOkAsync(provider: "Microsoft.Th
A resource list operation, with scope determined by BaseParameters

```typespec
op Azure.ResourceManager.ArmResourceListAtScope(provider: "Microsoft.ThisWillBeReplaced"): Response | Azure.ResourceManager.ErrorResponse
op Azure.ResourceManager.ArmResourceListAtScope(provider: "Microsoft.ThisWillBeReplaced"): Response | Error
```

#### Template Parameters
Expand All @@ -934,7 +952,7 @@ op Azure.ResourceManager.ArmResourceListAtScope(provider: "Microsoft.ThisWillBeR
A resource list operation, at the scope of the resource's parent

```typespec
op Azure.ResourceManager.ArmResourceListByParent(provider: "Microsoft.ThisWillBeReplaced"): Response | Azure.ResourceManager.ErrorResponse
op Azure.ResourceManager.ArmResourceListByParent(provider: "Microsoft.ThisWillBeReplaced"): Response | Error
```

#### Template Parameters
Expand Down Expand Up @@ -985,14 +1003,14 @@ op Azure.ResourceManager.ArmResourcePatchSync(provider: "Microsoft.ThisWillBeRep
A resource GET operation

```typespec
op Azure.ResourceManager.ArmResourceRead(provider: "Microsoft.ThisWillBeReplaced"): Response | Azure.ResourceManager.ErrorResponse
op Azure.ResourceManager.ArmResourceRead(provider: "Microsoft.ThisWillBeReplaced"): Response | Error
```

#### Template Parameters

| Name | Description |
| -------------- | --------------------------------------------------------- |
| Resource | the resource being patched |
| Resource | the resource being read |
| BaseParameters | Optional. Allows overriding the operation parameters |
| Parameters | Optional. Additional parameters after the path parameters |
| Response | Optional. The success response for the read operation |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ interface RoleAssignments {
update is ArmResourcePatchSync<RoleAssignment, RoleAssignmentProperties>;
delete is ArmResourceDeleteSync<RoleAssignment>;
list is ArmResourceListByParent<RoleAssignment>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<RoleAssignment>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ interface Employees {
list is ArmResourceListByParent<Employee>;
/** A sample resource action that move employee to different location */
move is ArmResourceActionSync<Employee, MoveRequest, MoveResponse>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}

/** Employee move request */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,7 @@ interface Employees {

/** Sample async action with no request body and response */
actionNoReqResAsync is ArmResourceActionNoResponseContentAsync<Employee, void>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ interface Employees {
listBySubscription is ArmListBySubscription<Employee>;
/** A sample resource action that move employee to different location */
move is ArmResourceActionSync<Employee, MoveRequest, MoveResponse>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}

/** Employee move request */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ interface Employees {
list is ArmResourceListByParent<Employee>;
/** A sample resource action that move employee to different location */
move is ArmResourceActionSync<Employee, MoveRequest, MoveResponse>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}

/** Employee move request */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ interface Employees {
update is ArmResourcePatchSync<Employee, EmployeeProperties>;
delete is ArmResourceDeleteSync<Employee>;
list is ArmResourceListByParent<Employee>;

/** A sample resource action that move employee to different location */
move is ArmResourceActionSync<Employee, MoveRequest, MoveResponse>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}

/** Employee move request */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ interface Employees {
delete is ArmResourceDeleteSync<Employee>;
listByResourceGroup is ArmResourceListByParent<Employee>;
listBySubscription is ArmListBySubscription<Employee>;

/** A sample resource action that move employee to different location */
move is ArmResourceActionSync<Employee, MoveRequest, MoveResponse>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}

/** Employee move request */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ interface Employees {
list is ArmResourceListByParent<Employee>;
/** A sample resource action that move employee to different location */
move is ArmResourceActionSync<Employee, MoveRequest, MoveResponse>;

/** A sample HEAD operation to check resource existence */
checkExistence is ArmResourceCheckExistence<Employee>;
}

/** Employee move request */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,43 @@
}
}
}
},
"head": {
"operationId": "RoleAssignments_CheckExistence",
"tags": [
"RoleAssignments"
],
"description": "A sample HEAD operation to check resource existence",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/Azure.ResourceManager.ResourceUriParameter"
},
{
"name": "roleAssignmentName",
"in": "path",
"description": "Name of roleAssignment",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9-]{3,24}$"
}
],
"responses": {
"204": {
"description": "The Azure resource exists"
},
"404": {
"description": "The Azure resource is not found"
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
}
}
},
"/providers/Microsoft.ContosoProviderHub/operations": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,49 @@
}
}
}
},
"head": {
"operationId": "Employees_CheckExistence",
"tags": [
"Employees"
],
"description": "A sample HEAD operation to check resource existence",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/LocationParameter"
},
{
"name": "employeeName",
"in": "path",
"description": "Name of employee",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9-]{3,24}$"
}
],
"responses": {
"204": {
"description": "The Azure resource exists"
},
"404": {
"description": "The Azure resource is not found"
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
}
}
},
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/locations/{location}/employees/{employeeName}/move": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,46 @@
}
}
}
},
"head": {
"operationId": "Employees_CheckExistence",
"tags": [
"Employees"
],
"description": "A sample HEAD operation to check resource existence",
"parameters": [
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter"
},
{
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter"
},
{
"name": "employeeName",
"in": "path",
"description": "Name of employee",
"required": true,
"type": "string",
"pattern": "^[a-zA-Z0-9-]{3,24}$"
}
],
"responses": {
"204": {
"description": "The Azure resource exists"
},
"404": {
"description": "The Azure resource is not found"
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse"
}
}
}
}
},
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContosoProviderHub/employees/{employeeName}/actionAsync": {
Expand Down
Loading

0 comments on commit 53cc4de

Please sign in to comment.