Skip to content

Commit ebc22fc

Browse files
iscai-msftiscai-msfttimotheeguerinCopilot
authored
[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> Co-authored-by: Timothee Guerin <tiguerin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6d11b84 commit ebc22fc

14 files changed

Lines changed: 1330 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: internal
3+
packages:
4+
- "@azure-tools/typespec-python"
5+
---
6+
7+
Suppress `too-many-statements` pylint check for the generated `azure-resource-manager-operation-templates` package
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@azure-tools/typespec-ts"
5+
---
6+
7+
Regenerate the operation-templates public-API baseline for the new ARM operations
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
@@ -3307,6 +3307,88 @@ Expected response body:
33073307
}
33083308
```
33093309

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

33123394
- Endpoint: `get https://management.azure.com`
@@ -3622,6 +3704,55 @@ Expected response body:
36223704
[{ "content": "order1,product1,1" }, { "content": "order2,product2,2" }]
36233705
```
36243706

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

36273758
- Endpoint: `post https://management.azure.com`
@@ -3689,6 +3820,91 @@ Expected response body:
36893820
}
36903821
```
36913822

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

36943910
- Endpoint: `get https://management.azure.com`
@@ -3859,6 +4075,95 @@ Expected response body (with body scenario):
38594075
}
38604076
```
38614077

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

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

0 commit comments

Comments
 (0)