From 2ec599ba1ad44cdb022d8412d0c386c5cdd57b89 Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Mon, 28 Oct 2024 15:47:20 +0800 Subject: [PATCH 1/3] Reopen Tests ARM, test case for ExtensionResource --- .changeset/ten-carrots-taste.md | 5 + .../cadl-ranch-specs/cadl-ranch-summary.md | 407 +++++++++++++++++ .../resource-manager/resources/extension.tsp | 415 ++++++++++++++++++ .../azure/resource-manager/resources/main.tsp | 1 + .../resource-manager/resources/mockapi.ts | 382 ++++++++++++++++ 5 files changed, 1210 insertions(+) create mode 100644 .changeset/ten-carrots-taste.md create mode 100644 packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp diff --git a/.changeset/ten-carrots-taste.md b/.changeset/ten-carrots-taste.md new file mode 100644 index 000000000..77cc7a95b --- /dev/null +++ b/.changeset/ten-carrots-taste.md @@ -0,0 +1,5 @@ +--- +"@azure-tools/cadl-ranch-specs": patch +--- + +Added tests for ARM, test case for ExtensionResource. diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 997161e40..383bf68fc 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -907,6 +907,413 @@ Expected response body: } ``` +### Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate + +- Endpoint: `put https://management.azure.com` + + Resource PUT operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource PUT operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource PUT operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + +### Azure_ResourceManager_Resources_ExtensionsResources_delete + +- Endpoint: `delete https://management.azure.com` + + Resource DELETE operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + + Resource DELETE operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + + Resource DELETE operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + +### Azure_ResourceManager_Resources_ExtensionsResources_get + +- Endpoint: `get https://management.azure.com` + + Resource GET operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource GET operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource GET operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + 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.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + +### Azure_ResourceManager_Resources_ExtensionsResources_listByParent + +- Endpoint: `get https://management.azure.com` + + Resource LIST by parent url operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionResources + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + + ```json + { + "value": [{ + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + + Resource LIST by parent url operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionResources + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + + ```json + { + "value": [{ + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + + Resource LIST by parent url operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionResources + 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.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + +### Azure_ResourceManager_Resources_ExtensionsResources_update + +- Endpoint: `patch https://management.azure.com` + + Resource Patch operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource Patch operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource Patch operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + ### Azure_ResourceManager_Resources_Nested_createOrReplace - Endpoint: `put https://management.azure.com` diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp new file mode 100644 index 000000000..ae253afda --- /dev/null +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp @@ -0,0 +1,415 @@ +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.Resources; + +model ExtensionsResource is ExtensionResource { + ...ResourceNameParameter; +} + +/** ExtensionsResource properties */ +model ExtensionsResourceProperties { + @doc("The description of the resource.") + description?: string; + + /** The status of the last operation. */ + @visibility("read") + provisioningState?: ProvisioningState; +} + +@armResourceOperations +interface ExtensionsResources { + @scenario + @scenarioDoc(""" + Resource GET operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + Resource GET operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + Resource GET operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + 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.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + """) + get is ArmResourceRead; + + @scenario + @scenarioDoc(""" + Resource PUT operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource PUT operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + Resource PUT operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + """) + createOrUpdate is ArmResourceCreateOrReplaceAsync; + + @scenario + @scenarioDoc(""" + Resource Patch operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource Patch operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + + Resource Patch operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + ```json + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + """) + update is ArmResourcePatchSync; + + @scenario + @scenarioDoc(""" + Resource DELETE operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + + Resource DELETE operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + + Resource DELETE operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + """) + delete is ArmResourceDeleteSync; + + @scenario + @scenarioDoc(""" + Resource LIST by parent url operation. + Expected path: /providers/Azure.ResourceManager.Resources/extensionResources + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + ```json + { + "value": [{ + "id": "/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + + Resource LIST by parent url operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionResources + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + ```json + { + "value": [{ + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + + Resource LIST by parent url operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionResources + 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.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + """) + listByParent is ArmResourceListByParent; +} diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/main.tsp b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/main.tsp index 491bdec82..135d5afd1 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/main.tsp +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/main.tsp @@ -8,6 +8,7 @@ import "@azure-tools/typespec-client-generator-core"; import "./toplevel.tsp"; import "./nested.tsp"; import "./singleton.tsp"; +import "./extension.tsp"; using TypeSpec.Http; using TypeSpec.Rest; diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts index 1baa7c551..2d8bbdbb1 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts @@ -61,6 +61,388 @@ const validSingletonResource = { }, }; +const validResourceGroupExtensionsResource = { + id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + name: "extension", + type: "Azure.ResourceManager.Resources/extensionsResources", + properties: { + description: "valid", + provisioningState: "Succeeded", + }, + systemData: { + createdBy: "AzureSDK", + createdByType: "User", + createdAt: new Date(), + lastModifiedBy: "AzureSDK", + lastModifiedAt: new Date(), + lastModifiedByType: "User", + }, +}; + +const validSubscriptionExtensionsResource = { + id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + name: "extension", + type: "Azure.ResourceManager.Resources/extensionsResources", + properties: { + description: "valid", + provisioningState: "Succeeded", + }, + systemData: { + createdBy: "AzureSDK", + createdByType: "User", + createdAt: new Date(), + lastModifiedBy: "AzureSDK", + lastModifiedAt: new Date(), + lastModifiedByType: "User", + }, +}; + +const validTenantExtensionsResource = { + id: `/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + name: "extension", + type: "Azure.ResourceManager.Resources/extensionsResources", + properties: { + description: "valid", + provisioningState: "Succeeded", + }, + systemData: { + createdBy: "AzureSDK", + createdByType: "User", + createdAt: new Date(), + lastModifiedBy: "AzureSDK", + lastModifiedAt: new Date(), + lastModifiedByType: "User", + }, +}; + +// extension tracked resource +Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_get = passOnSuccess([ + { + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "get", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json(validResourceGroupExtensionsResource), + }, + kind: "MockApiDefinition", + }, + { + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "get", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json(validSubscriptionExtensionsResource), + }, + kind: "MockApiDefinition", + }, + { + uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "get", + request: { + params: { + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json(validTenantExtensionsResource), + }, + kind: "MockApiDefinition", + }, +]); + +Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = passOnSuccess([ + { + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "put", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid", + }, + }, + }, + response: { + status: 200, + body: json(validResourceGroupExtensionsResource), + }, + kind: "MockApiDefinition", + }, + { + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "put", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid", + }, + }, + }, + response: { + status: 200, + body: json(validSubscriptionExtensionsResource), + }, + kind: "MockApiDefinition", + }, + { + uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "put", + request: { + params: { + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid", + }, + }, + }, + response: { + status: 200, + body: json(validTenantExtensionsResource), + }, + kind: "MockApiDefinition", + }, +]); + +Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuccess([ + { + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "patch", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid2", + }, + }, + headers: { + "Content-Type": "application/merge-patch+json", + }, + }, + response: { + status: 200, + body: json({ + ...validResourceGroupExtensionsResource, + properties: { + provisioningState: "Succeeded", + description: "valid2", + }, + }), + }, + kind: "MockApiDefinition", + }, + { + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "patch", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid2", + }, + }, + headers: { + "Content-Type": "application/merge-patch+json", + }, + }, + response: { + status: 200, + body: json({ + ...validSubscriptionExtensionsResource, + properties: { + provisioningState: "Succeeded", + description: "valid2", + }, + }), + }, + kind: "MockApiDefinition", + }, + { + uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "patch", + request: { + params: { + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid2", + }, + }, + headers: { + "Content-Type": "application/merge-patch+json", + }, + }, + response: { + status: 200, + body: json({ + ...validTenantExtensionsResource, + properties: { + provisioningState: "Succeeded", + description: "valid2", + }, + }), + }, + kind: "MockApiDefinition", + }, +]); + +Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_delete = passOnSuccess([ + { + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "delete", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 204, + }, + kind: "MockApiDefinition", + }, + { + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "delete", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 204, + }, + kind: "MockApiDefinition", + }, + { + uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "delete", + request: { + params: { + "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 204, + }, + kind: "MockApiDefinition", + }, +]); + +Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_listByParent = passOnSuccess([ + { + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", + method: "get", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, + "topLevelResourceName": "top", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json({ + value: [validResourceGroupExtensionsResource], + }), + }, + kind: "MockApiDefinition", + }, + { + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", + method: "get", + request: { + params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "topLevelResourceName": "top", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json({ + value: [validSubscriptionExtensionsResource], + }), + }, + kind: "MockApiDefinition", + }, + { + uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", + method: "get", + request: { + params: { + "topLevelResourceName": "top", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json({ + value: [validTenantExtensionsResource], + }), + }, + kind: "MockApiDefinition", + }, +]); + // singleton tracked resource Scenarios.Azure_ResourceManager_Resources_Singleton_getByResourceGroup = passOnSuccess({ uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default", From a94977fd2b79ac39cf8aeae430524dcbcc4c4a87 Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Thu, 31 Oct 2024 13:47:28 +0800 Subject: [PATCH 2/3] Reopen Tests ARM, test case for ExtensionResource --- .../cadl-ranch-specs/cadl-ranch-summary.md | 131 ++++++++++++++- .../resource-manager/resources/extension.tsp | 131 ++++++++++++++- .../resource-manager/resources/mockapi.ts | 156 +++++++++++++++--- 3 files changed, 389 insertions(+), 29 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 383bf68fc..d0615f7ed 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -947,7 +947,7 @@ Expected response body: ``` Resource PUT operation. - Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected request body: @@ -1016,6 +1016,41 @@ Expected response body: } ``` + Resource PUT operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + ### Azure_ResourceManager_Resources_ExtensionsResources_delete - Endpoint: `delete https://management.azure.com` @@ -1035,6 +1070,11 @@ Expected response body: Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 + Resource DELETE operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 + ### Azure_ResourceManager_Resources_ExtensionsResources_get - Endpoint: `get https://management.azure.com` @@ -1117,6 +1157,32 @@ Expected response body: } ``` + Resource GET operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + ### Azure_ResourceManager_Resources_ExtensionsResources_listByParent - Endpoint: `get https://management.azure.com` @@ -1205,6 +1271,34 @@ Expected response body: } ``` + Resource LIST by parent url operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionResources + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + + ```json + { + "value": [{ + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` + ### Azure_ResourceManager_Resources_ExtensionsResources_update - Endpoint: `patch https://management.azure.com` @@ -1314,6 +1408,41 @@ Expected response body: } ``` + Resource Patch operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` + ### Azure_ResourceManager_Resources_Nested_createOrReplace - Endpoint: `put https://management.azure.com` diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp index ae253afda..31778f26f 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp @@ -25,6 +25,9 @@ model ExtensionsResourceProperties { provisioningState?: ProvisioningState; } +/** The interface of extensions resources, + * it contains 4 kinds of URLs (resource, resource group, subscription and tenant) + */ @armResourceOperations interface ExtensionsResources { @scenario @@ -53,6 +56,7 @@ interface ExtensionsResources { } } ``` + Resource GET operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -77,6 +81,7 @@ interface ExtensionsResources { } } ``` + Resource GET operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -101,6 +106,31 @@ interface ExtensionsResources { } } ``` + + Resource GET operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` """) get is ArmResourceRead; @@ -140,7 +170,7 @@ interface ExtensionsResources { ``` Resource PUT operation. - Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected request body: @@ -171,6 +201,7 @@ interface ExtensionsResources { } } ``` + Resource PUT operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -203,6 +234,39 @@ interface ExtensionsResources { } } ``` + + Resource PUT operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid", + } + ``` + + Expected response body: + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` """) createOrUpdate is ArmResourceCreateOrReplaceAsync; @@ -306,6 +370,39 @@ interface ExtensionsResources { } } ``` + + Resource Patch operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + + Expected request body: + ```json + { + "properties":{ + "description": "valid2", + } + ``` + + Expected response body: + ```json + { + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid2", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + } + ``` """) update is ArmResourcePatchSync; @@ -325,6 +422,11 @@ interface ExtensionsResources { Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 + + Resource DELETE operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Expected query parameter: api-version=2023-12-01-preview + Expected response status code: 204 """) delete is ArmResourceDeleteSync; @@ -410,6 +512,33 @@ interface ExtensionsResources { }] } ``` + + Resource LIST by parent url operation. + Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionResources + Expected query parameter: api-version=2023-12-01-preview + + Expected response body: + ```json + { + "value": [{ + "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "name": "extension", + "type": "Azure.ResourceManager.Resources/extensionsResources", + "properties":{ + "description": "valid", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdBy": "AzureSDK", + "createdByType": "User", + "createdAt": , + "lastModifiedBy": "AzureSDK", + "lastModifiedAt": , + "lastModifiedByType": "User", + } + }] + } + ``` """) listByParent is ArmResourceListByParent; } diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts index 2d8bbdbb1..63c2b4770 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts @@ -62,7 +62,7 @@ const validSingletonResource = { }; const validResourceGroupExtensionsResource = { - id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, name: "extension", type: "Azure.ResourceManager.Resources/extensionsResources", properties: { @@ -80,7 +80,7 @@ const validResourceGroupExtensionsResource = { }; const validSubscriptionExtensionsResource = { - id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, name: "extension", type: "Azure.ResourceManager.Resources/extensionsResources", properties: { @@ -98,6 +98,24 @@ const validSubscriptionExtensionsResource = { }; const validTenantExtensionsResource = { + id: `/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + name: "extension", + type: "Azure.ResourceManager.Resources/extensionsResources", + properties: { + description: "valid", + provisioningState: "Succeeded", + }, + systemData: { + createdBy: "AzureSDK", + createdByType: "User", + createdAt: new Date(), + lastModifiedBy: "AzureSDK", + lastModifiedAt: new Date(), + lastModifiedByType: "User", + }, +}; + +const validResourceExtensionsResource = { id: `/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, name: "extension", type: "Azure.ResourceManager.Resources/extensionsResources", @@ -118,13 +136,12 @@ const validTenantExtensionsResource = { // extension tracked resource Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_get = passOnSuccess([ { - uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "get", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, "resourceGroup": RESOURCE_GROUP_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -136,12 +153,11 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_get = passOnSucces kind: "MockApiDefinition", }, { - uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "get", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -153,11 +169,10 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_get = passOnSucces kind: "MockApiDefinition", }, { - uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "get", request: { params: { - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -168,17 +183,32 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_get = passOnSucces }, kind: "MockApiDefinition", }, + { + uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "get", + request: { + params: { + "extensionName": "extension", + "topLevelResourceName": "top", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json(validResourceExtensionsResource), + }, + kind: "MockApiDefinition", + }, ]); Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = passOnSuccess([ { - uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "put", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, "resourceGroup": RESOURCE_GROUP_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -195,12 +225,11 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = p kind: "MockApiDefinition", }, { - uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "put", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -216,6 +245,26 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = p }, kind: "MockApiDefinition", }, + { + uri: "/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "put", + request: { + params: { + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid", + }, + }, + }, + response: { + status: 200, + body: json(validTenantExtensionsResource), + }, + kind: "MockApiDefinition", + }, { uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "put", @@ -233,7 +282,7 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = p }, response: { status: 200, - body: json(validTenantExtensionsResource), + body: json(validResourceExtensionsResource), }, kind: "MockApiDefinition", }, @@ -241,13 +290,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = p Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuccess([ { - uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "patch", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, "resourceGroup": RESOURCE_GROUP_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -273,12 +321,11 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuc kind: "MockApiDefinition", }, { - uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "patch", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -303,6 +350,35 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuc }, kind: "MockApiDefinition", }, + { + uri: "/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "patch", + request: { + params: { + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + body: { + properties: { + description: "valid2", + }, + }, + headers: { + "Content-Type": "application/merge-patch+json", + }, + }, + response: { + status: 200, + body: json({ + ...validTenantExtensionsResource, + properties: { + provisioningState: "Succeeded", + description: "valid2", + }, + }), + }, + kind: "MockApiDefinition", + }, { uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "patch", @@ -324,7 +400,7 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuc response: { status: 200, body: json({ - ...validTenantExtensionsResource, + ...validResourceExtensionsResource, properties: { provisioningState: "Succeeded", description: "valid2", @@ -337,13 +413,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuc Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_delete = passOnSuccess([ { - uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "delete", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, "resourceGroup": RESOURCE_GROUP_EXPECTED, - "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -354,12 +429,25 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_delete = passOnSuc kind: "MockApiDefinition", }, { - uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "delete", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, - "topLevelResourceName": "top", + "extensionName": "extension", + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 204, + }, + kind: "MockApiDefinition", + }, + { + uri: "/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + method: "delete", + request: { + params: { "extensionName": "extension", "api-version": "2023-12-01-preview", }, @@ -388,13 +476,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_delete = passOnSuc Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_listByParent = passOnSuccess([ { - uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/extensionsResources", method: "get", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, "resourceGroup": RESOURCE_GROUP_EXPECTED, - "topLevelResourceName": "top", "api-version": "2023-12-01-preview", }, }, @@ -407,12 +494,11 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_listByParent = pas kind: "MockApiDefinition", }, { - uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", + uri: "/subscriptions/:subscriptionId/providers/Azure.ResourceManager.Resources/extensionsResources", method: "get", request: { params: { "subscriptionId": SUBSCRIPTION_ID_EXPECTED, - "topLevelResourceName": "top", "api-version": "2023-12-01-preview", }, }, @@ -424,6 +510,22 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_listByParent = pas }, kind: "MockApiDefinition", }, + { + uri: "/providers/Azure.ResourceManager.Resources/extensionsResources", + method: "get", + request: { + params: { + "api-version": "2023-12-01-preview", + }, + }, + response: { + status: 200, + body: json({ + value: [validTenantExtensionsResource], + }), + }, + kind: "MockApiDefinition", + }, { uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", method: "get", @@ -436,7 +538,7 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_listByParent = pas response: { status: 200, body: json({ - value: [validTenantExtensionsResource], + value: [validResourceExtensionsResource], }), }, kind: "MockApiDefinition", From 0d1a1d6028a63db9c6c3dada4b39e9c6b5bab6a3 Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Fri, 1 Nov 2024 16:04:30 +0800 Subject: [PATCH 3/3] Reopen Tests ARM, test case for ExtensionResource --- .../cadl-ranch-specs/cadl-ranch-summary.md | 58 +++++++++---------- .../resource-manager/resources/extension.tsp | 58 +++++++++---------- .../resource-manager/resources/mockapi.ts | 20 +++++-- 3 files changed, 72 insertions(+), 64 deletions(-) diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 099ec14df..bde452662 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -911,7 +911,7 @@ Expected response body: - Endpoint: `put https://management.azure.com` - Resource PUT operation. + Resource PUT operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -946,7 +946,7 @@ Expected response body: } ``` - Resource PUT operation. + Resource PUT operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -981,7 +981,7 @@ Expected response body: } ``` - Resource PUT operation. + Resource PUT operation for resource group level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1016,8 +1016,8 @@ Expected response body: } ``` - Resource PUT operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource PUT operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected request body: @@ -1033,7 +1033,7 @@ Expected response body: ```json { - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ @@ -1055,23 +1055,23 @@ Expected response body: - Endpoint: `delete https://management.azure.com` - Resource DELETE operation. + Resource DELETE operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 - Resource DELETE operation. + Resource DELETE operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 - Resource DELETE operation. + Resource DELETE operation for resource get level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 - Resource DELETE operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource DELETE operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 @@ -1079,7 +1079,7 @@ Expected response body: - Endpoint: `get https://management.azure.com` - Resource GET operation. + Resource GET operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1105,7 +1105,7 @@ Expected response body: } ``` - Resource GET operation. + Resource GET operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1131,7 +1131,7 @@ Expected response body: } ``` - Resource GET operation. + Resource GET operation for resource group level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1157,15 +1157,15 @@ Expected response body: } ``` - Resource GET operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource GET operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response body: ```json { - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ @@ -1187,7 +1187,7 @@ Expected response body: - Endpoint: `get https://management.azure.com` - Resource LIST by parent url operation. + Resource LIST by tenant level url operation. Expected path: /providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview @@ -1215,7 +1215,7 @@ Expected response body: } ``` - Resource LIST by parent url operation. + Resource LIST by subscription level url operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview @@ -1243,7 +1243,7 @@ Expected response body: } ``` - Resource LIST by parent url operation. + Resource LIST by resource group level url operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview @@ -1271,8 +1271,8 @@ Expected response body: } ``` - Resource LIST by parent url operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionResources + Resource LIST by resource level url operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview Expected response body: @@ -1280,7 +1280,7 @@ Expected response body: ```json { "value": [{ - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ @@ -1303,7 +1303,7 @@ Expected response body: - Endpoint: `patch https://management.azure.com` - Resource Patch operation. + Resource Patch operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1338,7 +1338,7 @@ Expected response body: } ``` - Resource Patch operation. + Resource Patch operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1373,7 +1373,7 @@ Expected response body: } ``` - Resource Patch operation. + Resource Patch operation for resource group level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -1408,8 +1408,8 @@ Expected response body: } ``` - Resource Patch operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource Patch operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected request body: @@ -1425,7 +1425,7 @@ Expected response body: ```json { - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp index 31778f26f..9ad99d50c 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/extension.tsp @@ -32,7 +32,7 @@ model ExtensionsResourceProperties { interface ExtensionsResources { @scenario @scenarioDoc(""" - Resource GET operation. + Resource GET operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -57,7 +57,7 @@ interface ExtensionsResources { } ``` - Resource GET operation. + Resource GET operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -82,7 +82,7 @@ interface ExtensionsResources { } ``` - Resource GET operation. + Resource GET operation for resource group level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -107,14 +107,14 @@ interface ExtensionsResources { } ``` - Resource GET operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource GET operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response body: ```json { - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ @@ -136,7 +136,7 @@ interface ExtensionsResources { @scenario @scenarioDoc(""" - Resource PUT operation. + Resource PUT operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -169,7 +169,7 @@ interface ExtensionsResources { } ``` - Resource PUT operation. + Resource PUT operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -202,7 +202,7 @@ interface ExtensionsResources { } ``` - Resource PUT operation. + Resource PUT operation for resource group level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -235,8 +235,8 @@ interface ExtensionsResources { } ``` - Resource PUT operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource PUT operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected request body: @@ -250,7 +250,7 @@ interface ExtensionsResources { Expected response body: ```json { - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ @@ -272,7 +272,7 @@ interface ExtensionsResources { @scenario @scenarioDoc(""" - Resource Patch operation. + Resource Patch operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -305,7 +305,7 @@ interface ExtensionsResources { } ``` - Resource Patch operation. + Resource Patch operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -338,7 +338,7 @@ interface ExtensionsResources { } ``` - Resource Patch operation. + Resource Patch operation for resource group level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview @@ -371,8 +371,8 @@ interface ExtensionsResources { } ``` - Resource Patch operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource Patch operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected request body: @@ -386,7 +386,7 @@ interface ExtensionsResources { Expected response body: ```json { - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ @@ -408,23 +408,23 @@ interface ExtensionsResources { @scenario @scenarioDoc(""" - Resource DELETE operation. + Resource DELETE operation for tenant level extension resource. Expected path: /providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 - Resource DELETE operation. + Resource DELETE operation for subscription level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 - Resource DELETE operation. + Resource DELETE operation for resource get level extension resource. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 - Resource DELETE operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension + Resource DELETE operation for resource level extension resource. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension Expected query parameter: api-version=2023-12-01-preview Expected response status code: 204 """) @@ -432,7 +432,7 @@ interface ExtensionsResources { @scenario @scenarioDoc(""" - Resource LIST by parent url operation. + Resource LIST by tenant level url operation. Expected path: /providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview @@ -459,7 +459,7 @@ interface ExtensionsResources { } ``` - Resource LIST by parent url operation. + Resource LIST by subscription level url operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview @@ -486,7 +486,7 @@ interface ExtensionsResources { } ``` - Resource LIST by parent url operation. + Resource LIST by resource group level url operation. Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview @@ -513,15 +513,15 @@ interface ExtensionsResources { } ``` - Resource LIST by parent url operation. - Expected path: /providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionResources + Resource LIST by resource level url operation. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionResources Expected query parameter: api-version=2023-12-01-preview Expected response body: ```json { "value": [{ - "id": "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension", "name": "extension", "type": "Azure.ResourceManager.Resources/extensionsResources", "properties":{ diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts index 63c2b4770..1b5f8a756 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/resources/mockapi.ts @@ -116,7 +116,7 @@ const validTenantExtensionsResource = { }; const validResourceExtensionsResource = { - id: `/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, + id: `/subscriptions/${SUBSCRIPTION_ID_EXPECTED}/resourceGroups/${RESOURCE_GROUP_EXPECTED}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/top/providers/Azure.ResourceManager.Resources/extensionsResources/extension`, name: "extension", type: "Azure.ResourceManager.Resources/extensionsResources", properties: { @@ -184,7 +184,7 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_get = passOnSucces kind: "MockApiDefinition", }, { - uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "get", request: { params: { @@ -266,10 +266,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_createOrUpdate = p kind: "MockApiDefinition", }, { - uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "put", request: { params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", @@ -380,10 +382,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_update = passOnSuc kind: "MockApiDefinition", }, { - uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "patch", request: { params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", @@ -458,10 +462,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_delete = passOnSuc kind: "MockApiDefinition", }, { - uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources/:extensionName", method: "delete", request: { params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, "topLevelResourceName": "top", "extensionName": "extension", "api-version": "2023-12-01-preview", @@ -527,10 +533,12 @@ Scenarios.Azure_ResourceManager_Resources_ExtensionsResources_listByParent = pas kind: "MockApiDefinition", }, { - uri: "/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", + uri: "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/:topLevelResourceName/providers/Azure.ResourceManager.Resources/extensionsResources", method: "get", request: { params: { + "subscriptionId": SUBSCRIPTION_ID_EXPECTED, + "resourceGroup": RESOURCE_GROUP_EXPECTED, "topLevelResourceName": "top", "api-version": "2023-12-01-preview", },