Skip to content

Commit

Permalink
azure-http-specs, add ARM LRO case (#1821)
Browse files Browse the repository at this point in the history
### Context
- fix Azure/cadl-ranch#696
- ARM LRO guideline:
https://github.com/cloud-and-ai-microsoft/resource-provider-contract/blob/master/v1.0/async-api-reference.md
- not covering legacy cases

### Content
|verb|lro type|expected polling pattern|
|--|--|--|
|PUT|AAO|poll AAO, get final result through original(resource) uri
|POST|AAO+Location|poll AAO, get final result through Location|
|DELETE|Location|poll Location, until 204|
  • Loading branch information
XiaofeiCao authored Dec 10, 2024
1 parent e12bf51 commit cff495c
Show file tree
Hide file tree
Showing 5 changed files with 799 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/specs_arm_lro-2024-10-7-15-31-16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/azure-http-specs"
---

Added LRO case for ARM tests.
212 changes: 212 additions & 0 deletions packages/azure-http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,218 @@ Expected response body:
}
```

### Azure_ResourceManager_OperationTemplates_Lro_createOrReplace

- Endpoint: `put https://management.azure.com`

Resource PUT operation.
Service returns "Azure-AsyncOperation" on initial request.
final-state-via: Azure-AsyncOperation

Expected verb: PUT
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"location": "eastus",
"properties": {
"productId": "product1",
"amount": 1
}
}
```

Expected status code: 201
Expected response header: Azure-AsyncOperation={endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_create_aao
Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1",
"name": "order1",
"type": "Azure.ResourceManager.Resources/orders",
"location": "eastus",
"properties": {
"productId": "product1",
"amount": 1,
"provisioningState": "InProgress"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_create_aao

Expected status code: 200
Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_create_aao",
"name": "lro_create_aao",
"startTime": "2024-11-08T01:41:53.5508583+00:00",
"status": "InProgress"
}
```

Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_create_aao

Expected status code: 200
Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_create_aao",
"name": "lro_create_aao",
"status": "Succeeded",
"startTime": "2024-11-08T01:41:53.5508583+00:00",
"endTime": "2024-11-08T01:42:41.5354192+00:00"
}
```

Last get call on resource URL
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1

Expected status code: 200
Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1",
"name": "order1",
"type": "Azure.ResourceManager.Resources/orders",
"location": "eastus",
"properties": {
"productId": "product1",
"amount": 1,
"provisioningState": "Succeeded"
},
"systemData": {
"createdBy": "AzureSDK",
"createdByType": "User",
"createdAt": <any date>,
"lastModifiedBy": "AzureSDK",
"lastModifiedAt": <any date>,
"lastModifiedByType": "User",
}
}
```

### Azure_ResourceManager_OperationTemplates_Lro_delete

- Endpoint: `delete https://management.azure.com`

Resource DELETE operation.
Service returns both Location header on initial request.

Expected verb: DELETE
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1
Expected query parameter: api-version=2023-12-01-preview
Expected response status code: 202
Expected response header: Location={endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operationResults/lro_delete_location
Expected no response body

Location first poll.
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operationResults/lro_delete_location
Expected status code: 202
Expected no response body

Location second poll.
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operationResults/lro_delete_location
Expected status code: 204
Expected no response body

### Azure_ResourceManager_OperationTemplates_Lro_export

- Endpoint: `post https://management.azure.com`

Resource POST operation.
Service returns both Location and Azure-AsyncOperation header on initial request.
final-state-via: location

Expected verb: POST
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1/export
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"format": "csv"
}
```

Expected response status code: 202
Expected response headers:

- Azure-AsyncOperation={endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_aao
- Location={endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/operations/lro_post_location
Expected no response body

Whether you do polling through AAO, Location or combined, first one will respond with provisioning state "InProgress", second one with "Succeeded".

AAO first poll.
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_aao
Expected status code: 200
Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_aao",
"name": "lro_post_aao",
"status": "InProgress",
"startTime": "2024-11-08T01:41:53.5508583+00:00"
}
```

AAO second poll.
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_aao
Expected status code: 200
Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_aao",
"name": "lro_post_aao",
"status": "Succeeded",
"startTime": "2024-11-08T01:41:53.5508583+00:00",
"endTime": "2024-11-08T01:42:41.5354192+00:00"
}
```

Location first poll.
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_location
Expected status code: 202
Expected no response body

Location second poll.
Expected verb: GET
Expected URL: {endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_post_location
Expected status code: 200
Expected response body:

```json
{
"content": "order1,product1,1"
}
```

### Azure_ResourceManager_Resources_Nested_createOrReplace

- Endpoint: `put https://management.azure.com`
Expand Down
Loading

0 comments on commit cff495c

Please sign in to comment.