diff --git a/.changeset/happy-avocados-type.md b/.changeset/happy-avocados-type.md new file mode 100644 index 000000000..c3a1c084f --- /dev/null +++ b/.changeset/happy-avocados-type.md @@ -0,0 +1,5 @@ +--- +"@azure-tools/cadl-ranch-specs": patch +--- + +Tests ARM, test case for listing available operations diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 336e23b5a..0133cd5e4 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -907,6 +907,35 @@ Expected response body: } ``` +### Azure_ResourceManager_Models_Resources_ListAvailableOperations + +- 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` diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/main.tsp b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/main.tsp index bb2d8df67..746aefb27 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/main.tsp +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/main.tsp @@ -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 {} diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts index 011bd053a..143e4165c 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts @@ -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(