From 2ec599ba1ad44cdb022d8412d0c386c5cdd57b89 Mon Sep 17 00:00:00 2001 From: hongli750210 Date: Mon, 28 Oct 2024 15:47:20 +0800 Subject: [PATCH] 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",