public async void GetFilteredAlertsForDev() { var alerts = await PortalClient.GetAlertsAsync( new AlertFilter { StartEpochIsAfter = 1470009600, StartEpochIsBefore = 1471564800, MonitorObjectId = WindowsDeviceId, Levels = new List <AlertLevel> { AlertLevel.Critical, AlertLevel.Error, AlertLevel.Warning } }).ConfigureAwait(false); CheckAlertsAreValid(alerts); // Refetch with GetAlertAsync foreach (var alert in alerts) { var refetchedAlert = await PortalClient.GetAlertAsync(alert.Id).ConfigureAwait(false); Assert.Equal(alert.MonitorObjectId, refetchedAlert.MonitorObjectId); Assert.Equal(alert.Id, refetchedAlert.Id); Assert.Equal(alert.AlertType, refetchedAlert.AlertType); Assert.Equal(alert.DetailMessage?.Body, refetchedAlert.DetailMessage?.Body); } }
public async void GetAlertsFilteredByDevice() { var device = await GetWindowsDeviceAsync().ConfigureAwait(false); foreach (var alertType in new List <AlertType> { AlertType.DataSource, AlertType.EventSource }) { var alertFilter = new Filter <Alert> { Skip = 0, Take = 10, FilterItems = new List <FilterItem <Alert> > { new Eq <Alert>(nameof(Alert.MonitorObjectName), device.DisplayName) } }; // Refetch each alert foreach (var alert in await PortalClient.GetAllAsync(alertFilter).ConfigureAwait(false)) { var _ = await PortalClient.GetAlertAsync(alert.Id).ConfigureAwait(false); } } }
public async void GetFilteredAlertsForDatacenter() { var alerts = await PortalClient.GetAlertsAsync(new AlertFilter { StartEpochIsAfter = StartDateTimeSeconds, StartEpochIsBefore = EndDateTimeSeconds, MonitorObjectGroupFullPaths = new List <string> { "Datacenter/*" }, IncludeCleared = true }).ConfigureAwait(false); CheckAlertsAreValid(alerts); // Refetch with GetAlertAsync foreach (var alert in alerts.Take(10)) { var refetchedAlert = await PortalClient.GetAlertAsync(alert.Id).ConfigureAwait(false); Assert.NotNull(refetchedAlert); Assert.Equal(alert.MonitorObjectId, refetchedAlert.MonitorObjectId); Assert.Equal(alert.Id, refetchedAlert.Id); Assert.Equal(alert.AlertType, refetchedAlert.AlertType); Assert.Equal(alert.DetailMessage?.Body, refetchedAlert.DetailMessage?.Body); } }