diff --git a/.chronus/changes/specs_arm_listing_available_operations-2024-10-29-16-23-15.md b/.chronus/changes/specs_arm_listing_available_operations-2024-10-29-16-23-15.md new file mode 100644 index 000000000..e575d1085 --- /dev/null +++ b/.chronus/changes/specs_arm_listing_available_operations-2024-10-29-16-23-15.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/azure-http-specs" +--- + +Added listing available operations case for ARM tests. \ No newline at end of file diff --git a/packages/azure-http-specs/spec-summary.md b/packages/azure-http-specs/spec-summary.md index 0a1b2441b..899eb39c5 100644 --- a/packages/azure-http-specs/spec-summary.md +++ b/packages/azure-http-specs/spec-summary.md @@ -968,6 +968,34 @@ Expected response body: } ``` +### Azure_ResourceManager_OperationTemplates_ListAvailableOperations + +- Endpoint: `get https://management.azure.com` + +Resource GET operation. +Expected path: /providers/Azure.ResourceManager.OperationTemplates/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_OperationTemplates_Lro_createOrReplace - Endpoint: `put https://management.azure.com` diff --git a/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/available-operations.tsp b/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/available-operations.tsp new file mode 100644 index 000000000..a31e0d1c2 --- /dev/null +++ b/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/available-operations.tsp @@ -0,0 +1,39 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@typespec/spector"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using Azure.Core; +using Azure.ResourceManager; +using TypeSpec.OpenAPI; +using Spector; + +namespace Azure.ResourceManager.OperationTemplates; + +@scenario("ListAvailableOperations") +@scenarioDoc(""" + Resource GET operation. + Expected path: /providers/Azure.ResourceManager.OperationTemplates/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/azure-http-specs/specs/azure/resource-manager/operation-templates/main.tsp b/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/main.tsp index c786aaf4a..4443633fa 100644 --- a/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/main.tsp +++ b/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/main.tsp @@ -4,6 +4,7 @@ import "@typespec/versioning"; import "@azure-tools/typespec-azure-core"; import "@azure-tools/typespec-azure-resource-manager"; import "@azure-tools/typespec-client-generator-core"; +import "./available-operations.tsp"; import "./checkname-availability.tsp"; import "./lro.tsp"; diff --git a/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/mockapi.ts b/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/mockapi.ts index 26fcb4293..3dc7add6c 100644 --- a/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/mockapi.ts +++ b/packages/azure-http-specs/specs/azure/resource-manager/operation-templates/mockapi.ts @@ -29,6 +29,18 @@ const validOrder = { lastModifiedByType: "User", }, }; +const validOperation = { + 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", +}; const checkNameAvailabilityResponse = { nameAvailable: false, reason: "AlreadyExists", @@ -38,6 +50,24 @@ let createOrReplacePollCount = 0; let postPollCount = 0; let deletePollCount = 0; +// operation list +Scenarios.Azure_ResourceManager_OperationTemplates_ListAvailableOperations = passOnSuccess({ + uri: "/providers/Azure.ResourceManager.OperationTemplates/operations", + method: "get", + request: { + params: { + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json({ + value: [validOperation], + }), + }, + kind: "MockApiDefinition", +}); + // Check Global Name Availability Scenarios.Azure_ResourceManager_OperationTemplates_CheckNameAvailability_checkGlobal = passOnSuccess({