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

fix ARM scenario names #714

Merged
merged 16 commits into from
Oct 17, 2024
Merged
12 changes: 12 additions & 0 deletions .changeset/warm-comics-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@azure-tools/cadl-ranch-specs": minor
---

Reorganized ARM tests.

Breaking changes:

1. Renamed namespace `Azure.ResourceManager.Models.Resources` to `Azure.ResourceManager.Resources`.
2. Renamed namespace `Azure.ResourceManager.Models.CommonTypes.ManagedIdentity` to `Azure.ResourceManager.CommonProperties`.
3. Renamed folder `common-types/managed-identity` to `common-properties`.
4. Renamed `ManagedIdentityTrackedResources` interface in `common-properties` to `ManagedIdentity`.
116 changes: 58 additions & 58 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 "./managed-identity.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 Managed Identity Provider management API.")
namespace Azure.ResourceManager.CommonProperties;

@doc("Azure API versions.")
enum Versions {
@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
Expand Up @@ -4,7 +4,6 @@ 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";

using TypeSpec.Http;
using TypeSpec.Rest;
Expand All @@ -13,22 +12,11 @@ using Azure.Core;
using Azure.ResourceManager;
using TypeSpec.OpenAPI;

@armProviderNamespace
@service
@versioned(Versions)
@doc("Arm Managed Identity Provider management API.")
namespace Azure.ResourceManager.Models.CommonTypes.ManagedIdentity;

@doc("Azure API versions.")
enum Versions {
@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",
}
namespace Azure.ResourceManager.CommonProperties;

@resource("managedIdentityTrackedResources")
model ManagedIdentityTrackedResource is TrackedResource<ManagedIdentityTrackedResourceProperties> {
model ManagedIdentityTrackedResource
is Azure.ResourceManager.TrackedResource<ManagedIdentityTrackedResourceProperties> {
@key("managedIdentityTrackedResourceName")
@path
@segment("managedIdentityTrackedResources")
Expand All @@ -47,17 +35,17 @@ model ManagedIdentityTrackedResourceProperties {
}

@armResourceOperations
interface ManagedIdentityTrackedResources {
interface ManagedIdentity {
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity",
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity",
Expected query parameter: api-version=2023-12-01-preview

Expected response body:
```json
{
"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity",
"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity",
"location": "eastus",
"tags": {
"tagKey1": "tagValue1"
Expand All @@ -78,7 +66,7 @@ interface ManagedIdentityTrackedResources {
@scenario
@scenarioDoc("""
Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity",
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity",
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
Expand All @@ -96,7 +84,7 @@ interface ManagedIdentityTrackedResources {
Expected response body:
```json
{
"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity",
"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity",
"location": "eastus",
"tags": {
"tagKey1": "tagValue1"
Expand All @@ -117,7 +105,7 @@ interface ManagedIdentityTrackedResources {
@scenario
@scenarioDoc("""
Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity",
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity",
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
Expand All @@ -133,7 +121,7 @@ interface ManagedIdentityTrackedResources {
Expected response body:
```json
{
"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity",
"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity",
"location": "eastus",
"tags": {
"tagKey1": "tagValue1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const RESOURCE_GROUP_EXPECTED = "test-rg";
const IDENTITY_TYPE_SYSTEM_ASSIGNED_EXPECTED = "SystemAssigned";
const IDENTITY_TYPE_SYSTEM_USER_ASSIGNED_EXPECTED = "SystemAssigned,UserAssigned";
const validSystemAssignedManagedIdentityResource = {
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity`,
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity`,
location: `${LOCATION_REGION_EXPECTED}`,
tags: {
tagKey1: "tagValue1",
Expand All @@ -28,7 +28,7 @@ const validSystemAssignedManagedIdentityResource = {
};

const validUserAssignedAndSystemAssignedManagedIdentityResource = {
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/identity`,
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/identity`,
location: `${LOCATION_REGION_EXPECTED}`,
tags: {
tagKey1: "tagValue1",
Expand Down Expand Up @@ -63,8 +63,8 @@ const updateExpectedIdentity = {
};

// managed identity tracked resource
Scenarios.Azure_ResourceManager_Models_CommonTypes_ManagedIdentity_ManagedIdentityTrackedResources_get = passOnSuccess({
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/:managedIdentityResourceName",
Scenarios.Azure_ResourceManager_CommonProperties_ManagedIdentity_get = passOnSuccess({
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/:managedIdentityResourceName",
method: "get",
request: {
params: {
Expand Down Expand Up @@ -101,52 +101,51 @@ Scenarios.Azure_ResourceManager_Models_CommonTypes_ManagedIdentity_ManagedIdenti
kind: "MockApiDefinition",
});

Scenarios.Azure_ResourceManager_Models_CommonTypes_ManagedIdentity_ManagedIdentityTrackedResources_createWithSystemAssigned =
passOnSuccess({
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/:managedIdentityResourceName",
method: "put",
request: {
body: {
identity: createExpectedIdentity,
},
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"managedIdentityResourceName": "identity",
"api-version": "2023-12-01-preview",
},
Scenarios.Azure_ResourceManager_CommonProperties_ManagedIdentity_createWithSystemAssigned = passOnSuccess({
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/:managedIdentityResourceName",
method: "put",
request: {
body: {
identity: createExpectedIdentity,
},
response: {
params: {
"subscriptionId": SUBSCRIPTION_ID_EXPECTED,
"resourceGroup": RESOURCE_GROUP_EXPECTED,
"managedIdentityResourceName": "identity",
"api-version": "2023-12-01-preview",
},
},
response: {
status: 200,
body: json(validSystemAssignedManagedIdentityResource),
},
handler: (req: MockRequest) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
if (req.params.subscriptionId !== SUBSCRIPTION_ID_EXPECTED) {
throw new ValidationError("Unexpected subscriptionId", SUBSCRIPTION_ID_EXPECTED, req.params.subscriptionId);
}
if (req.params.resourceGroup.toLowerCase() !== RESOURCE_GROUP_EXPECTED) {
throw new ValidationError("Unexpected resourceGroup", RESOURCE_GROUP_EXPECTED, req.params.resourceGroup);
}
if (req.params.managedIdentityResourceName.toLowerCase() !== "identity") {
throw new ValidationError(
"Unexpected managed identity resource name",
"identity",
req.params.managedIdentityResourceName,
);
}
req.expect.deepEqual(req.body["identity"], createExpectedIdentity);
return {
status: 200,
body: json(validSystemAssignedManagedIdentityResource),
},
handler: (req: MockRequest) => {
req.expect.containsQueryParam("api-version", "2023-12-01-preview");
if (req.params.subscriptionId !== SUBSCRIPTION_ID_EXPECTED) {
throw new ValidationError("Unexpected subscriptionId", SUBSCRIPTION_ID_EXPECTED, req.params.subscriptionId);
}
if (req.params.resourceGroup.toLowerCase() !== RESOURCE_GROUP_EXPECTED) {
throw new ValidationError("Unexpected resourceGroup", RESOURCE_GROUP_EXPECTED, req.params.resourceGroup);
}
if (req.params.managedIdentityResourceName.toLowerCase() !== "identity") {
throw new ValidationError(
"Unexpected managed identity resource name",
"identity",
req.params.managedIdentityResourceName,
);
}
req.expect.deepEqual(req.body["identity"], createExpectedIdentity);
return {
status: 200,
body: json(validSystemAssignedManagedIdentityResource),
};
},
kind: "MockApiDefinition",
});
};
},
kind: "MockApiDefinition",
});

Scenarios.Azure_ResourceManager_Models_CommonTypes_ManagedIdentity_ManagedIdentityTrackedResources_updateWithUserAssignedAndSystemAssigned =
Scenarios.Azure_ResourceManager_CommonProperties_ManagedIdentity_updateWithUserAssignedAndSystemAssigned =
passOnSuccess({
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.CommonTypes.ManagedIdentity/managedIdentityTrackedResources/:managedIdentityResourceName",
uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/:managedIdentityResourceName",
method: "patch",
request: {
body: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using TypeSpec.OpenAPI;
@service
@versioned(Versions)
@doc("Arm Resource Provider management API.")
namespace Azure.ResourceManager.Models.Resources;
namespace Azure.ResourceManager.Resources;

@doc("Azure API versions.")
enum Versions {
Expand Down
Loading
Loading