Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Tests ARM, test case for listing available operations #713

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/happy-avocados-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@azure-tools/cadl-ranch-specs": patch
---

Tests ARM, test case for listing available operations
29 changes: 29 additions & 0 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,35 @@ Expected response body:
}
```

### Azure_ResourceManager_Models_Resources_ListAvailableOperations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this to list which resources are available? or are you looking for available operations on a resource? I'm confused by the name. What about Azure_ResourceManager_Resources_ListAvailable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for listing all available operations for an RP, not for a particular resource or resource type.

Reason for putting it under Resources, is that it's a common interface(API) for almost all RPs, and it only has one scenario, which is interface Operations extends Azure.ResourceManager.Operations {}. I'm not sure it's worth a separate folder/file.


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

Resource GET operation.
Expected path: /providers/Azure.ResourceManager.Models.Resources/operations
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [
{
"name": "Microsoft.Compute/virtualMachines/write",
"isDataAction": false,
"display": {
"provider": "Microsoft Compute",
"resource": "Virtual Machines",
"operation": "Create or Update Virtual Machine.",
"description": "Add or modify virtual machines."
},
"origin": "user,system",
"actionType": "Internal"
}
]
}
```

### Azure_ResourceManager_Models_Resources_NestedProxyResources_createOrReplace

- Endpoint: `put https://management.azure.com`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,29 @@ union ProvisioningState {
Deleting: "Deleting",
Accepted: "Accepted",
}

@scenario("ListAvailableOperations")
@scenarioDoc("""
Resource GET operation.
Expected path: /providers/Azure.ResourceManager.Models.Resources/operations
Expected query parameter: api-version=2023-12-01-preview

Expected response body:
```json
{
"value": [{
"name": "Microsoft.Compute/virtualMachines/write",
"isDataAction": false,
"display": {
"provider": "Microsoft Compute",
"resource": "Virtual Machines",
"operation": "Create or Update Virtual Machine.",
"description": "Add or modify virtual machines."
},
"origin": "user,system",
"actionType": "Internal"
}]
}
```
""")
interface Operations extends Azure.ResourceManager.Operations {}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ const validSingletonResource = {
},
};

const validAvailableOperations = {
name: "Microsoft.Compute/virtualMachines/write",
isDataAction: false,
display: {
provider: "Microsoft Compute",
resource: "Virtual Machines",
operation: "Create or Update Virtual Machine.",
description: "Add or modify virtual machines.",
},
origin: "user,system",
actionType: "Internal",
};

// operation list
Scenarios.Azure_ResourceManager_Models_Resources_ListAvailableOperations = passOnSuccess([
mockapi.get("/providers/Azure.ResourceManager.Models.Resources/operations", (req) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
return {
status: 200,
body: json({
value: [validAvailableOperations],
}),
};
}),
]);

// singleton tracked resource
Scenarios.Azure_ResourceManager_Models_Resources_SingletonTrackedResources_getByResourceGroup = passOnSuccess([
mockapi.get(
Expand Down
Loading