Skip to content

Commit

Permalink
Device refactored to Resource throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnmbond committed Nov 11, 2024
1 parent 5cb4ae2 commit 94fe6a0
Show file tree
Hide file tree
Showing 78 changed files with 405 additions and 399 deletions.
8 changes: 4 additions & 4 deletions LogicMonitor.Api.Test/Alerts/AlertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public async Task GetAlertsAndCheckUnique()
}

[Fact]
public async Task GetAlertsFilteredByDevice()
public async Task GetAlertsFilteredByResource()
{
var device = await GetWindowsDeviceAsync(default)
var device = await GetWindowsResourceAsync(default)
.ConfigureAwait(true);
var startUtcIsBefore = new DateTime(2018, 1, 1);
foreach (var alertType in new List<AlertType> { AlertType.DataSource, AlertType.EventSource })
Expand Down Expand Up @@ -233,9 +233,9 @@ public async Task GetAlertsFilteredByDevice()
}

[Fact]
public async Task GetAlertsFilteredByDeviceRest()
public async Task GetAlertsFilteredByResourceRest()
{
var device = await GetWindowsDeviceAsync(default)
var device = await GetWindowsResourceAsync(default)
.ConfigureAwait(true);
var resourceGroupFullPathFilter = new List<string> { "Collectors*" };
const string dataSourceNameFilter = "Volume Usage-";
Expand Down
4 changes: 2 additions & 2 deletions LogicMonitor.Api.Test/Alerts/NewAlertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public async Task GetAlertsAndCheckUnique()
}

