From 45374f48f560b3337ed55735038f1e9bf8cbea65 Mon Sep 17 00:00:00 2001 From: radhikajain99 <86242402+radhikajain99@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:28:20 +0530 Subject: [PATCH] Adding API for notification rules in loadtesting (#31078) * Adding API for notification rules in loadtesting * Update description * Moving to new API version 2024-11-01-preview * Updates * Remove wrong files * Update example to dict * Update as per review * Update key in example * Add new trigger scope * Add test run started/ended to trigger scope * Change event name to trigger completed * Update name * Remove triggers scope * Update spec * Move notifications to 2024-12-01-preview * Update api version in examples * Update doc --- .../CreateOrUpdateNotificationRule.json | 126 ++++ .../DeleteNotificationRule.json | 11 + .../GetNotificationRule.json | 51 ++ .../ListNotificationRules.json | 87 +++ .../models.notificationrule.tsp | 161 +++++ .../LoadTestService/routes.tsp | 19 + .../CreateOrUpdateNotificationRule.json | 126 ++++ .../examples/DeleteNotificationRule.json | 11 + .../examples/GetNotificationRule.json | 51 ++ .../examples/ListNotificationRules.json | 87 +++ .../2024-12-01-preview/loadtestservice.json | 621 ++++++++++++++++++ 11 files changed, 1351 insertions(+) create mode 100644 specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/CreateOrUpdateNotificationRule.json create mode 100644 specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/DeleteNotificationRule.json create mode 100644 specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/GetNotificationRule.json create mode 100644 specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/ListNotificationRules.json create mode 100644 specification/loadtestservice/LoadTestService/models.notificationrule.tsp create mode 100644 specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/CreateOrUpdateNotificationRule.json create mode 100644 specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/DeleteNotificationRule.json create mode 100644 specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/GetNotificationRule.json create mode 100644 specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/ListNotificationRules.json diff --git a/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/CreateOrUpdateNotificationRule.json b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/CreateOrUpdateNotificationRule.json new file mode 100644 index 000000000000..890108b7b450 --- /dev/null +++ b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/CreateOrUpdateNotificationRule.json @@ -0,0 +1,126 @@ +{ + "operationId": "NotificationRuleAdministration_CreateOrUpdateNotificationRule", + "title": "Create or update a notification rule for tests.", + "parameters": { + "api-version": "2024-12-01-preview", + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "body": { + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + } + } + }, + "responses": { + "200": { + "body": { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + }, + "201": { + "body": { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + } + } +} diff --git a/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/DeleteNotificationRule.json b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/DeleteNotificationRule.json new file mode 100644 index 000000000000..5cf5ee5b0314 --- /dev/null +++ b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/DeleteNotificationRule.json @@ -0,0 +1,11 @@ +{ + "operationId": "NotificationRuleAdministration_DeleteNotificationRule", + "title": "Delete a notification rule", + "parameters": { + "api-version": "2024-12-01-preview", + "notificationRuleId": "12345678-1234-1234-1234-123456789012" + }, + "responses": { + "204": {} + } +} diff --git a/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/GetNotificationRule.json b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/GetNotificationRule.json new file mode 100644 index 000000000000..fb3c5bdce3c3 --- /dev/null +++ b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/GetNotificationRule.json @@ -0,0 +1,51 @@ +{ + "operationId": "NotificationRuleAdministration_GetNotificationRule", + "title": "Get a notification rule.", + "parameters": { + "api-version": "2024-12-01-preview", + "notificationRuleId": "12345678-1234-1234-1234-123456789012" + }, + "responses": { + "200": { + "body": { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + } + } +} diff --git a/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/ListNotificationRules.json b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/ListNotificationRules.json new file mode 100644 index 000000000000..dbb2b787ec0a --- /dev/null +++ b/specification/loadtestservice/LoadTestService/examples/2024-12-01-preview/ListNotificationRules.json @@ -0,0 +1,87 @@ +{ + "operationId": "NotificationRuleAdministration_ListNotificationRule", + "title": "Get all notification rules for the specified filters.", + "parameters": { + "maxPageSize": 30, + "lastModifiedStartTime": "2024-05-01T16:00:46.072Z", + "lastModifiedEndTime": "2024-05-01T16:50:46.072Z", + "api-version": "2024-12-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule1", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup1", + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup2" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012", + "12345678-1234-1234-1234-123456789013" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + }, + { + "notificationRuleId": "12345678-1234-1234-1234-123456789013", + "displayName": "Sample_Notification_Rule2", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup2" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED" + ], + "testRunResults": [ + "FAILED" + ] + } + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + ] + } + } + } +} diff --git a/specification/loadtestservice/LoadTestService/models.notificationrule.tsp b/specification/loadtestservice/LoadTestService/models.notificationrule.tsp new file mode 100644 index 000000000000..c05a4f1ac08a --- /dev/null +++ b/specification/loadtestservice/LoadTestService/models.notificationrule.tsp @@ -0,0 +1,161 @@ +import "@typespec/rest"; +import "@typespec/http"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; +using Azure.ClientGenerator.Core; + +namespace Microsoft.LoadTestService; + +@added(APIVersions.v2024_12_01_preview) +@doc("Scope type of a notification rule.") +union NotificationScopeType { + string, + + @doc("Notification rule is for Tests.") + Tests: "Tests", +} + +@added(APIVersions.v2024_12_01_preview) +@doc("Notification event type.") +union NotificationEventType { + string, + + @doc("Test run ended event. This event would occur when a test run reaches terminal state.") + TestRunEnded: "TestRunEnded", + + @doc("Test run started event. This event would occur when a new test run is triggered.") + TestRunStarted: "TestRunStarted", + + @doc("Trigger completed event. This event would occur when a trigger completes.") + TriggerCompleted: "TriggerCompleted", + + @doc("Trigger disabled event. This event would occur when a trigger is disabled.") + TriggerDisabled: "TriggerDisabled", +} + +@added(APIVersions.v2024_12_01_preview) +@discriminator("kind") +@doc("The notification event filter for Tests scope.") +model TestsNotificationEventFilter { + @doc("The event type") + kind: NotificationEventType; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("The notification event filter when the event type is TestRunEnded and scope is Tests.") +model TestRunEndedNotificationEventFilter extends TestsNotificationEventFilter { + @doc("Event type for test run ended event.") + kind: NotificationEventType.TestRunEnded; + + @doc("Event filtering condition.") + condition?: TestRunEndedEventCondition; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("The notification event filter when the event type is TestRunStarted and scope is Tests.") +model TestRunStartedNotificationEventFilter + extends TestsNotificationEventFilter { + @doc("Event type for test run started event.") + kind: NotificationEventType.TestRunStarted; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("The notification event filter when the event type is TriggerCompleted.") +model TriggerCompletedNotificationEventFilter + extends TestsNotificationEventFilter { + @doc("Event type for trigger ended event.") + kind: NotificationEventType.TriggerCompleted; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("The notification event filter when the event type is TriggerDisabled.") +model TriggerDisabledNotificationEventFilter + extends TestsNotificationEventFilter { + @doc("Event type for trigger disabled event.") + kind: NotificationEventType.TriggerDisabled; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("TestRunEnded Event condition.") +model TestRunEndedEventCondition { + @doc("The test run statuses to send notification for.") + testRunStatuses?: Status[]; + + @doc("The test run results to send notification for.") + testRunResults?: PFTestResult[]; +} + +@added(APIVersions.v2024_12_01_preview) +@resource("notification-rules") +@discriminator("scope") +@doc("Notification rule model.") +model NotificationRule { + @key + @maxLength(50) + @minLength(2) + @pattern("^[a-z0-9_-]*$") + @doc("The unique identifier of the notification rule.") + @visibility("read") + notificationRuleId: string; + + @maxLength(50) + @minLength(2) + @doc("The name of the notification rule.") + displayName: string; + + @doc("The action groups to notify.") + actionGroupIds: string[]; + + @doc("The scope of the notification rule.") + scope: NotificationScopeType; + + ...SystemMetaData; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("Tests Notification rule model.") +model TestsNotificationRule extends NotificationRule { + @doc("Scope of type Tests.") + scope: NotificationScopeType.Tests; + + @doc("The test ids to include. If not provided, notification will be sent for all testIds.") + testIds?: string[]; + + @doc(""" + The event to receive notifications for along with filtering conditions. + Key is a user-assigned identifier for the event filter. + """) + eventFilters: Record; +} + +@added(APIVersions.v2024_12_01_preview) +@doc("Parameters for list notification rule operation.") +model ListNotificationRuleQueryParams { + @doc("Search based on notification rules associated with the provided test ids.") + @query + testIds?: string; + + @doc("Search based on notification rules for the provided scopes.") + @query + scopes?: string; + + @doc(""" + Start DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + """) + @query + lastModifiedStartTime?: utcDateTime; + + @doc(""" + End DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules. + """) + @query + lastModifiedEndTime?: utcDateTime; + + @doc("Number of results in response. Default page size is 50.") + @query + maxpagesize?: int32 = 50; +} diff --git a/specification/loadtestservice/LoadTestService/routes.tsp b/specification/loadtestservice/LoadTestService/routes.tsp index 95a32f0d199b..f8d106994770 100644 --- a/specification/loadtestservice/LoadTestService/routes.tsp +++ b/specification/loadtestservice/LoadTestService/routes.tsp @@ -6,6 +6,7 @@ import "@azure-tools/typespec-client-generator-core"; import "./models.tsp"; import "./models.testprofile.tsp"; import "./models.trigger.tsp"; +import "./models.notificationrule.tsp"; using Azure.Core; using Azure.Core.Traits; @@ -530,3 +531,21 @@ interface TriggerAdministration { ListQueryParametersTrait >; } + +@tag("NotificationRule") +interface NotificationRuleAdministration { + @added(APIVersions.v2024_12_01_preview) + getNotificationRule is StandardResourceOperations.ResourceRead; + + @added(APIVersions.v2024_12_01_preview) + createOrUpdateNotificationRule is StandardResourceOperations.ResourceCreateOrUpdate; + + @added(APIVersions.v2024_12_01_preview) + deleteNotificationRule is StandardResourceOperations.ResourceDelete; + + @added(APIVersions.v2024_12_01_preview) + listNotificationRule is StandardResourceOperations.ResourceList< + NotificationRule, + ListQueryParametersTrait + >; +} diff --git a/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/CreateOrUpdateNotificationRule.json b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/CreateOrUpdateNotificationRule.json new file mode 100644 index 000000000000..890108b7b450 --- /dev/null +++ b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/CreateOrUpdateNotificationRule.json @@ -0,0 +1,126 @@ +{ + "operationId": "NotificationRuleAdministration_CreateOrUpdateNotificationRule", + "title": "Create or update a notification rule for tests.", + "parameters": { + "api-version": "2024-12-01-preview", + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "body": { + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + } + } + }, + "responses": { + "200": { + "body": { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + }, + "201": { + "body": { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + } + } +} diff --git a/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/DeleteNotificationRule.json b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/DeleteNotificationRule.json new file mode 100644 index 000000000000..5cf5ee5b0314 --- /dev/null +++ b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/DeleteNotificationRule.json @@ -0,0 +1,11 @@ +{ + "operationId": "NotificationRuleAdministration_DeleteNotificationRule", + "title": "Delete a notification rule", + "parameters": { + "api-version": "2024-12-01-preview", + "notificationRuleId": "12345678-1234-1234-1234-123456789012" + }, + "responses": { + "204": {} + } +} diff --git a/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/GetNotificationRule.json b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/GetNotificationRule.json new file mode 100644 index 000000000000..fb3c5bdce3c3 --- /dev/null +++ b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/GetNotificationRule.json @@ -0,0 +1,51 @@ +{ + "operationId": "NotificationRuleAdministration_GetNotificationRule", + "title": "Get a notification rule.", + "parameters": { + "api-version": "2024-12-01-preview", + "notificationRuleId": "12345678-1234-1234-1234-123456789012" + }, + "responses": { + "200": { + "body": { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + } + } +} diff --git a/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/ListNotificationRules.json b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/ListNotificationRules.json new file mode 100644 index 000000000000..dbb2b787ec0a --- /dev/null +++ b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/examples/ListNotificationRules.json @@ -0,0 +1,87 @@ +{ + "operationId": "NotificationRuleAdministration_ListNotificationRule", + "title": "Get all notification rules for the specified filters.", + "parameters": { + "maxPageSize": 30, + "lastModifiedStartTime": "2024-05-01T16:00:46.072Z", + "lastModifiedEndTime": "2024-05-01T16:50:46.072Z", + "api-version": "2024-12-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "notificationRuleId": "12345678-1234-1234-1234-123456789012", + "displayName": "Sample_Notification_Rule1", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup1", + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup2" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012", + "12345678-1234-1234-1234-123456789013" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED", + "DONE" + ], + "testRunResults": [ + "PASSED", + "FAILED" + ] + } + }, + "eventfilter2": { + "kind": "TestRunStarted" + }, + "eventfilter3": { + "kind": "TriggerCompleted" + }, + "eventfilter4": { + "kind": "TriggerDisabled" + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + }, + { + "notificationRuleId": "12345678-1234-1234-1234-123456789013", + "displayName": "Sample_Notification_Rule2", + "actionGroupIds": [ + "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sampleRG/providers/microsoft.insights/actionGroups/sampleActionGroup2" + ], + "scope": "Tests", + "testIds": [ + "12345678-1234-1234-1234-123456789012" + ], + "eventFilters": { + "eventfilter1": { + "kind": "TestRunEnded", + "condition": { + "testRunStatuses": [ + "FAILED" + ], + "testRunResults": [ + "FAILED" + ] + } + } + }, + "createdDateTime": "2024-05-01T16:43:46.072Z", + "createdBy": "user@contoso.com", + "lastModifiedDateTime": "2024-05-01T16:43:46.072Z", + "lastModifiedBy": "user@contoso.com" + } + ] + } + } + } +} diff --git a/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/loadtestservice.json b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/loadtestservice.json index 0908e8efbbe2..b2e583c76911 100644 --- a/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/loadtestservice.json +++ b/specification/loadtestservice/data-plane/Microsoft.LoadTestService/preview/2024-12-01-preview/loadtestservice.json @@ -64,9 +64,228 @@ }, { "name": "Trigger" + }, + { + "name": "NotificationRule" } ], "paths": { + "/notification-rules": { + "get": { + "operationId": "NotificationRuleAdministration_ListNotificationRule", + "tags": [ + "NotificationRule" + ], + "description": "Resource list operation template.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "$ref": "#/parameters/ListNotificationRuleQueryParams.testIds" + }, + { + "$ref": "#/parameters/ListNotificationRuleQueryParams.scopes" + }, + { + "$ref": "#/parameters/ListNotificationRuleQueryParams.lastModifiedStartTime" + }, + { + "$ref": "#/parameters/ListNotificationRuleQueryParams.lastModifiedEndTime" + }, + { + "$ref": "#/parameters/ListNotificationRuleQueryParams.maxpagesize" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/PagedNotificationRule" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Get all notification rules for the specified filters.": { + "$ref": "./examples/ListNotificationRules.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/notification-rules/{notificationRuleId}": { + "get": { + "operationId": "NotificationRuleAdministration_GetNotificationRule", + "tags": [ + "NotificationRule" + ], + "description": "Resource read operation template.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "notificationRuleId", + "in": "path", + "description": "The unique identifier of the notification rule.", + "required": true, + "type": "string", + "minLength": 2, + "maxLength": 50, + "pattern": "^[a-z0-9_-]*$" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/NotificationRule" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Get a notification rule.": { + "$ref": "./examples/GetNotificationRule.json" + } + } + }, + "patch": { + "operationId": "NotificationRuleAdministration_CreateOrUpdateNotificationRule", + "tags": [ + "NotificationRule" + ], + "description": "Create or update operation template.", + "consumes": [ + "application/merge-patch+json" + ], + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "notificationRuleId", + "in": "path", + "description": "The unique identifier of the notification rule.", + "required": true, + "type": "string", + "minLength": 2, + "maxLength": 50, + "pattern": "^[a-z0-9_-]*$" + }, + { + "name": "body", + "in": "body", + "description": "The resource instance.", + "required": true, + "schema": { + "$ref": "#/definitions/NotificationRuleCreateOrUpdate" + }, + "x-ms-client-name": "resource" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/NotificationRule" + } + }, + "201": { + "description": "The request has succeeded and a new resource has been created as a result.", + "schema": { + "$ref": "#/definitions/NotificationRule" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Create or update a notification rule for tests.": { + "$ref": "./examples/CreateOrUpdateNotificationRule.json" + } + } + }, + "delete": { + "operationId": "NotificationRuleAdministration_DeleteNotificationRule", + "tags": [ + "NotificationRule" + ], + "description": "Resource delete operation template.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "notificationRuleId", + "in": "path", + "description": "The unique identifier of the notification rule.", + "required": true, + "type": "string", + "minLength": 2, + "maxLength": 50, + "pattern": "^[a-z0-9_-]*$" + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-examples": { + "Delete a notification rule": { + "$ref": "./examples/DeleteNotificationRule.json" + } + } + } + }, "/test-profile-runs": { "get": { "operationId": "TestProfileRunAdministration_ListTestProfileRuns", @@ -3398,6 +3617,147 @@ } } }, + "NotificationEventType": { + "type": "string", + "description": "Notification event type.", + "enum": [ + "TestRunEnded", + "TestRunStarted", + "TriggerCompleted", + "TriggerDisabled" + ], + "x-ms-enum": { + "name": "NotificationEventType", + "modelAsString": true, + "values": [ + { + "name": "TestRunEnded", + "value": "TestRunEnded", + "description": "Test run ended event. This event would occur when a test run reaches terminal state." + }, + { + "name": "TestRunStarted", + "value": "TestRunStarted", + "description": "Test run started event. This event would occur when a new test run is triggered." + }, + { + "name": "TriggerCompleted", + "value": "TriggerCompleted", + "description": "Trigger completed event. This event would occur when a trigger completes." + }, + { + "name": "TriggerDisabled", + "value": "TriggerDisabled", + "description": "Trigger disabled event. This event would occur when a trigger is disabled." + } + ] + } + }, + "NotificationRule": { + "type": "object", + "description": "Notification rule model.", + "properties": { + "notificationRuleId": { + "type": "string", + "description": "The unique identifier of the notification rule.", + "minLength": 2, + "maxLength": 50, + "pattern": "^[a-z0-9_-]*$", + "readOnly": true + }, + "displayName": { + "type": "string", + "description": "The name of the notification rule.", + "minLength": 2, + "maxLength": 50 + }, + "actionGroupIds": { + "type": "array", + "description": "The action groups to notify.", + "items": { + "type": "string" + } + }, + "scope": { + "$ref": "#/definitions/NotificationScopeType", + "description": "The scope of the notification rule." + }, + "createdDateTime": { + "type": "string", + "format": "date-time", + "description": "The creation datetime(RFC 3339 literal format).", + "readOnly": true + }, + "createdBy": { + "type": "string", + "description": "The user that created.", + "readOnly": true + }, + "lastModifiedDateTime": { + "type": "string", + "format": "date-time", + "description": "The last Modified datetime(RFC 3339 literal format).", + "readOnly": true + }, + "lastModifiedBy": { + "type": "string", + "description": "The user that last modified.", + "readOnly": true + } + }, + "discriminator": "scope", + "required": [ + "notificationRuleId", + "displayName", + "actionGroupIds", + "scope" + ] + }, + "NotificationRuleCreateOrUpdate": { + "type": "object", + "description": "Notification rule model.", + "properties": { + "displayName": { + "type": "string", + "description": "The name of the notification rule.", + "minLength": 2, + "maxLength": 50 + }, + "actionGroupIds": { + "type": "array", + "description": "The action groups to notify.", + "items": { + "type": "string" + } + }, + "scope": { + "$ref": "#/definitions/NotificationScopeType", + "description": "The scope of the notification rule." + } + }, + "discriminator": "scope", + "required": [ + "scope" + ] + }, + "NotificationScopeType": { + "type": "string", + "description": "Scope type of a notification rule.", + "enum": [ + "Tests" + ], + "x-ms-enum": { + "name": "NotificationScopeType", + "modelAsString": true, + "values": [ + { + "name": "Tests", + "value": "Tests", + "description": "Notification rule is for Tests." + } + ] + } + }, "OptionalLoadTestConfig": { "type": "object", "description": "Configuration for quick load test", @@ -3637,6 +3997,28 @@ ] } }, + "PagedNotificationRule": { + "type": "object", + "description": "Paged collection of NotificationRule items", + "properties": { + "value": { + "type": "array", + "description": "The NotificationRule items on this page", + "items": { + "$ref": "#/definitions/NotificationRule" + }, + "x-ms-identifiers": [] + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, "PagedTest": { "type": "object", "description": "Paged collection of Test items", @@ -5599,6 +5981,58 @@ "properties" ] }, + "TestRunEndedEventCondition": { + "type": "object", + "description": "TestRunEnded Event condition.", + "properties": { + "testRunStatuses": { + "type": "array", + "description": "The test run statuses to send notification for.", + "items": { + "$ref": "#/definitions/Status" + } + }, + "testRunResults": { + "type": "array", + "description": "The test run results to send notification for.", + "items": { + "$ref": "#/definitions/PFTestResult" + } + } + } + }, + "TestRunEndedNotificationEventFilter": { + "type": "object", + "description": "The notification event filter when the event type is TestRunEnded and scope is Tests.", + "properties": { + "condition": { + "$ref": "#/definitions/TestRunEndedEventCondition", + "description": "Event filtering condition." + } + }, + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilter" + } + ], + "x-ms-discriminator-value": "TestRunEnded" + }, + "TestRunEndedNotificationEventFilterCreateOrUpdate": { + "type": "object", + "description": "The notification event filter when the event type is TestRunEnded and scope is Tests.", + "properties": { + "condition": { + "$ref": "#/definitions/TestRunEndedEventCondition", + "description": "Event filtering condition." + } + }, + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilterCreateOrUpdate" + } + ], + "x-ms-discriminator-value": "TestRunEnded" + }, "TestRunFileInfo": { "type": "object", "description": "Test run file info.", @@ -5736,6 +6170,26 @@ } } }, + "TestRunStartedNotificationEventFilter": { + "type": "object", + "description": "The notification event filter when the event type is TestRunStarted and scope is Tests.", + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilter" + } + ], + "x-ms-discriminator-value": "TestRunStarted" + }, + "TestRunStartedNotificationEventFilterCreateOrUpdate": { + "type": "object", + "description": "The notification event filter when the event type is TestRunStarted and scope is Tests.", + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilterCreateOrUpdate" + } + ], + "x-ms-discriminator-value": "TestRunStarted" + }, "TestRunStatistics": { "type": "object", "description": "Test run statistics.", @@ -5917,6 +6371,89 @@ } } }, + "TestsNotificationEventFilter": { + "type": "object", + "description": "The notification event filter for Tests scope.", + "properties": { + "kind": { + "$ref": "#/definitions/NotificationEventType", + "description": "The event type" + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "TestsNotificationEventFilterCreateOrUpdate": { + "type": "object", + "description": "The notification event filter for Tests scope.", + "properties": { + "kind": { + "$ref": "#/definitions/NotificationEventType", + "description": "The event type" + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "TestsNotificationRule": { + "type": "object", + "description": "Tests Notification rule model.", + "properties": { + "testIds": { + "type": "array", + "description": "The test ids to include. If not provided, notification will be sent for all testIds.", + "items": { + "type": "string" + } + }, + "eventFilters": { + "type": "object", + "description": "The event to receive notifications for along with filtering conditions.\nKey is a user-assigned identifier for the event filter.", + "additionalProperties": { + "$ref": "#/definitions/TestsNotificationEventFilter" + } + } + }, + "required": [ + "eventFilters" + ], + "allOf": [ + { + "$ref": "#/definitions/NotificationRule" + } + ], + "x-ms-discriminator-value": "Tests" + }, + "TestsNotificationRuleCreateOrUpdate": { + "type": "object", + "description": "Tests Notification rule model.", + "properties": { + "testIds": { + "type": "array", + "description": "The test ids to include. If not provided, notification will be sent for all testIds.", + "items": { + "type": "string" + } + }, + "eventFilters": { + "type": "object", + "description": "The event to receive notifications for along with filtering conditions.\nKey is a user-assigned identifier for the event filter.", + "additionalProperties": { + "$ref": "#/definitions/TestsNotificationEventFilterCreateOrUpdate" + } + } + }, + "allOf": [ + { + "$ref": "#/definitions/NotificationRuleCreateOrUpdate" + } + ], + "x-ms-discriminator-value": "Tests" + }, "TimeGrain": { "type": "string", "description": "Time Grain", @@ -6047,6 +6584,26 @@ "kind" ] }, + "TriggerCompletedNotificationEventFilter": { + "type": "object", + "description": "The notification event filter when the event type is TriggerCompleted.", + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilter" + } + ], + "x-ms-discriminator-value": "TriggerCompleted" + }, + "TriggerCompletedNotificationEventFilterCreateOrUpdate": { + "type": "object", + "description": "The notification event filter when the event type is TriggerCompleted.", + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilterCreateOrUpdate" + } + ], + "x-ms-discriminator-value": "TriggerCompleted" + }, "TriggerCreateOrUpdate": { "type": "object", "description": "Trigger model.", @@ -6076,6 +6633,26 @@ "kind" ] }, + "TriggerDisabledNotificationEventFilter": { + "type": "object", + "description": "The notification event filter when the event type is TriggerDisabled.", + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilter" + } + ], + "x-ms-discriminator-value": "TriggerDisabled" + }, + "TriggerDisabledNotificationEventFilterCreateOrUpdate": { + "type": "object", + "description": "The notification event filter when the event type is TriggerDisabled.", + "allOf": [ + { + "$ref": "#/definitions/TestsNotificationEventFilterCreateOrUpdate" + } + ], + "x-ms-discriminator-value": "TriggerDisabled" + }, "TriggerState": { "type": "string", "description": "Current state of a trigger.", @@ -6244,6 +6821,50 @@ "x-ms-parameter-location": "method", "x-ms-client-name": "apiVersion" }, + "ListNotificationRuleQueryParams.lastModifiedEndTime": { + "name": "lastModifiedEndTime", + "in": "query", + "description": "End DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules.", + "required": false, + "type": "string", + "format": "date-time", + "x-ms-parameter-location": "method" + }, + "ListNotificationRuleQueryParams.lastModifiedStartTime": { + "name": "lastModifiedStartTime", + "in": "query", + "description": "Start DateTime(RFC 3339 literal format) of the last updated time range to filter notification rules.", + "required": false, + "type": "string", + "format": "date-time", + "x-ms-parameter-location": "method" + }, + "ListNotificationRuleQueryParams.maxpagesize": { + "name": "maxpagesize", + "in": "query", + "description": "Number of results in response. Default page size is 50.", + "required": false, + "type": "integer", + "format": "int32", + "default": 50, + "x-ms-parameter-location": "method" + }, + "ListNotificationRuleQueryParams.scopes": { + "name": "scopes", + "in": "query", + "description": "Search based on notification rules for the provided scopes.", + "required": false, + "type": "string", + "x-ms-parameter-location": "method" + }, + "ListNotificationRuleQueryParams.testIds": { + "name": "testIds", + "in": "query", + "description": "Search based on notification rules associated with the provided test ids.", + "required": false, + "type": "string", + "x-ms-parameter-location": "method" + }, "ListTestProfileQueryParams.lastModifiedEndTime": { "name": "lastModifiedEndTime", "in": "query",