Skip to content

Commit 011192c

Browse files
welovejv-xutoChenxiJiang333v-jiaodipshao25
authored
Tyespec migration for alertsmanagement PreviewAlertRule (#39115)
* converted * could compile * update * Update tspconfig.yaml * Refactor folder * Create client.tsp * Update tspconfig.yaml * Refactor tspconfig.yaml by removing unused fields Removed package-dir and is-modular-library fields from tspconfig.yaml. * Update client.tsp * Update client.tsp * Update client.tsp * Update client.tsp * add go config --------- Co-authored-by: Tong Xu (MSFT) <v-xuto@microsoft.com> Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com> Co-authored-by: Pan Shao <97225342+pshao25@users.noreply.github.com> Co-authored-by: judy.liu <v-liujudy@microsoft.com>
1 parent a8e6c4f commit 011192c

10 files changed

Lines changed: 1314 additions & 356 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
3+
using Azure.ClientGenerator.Core;
4+
using Microsoft.AlertsManagement;
5+
6+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
7+
@@Legacy.flattenProperty(LogAlertRuleResource.properties);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import "./main.tsp";
2+
import "@azure-tools/typespec-client-generator-core";
3+
4+
using Azure.ClientGenerator.Core;
5+
using Microsoft.AlertsManagement;
6+
7+
@@clientName(Microsoft.AlertsManagement,
8+
"PreviewAlertRuleMgmtClient",
9+
"python"
10+
);
11+
@@clientName(AlertSeverity.`0`, "ZERO", "python");
12+
@@clientName(AlertSeverity.`1`, "ONE", "python");
13+
@@clientName(AlertSeverity.`2`, "TWO", "python");
14+
@@clientName(AlertSeverity.`3`, "THREE", "python");
15+
@@clientName(AlertSeverity.`4`, "FOUR", "python");
16+
17+
@@clientName(AlertSeverity.`0`, "Zero", "go");
18+
@@clientName(AlertSeverity.`1`, "One", "go");
19+
@@clientName(AlertSeverity.`2`, "Two", "go");
20+
@@clientName(AlertSeverity.`3`, "Three", "go");
21+
@@clientName(AlertSeverity.`4`, "Four", "go");
22+
@@clientName(Microsoft.AlertsManagement, "Client", "go");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"parameters": {
3+
"api-version": "2025-07-01-preview",
4+
"parameters": {
5+
"location": "eastus",
6+
"properties": {
7+
"scheduledQueryRuleProperties": {
8+
"location": "eastus",
9+
"properties": {
10+
"description": "Performance rule",
11+
"criteria": {
12+
"allOf": [
13+
{
14+
"alertSensitivity": "Medium",
15+
"criterionType": "DynamicThresholdCriterion",
16+
"dimensions": [
17+
{
18+
"name": "AlertName",
19+
"operator": "Include",
20+
"values": [
21+
"alert"
22+
]
23+
}
24+
],
25+
"operator": "GreaterThan",
26+
"query": "Alert",
27+
"timeAggregation": "Count"
28+
}
29+
]
30+
},
31+
"enabled": true,
32+
"evaluationFrequency": "PT1H",
33+
"scopes": [
34+
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"
35+
],
36+
"severity": 4,
37+
"windowSize": "PT1H"
38+
}
39+
},
40+
"timespan": "PT24H"
41+
}
42+
},
43+
"resourceId": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"
44+
},
45+
"responses": {
46+
"200": {
47+
"body": {
48+
"rulePreviewResults": [
49+
{
50+
"dimensionCombination": [
51+
{
52+
"name": "AlertName",
53+
"value": "Alert1"
54+
}
55+
],
56+
"evaluations": [
57+
{
58+
"alertState": "Fired",
59+
"evaluatedPeriods": [
60+
{
61+
"highThreshold": 80,
62+
"lowThreshold": 20,
63+
"metricValue": 85,
64+
"thresholdMet": true,
65+
"timestamp": "2025-02-15T09:00:00Z"
66+
},
67+
{
68+
"highThreshold": 80,
69+
"lowThreshold": 20,
70+
"metricValue": 75,
71+
"thresholdMet": false,
72+
"timestamp": "2025-02-15T08:00:00Z"
73+
}
74+
],
75+
"evaluationTime": "2025-02-15T10:00:00Z",
76+
"thresholdMet": true
77+
},
78+
{
79+
"alertState": "Resolved",
80+
"evaluatedPeriods": [
81+
{
82+
"highThreshold": 80,
83+
"lowThreshold": 20,
84+
"metricValue": 65,
85+
"thresholdMet": false,
86+
"timestamp": "2025-02-15T10:00:00Z"
87+
},
88+
{
89+
"highThreshold": 80,
90+
"lowThreshold": 20,
91+
"metricValue": 85,
92+
"thresholdMet": true,
93+
"timestamp": "2025-02-15T09:00:00Z"
94+
}
95+
],
96+
"evaluationTime": "2025-02-15T11:00:00Z",
97+
"thresholdMet": false
98+
}
99+
]
100+
}
101+
]
102+
}
103+
}
104+
},
105+
"operationId": "PreviewAlertRule",
106+
"title": "Run preview of a dynamic threshold log search alert rule"
107+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* PLEASE DO NOT REMOVE - USED FOR CONVERTER METRICS
3+
* Generated by package: @autorest/openapi-to-typespec
4+
* Parameters used:
5+
* isFullCompatible: true
6+
* guessResourceKey: false
7+
* Version: 0.11.12
8+
* Date: 2025-12-08T01:30:48.361Z
9+
*/
10+
import "@typespec/rest";
11+
import "@typespec/versioning";
12+
import "@azure-tools/typespec-azure-core";
13+
import "@azure-tools/typespec-azure-resource-manager";
14+
import "./models.tsp";
15+
import "./back-compatible.tsp";
16+
import "./routes.tsp";
17+
18+
using TypeSpec.Rest;
19+
using TypeSpec.Http;
20+
using Azure.ResourceManager.Foundations;
21+
using Azure.Core;
22+
using Azure.ResourceManager;
23+
using TypeSpec.Versioning;
24+
/**
25+
* The Preview Alert Rule API provides the ability to retrieve the results of a simulated historical execution of an alert rule
26+
*/
27+
#suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
28+
@armProviderNamespace
29+
@service(#{
30+
title: "Preview Alert Rule API in Alerts Management Service Resource Provider",
31+
})
32+
@versioned(Versions)
33+
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3)
34+
namespace Microsoft.AlertsManagement;
35+
36+
/**
37+
* The available API versions.
38+
*/
39+
enum Versions {
40+
/**
41+
* The 2025-07-01-preview API version.
42+
*/
43+
v2025_07_01_preview: "2025-07-01-preview",
44+
}

0 commit comments

Comments
 (0)