-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Tyespec migration for alertsmanagement PreviewAlertRule #39115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Pan Shao (pshao25)
merged 14 commits into
Azure:main
from
welovej:TspMig-alertsmanagement-PreviewAlertRule
Feb 2, 2026
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
039ec4e
converted
welovej 3e1531b
could compile
welovej 0e57479
update
welovej e519ae0
Update tspconfig.yaml
welovej f47405e
Refactor folder
v-xuto 22e7c84
Create client.tsp
ChenxiJiang333 de517db
Update tspconfig.yaml
ChenxiJiang333 75ae723
Refactor tspconfig.yaml by removing unused fields
v-jiaodi f0e74e3
Update client.tsp
ChenxiJiang333 4e2bd34
Update client.tsp
ChenxiJiang333 4b0195d
Update client.tsp
ChenxiJiang333 17d211d
Update client.tsp
ChenxiJiang333 b12f65a
Merge branch 'main' into TspMig-alertsmanagement-PreviewAlertRule
pshao25 c458ebb
add go config
jliusan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...nagement/resource-manager/Microsoft.AlertsManagement/PreviewAlertRule/back-compatible.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
|
|
||
| using Azure.ClientGenerator.Core; | ||
| using Microsoft.AlertsManagement; | ||
|
|
||
| #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| @@Legacy.flattenProperty(LogAlertRuleResource.properties); |
48 changes: 48 additions & 0 deletions
48
.../alertsmanagement/resource-manager/Microsoft.AlertsManagement/PreviewAlertRule/client.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import "./main.tsp"; | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
|
|
||
| using Azure.ClientGenerator.Core; | ||
| using Microsoft.AlertsManagement; | ||
|
|
||
| @@clientName(Microsoft.AlertsManagement, | ||
| "PreviewAlertRuleMgmtClient", | ||
| "python" | ||
| ); | ||
|
|
||
| namespace AlertSeverityCustomization { | ||
| /** | ||
| * Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and required only for rules of the kind LogAlert. | ||
| */ | ||
| union AlertSeverity { | ||
| float64, | ||
|
|
||
| /** | ||
| * 0 | ||
| */ | ||
| ZERO: 0, | ||
|
|
||
| /** | ||
| * 1 | ||
| */ | ||
| ONE: 1, | ||
|
|
||
| /** | ||
| * 2 | ||
| */ | ||
| TWO: 2, | ||
|
|
||
| /** | ||
| * 3 | ||
| */ | ||
| THREE: 3, | ||
|
|
||
| /** | ||
| * 4 | ||
| */ | ||
| FOUR: 4, | ||
| } | ||
| } | ||
| @@alternateType(AlertSeverity, | ||
| AlertSeverityCustomization.AlertSeverity, | ||
| "python" | ||
| ); | ||
107 changes: 107 additions & 0 deletions
107
...eviewAlertRule/examples/2025-07-01-preview/previewDynamicThresholdLogSearchAlertRule.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-07-01-preview", | ||
| "parameters": { | ||
| "location": "eastus", | ||
| "properties": { | ||
| "scheduledQueryRuleProperties": { | ||
| "location": "eastus", | ||
| "properties": { | ||
| "description": "Performance rule", | ||
| "criteria": { | ||
| "allOf": [ | ||
| { | ||
| "alertSensitivity": "Medium", | ||
| "criterionType": "DynamicThresholdCriterion", | ||
| "dimensions": [ | ||
| { | ||
| "name": "AlertName", | ||
| "operator": "Include", | ||
| "values": [ | ||
| "alert" | ||
| ] | ||
| } | ||
| ], | ||
| "operator": "GreaterThan", | ||
| "query": "Alert", | ||
| "timeAggregation": "Count" | ||
| } | ||
| ] | ||
| }, | ||
| "enabled": true, | ||
| "evaluationFrequency": "PT1H", | ||
| "scopes": [ | ||
| "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/myWorkspace" | ||
| ], | ||
| "severity": 4, | ||
| "windowSize": "PT1H" | ||
| } | ||
| }, | ||
| "timespan": "PT24H" | ||
| } | ||
| }, | ||
| "resourceId": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/myWorkspace" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "rulePreviewResults": [ | ||
| { | ||
| "dimensionCombination": [ | ||
| { | ||
| "name": "AlertName", | ||
| "value": "Alert1" | ||
| } | ||
| ], | ||
| "evaluations": [ | ||
| { | ||
| "alertState": "Fired", | ||
| "evaluatedPeriods": [ | ||
| { | ||
| "highThreshold": 80, | ||
| "lowThreshold": 20, | ||
| "metricValue": 85, | ||
| "thresholdMet": true, | ||
| "timestamp": "2025-02-15T09:00:00Z" | ||
| }, | ||
| { | ||
| "highThreshold": 80, | ||
| "lowThreshold": 20, | ||
| "metricValue": 75, | ||
| "thresholdMet": false, | ||
| "timestamp": "2025-02-15T08:00:00Z" | ||
| } | ||
| ], | ||
| "evaluationTime": "2025-02-15T10:00:00Z", | ||
| "thresholdMet": true | ||
| }, | ||
| { | ||
| "alertState": "Resolved", | ||
| "evaluatedPeriods": [ | ||
| { | ||
| "highThreshold": 80, | ||
| "lowThreshold": 20, | ||
| "metricValue": 65, | ||
| "thresholdMet": false, | ||
| "timestamp": "2025-02-15T10:00:00Z" | ||
| }, | ||
| { | ||
| "highThreshold": 80, | ||
| "lowThreshold": 20, | ||
| "metricValue": 85, | ||
| "thresholdMet": true, | ||
| "timestamp": "2025-02-15T09:00:00Z" | ||
| } | ||
| ], | ||
| "evaluationTime": "2025-02-15T11:00:00Z", | ||
| "thresholdMet": false | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "PreviewAlertRule", | ||
| "title": "Run preview of a dynamic threshold log search alert rule" | ||
| } |
44 changes: 44 additions & 0 deletions
44
...on/alertsmanagement/resource-manager/Microsoft.AlertsManagement/PreviewAlertRule/main.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * PLEASE DO NOT REMOVE - USED FOR CONVERTER METRICS | ||
| * Generated by package: @autorest/openapi-to-typespec | ||
| * Parameters used: | ||
| * isFullCompatible: true | ||
| * guessResourceKey: false | ||
| * Version: 0.11.12 | ||
| * Date: 2025-12-08T01:30:48.361Z | ||
| */ | ||
| import "@typespec/rest"; | ||
| import "@typespec/versioning"; | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "./models.tsp"; | ||
| import "./back-compatible.tsp"; | ||
| import "./routes.tsp"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using TypeSpec.Http; | ||
| using Azure.ResourceManager.Foundations; | ||
| using Azure.Core; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.Versioning; | ||
| /** | ||
| * The Preview Alert Rule API provides the ability to retrieve the results of a simulated historical execution of an alert rule | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| @armProviderNamespace | ||
| @service(#{ | ||
| title: "Preview Alert Rule API in Alerts Management Service Resource Provider", | ||
| }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) | ||
| namespace Microsoft.AlertsManagement; | ||
|
|
||
| /** | ||
| * The available API versions. | ||
| */ | ||
| enum Versions { | ||
| /** | ||
| * The 2025-07-01-preview API version. | ||
| */ | ||
| v2025_07_01_preview: "2025-07-01-preview", | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.