Skip to content

Commit

Permalink
More refactoring Device -> Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnmbond committed Oct 1, 2024
1 parent 2d3824a commit e778346
Show file tree
Hide file tree
Showing 155 changed files with 3,438 additions and 3,059 deletions.
2 changes: 2 additions & 0 deletions LogicMonitor.Api.Test/Attributes/IsPropertyReadonlyTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using LogicMonitor.Api.Resources;

namespace LogicMonitor.Api.Test.Attributes;

public class IsPropertyReadonlyTests
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.Api.Test/Dashboards/DashboardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public async Task Get()
websiteOverallStatusWidget.Should().NotBeNull();

// Device SLA widget
var deviceSlaStatusWidget = widgets.OfType<DeviceSlaWidget>().FirstOrDefault();
var deviceSlaStatusWidget = widgets.OfType<ResourceSlaWidget>().FirstOrDefault();
deviceSlaStatusWidget.Should().NotBeNull();
deviceSlaStatusWidget.Metrics.Should().NotBeNull();
deviceSlaStatusWidget.Metrics.Should().NotBeNullOrEmpty();
Expand Down
10 changes: 5 additions & 5 deletions LogicMonitor.Api.Test/Data/DataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task GetOverviewGraphData()
.ConfigureAwait(true);
overviewGraph.Should().NotBeNull();

