Skip to content

Commit fc600dc

Browse files
authored
[PS] migrate ActivityLogAlert in Monitor module to autorest v4 (#28024)
1 parent c2921c6 commit fc600dc

30 files changed

+481
-357
lines changed

src/Monitor/ActivityLogAlert.Autorest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
2121
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
2222
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - ActivityLogAlert")]
23-
[assembly: System.Reflection.AssemblyFileVersionAttribute("6.0.2")]
24-
[assembly: System.Reflection.AssemblyVersionAttribute("6.0.2")]
23+
[assembly: System.Reflection.AssemblyFileVersionAttribute("6.0.3")]
24+
[assembly: System.Reflection.AssemblyVersionAttribute("6.0.3")]
2525
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
2626
[assembly: System.CLSCompliantAttribute(false)]

src/Monitor/ActivityLogAlert.Autorest/README.md

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -39,69 +39,13 @@ title: ActivityLogAlert
3939
module-version: 0.1.0
4040
subject-prefix: ActivityLogAlert
4141
namespace: Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert
42-
resourcegroup-append: true
43-
nested-object-to-string: true
44-
45-
# If there are post APIs for some kinds of actions in the RP, you may need to
46-
# uncomment following line to support viaIdentity for these post APIs
47-
# identity-correction-for-post: true
48-
49-
# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
50-
use-extension:
51-
"@autorest/powershell": "3.x"
5242

5343
directive:
54-
- where:
55-
verb: Get
56-
subject: ActivityLogAlert
57-
set:
58-
breaking-change:
59-
deprecated-output-properties:
60-
- ActionGroup
61-
- ConditionAllOf
62-
- Scope
63-
new-output-properties:
64-
- ActionGroup
65-
- ConditionAllOf
66-
- Scope
67-
change-description: The types of the properties ActionGroup, ConditionAllOf and Scope will be changed from single object or fixed array to 'List'.
68-
deprecated-by-version: 7.0.0
69-
deprecated-by-azversion: 15.0.0
70-
change-effective-date: 2025/11/03
71-
- where:
72-
verb: New|Update
73-
subject: ActivityLogAlert
74-
set:
75-
breaking-change:
76-
deprecated-output-properties:
77-
- ActionGroup
78-
- ConditionAllOf
79-
- Scope
80-
- AnyOf
81-
new-output-properties:
82-
- ActionGroup
83-
- ConditionAllOf
84-
- Scope
85-
- AnyOf
86-
change-description: The types of the properties ActionGroup, ConditionAllOf, Scope and AnyOf will be changed from single object or fixed array to 'List'.
87-
deprecated-by-version: 7.0.0
88-
deprecated-by-azversion: 15.0.0
89-
change-effective-date: 2025/11/03
90-
- where:
91-
parameter-name: Action|Condition|Scope
92-
set:
93-
breaking-change:
94-
old-parameter-type: Array
95-
new-parameter-type: List
96-
deprecated-by-version: 7.0.0
97-
deprecated-by-azversion: 15.0.0
98-
change-effective-date: 2025/11/03
99-
10044
# Following is two common directive which are normally required in all the RPs
10145
# 1. Remove the unexpanded parameter set
10246
# 2. For New-* cmdlets, ViaIdentity is not required, so CreateViaIdentityExpanded is removed as well
10347
- where:
104-
variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$
48+
variant: ^(Create|Update)(?!.*?(Expanded|JsonFilePath|JsonString))
10549
remove: true
10650
# Remove Set cmdlet
10751
- where:
@@ -131,7 +75,7 @@ directive:
13175
subject-prefix: ""
13276
# Add breaking change for them, will add back.
13377
- model-cmdlet:
134-
# - AlertRuleAnyOfOrLeafCondition
135-
# - AlertRuleLeafCondition
136-
- ActionGroup
78+
- model-name: AlertRuleAnyOfOrLeafCondition
79+
- model-name: AlertRuleLeafCondition
80+
- model-name: ActionGroup
13781
```

src/Monitor/ActivityLogAlert.Autorest/custom/New-AzActivityLogAlert.ps1

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ Create a new Activity Log Alert rule or update an existing one.
2020
.Description
2121
Create a new Activity Log Alert rule or update an existing one.
2222
.Example
23-
{{ Add code here }}
24-
.Example
25-
{{ Add code here }}
23+
$scope = "/subscriptions/"+(Get-AzContext).Subscription.ID
24+
$actiongroup=New-AzActivityLogAlertActionGroupObject -Id $ActionGroupResourceId -WebhookProperty @{"sampleWebhookProperty"="SamplePropertyValue"}
25+
$condition1=New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Administrative -Field category
26+
$condition2=New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Error -Field level
27+
$any1=New-AzActivityLogAlertAlertRuleLeafConditionObject -Field properties.incidentType -Equal Maintenance
28+
$any2=New-AzActivityLogAlertAlertRuleLeafConditionObject -Field properties.incidentType -Equal Incident
29+
$condition3=New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -AnyOf $any1,$any2
30+
New-AzActivityLogAlert -Name $AlertName -ResourceGroupName $ResourceGroupName -Action $actiongroup -Condition @($condition1,$condition2,$condition3) -Location global -Scope $scope
2631
2732
.Outputs
28-
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IActivityLogAlertResource
33+
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActivityLogAlertResource
2934
.Notes
3035
COMPLEX PARAMETER PROPERTIES
3136
@@ -37,18 +42,18 @@ ACTIONGROUP <IActionGroup[]>: The list of the Action Groups.
3742
[(Any) <String>]: This indicates any property can be added to this object.
3843
3944
CONDITIONALLOF <IAlertRuleAnyOfOrLeafCondition[]>: The list of Activity Log Alert rule conditions.
40-
[ContainsAny <String[]>]: The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition is met.
45+
[ContainsAny <List<String>>]: The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition is met.
4146
[Equal <String>]: The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met.
4247
[Field <String>]: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'.
43-
[AnyOf <IAlertRuleLeafCondition[]>]: An Activity Log Alert rule condition that is met when at least one of its member leaf conditions are met.
44-
[ContainsAny <String[]>]: The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition is met.
48+
[AnyOf <List<IAlertRuleLeafCondition>>]: An Activity Log Alert rule condition that is met when at least one of its member leaf conditions are met.
49+
[ContainsAny <List<String>>]: The value of the event's field will be compared to the values in this array (case-insensitive) to determine if the condition is met.
4550
[Equal <String>]: The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met.
4651
[Field <String>]: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'.
4752
.Link
4853
https://learn.microsoft.com/powershell/module/az.monitor/new-azactivitylogalert
4954
#>
5055
function New-AzActivityLogAlert {
51-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IActivityLogAlertResource])]
56+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActivityLogAlertResource])]
5257
[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
5358
param(
5459
[Parameter(Mandatory)]
@@ -72,43 +77,43 @@ function New-AzActivityLogAlert {
7277
# The ID of the target subscription.
7378
${SubscriptionId},
7479

75-
[Parameter(Mandatory)]
80+
[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
7681
[AllowEmptyCollection()]
7782
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
78-
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IActionGroup[]]
83+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActionGroup[]]
7984
# The list of the Action Groups.
8085
# To construct, see NOTES section for ACTIONGROUP properties and create a hash table.
8186
${Action},
8287

83-
[Parameter(Mandatory)]
88+
[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
8489
[AllowEmptyCollection()]
8590
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
86-
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IAlertRuleAnyOfOrLeafCondition[]]
91+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IAlertRuleAnyOfOrLeafCondition[]]
8792
# The list of Activity Log Alert rule conditions.
8893
# To construct, see NOTES section for CONDITIONALLOF properties and create a hash table.
8994
${Condition},
9095

91-
[Parameter()]
96+
[Parameter(ParameterSetName='CreateExpanded')]
9297
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
9398
[System.String]
9499
# A description of this Activity Log Alert rule.
95100
${Description},
96101

97-
[Parameter()]
102+
[Parameter(ParameterSetName='CreateExpanded')]
98103
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
99104
[System.Boolean]
100105
# Indicates whether this Activity Log Alert rule is enabled.
101106
# If an Activity Log Alert rule is not enabled, then none of its actions will be activated.
102107
${Enabled},
103108

104-
[Parameter(Mandatory)]
109+
[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
105110
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
106111
[System.String]
107112
# The location of the resource.
108113
# Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'.
109114
${Location},
110115

111-
[Parameter(Mandatory)]
116+
[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
112117
[AllowEmptyCollection()]
113118
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
114119
[System.String[]]
@@ -117,19 +122,32 @@ function New-AzActivityLogAlert {
117122
# This list must include at least one item.
118123
${Scope},
119124

120-
[Parameter()]
125+
[Parameter(ParameterSetName='CreateExpanded')]
121126
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
122-
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IAzureResourceTags]))]
127+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IAzureResourceTags]))]
123128
[System.Collections.Hashtable]
124129
# The tags of the resource.
125130
${Tag},
131+
132+
[Parameter(ParameterSetName='CreateViaJsonFilePath', Mandatory)]
133+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
134+
[System.String]
135+
# Path of Json file supplied to the Create operation
136+
${JsonFilePath},
137+
138+
[Parameter(ParameterSetName='CreateViaJsonString', Mandatory)]
139+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
140+
[System.String]
141+
# Json string supplied to the Create operation
142+
${JsonString},
126143

127144
[Parameter()]
128145
[Alias('AzureRMContext', 'AzureCredential')]
129146
[ValidateNotNull()]
130147
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Azure')]
131148
[System.Management.Automation.PSObject]
132-
# The credentials, account, tenant, and subscription used for communication with Azure.
149+
# The DefaultProfile parameter is not functional.
150+
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
133151
${DefaultProfile},
134152

135153
[Parameter(DontShow)]

src/Monitor/ActivityLogAlert.Autorest/custom/Update-AzActivityLogAlert.ps1

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ Updates 'tags' and 'enabled' fields in an existing Alert rule.
2424
This method is used to update the Alert rule tags, and to enable or disable the Alert rule.
2525
To update other fields use CreateOrUpdate operation.
2626
.Example
27-
{{ Add code here }}
28-
.Example
29-
{{ Add code here }}
27+
Update-AzActivityLogAlert -ResourceGroupName $ResourceGroupName -Name $AlertName -Tag @{"key"="val"} -Enabled $false
3028
3129
.Inputs
3230
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActivityLogAlertIdentity
3331
.Outputs
34-
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IActivityLogAlertResource
32+
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActivityLogAlertResource
3533
.Notes
3634
COMPLEX PARAMETER PROPERTIES
3735
@@ -46,24 +44,30 @@ INPUTOBJECT <IMonitorIdentity>: Identity Parameter
4644
https://learn.microsoft.com/powershell/module/az.monitor/update-azactivitylogalert
4745
#>
4846
function Update-AzActivityLogAlert {
49-
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IActivityLogAlertResource])]
47+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActivityLogAlertResource])]
5048
[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
5149
param(
5250
[Parameter(ParameterSetName='UpdateExpanded', Mandatory)]
51+
[Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)]
52+
[Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)]
5353
[Alias('ActivityLogAlertName')]
5454
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Path')]
5555
[System.String]
5656
# The name of the Activity Log Alert rule.
5757
${Name},
5858

5959
[Parameter(ParameterSetName='UpdateExpanded', Mandatory)]
60+
[Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)]
61+
[Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)]
6062
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Path')]
6163
[System.String]
6264
# The name of the resource group.
6365
# The name is case insensitive.
6466
${ResourceGroupName},
6567

6668
[Parameter(ParameterSetName='UpdateExpanded')]
69+
[Parameter(ParameterSetName='UpdateViaJsonFilePath')]
70+
[Parameter(ParameterSetName='UpdateViaJsonString')]
6771
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Path')]
6872
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
6973
[System.String]
@@ -77,26 +81,41 @@ function Update-AzActivityLogAlert {
7781
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
7882
${InputObject},
7983

80-
[Parameter()]
84+
[Parameter(ParameterSetName='UpdateExpanded')]
85+
[Parameter(ParameterSetName='UpdateViaIdentityExpanded')]
8186
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
8287
[System.Boolean]
8388
# Indicates whether this Activity Log Alert rule is enabled.
8489
# If an Activity Log Alert rule is not enabled, then none of its actions will be activated.
8590
${Enabled},
8691

87-
[Parameter()]
92+
[Parameter(ParameterSetName='UpdateExpanded')]
93+
[Parameter(ParameterSetName='UpdateViaIdentityExpanded')]
8894
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
89-
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IAlertRulePatchObjectTags]))]
95+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IAlertRulePatchObjectTags]))]
9096
[System.Collections.Hashtable]
9197
# The resource tags
9298
${Tag},
99+
100+
[Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)]
101+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
102+
[System.String]
103+
# Path of Json file supplied to the Update operation
104+
${JsonFilePath},
105+
106+
[Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)]
107+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Body')]
108+
[System.String]
109+
# Json string supplied to the Update operation
110+
${JsonString},
93111

94112
[Parameter()]
95113
[Alias('AzureRMContext', 'AzureCredential')]
96114
[ValidateNotNull()]
97115
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Category('Azure')]
98116
[System.Management.Automation.PSObject]
99-
# The credentials, account, tenant, and subscription used for communication with Azure.
117+
# The DefaultProfile parameter is not functional.
118+
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
100119
${DefaultProfile},
101120

102121
[Parameter(DontShow)]

src/Monitor/ActivityLogAlert.Autorest/custom/autogen-model-cmdlets/New-AzActivityLogAlertActionGroupObject.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@ Create an in-memory object for ActionGroup.
2121
Create an in-memory object for ActionGroup.
2222
2323
.Outputs
24-
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.ActionGroup
24+
Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.ActionGroup
2525
.Link
26-
https://learn.microsoft.com/powershell/module/Az.Monitor/new-AzActivityLogAlertActionGroupObject
26+
https://learn.microsoft.com/powershell/module/Az.Monitor/new-azactivitylogalertactiongroupobject
2727
#>
2828
function New-AzActivityLogAlertActionGroupObject {
29-
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.ActionGroup')]
29+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.ModelCmdletAttribute()]
30+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.ActionGroup')]
3031
[CmdletBinding(PositionalBinding=$false)]
3132
Param(
3233

3334
[Parameter(Mandatory, HelpMessage="The resource ID of the Action Group. This cannot be null or empty.")]
3435
[string]
3536
$Id,
3637
[Parameter(HelpMessage="the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload.")]
37-
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.IActionGroupWebhookProperties]
38+
[Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.IActionGroupWebhookProperties]
3839
$WebhookProperty
3940
)
4041

4142
process {
42-
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.Api20201001.ActionGroup]::New()
43+
$Object = [Microsoft.Azure.PowerShell.Cmdlets.Monitor.ActivityLogAlert.Models.ActionGroup]::New()
4344

4445
if ($PSBoundParameters.ContainsKey('Id')) {
4546
$Object.Id = $Id

0 commit comments

Comments
 (0)