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

Commit

Permalink
Change the referenced ARM Resource Type to @locationResource.
Browse files Browse the repository at this point in the history
  • Loading branch information
v-hongli1 committed Sep 2, 2024
1 parent cd2eb5c commit 0c483cf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 60 deletions.
26 changes: 10 additions & 16 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -912,13 +912,12 @@ Expected response body:
- Endpoint: `put https://management.azure.com`

Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"location": "westus",
"properties": {
"description": "valid"
}
Expand All @@ -929,10 +928,9 @@ Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "westus",
"properties": {
"description": "valid",
"provisioningState": "Succeeded"
Expand All @@ -953,7 +951,7 @@ Expected response body:
- Endpoint: `delete https://management.azure.com`

Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview

````
Expand All @@ -964,16 +962,15 @@ Expected response status code: 204
- Endpoint: `get https://management.azure.com`
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
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.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
Expand All @@ -989,23 +986,22 @@ Expected response body:
}
````

### Azure_ResourceManager_Models_Resources_LocationResources_listByLocation
### Azure_ResourceManager_Models_Resources_LocationResources_listByParent

- Endpoint: `get https://management.azure.com`

Resource LIST by resource group operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources
Expected query parameter: api-version=2023-12-01-preview

Expected response body:

```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "westus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
Expand All @@ -1027,13 +1023,12 @@ Expected response body:
- Endpoint: `patch https://management.azure.com`

Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected request body:

```json
{
"location": "westus",
"properties": {
"description": "valid2"
}
Expand All @@ -1044,10 +1039,9 @@ Expected response body:

```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "westus",
"properties":{
"description": "valid2",
"provisioningState": "Succeeded"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using TypeSpec.OpenAPI;

namespace Azure.ResourceManager.Models.Resources;

@parentResource(ResourceGroupLocationResource)
model LocationResource is TrackedResource<LocationResourceProperties> {
@locationResource
model LocationResource is ProxyResource<LocationResourceProperties> {
...ResourceNameParameter<LocationResource>;
}

Expand All @@ -31,16 +31,15 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource GET operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
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.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "eastus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
Expand All @@ -61,12 +60,11 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource PUT operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"location": "westus",
"properties": {
"description": "valid",
}
Expand All @@ -75,10 +73,9 @@ interface LocationResources {
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "westus",
"properties": {
"description": "valid",
"provisioningState": "Succeeded"
Expand All @@ -94,17 +91,16 @@ interface LocationResources {
}
```
""")
createOrUpdate is ArmResourceCreateOrReplaceSync<LocationResource>;
createOrUpdate is ArmResourceCreateOrUpdateAsync<LocationResource>;

@scenario
@scenarioDoc("""
Resource PATCH operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
Expected request body:
```json
{
"location": "westus",
"properties": {
"description": "valid2",
}
Expand All @@ -113,10 +109,9 @@ interface LocationResources {
Expected response body:
```json
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "westus",
"properties":{
"description": "valid2",
"provisioningState": "Succeeded"
Expand All @@ -137,7 +132,7 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource DELETE operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource
Expected query parameter: api-version=2023-12-01-preview
```
Expected response status code: 204
Expand All @@ -147,17 +142,16 @@ interface LocationResources {
@scenario
@scenarioDoc("""
Resource LIST by resource group operation.
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/
Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources
Expected query parameter: api-version=2023-12-01-preview
Expected response body:
```json
{
"value": [{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/locations/eastus/locationResources/resource",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus/providers/Azure.ResourceManager.Models.Resources/locationResources/resource",
"name": "resource",
"type": "Azure.ResourceManager.Models.Resources/locationResources",
"location": "westus",
"properties":{
"description": "valid",
"provisioningState": "Succeeded"
Expand All @@ -174,5 +168,5 @@ interface LocationResources {
}
```
""")
listByLocation is ArmResourceListByParent<LocationResource>;
listByParent is ArmResourceListByParent<LocationResource>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ const validSingletonResource = {
};

const validLocationResource = {
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Models.Resources/locations/${LOCATION_EXPECTED}/locationResources/resource`,
id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/locations/${LOCATION_EXPECTED}/providers/Azure.ResourceManager.Models.Resources/locationResources/resource`,
name: "resource",
type: "Azure.ResourceManager.Models.Resources/locationResources",
location: "westus",
properties: {
description: "valid",
provisioningState: "Succeeded",
Expand All @@ -83,15 +82,12 @@ const validLocationResource = {

Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_get = passOnSuccess([
mockapi.get(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/locations/:location/locationResources/:locationResourceName",
"/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Models.Resources/locationResources/:locationResourceName",
(req) => {
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.location.toLowerCase() !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected parent resource location", LOCATION_EXPECTED, req.params.location);
}
Expand All @@ -108,23 +104,19 @@ Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_get = passOnS

Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_createOrUpdate = passOnSuccess([
mockapi.put(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/locations/:location/locationResources/:locationResourceName",
"/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Models.Resources/locationResources/:locationResourceName",
(req) => {
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.location.toLowerCase() !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected parent resource location", LOCATION_EXPECTED, req.params.location);
}
if (req.params.locationResourceName.toLowerCase() !== "resource") {
throw new ValidationError("Unexpected resource name", "resource", req.params.locationResourceName);
}
req.expect.bodyEquals({
location: "westus",
properties: {
description: "valid",
},
Expand All @@ -139,23 +131,19 @@ Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_createOrUpdat

Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_update = passOnSuccess([
mockapi.patch(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/locations/:location/locationResources/:locationResourceName",
"/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Models.Resources/locationResources/:locationResourceName",
(req) => {
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.location.toLowerCase() !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected parent resource location", LOCATION_EXPECTED, req.params.location);
}
if (req.params.locationResourceName.toLowerCase() !== "resource") {
throw new ValidationError("Unexpected resource name", "resource", req.params.locationResourceName);
}
req.expect.bodyEquals({
location: "westus",
properties: {
description: "valid2",
},
Expand All @@ -172,15 +160,12 @@ Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_update = pass

Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_delete = passOnSuccess([
mockapi.delete(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/locations/:location/locationResources/:locationResourceName",
"/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Models.Resources/locationResources/:locationResourceName",
(req) => {
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.location.toLowerCase() !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected parent resource location", LOCATION_EXPECTED, req.params.location);
}
Expand All @@ -194,17 +179,14 @@ Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_delete = pass
),
]);

Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_listByLocation = passOnSuccess([
Scenarios.Azure_ResourceManager_Models_Resources_LocationResources_listByParent = passOnSuccess([
mockapi.get(
"/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/locations/:location/locationResources",
"/subscriptions/:subscriptionId/locations/:location/providers/Azure.ResourceManager.Models.Resources/locationResources",
(req) => {
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.location.toLowerCase() !== LOCATION_EXPECTED) {
throw new ValidationError("Unexpected parent resource location", LOCATION_EXPECTED, req.params.location);
}
Expand Down

0 comments on commit 0c483cf

Please sign in to comment.