var graphDataRequest = new DeviceDataSourceGraphDataRequest
var graphDataRequest = new ResourceDataSourceGraphDataRequest
{
DataSourceInstanceGroupId = deviceDataSourceInstanceGroup.Id,
OverviewGraphId = overviewGraph.Id,
Expand Down Expand Up @@ -109,7 +109,7 @@ public async Task GetNetflowGraphData()
.ConfigureAwait(true);
_ = await LogicMonitorClient.GetGraphDataAsync(new NetflowGraphDataRequest
{
DeviceId = netflowDevice.Id,
ResourceId = netflowDevice.Id,
StartDateTime = new DateTime(utcNow.Year, utcNow.Month, 1).AddMonths(-1),
EndDateTime = new DateTime(utcNow.Year, utcNow.Month, 1),
NetflowFilter = new NetflowFilters(),
Expand Down Expand Up @@ -168,7 +168,7 @@ public async Task GetGraphData_X250()
var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.ConfigureAwait(true);
var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest
var deviceGraphDataRequest = new ResourceDataSourceInstanceGraphDataRequest
{
DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id,
DataSourceGraphId = dataSourceGraph.Id,
Expand Down Expand Up @@ -214,7 +214,7 @@ public async Task GetGraphData()
deviceDataSourceInstances.Should().NotBeNull();
deviceDataSourceInstances.Should().NotBeNullOrEmpty();

var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest
var deviceGraphDataRequest = new ResourceDataSourceInstanceGraphDataRequest
{
DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id,
DataSourceGraphId = dataSourceGraph.Id,
Expand Down Expand Up @@ -272,7 +272,7 @@ public async Task GetGraphDataWithoutFakeData()
var startDateTime = new DateTime(2023, 7, 12, 10, 0, 0, DateTimeKind.Utc);
var endDateTime = startDateTime.AddHours(1);

var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest
var deviceGraphDataRequest = new ResourceDataSourceInstanceGraphDataRequest
{
DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id,
DataSourceGraphId = dataSourceGraph.Id,
Expand Down
1 change: 1 addition & 0 deletions LogicMonitor.Api.Test/Experimental/ExperimentalTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LogicMonitor.Api.Experimental;
using LogicMonitor.Api.Resources;

namespace LogicMonitor.Api.Test.Experimental;

Expand Down
4 changes: 2 additions & 2 deletions LogicMonitor.Api.Test/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
global using LogicMonitor.Api.Collectors;
global using LogicMonitor.Api.Dashboards;
global using LogicMonitor.Api.Data;
global using LogicMonitor.Api.DeviceProcesses;
global using LogicMonitor.Api.Devices;
global using LogicMonitor.Api.Extensions;
global using LogicMonitor.Api.Filters;
global using LogicMonitor.Api.Flows;
Expand All @@ -16,6 +14,8 @@
global using LogicMonitor.Api.PushMetrics;
global using LogicMonitor.Api.RecycleBin;
global using LogicMonitor.Api.Reports;
global using LogicMonitor.Api.ResourceProcesses;
global using LogicMonitor.Api.Resources;
global using LogicMonitor.Api.ScheduledDownTimes;
global using LogicMonitor.Api.Settings;
global using LogicMonitor.Api.Time;
Expand Down
1 change: 1 addition & 0 deletions LogicMonitor.Api.Test/Logging/LoggingTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LogicMonitor.Api.Logging;
using LogicMonitor.Api.Resources;
using System.Globalization;

namespace LogicMonitor.Api.Test.Logging;
Expand Down
31 changes: 16 additions & 15 deletions LogicMonitor.Api.Test/LogicModules/DataSourceTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using LogicMonitor.Api.ResourceProcesses;
using LogicMonitor.Api.Test.Extensions;

namespace LogicMonitor.Api.Test.LogicModules;
Expand Down Expand Up @@ -101,7 +102,7 @@ public async Task GetWinService()
var device = await GetWindowsDeviceAsync(default)
.ConfigureAwait(true);
var windowsServices = await LogicMonitorClient
.GetResourceProcessesAsync(device.Id, DeviceProcessServiceTaskType.WindowsService, default)
.GetResourceProcessesAsync(device.Id, ResourceProcessServiceTaskType.WindowsService, default)
.ConfigureAwait(true);
windowsServices.Should().NotBeNull();
windowsServices.Items.Should().NotBeNull();
Expand All @@ -112,7 +113,7 @@ public async Task GetWinService()
public async Task GetMonitoredWinService()
{
var windowsServices = await LogicMonitorClient
.GetMonitoredDeviceProcessesAsync(29, DeviceProcessServiceTaskType.WindowsService, default)
.GetMonitoredDeviceProcessesAsync(29, ResourceProcessServiceTaskType.WindowsService, default)
.ConfigureAwait(true);
windowsServices.Should().NotBeNullOrEmpty();
}
Expand Down Expand Up @@ -333,19 +334,19 @@ public async Task GetDeviceDataSourceByName_IsFast()
var stopwatch = Stopwatch.StartNew();
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(
425,
new Filter<DeviceDataSource>
new Filter<ResourceDataSource>
{
Take = 1,
Properties =
[
nameof(DeviceDataSource.Id),
nameof(DeviceDataSource.DataSourceName)
nameof(ResourceDataSource.Id),
nameof(ResourceDataSource.DataSourceName)
],
FilterItems =
[
new FilterItem<DeviceDataSource>
new FilterItem<ResourceDataSource>
{
Property = nameof(DeviceDataSource.DataSourceName),
Property = nameof(ResourceDataSource.DataSourceName),
Operation = ":",
Value = "SSL_Certificates"
}
Expand All @@ -362,14 +363,14 @@ public async Task GetDeviceDataSourceByName_IsFast()
[Fact]
public async Task GetDeviceDataSources()
{
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(WindowsDeviceId, new Filter<DeviceDataSource>
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(WindowsDeviceId, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 10,
Properties =
[
nameof(DeviceDataSource.Id),
nameof(DeviceDataSource.CreatedOnSeconds),
nameof(ResourceDataSource.Id),
nameof(ResourceDataSource.CreatedOnSeconds),
]
}, default).ConfigureAwait(true);

Expand All @@ -378,7 +379,7 @@ public async Task GetDeviceDataSources()

foreach (var deviceDataSource in deviceDataSources)
{
// Refetch
// Re-fetch
var deviceDataSourceRefetch = await LogicMonitorClient
.GetDeviceDataSourceAsync(
WindowsDeviceId,
Expand Down Expand Up @@ -406,7 +407,7 @@ public async Task GetDeviceDataSources()
var deviceDataSourceGroups = await LogicMonitorClient.GetDeviceDataSourceGroupsPageAsync(
WindowsDeviceId,
deviceDataSource.Id,
new Filter<DeviceDataSourceGroup>
new Filter<ResourceDataSourceGroup>
{
Skip = 0,
Take = 300,
Expand All @@ -417,7 +418,7 @@ public async Task GetDeviceDataSources()
foreach (var deviceDataSourceGroup in deviceDataSourceGroups.Items)
{
// Make sure they match
deviceDataSourceGroup.DeviceId.Should().Be(WindowsDeviceId);
deviceDataSourceGroup.ResourceId.Should().Be(WindowsDeviceId);
}
}
}
Expand All @@ -428,13 +429,13 @@ public async Task CollectDeviceConfig()
var device = await GetWindowsDeviceAsync(default)
.ConfigureAwait(true);

var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<DeviceDataSource>
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 1,
Properties =
[
nameof(DeviceDataSource.Id),
nameof(ResourceDataSource.Id),
]
}, default).ConfigureAwait(true);

Expand Down
8 changes: 4 additions & 4 deletions LogicMonitor.Api.Test/LogicModules/EventSourceTests2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task GetDeviceEventSources()
var deviceEventSources = await LogicMonitorClient
.GetDeviceEventSourcesPageAsync(
device.Id,
new Filter<DeviceEventSource> { Skip = 0, Take = 300 },
new Filter<ResourceEventSource> { Skip = 0, Take = 300 },
default)
.ConfigureAwait(true);

Expand All @@ -97,7 +97,7 @@ public async Task GetDeviceEventSources()
public async Task GetDeviceEventSourceByIdAsync()
{
var eventsources = await LogicMonitorClient
.GetDeviceEventSourcesPageAsync(WindowsDeviceId, new Filter<DeviceEventSource>(), default)
.GetDeviceEventSourcesPageAsync(WindowsDeviceId, new Filter<ResourceEventSource>(), default)
.ConfigureAwait(true);

var specificEventSource = eventsources.Items[0];
Expand Down Expand Up @@ -137,13 +137,13 @@ public async Task GetFilteredEventSources()
public async Task GetEventSourceGroupsAsync()
{
var eventSource = await LogicMonitorClient
.GetDeviceEventSourcesPageAsync(WindowsDeviceId, new Filter<DeviceEventSource>(), default)
.GetDeviceEventSourcesPageAsync(WindowsDeviceId, new Filter<ResourceEventSource>(), default)
.ConfigureAwait(true);

eventSource.Items.Should().NotBeNullOrEmpty();

var groups = await LogicMonitorClient
.GetDeviceEventSourceGroupsPageAsync(WindowsDeviceId, eventSource.Items[0].EventSourceId, new Filter<DeviceEventSourceGroup>(), default)
.GetDeviceEventSourceGroupsPageAsync(WindowsDeviceId, eventSource.Items[0].EventSourceId, new Filter<ResourceEventSourceGroup>(), default)
.ConfigureAwait(true);
groups.Should().NotBeNull();
}
Expand Down
6 changes: 4 additions & 2 deletions LogicMonitor.Api.Test/OpsNotes/OpsNotesTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using LogicMonitor.Api.Resources;

namespace LogicMonitor.Api.Test.OpsNotes;

/// <summary>
Expand Down Expand Up @@ -31,7 +33,7 @@ public async Task GetOpsNotes()
}

[Theory]
[InlineData(typeof(DeviceOpsNoteScopeCreationDto))]
[InlineData(typeof(ResourceOpsNoteScopeCreationDto))]
[InlineData(typeof(WebsiteOpsNoteScopeCreationDto))]
[InlineData(typeof(WebsiteGroupOpsNoteScopeCreationDto))]
[InlineData(typeof(ResourceGroupOpsNoteScopeCreationDto))]
Expand Down Expand Up @@ -59,7 +61,7 @@ public async Task AddRemoveOpsNote(Type t)
[
t.Name switch
{
nameof(DeviceOpsNoteScopeCreationDto) => new DeviceOpsNoteScopeCreationDto {DeviceId = device.Id},
nameof(ResourceOpsNoteScopeCreationDto) => new ResourceOpsNoteScopeCreationDto {ResourceId = device.Id},
nameof(ResourceGroupOpsNoteScopeCreationDto) => new ResourceGroupOpsNoteScopeCreationDto {ResourceGroupId = device.ResourceGroupIdsString.Split(',').Select(int.Parse).First()},
nameof(WebsiteOpsNoteScopeCreationDto) => new WebsiteOpsNoteScopeCreationDto {WebsitesId = website.Id},
nameof(WebsiteGroupOpsNoteScopeCreationDto) => new WebsiteGroupOpsNoteScopeCreationDto {WebsiteGroupId = website.GroupId},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LogicMonitor.Api.Test.Resources;

public class DeviceDataSourceInstanceTests(ITestOutputHelper iTestOutputHelper, Fixture fixture) : TestWithOutput(iTestOutputHelper, fixture)
public class ResourceDataSourceInstanceTests(ITestOutputHelper iTestOutputHelper, Fixture fixture) : TestWithOutput(iTestOutputHelper, fixture)
{
[Fact]
public async Task GetAllDeviceDataSourceInstancesAsync()
Expand Down Expand Up @@ -58,18 +58,18 @@ public async Task AddDeviceDataSourceInstance()
{
var resource = await GetWindowsDeviceAsync(default)
.ConfigureAwait(true);
var resourceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(resource.Id, new Filter<DeviceDataSource>
var resourceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(resource.Id, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 10,
Properties =
[
nameof(DeviceDataSource.Id),
nameof(ResourceDataSource.Id),
]
}, default)
.ConfigureAwait(true);

var newInstance = new DeviceDataSourceInstanceCreationDto()
var newInstance = new ResourceDataSourceInstanceCreationDto()
{
DisplayName = "lornaTest",
Description = "test",
Expand Down Expand Up @@ -120,13 +120,13 @@ public async Task GetDataPointConfiguration()
{
var device = await GetWindowsDeviceAsync(default)
.ConfigureAwait(true);
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<DeviceDataSource>
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 10,
Properties =
[
nameof(DeviceDataSource.Id),
nameof(ResourceDataSource.Id),
]
}, default).ConfigureAwait(true);

Expand All @@ -150,13 +150,13 @@ public async Task UpdateDataPointConfig()
{
var device = await GetWindowsDeviceAsync(default)
.ConfigureAwait(true);
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<DeviceDataSource>
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 10,
Properties =
[
nameof(DeviceDataSource.Id),
nameof(ResourceDataSource.Id),
]
}, default).ConfigureAwait(true);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LogicMonitor.Api.Test.Resources;

public class DeviceDataSourceTests(ITestOutputHelper iTestOutputHelper, Fixture fixture) : TestWithOutput(iTestOutputHelper, fixture)
public class ResourceDataSourceTests(ITestOutputHelper iTestOutputHelper, Fixture fixture) : TestWithOutput(iTestOutputHelper, fixture)
{
[Fact]
public async Task GetAllDeviceDataSourcesAsync()
Expand All @@ -26,7 +26,7 @@ public async Task DeviceDataSourceTests2()
// We have devices

// Find datacenter devices with WinCPU datasource
var deviceDataSources = new List<DeviceDataSource>();
var resourceDataSources = new List<ResourceDataSource>();
foreach (var device in resources)
{
if (dataSource != null)
Expand All @@ -39,11 +39,11 @@ public async Task DeviceDataSourceTests2()
continue;
}

deviceDataSources.Add(deviceDataSourceByDeviceIdAndDataSourceId);
resourceDataSources.Add(deviceDataSourceByDeviceIdAndDataSourceId);
}
}

deviceDataSources.Should().NotBeNullOrEmpty();
resourceDataSources.Should().NotBeNullOrEmpty();
}

[Fact]
Expand Down
Loading

0 comments on commit e778346

Please sign in to comment.