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

Reopen Tests ARM, test case for listing available operations #763

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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/slow-singers-protect.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
28 changes: 28 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,34 @@ Expected response body:
}
```

### Azure_ResourceManager_OperationTemplates_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_Resources_Nested_createOrReplace

- Endpoint: `put https://management.azure.com`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

using TypeSpec.Http;
using TypeSpec.Rest;
using Azure.Core;
using Azure.ResourceManager;
using TypeSpec.OpenAPI;

namespace Azure.ResourceManager.OperationTemplates;

@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
@@ -0,0 +1,30 @@
import "@azure-tools/cadl-ranch-expect";
import "@typespec/http";
import "@typespec/rest";
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";

using TypeSpec.Http;
using TypeSpec.Rest;
using TypeSpec.Versioning;
using Azure.Core;
using Azure.ResourceManager;
using TypeSpec.OpenAPI;

@armProviderNamespace
@service
@versioned(Versions)
@doc("Arm Resource Provider management API.")
namespace Azure.ResourceManager.OperationTemplates;

@doc("Azure API versions.")
enum Versions {
@armCommonTypesVersion(CommonTypes.Versions.v5)
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1)
@doc("Preview API version 2023-12-01-preview.")
v2023_12_01_preview: "2023-12-01-preview",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { passOnSuccess, json } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

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_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: [validAvailableOperations],
}),
},
kind: "MockApiDefinition",
});
Loading