Skip to content

Commit 438202d

Browse files
iscai-msftiscai-msft
andauthored
[specs] add missing ARM scenarios (#4632)
fixes #4609 1. `getLro` with `@markAsLro` 2. `postActionPaging` 3. `@markAsPageable` 4. `postPaginglroWithBody` 5. legacy template usages --------- Co-authored-by: iscai-msft <isabellavcai@gmail.com>
1 parent d4ac4a6 commit 438202d

8 files changed

Lines changed: 1208 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: feature
3+
packages:
4+
- "@azure-tools/azure-http-specs"
5+
---
6+
7+
Add tests for ARM `getLro`, `postActionPaging`, `markAsPageable`, `postPagingLroWithBody`, `routedGet`, and `createOrReplaceOptionalBody`

packages/azure-http-specs/spec-summary.md

Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,88 @@ Expected response body:
33043304
}
33053305
```
33063306

3307+
### Azure_ResourceManager_OperationTemplates_Legacy_createOrReplaceOptionalBody
3308+
3309+
- Endpoint: `put https://management.azure.com`
3310+
3311+
PUT operation using Legacy.CreateOrReplaceSync with optional request body.
3312+
Tests the pattern where a resource can be created or replaced with an optional body,
3313+
as seen in marketplace Collections.
3314+
3315+
This tests two sub-scenarios:
3316+
3317+
1. With body: PUT with a resource body creates/updates the resource
3318+
2. Without body: PUT without a body creates the resource with defaults
3319+
3320+
Expected verb: PUT
3321+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/configurations/default
3322+
Expected query parameter: api-version=2023-12-01-preview
3323+
3324+
Scenario 1 (with body) - Expected request body:
3325+
3326+
```json
3327+
{
3328+
"location": "eastus",
3329+
"properties": {
3330+
"configValue": "custom-value"
3331+
}
3332+
}
3333+
```
3334+
3335+
Expected response status code: 200
3336+
Expected response body:
3337+
3338+
```json
3339+
{
3340+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/configurations/default",
3341+
"name": "default",
3342+
"type": "Azure.ResourceManager.OperationTemplates/configurations",
3343+
"location": "eastus",
3344+
"properties": {
3345+
"configValue": "custom-value",
3346+
"provisioningState": "Succeeded"
3347+
}
3348+
}
3349+
```
3350+
3351+
Scenario 2 (without body) - Expected request body: None (empty)
3352+
Expected response status code: 200
3353+
Expected response body:
3354+
3355+
```json
3356+
{
3357+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/configurations/default",
3358+
"name": "default",
3359+
"type": "Azure.ResourceManager.OperationTemplates/configurations",
3360+
"location": "eastus",
3361+
"properties": {
3362+
"configValue": "default-value",
3363+
"provisioningState": "Succeeded"
3364+
}
3365+
}
3366+
```
3367+
3368+
### Azure_ResourceManager_OperationTemplates_Legacy_routedGet
3369+
3370+
- Endpoint: `get https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/configurations/{name}/diagnostics/{diagnosticName}`
3371+
3372+
GET operation using RoutedOperations with a custom route path override.
3373+
Tests the Legacy.RoutedOperations pattern where the resource path is overridden
3374+
using ResourceRoute, and additional path parameters are added via @route.
3375+
3376+
Expected verb: GET
3377+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/configurations/default/diagnostics/memory
3378+
Expected query parameter: api-version=2023-12-01-preview
3379+
Expected response status code: 200
3380+
Expected response body:
3381+
3382+
```json
3383+
{
3384+
"name": "memory",
3385+
"status": "healthy"
3386+
}
3387+
```
3388+
33073389
### Azure_ResourceManager_OperationTemplates_ListAvailableOperations
33083390

