Skip to content

Commit 607360e

Browse files
committed
correct fix - convert the type
1 parent ca93c7b commit 607360e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Monitor/Monitor/ActivityLogAlert/SetAzureRmActivityLogAlertCommand.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ protected override void ProcessRecordInternal()
150150
resourceGroupName: out resourceGroupName,
151151
activityLogAlertName: out activityLogAlertName);
152152

153-
requestBody = this.UpdateActivityLogAlertResource(this.InputObject);
153+
requestBody = this.UpdateActivityLogAlertPsResource(this.InputObject);
154154
}
155155
else if (this.MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(this.ResourceId))
156156
{
@@ -205,6 +205,23 @@ protected override void ProcessRecordInternal()
205205
}
206206
}
207207

208+
private ActivityLogAlertResource UpdateActivityLogAlertPsResource(PSActivityLogAlertResource inputObject)
209+
{
210+
var activityLogAlertResource = new ActivityLogAlertResource(
211+
inputObject.Location,
212+
inputObject.Scopes,
213+
new ActivityLogAlertAllOfCondition(inputObject.Condition.AllOf.Select(e => new ActivityLogAlertLeafCondition(field: e.Field, equals: e.Equals)).ToList()),
214+
new ActivityLogAlertActionList(inputObject.Actions.ActionGroups.Select(e => new ActivityLogAlertActionGroup(actionGroupId: e.ActionGroupId, webhookProperties: e.WebhookProperties)).ToList()),
215+
inputObject.Id,
216+
inputObject.Name,
217+
inputObject.Type,
218+
inputObject.Tags,
219+
inputObject.Enabled,
220+
inputObject.Description);
221+
222+
return UpdateActivityLogAlertResource(activityLogAlertResource);
223+
}
224+
208225
private ActivityLogAlertResource UpdateActivityLogAlertResource(ActivityLogAlertResource requestBody)
209226
{
210227
// There was an ActivityLogAlert already there, just modify what can be modifed

src/Monitor/Monitor/TransitionalClasses/ActivityLogAlertResource.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public ActivityLogAlertResource(Monitor.Models.ActivityLogAlertResource activity
5454
enabled: activityLogAlertResource?.Enabled,
5555
description: activityLogAlertResource?.Description)
5656
{
57-
57+
if (activityLogAlertResource != null)
58+
{
59+
this.Actions = activityLogAlertResource.Actions != null ? new ActivityLogAlertActionList(activityLogAlertResource.Actions) : null;
60+
this.Condition = activityLogAlertResource.Condition != null ? new ActivityLogAlertAllOfCondition(activityLogAlertResource.Condition) : null;
61+
}
5862
}
5963
}
6064
}

0 commit comments

Comments
 (0)