Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure-http-specs, add ARM listing available operations case #1933

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/azure-http-specs"
---

Added listing available operations case for ARM tests.
28 changes: 28 additions & 0 deletions packages/azure-http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,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_OperationTemplates_Lro_createOrReplace

- Endpoint: `put https://management.azure.com`
Expand Down
Original file line number Diff line number Diff line change
@@ -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.Models.Resources/operations
v-hongli1 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -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 "./lro.tsp";

using TypeSpec.Http;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,40 @@ const validOrder = {
lastModifiedByType: "User",
},
};
const validAvailableOperations = {
v-hongli1 marked this conversation as resolved.
Show resolved Hide resolved
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",
};
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: [validAvailableOperations],
}),
},
kind: "MockApiDefinition",
});

// lro resource
Scenarios.Azure_ResourceManager_OperationTemplates_Lro_createOrReplace = passOnSuccess([
{
Expand Down
Loading