33093391
- Endpoint: `get https://management.azure.com`
@@ -3619,6 +3701,55 @@ Expected response body:
36193701
[{ "content": "order1,product1,1" }, { "content": "order2,product2,2" }]
36203702
```
36213703

3704+
### Azure_ResourceManager_OperationTemplates_Lro_getLro
3705+
3706+
- Endpoint: `get https://management.azure.com`
3707+
3708+
Resource GET operation that returns a long-running operation.
3709+
Uses Extension.Read with @markAsLro, which returns 200 or 202.
3710+
The Location header points back to the same resource URL (matches real service behavior).
3711+
3712+
Step 1: Initial GET Request (returns 202 Accepted)
3713+
Expected verb: GET
3714+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/costReports/report1
3715+
Expected query parameter: api-version=2023-12-01-preview
3716+
Expected response status code: 202
3717+
Expected response header: Location={endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/costReports/report1
3718+
3719+
Step 2: Polling Request (returns 202 Accepted)
3720+
Expected verb: GET
3721+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/costReports/report1
3722+
Expected query parameter: api-version=2023-12-01-preview
3723+
Expected response status code: 202
3724+
Expected response header: Location={endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/costReports/report1
3725+
3726+
Step 3: Final Polling Request (returns 200 OK with result)
3727+
Expected verb: GET
3728+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/costReports/report1
3729+
Expected query parameter: api-version=2023-12-01-preview
3730+
Expected response status code: 200
3731+
Expected response body:
3732+
3733+
```json
3734+
{
3735+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/costReports/report1",
3736+
"name": "report1",
3737+
"type": "Azure.ResourceManager.OperationTemplates/costReports",
3738+
"properties": {
3739+
"downloadUrl": "https://storage.blob.core.windows.net/reports/report1.csv",
3740+
"provisioningState": "Succeeded"
3741+
},
3742+
"systemData": {
3743+
"createdBy": "AzureSDK",
3744+
"createdByType": "User",
3745+
"createdAt": <any date>,
3746+
"lastModifiedBy": "AzureSDK",
3747+
"lastModifiedAt": <any date>,
3748+
"lastModifiedByType": "User"
3749+
}
3750+
}
3751+
```
3752+
36223753
### Azure_ResourceManager_OperationTemplates_LroPaging_postPagingLro
36233754

36243755
- Endpoint: `post https://management.azure.com`
@@ -3686,6 +3817,91 @@ Expected response body:
36863817
}
36873818
```
36883819

3820+
### Azure_ResourceManager_OperationTemplates_LroPaging_postPagingLroWithBody
3821+
3822+
- Endpoint: `post https://management.azure.com`
3823+
3824+
Resource POST operation that returns a LRO with paging, using ArmResourceActionAsyncBase
3825+
with a request body and a response that includes a body on both 200 and 202.
3826+
Unlike postPagingLro which uses the convenience ArmResourceActionAsync with no body,
3827+
this tests the lower-level ArmResourceActionAsyncBase pattern.
3828+
3829+
Step 1: Initial Request
3830+
Expected verb: POST
3831+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/products/default/postPagingLroWithBody
3832+
Expected query parameter: api-version=2023-12-01-preview
3833+
Expected request body:
3834+
3835+
```json
3836+
{
3837+
"vnetId": "vnet1"
3838+
}
3839+
```
3840+
3841+
Expected response: 202 Accepted with Location and Retry-After headers.
3842+
Expected response body:
3843+
3844+
```json
3845+
{
3846+
"value": []
3847+
}
3848+
```
3849+
3850+
Step 2: Polling Request
3851+
Expected verb: GET
3852+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_paging_post_body_location
3853+
Expected query parameter: api-version=2023-12-01-preview
3854+
Expected response: 202 Accepted with Location and Retry-After headers.
3855+
3856+
Step 3: Final Result Request
3857+
Expected verb: GET
3858+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_paging_post_body_location
3859+
Expected query parameter: api-version=2023-12-01-preview
3860+
Expected response: 200 OK with a paged result. The response body contains a "nextLink" field.
3861+
Expected response body:
3862+
3863+
```json
3864+
{
3865+
"value": [
3866+
{
3867+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/products/product1",
3868+
"name": "product1",
3869+
"type": "Azure.ResourceManager.OperationTemplates/products",
3870+
"location": "eastus",
3871+
"properties": {
3872+
"provisioningState": "Succeeded",
3873+
"productId": "product1"
3874+
}
3875+
}
3876+
],
3877+
"nextLink": "..."
3878+
}
3879+
```
3880+
3881+
Step 4: Next Page Request
3882+
Expected verb: GET
3883+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.OperationTemplates/locations/eastus/operations/lro_paging_post_body_location/nextPage
3884+
Expected query parameter: api-version=2023-12-01-preview
3885+
Expected response: 200 OK with the second page of results.
3886+
Expected response body:
3887+
3888+
```json
3889+
{
3890+
"value": [
3891+
{
3892+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/products/product2",
3893+
"name": "product2",
3894+
"type": "Azure.ResourceManager.OperationTemplates/products",
3895+
"location": "eastus",
3896+
"properties": {
3897+
"provisioningState": "Succeeded",
3898+
"productId": "product2"
3899+
}
3900+
}
3901+
]
3902+
}
3903+
```
3904+
36893905
### Azure_ResourceManager_OperationTemplates_OptionalBody_get
36903906

36913907
- Endpoint: `get https://management.azure.com`
@@ -3856,6 +4072,95 @@ Expected response body (with body scenario):
38564072
}
38574073
```
38584074

4075+
### Azure_ResourceManager_OperationTemplates_Paging_markAsPageable
4076+
4077+
- Endpoint: `get https://management.azure.com`
4078+
4079+
List operation using ArmListSinglePageByParent with @markAsPageable.
4080+
The response uses a custom list model (CollectionsList) wrapping
4081+
the resource array.
4082+
4083+
Expected verb: GET
4084+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/monitors/monitor1/collections
4085+
Expected query parameter: api-version=2023-12-01-preview
4086+
Expected response status code: 200
4087+
Expected response body:
4088+
4089+
```json
4090+
{
4091+
"value": [
4092+
{
4093+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/monitors/monitor1/collections/collection1",
4094+
"name": "collection1",
4095+
"type": "Azure.ResourceManager.OperationTemplates/monitors/collections",
4096+
"properties": {
4097+
"displayName": "Test Collection"
4098+
}
4099+
},
4100+
{
4101+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/monitors/monitor1/collections/collection2",
4102+
"name": "collection2",
4103+
"type": "Azure.ResourceManager.OperationTemplates/monitors/collections",
4104+
"properties": {
4105+
"displayName": "Another Collection"
4106+
}
4107+
}
4108+
]
4109+
}
4110+
```
4111+
4112+
### Azure_ResourceManager_OperationTemplates_Paging_postActionPaging
4113+
4114+
- Endpoint: `post https://management.azure.com`
4115+
4116+
Resource POST action returning pageable results.
4117+
This tests a POST action with @list that returns pageable results (not an LRO).
4118+
4119+
Step 1: Initial POST Request (returns first page)
4120+
Expected verb: POST
4121+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/monitors/monitor1/postActionPaging
4122+
Expected query parameter: api-version=2023-12-01-preview
4123+
Expected request body:
4124+
4125+
```json
4126+
{
4127+
"filter": "status eq 'active'"
4128+
}
4129+
```
4130+
4131+
Expected response status code: 200
4132+
Expected response body:
4133+
4134+
```json
4135+
{
4136+
"value": [
4137+
{
4138+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm1",
4139+
"sendingMetrics": true
4140+
}
4141+
],
4142+
"nextLink": "{endpoint}/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/monitors/monitor1/postActionPaging/nextPage?api-version=2023-12-01-preview"
4143+
}
4144+
```
4145+
4146+
Step 2: Next Page Request
4147+
Expected verb: GET
4148+
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/monitors/monitor1/postActionPaging/nextPage
4149+
Expected query parameter: api-version=2023-12-01-preview
4150+
Expected response status code: 200
4151+
Expected response body:
4152+
4153+
```json
4154+
{
4155+
"value": [
4156+
{
4157+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/vm2",
4158+
"sendingMetrics": false
4159+
}
4160+
]
4161+
}
4162+
```
4163+
38594164
### Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate
38604165

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

0 commit comments

Comments
 (0)