[Fact]
public async Task GetAlertsFilteredByDevice()
public async Task GetAlertsFilteredByResource()
{
var device = await GetWindowsDeviceAsync(default)
var device = await GetWindowsResourceAsync(default)
.ConfigureAwait(true);
foreach (var alertType in new List<AlertType> { AlertType.DataSource, AlertType.EventSource })
{
Expand Down
12 changes: 6 additions & 6 deletions LogicMonitor.Api.Test/Cache/CacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public async Task CacheTestFasterSecondTimeAround()
await Task.Delay(TimeSpan.FromSeconds(4)).ConfigureAwait(true);

var stopwatch = Stopwatch.StartNew();
var firstDevice = await GetWindowsDeviceAsync(default).ConfigureAwait(true);
var firstResource = await GetWindowsResourceAsync(default).ConfigureAwait(true);

var firstDuration = stopwatch.Elapsed;
Logger.LogInformation("Duration 1 {FirstDuration}", firstDuration);
stopwatch.Restart();

var secondDevice = await GetWindowsDeviceAsync(default).ConfigureAwait(true);
var secondResource = await GetWindowsResourceAsync(default).ConfigureAwait(true);

var secondDuration = stopwatch.Elapsed;
Logger.LogInformation("Duration 2 {SecondDuration}", secondDuration);
Expand All @@ -31,7 +31,7 @@ public async Task CacheTestFasterSecondTimeAround()
secondDuration.Should().BeLessThan(TimeSpan.FromMilliseconds(100));

// The devices should be identical
secondDevice.DisplayName.Should().Be(firstDevice.DisplayName);
secondResource.DisplayName.Should().Be(firstResource.DisplayName);
}

[Fact]
Expand All @@ -48,7 +48,7 @@ public async Task CacheRefetchesAfterTimeout()

// Fetch a result
var stopwatch = Stopwatch.StartNew();
var firstDevice = await GetWindowsDeviceAsync(default).ConfigureAwait(true);
var firstDevice = await GetWindowsResourceAsync(default).ConfigureAwait(true);
firstDevice.Should().NotBeNull();
var firstDuration = stopwatch.Elapsed;
Logger.LogInformation("Duration 1 {FirstDuration}", firstDuration);
Expand All @@ -58,7 +58,7 @@ public async Task CacheRefetchesAfterTimeout()

// Re-fetch a result
stopwatch.Restart();
var secondDevice = await GetWindowsDeviceAsync(default).ConfigureAwait(true);
var secondDevice = await GetWindowsResourceAsync(default).ConfigureAwait(true);
secondDevice.Should().NotBeNull();
var secondDuration = stopwatch.Elapsed;
Logger.LogInformation("Duration 2 {SecondDuration}", secondDuration);
Expand All @@ -78,7 +78,7 @@ public async Task RateLimitCheckGetDeviceByDisplayNameAsync()
for (var n = 0; n < 1000; n++)
{
var innerStopwatch = Stopwatch.StartNew();
_ = await GetWindowsDeviceAsync(default).ConfigureAwait(true);
_ = await GetWindowsResourceAsync(default).ConfigureAwait(true);
Logger.LogInformation("Run {RunIndex}: {Milliseconds}ms", n, innerStopwatch.ElapsedMilliseconds);
}

Expand Down
4 changes: 2 additions & 2 deletions LogicMonitor.Api.Test/Dashboards/DashboardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public async Task Get()
deviceMapPoint.ResourceDisplayName.Should().NotBeNull();
deviceMapPoint.HasLocation.Should().BeTrue();

// Device and Website NOC widgets (now combined)
// Resource and Website NOC widgets (now combined)
var nocWidgets = widgets.OfType<NocWidget>().ToList();
nocWidgets.Should().HaveCount(2);
var deviceNocWidget = nocWidgets[0];
Expand Down Expand Up @@ -208,7 +208,7 @@ public async Task Get()
var websiteOverallStatusWidget = widgets.OfType<WebsiteOverallStatusWidget>().SingleOrDefault();
websiteOverallStatusWidget.Should().NotBeNull();

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

var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(
.GetAllResourceDataSourceInstancesAsync(
WindowsDeviceId,
deviceDataSource.Id,
new(),
Expand Down Expand Up @@ -51,7 +51,7 @@ public async Task GetForecastGraphData()
[Fact]
public async Task GetOverviewGraphData()
{
var device = await GetSnmpDeviceAsync(default)
var device = await GetSnmpResourceAsync(default)
.ConfigureAwait(true);
device.Should().NotBeNull();
var dataSource = await LogicMonitorClient
Expand All @@ -64,13 +64,13 @@ public async Task GetOverviewGraphData()
.ConfigureAwait(true);
deviceDataSource.Should().NotBeNull();
var deviceDataSourceInstanceGroups = await LogicMonitorClient
.GetDeviceDataSourceInstanceGroupsAsync(device.Id, deviceDataSource.Id, default)
.GetResourceDataSourceInstanceGroupsAsync(device.Id, deviceDataSource.Id, default)
.ConfigureAwait(true);
deviceDataSourceInstanceGroups.Should().NotBeNull();
deviceDataSourceInstanceGroups.Should().NotBeNullOrEmpty();
var deviceDataSourceInstanceGroup = deviceDataSourceInstanceGroups.Skip(2).First();
var deviceDataSourceInstanceGroupRefetch = await LogicMonitorClient
.GetDeviceDataSourceInstanceGroupByNameAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstanceGroup.Name, default)
.GetResourceDataSourceInstanceGroupByNameAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstanceGroup.Name, default)
.ConfigureAwait(true);
deviceDataSourceInstanceGroupRefetch.Should().NotBeNull();
deviceDataSourceInstanceGroupRefetch.Name.Should().Be(deviceDataSourceInstanceGroup.Name);
Expand Down Expand Up @@ -162,11 +162,11 @@ public async Task GetGraphData_X250()
.ConfigureAwait(true);
dataSourceGraph.Should().NotBeNull();

var deviceDataSource = await LogicMonitorClient
var resourceDataSource = await LogicMonitorClient
.GetResourceDataSourceByResourceIdAndDataSourceIdAsync(WindowsDeviceId, dataSource.Id, default)
.ConfigureAwait(true);
var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, resourceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.ConfigureAwait(true);
var deviceGraphDataRequest = new ResourceDataSourceInstanceGraphDataRequest
{
Expand Down Expand Up @@ -209,7 +209,7 @@ public async Task GetGraphData()
deviceDataSource.Should().NotBeNull();

var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.ConfigureAwait(true);
deviceDataSourceInstances.Should().NotBeNull();
deviceDataSourceInstances.Should().NotBeNullOrEmpty();
Expand Down Expand Up @@ -264,7 +264,7 @@ public async Task GetGraphDataWithoutFakeData()
deviceDataSource.Should().NotBeNull();

var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance>(), default)
.ConfigureAwait(true);
deviceDataSourceInstances.Should().NotBeNull();
deviceDataSourceInstances.Should().NotBeNullOrEmpty();
Expand Down Expand Up @@ -340,7 +340,7 @@ public async Task GetDeviceDataSourceInstances()
deviceDataSource.Should().NotBeNull();

var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(
.GetAllResourceDataSourceInstancesAsync(
WindowsDeviceId,
deviceDataSource.Id,
new Filter<ResourceDataSourceInstance>
Expand Down
8 changes: 4 additions & 4 deletions LogicMonitor.Api.Test/Data/RawDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public async Task GetRawData()
.GetResourceDataSourceByResourceIdAndDataSourceIdAsync(WindowsDeviceId, dataSource.Id, default)
.ConfigureAwait(true);
var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new(), cancellationToken: default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new(), cancellationToken: default)
.ConfigureAwait(true);
var deviceDataSourceInstance = deviceDataSourceInstances.Single();
var rawData = await LogicMonitorClient
Expand All @@ -36,7 +36,7 @@ public async Task GetRawDataTimeConstrained()
.GetResourceDataSourceByResourceIdAndDataSourceIdAsync(WindowsDeviceId, dataSource.Id, default)
.ConfigureAwait(true);
var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new(), cancellationToken: default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new(), cancellationToken: default)
.ConfigureAwait(true);
var deviceDataSourceInstance = deviceDataSourceInstances.Single();
var rawData = await LogicMonitorClient
Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task PollNow()
.ConfigureAwait(true);
deviceDataSource.Should().NotBeNull();
var deviceDataSourceInstances = await portalClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new(), cancellationToken: default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new(), cancellationToken: default)
.ConfigureAwait(true);
var deviceDataSourceInstance = deviceDataSourceInstances.FirstOrDefault();
deviceDataSourceInstance.Should().NotBeNull();
Expand Down Expand Up @@ -95,7 +95,7 @@ public async Task FetchInstanceData()
deviceDataSource.Should().NotBeNull();

var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(
.GetAllResourceDataSourceInstancesAsync(
WindowsDeviceId,
deviceDataSource.Id,
new(),
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.Api.Test/Experimental/ExperimentalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace LogicMonitor.Api.Test.Experimental;
public class ExperimentalTests(ITestOutputHelper iTestOutputHelper, Fixture fixture) : TestWithOutput(iTestOutputHelper, fixture)
{
[Fact]
public async Task GetDevices_Succeeds()
public async Task GetResources_Succeeds()
{
var devices = await ExperimentalLogicMonitorClient
.GetAsync(new LogicMonitorRequest<Resource>
Expand Down
4 changes: 2 additions & 2 deletions LogicMonitor.Api.Test/Logging/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task WriteLogAsync_WithCustomProperties_Succeeds()
{
// Get the device custom properties
var deviceProperties = await LogicMonitorClient
.GetDevicePropertiesAsync(WindowsDeviceId, default)
.GetResourcePropertiesAsync(WindowsDeviceId, default)
.ConfigureAwait(true);

// Get the cmdb.id
Expand All @@ -57,7 +57,7 @@ public async Task WriteLogAsync_WithDictionary_Succeeds()

// Get the device custom properties
var deviceProperties = await LogicMonitorClient
.GetDevicePropertiesAsync(WindowsDeviceId, default)
.GetResourcePropertiesAsync(WindowsDeviceId, default)
.ConfigureAwait(true);

// Get the cmdb.id
Expand Down
34 changes: 17 additions & 17 deletions LogicMonitor.Api.Test/LogicModules/DataSourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task GetDeviceGroupDeviceDataSourceInstances()
[Trait("Long Tests", "")]
public async Task GetWinService()
{
var device = await GetWindowsDeviceAsync(default)
var device = await GetWindowsResourceAsync(default)
.ConfigureAwait(true);
var windowsServices = await LogicMonitorClient
.GetResourceProcessesAsync(device.Id, ResourceProcessServiceTaskType.WindowsService, default)
Expand All @@ -112,7 +112,7 @@ public async Task GetWinService()
public async Task GetMonitoredWinService()
{
var windowsServices = await LogicMonitorClient
.GetMonitoredDeviceProcessesAsync(29, ResourceProcessServiceTaskType.WindowsService, default)
.GetMonitoredResourceProcessesAsync(29, ResourceProcessServiceTaskType.WindowsService, default)
.ConfigureAwait(true);
windowsServices.Should().NotBeNullOrEmpty();
}
Expand Down Expand Up @@ -185,7 +185,7 @@ public async Task GetDataPointThresholdDetailsForDeviceDataSourceInstance()
.GetResourceDataSourceByResourceIdAndDataSourceIdAsync(WindowsDeviceId, dataSource.Id, default)
.ConfigureAwait(true);
var deviceDataSourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance> { Skip = 0, Take = 10 }, default)
.GetAllResourceDataSourceInstancesAsync(WindowsDeviceId, deviceDataSource.Id, new Filter<ResourceDataSourceInstance> { Skip = 0, Take = 10 }, default)
.ConfigureAwait(true);
var deviceDataSourceInstance = deviceDataSourceInstances[0];
var dataPointDetails = await LogicMonitorClient
Expand Down Expand Up @@ -230,7 +230,7 @@ public async Task GetDataSourceByUniqueName_BadName_Null()
public async Task GetDeviceDataSourceInstances()
{
var portalClient = LogicMonitorClient;
var device = await GetSnmpDeviceAsync(default)
var device = await GetSnmpResourceAsync(default)
.ConfigureAwait(true);
device.Should().NotBeNull();

Expand All @@ -246,7 +246,7 @@ public async Task GetDeviceDataSourceInstances()
deviceDataSource.Should().NotBeNull();

var deviceDataSourceInstances = await portalClient
.GetAllDeviceDataSourceInstancesAsync(
.GetAllResourceDataSourceInstancesAsync(
device.Id,
deviceDataSource.Id,
new Filter<ResourceDataSourceInstance>
Expand All @@ -271,15 +271,15 @@ public async Task GetDeviceDataSourceInstances()
}

var deviceDataSourceInstanceGroups = await portalClient
.GetDeviceDataSourceInstanceGroupsAsync(
.GetResourceDataSourceInstanceGroupsAsync(
device.Id,
deviceDataSource.Id,
default)
.ConfigureAwait(true);
deviceDataSourceInstanceGroups.Should().NotBeNull();

var fetchedGraph = await LogicMonitorClient
.GetDeviceDataSourceInstanceGroupAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstanceGroups[0].Id, false, default)
.GetResourceDataSourceInstanceGroupAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstanceGroups[0].Id, false, default)
.ConfigureAwait(true);
if (fetchedGraph != null)
{
Expand All @@ -291,7 +291,7 @@ public async Task GetDeviceDataSourceInstances()
deviceDataSourceInstanceGroup.Should().NotBeNull();

var deviceDataSourceInstanceGroupInstances = await portalClient
.GetDeviceDataSourceInstanceGroupInstancesPageAsync(
.GetResourceDataSourceInstanceGroupInstancesPageAsync(
device.Id,
deviceDataSource.Id,
deviceDataSourceInstanceGroup.Id,
Expand Down Expand Up @@ -331,7 +331,7 @@ public async Task TestResourceGroupAlertSettings()
public async Task GetDeviceDataSourceByName_IsFast()
{
var stopwatch = Stopwatch.StartNew();
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(
var deviceDataSources = await LogicMonitorClient.GetAllResourceDataSourcesAsync(
425,
new Filter<ResourceDataSource>
{
Expand Down Expand Up @@ -362,7 +362,7 @@ public async Task GetDeviceDataSourceByName_IsFast()
[Fact]
public async Task GetDeviceDataSources()
{
var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(WindowsDeviceId, new Filter<ResourceDataSource>
var deviceDataSources = await LogicMonitorClient.GetAllResourceDataSourcesAsync(WindowsDeviceId, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 10,
Expand All @@ -380,7 +380,7 @@ public async Task GetDeviceDataSources()
{
// Re-fetch
var deviceDataSourceRefetch = await LogicMonitorClient
.GetDeviceDataSourceAsync(
.GetResourceDataSourceAsync(
WindowsDeviceId,
deviceDataSource.Id,
default)
Expand All @@ -392,7 +392,7 @@ public async Task GetDeviceDataSources()

// Get the instances
_ = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(
.GetAllResourceDataSourceInstancesAsync(
WindowsDeviceId,
deviceDataSource.Id,
new Filter<ResourceDataSourceInstance>
Expand All @@ -403,7 +403,7 @@ public async Task GetDeviceDataSources()
.ConfigureAwait(true);

// Get the groups
var deviceDataSourceGroups = await LogicMonitorClient.GetDeviceDataSourceGroupsPageAsync(
var deviceDataSourceGroups = await LogicMonitorClient.GetResourceDataSourceGroupsPageAsync(
WindowsDeviceId,
deviceDataSource.Id,
new Filter<ResourceDataSourceGroup>
Expand All @@ -425,10 +425,10 @@ public async Task GetDeviceDataSources()
[Fact]
public async Task CollectDeviceConfig()
{
var device = await GetWindowsDeviceAsync(default)
var device = await GetWindowsResourceAsync(default)
.ConfigureAwait(true);

var deviceDataSources = await LogicMonitorClient.GetAllDeviceDataSourcesAsync(device.Id, new Filter<ResourceDataSource>
var deviceDataSources = await LogicMonitorClient.GetAllResourceDataSourcesAsync(device.Id, new Filter<ResourceDataSource>
{
Skip = 0,
Take = 1,
Expand All @@ -439,15 +439,15 @@ public async Task CollectDeviceConfig()
}, default).ConfigureAwait(true);

var datasourceInstances = await LogicMonitorClient
.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSources[0].Id, new Filter<ResourceDataSourceInstance>()
.GetAllResourceDataSourceInstancesAsync(device.Id, deviceDataSources[0].Id, new Filter<ResourceDataSourceInstance>()
{
Skip = 0,
Properties = [nameof(ResourceDataSourceInstance.Id)]
}, default)
.ConfigureAwait(true);

await LogicMonitorClient
.CollectDeviceConfigSourceConfig(device.Id, deviceDataSources[0].Id, datasourceInstances[0].Id, default)
.CollectResourceConfigSourceConfig(device.Id, deviceDataSources[0].Id, datasourceInstances[0].Id, default)
.ConfigureAwait(true);
}

Expand Down
Loading

0 comments on commit 94fe6a0

Please sign in to comment.