Skip to content

Commit 2b392d9

Browse files
welovejv-jiaodiChenxiJiang333
authored
Tyespec migration for alertsmanagement TenantActivityLogAlerts (#39159)
* converted * could compile * update * update * delete for moving * add to destination * adjust tspconfig.yaml * Update tspconfig.yaml * Update tspconfig.yaml * Create client.tsp * Update TenantActivityLogAlertResource.tsp --------- Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com> Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com>
1 parent 467a8c1 commit 2b392d9

20 files changed

Lines changed: 1292 additions & 400 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/openapi";
4+
import "@typespec/rest";
5+
import "./models.tsp";
6+
7+
using TypeSpec.Rest;
8+
using Azure.ResourceManager;
9+
using TypeSpec.Http;
10+
using TypeSpec.OpenAPI;
11+
12+
namespace Microsoft.AlertsManagement;
13+
/**
14+
* A Tenant Activity Log Alert rule resource.
15+
*/
16+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
17+
model TenantActivityLogAlertResource
18+
is Azure.ResourceManager.Legacy.TrackedResourceWithOptionalLocation<
19+
AlertRuleProperties,
20+
false
21+
> {
22+
...ResourceNameParameter<
23+
Resource = TenantActivityLogAlertResource,
24+
KeyName = "alertRuleName",
25+
SegmentName = "tenantActivityLogAlerts",
26+
NamePattern = "^[-\\w\\._\\(\\)]+$"
27+
>;
28+
}
29+
30+
@armResourceOperations
31+
interface TenantActivityLogAlertResources {
32+
/**
33+
* Get a list of all Tenant Activity Log Alert rules in the tenant.
34+
*/
35+
listByTenant is Extension.ListByTarget<
36+
Extension.Tenant,
37+
TenantActivityLogAlertResource,
38+
Response = ArmResponse<TenantAlertRuleList>
39+
>;
40+
41+
/**
42+
* Get Tenant Activity Log Alert rule.
43+
*/
44+
get is Extension.Read<ManagementGroup, TenantActivityLogAlertResource>;
45+
46+
/**
47+
* Create a new Tenant Activity Log Alert rule or update an existing one.
48+
*/
49+
createOrUpdate is Extension.CreateOrReplaceSync<
50+
ManagementGroup,
51+
TenantActivityLogAlertResource
52+
>;
53+
54+
/**
55+
* Updates 'tags' and 'enabled' fields in an existing Tenant Alert rule. This method is used to update the Alert rule tags, and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation.
56+
*/
57+
@patch(#{ implicitOptionality: false })
58+
update is Extension.CustomPatchSync<
59+
ManagementGroup,
60+
TenantActivityLogAlertResource,
61+
PatchModel = TenantAlertRulePatchObject
62+
>;
63+
64+
/**
65+
* Delete a Tenant Activity Log Alert rule.
66+
*/
67+
delete is Extension.DeleteSync<
68+
ManagementGroup,
69+
TenantActivityLogAlertResource
70+
>;
71+
72+
/**
73+
* Get a list of all Tenant Activity Log Alert rules in a management group.
74+
*/
75+
listByManagementGroup is Extension.ListByTarget<
76+
ManagementGroup,
77+
TenantActivityLogAlertResource,
78+
Response = ArmResponse<TenantAlertRuleList>
79+
>;
80+
}
81+
82+
@@doc(TenantActivityLogAlertResource.name,
83+
"The name of the Tenant Activity Log Alert rule."
84+
);
85+
@@doc(TenantActivityLogAlertResource.properties,
86+
"The Activity Log Alert rule properties of the resource."
87+
);
88+
@@doc(TenantActivityLogAlertResources.createOrUpdate::parameters.resource,
89+
"The Tenant Activity Log Alert rule to create or use for the update."
90+
);
91+
@@doc(TenantActivityLogAlertResources.update::parameters.properties,
92+
"Parameters supplied to the operation."
93+
);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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(TenantAlertRulePatchObject.properties);
8+
9+
@@clientLocation(TenantActivityLogAlertResources.get,
10+
"TenantActivityLogAlerts"
11+
);
12+
@@clientLocation(TenantActivityLogAlertResources.createOrUpdate,
13+
"TenantActivityLogAlerts"
14+
);
15+
@@clientName(TenantActivityLogAlertResources.createOrUpdate::parameters.resource,
16+
"tenantActivityLogAlertRule"
17+
);
18+
@@clientLocation(TenantActivityLogAlertResources.update,
19+
"TenantActivityLogAlerts"
20+
);
21+
@@clientName(TenantActivityLogAlertResources.update::parameters.properties,
22+
"tenantActivityLogAlertRulePatch"
23+
);
24+
@@clientLocation(TenantActivityLogAlertResources.delete,
25+
"TenantActivityLogAlerts"
26+
);
27+
@@clientLocation(TenantActivityLogAlertResources.listByManagementGroup,
28+
"TenantActivityLogAlerts"
29+
);
30+
@@clientLocation(TenantActivityLogAlertResources.listByTenant,
31+
"TenantActivityLogAlerts"
32+
);
33+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
34+
@@Legacy.flattenProperty(TenantActivityLogAlertResource.properties);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import "./main.tsp";
2+
import "@azure-tools/typespec-client-generator-core";
3+
4+
using Azure.ClientGenerator.Core;
5+
6+
@@clientName(Microsoft.AlertsManagement,
7+
"TenantActivityLogAlertsMgmtClient",
8+
"python"
9+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"parameters": {
3+
"alertRuleName": "SampleActivityLogAlertSHRuleOnTenantLevel",
4+
"api-version": "2023-04-01-preview",
5+
"managementGroupName": "72f988bf-86f1-41af-91ab-2d7cd011db47",
6+
"tenantActivityLogAlertRule": {
7+
"location": "Global",
8+
"properties": {
9+
"description": "Description of sample Activity Log Alert service health rule on tenant level events.",
10+
"actions": {
11+
"actionGroups": [
12+
{
13+
"actionGroupId": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
14+
"actionProperties": {
15+
"Email.Title": "my email title"
16+
},
17+
"webhookProperties": {
18+
"sampleWebhookProperty": "SamplePropertyValue"
19+
}
20+
}
21+
]
22+
},
23+
"condition": {
24+
"allOf": [
25+
{
26+
"equals": "ServiceHealth",
27+
"field": "category"
28+
}
29+
]
30+
},
31+
"enabled": true,
32+
"tenantScope": "72f988bf-86f1-41af-91ab-2d7cd011db47"
33+
},
34+
"tags": {}
35+
}
36+
},
37+
"responses": {
38+
"200": {
39+
"body": {
40+
"name": "SampleActivityLogAlertSHRuleOnTenantLevel",
41+
"type": "Microsoft.AlertsManagement/TenantActivityLogAlerts",
42+
"id": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel",
43+
"location": "Global",
44+
"properties": {
45+
"description": "Description of sample Activity Log Alert service health rule on tenant level events.",
46+
"actions": {
47+
"actionGroups": [
48+
{
49+
"actionGroupId": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
50+
"actionProperties": {
51+
"Email.Title": "my email title"
52+
},
53+
"webhookProperties": {
54+
"sampleWebhookProperty": "SamplePropertyValue"
55+
}
56+
}
57+
]
58+
},
59+
"condition": {
60+
"allOf": [
61+
{
62+
"equals": "ServiceHealth",
63+
"field": "category"
64+
}
65+
]
66+
},
67+
"enabled": true,
68+
"tenantScope": "72f988bf-86f1-41af-91ab-2d7cd011db47"
69+
},
70+
"tags": {}
71+
},
72+
"headers": {}
73+
},
74+
"201": {
75+
"body": {
76+
"name": "SampleActivityLogAlertSHRuleOnTenantLevel",
77+
"type": "Microsoft.AlertsManagement/TenantActivityLogAlerts",
78+
"id": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel",
79+
"location": "Global",
80+
"properties": {
81+
"description": "Description of sample Activity Log Alert service health rule on tenant level events.",
82+
"actions": {
83+
"actionGroups": [
84+
{
85+
"actionGroupId": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
86+
"actionProperties": {
87+
"Email.Title": "my email title"
88+
},
89+
"webhookProperties": {
90+
"sampleWebhookProperty": "SamplePropertyValue"
91+
}
92+
}
93+
]
94+
},
95+
"condition": {
96+
"allOf": [
97+
{
98+
"equals": "ServiceHealth",
99+
"field": "category"
100+
}
101+
]
102+
},
103+
"enabled": true,
104+
"tenantScope": "72f988bf-86f1-41af-91ab-2d7cd011db47"
105+
},
106+
"tags": {}
107+
},
108+
"headers": {}
109+
}
110+
},
111+
"operationId": "TenantActivityLogAlerts_CreateOrUpdate",
112+
"title": "Create or update a Tenant Activity Log Alert rule for tenant level events"
113+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"parameters": {
3+
"alertRuleName": "SampleActivityLogAlertSHRuleOnTenantLevel",
4+
"api-version": "2023-04-01-preview",
5+
"managementGroupName": "72f988bf-86f1-41af-91ab-2d7cd011db47"
6+
},
7+
"responses": {
8+
"200": {},
9+
"204": {}
10+
},
11+
"operationId": "TenantActivityLogAlerts_Delete",
12+
"title": "Delete a Tenant Activity Log Alert rule"
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"parameters": {
3+
"alertRuleName": "SampleActivityLogAlertSHRuleOnTenantLevel",
4+
"api-version": "2023-04-01-preview",
5+
"managementGroupName": "72f988bf-86f1-41af-91ab-2d7cd011db47"
6+
},
7+
"responses": {
8+
"200": {
9+
"body": {
10+
"name": "SampleActivityLogAlertSHRuleOnTenantLevel",
11+
"type": "Microsoft.AlertsManagement/TenantActivityLogAlerts",
12+
"id": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel",
13+
"location": "Global",
14+
"properties": {
15+
"description": "Description of sample Activity Log Alert service health rule on tenant level events.",
16+
"actions": {
17+
"actionGroups": [
18+
{
19+
"actionGroupId": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
20+
"actionProperties": {
21+
"Email.Title": "my email title"
22+
},
23+
"webhookProperties": {
24+
"sampleWebhookProperty": "SamplePropertyValue"
25+
}
26+
}
27+
]
28+
},
29+
"condition": {
30+
"allOf": [
31+
{
32+
"equals": "ServiceHealth",
33+
"field": "category"
34+
}
35+
]
36+
},
37+
"enabled": true,
38+
"tenantScope": "72f988bf-86f1-41af-91ab-2d7cd011db47"
39+
},
40+
"tags": {}
41+
},
42+
"headers": {}
43+
}
44+
},
45+
"operationId": "TenantActivityLogAlerts_Get",
46+
"title": "Get a Tenant Activity Log Alert rule"
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"parameters": {
3+
"api-version": "2023-04-01-preview",
4+
"managementGroupName": "72f988bf-86f1-41af-91ab-2d7cd011db47"
5+
},
6+
"responses": {
7+
"200": {
8+
"body": {
9+
"value": [
10+
{
11+
"name": "SampleActivityLogAlertSHRuleOnTenantLevel",
12+
"type": "Microsoft.AlertsManagement/TenantActivityLogAlerts",
13+
"id": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.AlertsManagement/TenantActivityLogAlerts/SampleActivityLogAlertSHRuleOnTenantLevel",
14+
"location": "Global",
15+
"properties": {
16+
"description": "Description of sample Activity Log Alert service health rule on tenant level events.",
17+
"actions": {
18+
"actionGroups": [
19+
{
20+
"actionGroupId": "/providers/Microsoft.Management/ManagementGroups/72f988bf-86f1-41af-91ab-2d7cd011db47/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
21+
"actionProperties": {
22+
"Email.Title": "my email title"
23+
},
24+
"webhookProperties": {
25+
"sampleWebhookProperty": "SamplePropertyValue"
26+
}
27+
}
28+
]
29+
},
30+
"condition": {
31+
"allOf": [
32+
{
33+
"equals": "ServiceHealth",
34+
"field": "category"
35+
}
36+
]
37+
},
38+
"enabled": true,
39+
"tenantScope": "72f988bf-86f1-41af-91ab-2d7cd011db47"
40+
},
41+
"tags": {}
42+
}
43+
]
44+
},
45+
"headers": {}
46+
}
47+
},
48+
"operationId": "TenantActivityLogAlerts_ListByManagementGroup",
49+
"title": "List Activity Log Alerts by management group"
50+
}

0 commit comments

Comments
 (0)