public static PSSuppressionAlertsScope ConvertToPSType(this SuppressionAlertsScope value) { return(new PSSuppressionAlertsScope { AllOf = value?.AllOf?.Select(sc => sc.ConvertToPSType()).ToList() }); }
public override void ExecuteCmdlet() { var name = Name ?? InputObject?.Name; if (ShouldProcess(name, VerbsCommon.Set)) { AlertsSuppressionRule alertsSuppressionRuleInput; if (this.IsParameterBound(c => c.InputObject)) { if (this.IsParameterBound(c => c.Name)) { InputObject.Name = Name; } if (this.IsParameterBound(c => c.AlertType)) { InputObject.AlertType = AlertType; } if (this.IsParameterBound(c => c.Comment)) { InputObject.Comment = Comment; } if (this.IsParameterBound(c => c.ExpirationDateUtc)) { InputObject.ExpirationDateUtc = ExpirationDateUtc; } if (this.IsParameterBound(c => c.Reason)) { InputObject.Reason = Reason; } if (this.IsParameterBound(c => c.State)) { InputObject.State = State; } if (this.IsParameterBound(c => c.SuppressionAlertsScope)) { InputObject.SuppressionAlertsScope = SuppressionAlertsScope; } alertsSuppressionRuleInput = InputObject.ConvertToNetType(); } else { SuppressionAlertsScope alertsScope = null; if (this.IsParameterBound(c => c.SuppressionAlertsScope)) { alertsScope = SuppressionAlertsScope.ConvertToNetType(); } else if (this.IsParameterBound(c => c.AllOf)) { alertsScope = new SuppressionAlertsScope(AllOf?.Select(sc => sc.ConvertToNetType()).ToList()); } // Setting scope to null if there are no items in the array alertsScope = alertsScope?.AllOf?.Count > 0 ? alertsScope : null; alertsSuppressionRuleInput = new AlertsSuppressionRule(AlertType, Reason, State.ConvertToNetType(), name: Name, expirationDateUtc: ExpirationDateUtc, comment: Comment, suppressionAlertsScope: alertsScope); } var alertsSuppressionRule = SecurityCenterClient.AlertsSuppressionRules.UpdateWithHttpMessagesAsync(name, alertsSuppressionRuleInput).GetAwaiter().GetResult().Body; WriteObject(alertsSuppressionRule.ConvertToPSType(), enumerateCollection: false); } }