diff --git a/.changeset/funny-toes-hunt.md b/.changeset/funny-toes-hunt.md new file mode 100644 index 000000000..4227bf1ea --- /dev/null +++ b/.changeset/funny-toes-hunt.md @@ -0,0 +1,5 @@ +--- +"@azure-tools/cadl-ranch-specs": patch +--- + +Added tests for ARM, test case for resource action. diff --git a/packages/cadl-ranch-specs/cadl-ranch-summary.md b/packages/cadl-ranch-specs/cadl-ranch-summary.md index 0c0bc93bf..e9aa6ca39 100644 --- a/packages/cadl-ranch-specs/cadl-ranch-summary.md +++ b/packages/cadl-ranch-specs/cadl-ranch-summary.md @@ -964,6 +964,22 @@ Expected response body: } ``` +### Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_actionSync + +- Endpoint: `post https://management.azure.com` + + Resource sync action. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/top/actionSync + Expected query parameter: api-version=2023-12-01-preview + Expected request body: + + ```json + { + "message": "Resource action at top level.", + "urgent": true + } + ``` + ### Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_createOrReplace - Endpoint: `put https://management.azure.com` diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts index ac99dd930..25d2d6fb6 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/mockapi.ts @@ -42,6 +42,31 @@ const validNestedResource = { }, }; +Scenarios.Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_actionSync = passOnSuccess([ + mockapi.post( + "/subscriptions/:subscriptionId/resourceGroups/:resourceGroup/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/:topLevelResourceName/actionSync", + (req) => { + req.expect.containsQueryParam("api-version", "2023-12-01-preview"); + if (req.params.subscriptionId !== SUBSCRIPTION_ID_EXPECTED) { + throw new ValidationError("Unexpected subscriptionId", SUBSCRIPTION_ID_EXPECTED, req.params.subscriptionId); + } + if (req.params.resourceGroup.toLowerCase() !== RESOURCE_GROUP_EXPECTED) { + throw new ValidationError("Unexpected resourceGroup", RESOURCE_GROUP_EXPECTED, req.params.resourceGroup); + } + if (req.params.topLevelResourceName.toLowerCase() !== "top") { + throw new ValidationError("Unexpected top level resource name", "top", req.params.topLevelResourceName); + } + req.expect.bodyEquals({ + message: "Resource action at top level.", + urgent: true, + }); + return { + status: 204, + }; + }, + ), +]); + // top level tracked resource Scenarios.Azure_ResourceManager_Models_Resources_TopLevelTrackedResources_get = passOnSuccess([ mockapi.get( diff --git a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/toplevel.tsp b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/toplevel.tsp index 821de27d6..471b04ecf 100644 --- a/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/toplevel.tsp +++ b/packages/cadl-ranch-specs/http/azure/resource-manager/models/resources/toplevel.tsp @@ -31,6 +31,15 @@ model TopLevelTrackedResourceProperties { description?: string; } +@doc("The details of a user notification.") +model NotificationDetails { + @doc("The notification message.") + message: string; + + @doc("If true, the notification is urgent.") + urgent: boolean; +} + @armResourceOperations interface TopLevelTrackedResources { @scenario @@ -211,4 +220,19 @@ interface TopLevelTrackedResources { ``` """) listBySubscription is ArmListBySubscription; + + @scenario + @scenarioDoc(""" + Resource sync action. + Expected path: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.Models.Resources/topLevelTrackedResources/top/actionSync + Expected query parameter: api-version=2023-12-01-preview + Expected request body: + ```json + { + "message": "Resource action at top level.", + "urgent": true + } + ``` + """) + actionSync is ArmResourceActionNoContentSync; }