diff --git a/src/AzureIoTHub.Portal.Server.Tests/Controllers/ConcentratorsControllerTests.cs b/src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/ConcentratorsControllerTests.cs similarity index 100% rename from src/AzureIoTHub.Portal.Server.Tests/Controllers/ConcentratorsControllerTests.cs rename to src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/ConcentratorsControllerTests.cs diff --git a/src/AzureIoTHub.Portal.Server.Tests/Controllers/DevicesControllerTests.cs b/src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/DevicesControllerTests.cs similarity index 100% rename from src/AzureIoTHub.Portal.Server.Tests/Controllers/DevicesControllerTests.cs rename to src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/DevicesControllerTests.cs diff --git a/src/AzureIoTHub.Portal.Server.Tests/Controllers/GatewaysControllerTests.cs b/src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/EdgeDevicesControllerTests.cs similarity index 89% rename from src/AzureIoTHub.Portal.Server.Tests/Controllers/GatewaysControllerTests.cs rename to src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/EdgeDevicesControllerTests.cs index 44ba040db..ab485251a 100644 --- a/src/AzureIoTHub.Portal.Server.Tests/Controllers/GatewaysControllerTests.cs +++ b/src/AzureIoTHub.Portal.Server.Tests/Controllers/v1.0/EdgeDevicesControllerTests.cs @@ -16,7 +16,7 @@ namespace AzureIoTHub.Portal.Server.Tests.Controllers.V10 { [TestFixture] - public class GatewaysControllerTests + public class EdgeDevicesControllerTests { private MockRepository mockRepository; @@ -38,7 +38,7 @@ public void SetUp() this.mockDeviceService = this.mockRepository.Create(); } - private EdgeDevicesController CreateGatewaysController() + private EdgeDevicesController CreateEdgeDevicesController() { return new EdgeDevicesController( this.mockConfiguration.Object, @@ -64,10 +64,10 @@ public async Task Get_StateUnderTest_ExpectedBehavior() this.mockDeviceService.Setup(x => x.GetDeviceTwin(It.Is(c => c == twin.DeviceId))) .ReturnsAsync(twin); - var gatewaysController = this.CreateGatewaysController(); + var edgeDevicesController = this.CreateEdgeDevicesController(); // Act - var result = await gatewaysController.Get(); + var result = await edgeDevicesController.Get(); // Assert Assert.IsNotNull(result); @@ -77,8 +77,8 @@ public async Task Get_StateUnderTest_ExpectedBehavior() Assert.IsNotNull(okObjectResult); Assert.AreEqual(200, okObjectResult.StatusCode); Assert.IsNotNull(okObjectResult.Value); - Assert.IsAssignableFrom>(okObjectResult.Value); - var gatewayList = okObjectResult.Value as List; + Assert.IsAssignableFrom>(okObjectResult.Value); + var gatewayList = okObjectResult.Value as List; Assert.IsNotNull(gatewayList); Assert.AreEqual(1, gatewayList.Count); var gateway = gatewayList[0]; @@ -94,12 +94,12 @@ public async Task Get_StateUnderTest_ExpectedBehavior() public async Task GetSymmetricKey_StateUnderTest_ExpectedBehavior() { // Arrange - var gatewaysController = this.CreateGatewaysController(); + var edgeDevicesController = this.CreateEdgeDevicesController(); this.mockConnectionStringManager.Setup(c => c.GetSymmetricKey("aaa", "bbb")) .ReturnsAsync("dfhjkfdgh"); // Act - var result = await gatewaysController.GetSymmetricKey("aaa", "bbb"); + var result = await edgeDevicesController.GetSymmetricKey("aaa", "bbb"); // Assert Assert.IsNotNull(result); @@ -119,8 +119,8 @@ public async Task GetSymmetricKey_StateUnderTest_ExpectedBehavior() public async Task CreateGatewayAsync_StateUnderTest_ExpectedBehavior() { // Arrange - var gatewaysController = this.CreateGatewaysController(); - var gateway = new Gateway() + var edgeDevicesController = this.CreateEdgeDevicesController(); + var gateway = new IoTEdgeDevice() { DeviceId = "aaa", Type = "lora" @@ -140,7 +140,7 @@ public async Task CreateGatewayAsync_StateUnderTest_ExpectedBehavior() this.mockLogger.Setup(x => x.Log(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); // Act - var result = await gatewaysController.CreateGatewayAsync(gateway); + var result = await edgeDevicesController.CreateGatewayAsync(gateway); // Assert Assert.IsNotNull(result); @@ -157,8 +157,8 @@ public async Task CreateGatewayAsync_StateUnderTest_ExpectedBehavior() public async Task UpdateDeviceAsync_StateUnderTest_ExpectedBehavior() { // Arrange - var gatewaysController = this.CreateGatewaysController(); - var gateway = new Gateway() + var edgeDevicesController = this.CreateEdgeDevicesController(); + var gateway = new IoTEdgeDevice() { DeviceId = "aaa", Type = "lora", @@ -195,7 +195,7 @@ public async Task UpdateDeviceAsync_StateUnderTest_ExpectedBehavior() this.mockLogger.Setup(x => x.Log(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())); // Act - var result = await gatewaysController.UpdateDeviceAsync(gateway); + var result = await edgeDevicesController.UpdateDeviceAsync(gateway); // Assert Assert.IsNotNull(result); diff --git a/src/AzureIoTHub.Portal/Client/Pages/Configurations/ConfigDetail.razor b/src/AzureIoTHub.Portal/Client/Pages/Configurations/ConfigDetail.razor index bcf405ac0..be0b3eb02 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Configurations/ConfigDetail.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Configurations/ConfigDetail.razor @@ -177,7 +177,7 @@ /// /// Selected module /// - public async Task ShowModuleDetail(GatewayModule module) + public async Task ShowModuleDetail(IoTEdgeModule module) { var parameters = new DialogParameters(); parameters.Add("module", module); diff --git a/src/AzureIoTHub.Portal/Client/Pages/Configurations/ModuleDetail.razor b/src/AzureIoTHub.Portal/Client/Pages/Configurations/ModuleDetail.razor index a02f28d21..f28e92f80 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Configurations/ModuleDetail.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Configurations/ModuleDetail.razor @@ -54,7 +54,7 @@ [CascadingParameter] MudDialogInstance MudDialog { get; set; } [Parameter] - public GatewayModule Module { get; set; } + public IoTEdgeModule Module { get; set; } void Cancel() => MudDialog.Cancel(); } diff --git a/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/CreateEdgeDeviceDialog.razor b/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/CreateEdgeDeviceDialog.razor index f84519049..80663ddba 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/CreateEdgeDeviceDialog.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/CreateEdgeDeviceDialog.razor @@ -55,7 +55,7 @@ @code { [CascadingParameter] MudDialogInstance MudDialog { get; set; } - private Gateway gateway = new Gateway(); + private IoTEdgeDevice gateway = new IoTEdgeDevice(); void Cancel() => MudDialog.Cancel(); diff --git a/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceDetailPage.razor b/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceDetailPage.razor index 4046d14ef..b14ab9e73 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceDetailPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceDetailPage.razor @@ -181,17 +181,17 @@ private bool processingUpdate = false; private bool processingDelete = false; - private Gateway Gateway; + private IoTEdgeDevice Gateway; protected override async Task OnInitializedAsync() { - Gateway = new Gateway(); + Gateway = new IoTEdgeDevice(); await LoadDevice(); } public async Task LoadDevice() { - Gateway = await Http.GetFromJsonAsync($"api/edge/device/{deviceId}"); + Gateway = await Http.GetFromJsonAsync($"api/edge/device/{deviceId}"); if (Gateway.ConnectionState == "Disconnected") { @@ -213,7 +213,7 @@ processingUpdate = false; } - public async Task OnMethod(GatewayModule module, string methodName) + public async Task OnMethod(IoTEdgeModule module, string methodName) { var result = await Http.PostAsJsonAsync($"api/edge/device/{Gateway.DeviceId}/{module.ModuleName}/{methodName}", module); diff --git a/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceListPage.razor b/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceListPage.razor index 3dffc78d0..dd5f422b4 100644 --- a/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceListPage.razor +++ b/src/AzureIoTHub.Portal/Client/Pages/Edge_Devices/EdgeDeviceListPage.razor @@ -62,7 +62,7 @@ else { - + @@ -122,7 +122,7 @@ @code { - private List result; + private List result; private List typeList = new List() { "LoRa", "Other" }; private SearchModel searchModel = new SearchModel(null, ""); @@ -138,7 +138,7 @@ { try { - result = await Http.GetFromJsonAsync>("api/edge/device"); + result = await Http.GetFromJsonAsync>("api/edge/device"); } catch (AccessTokenNotAvailableException exception) { @@ -146,7 +146,7 @@ } } - private bool FilterFunc(GatewayListItem element) + private bool FilterFunc(IoTEdgeListItem element) { if (element.Type == null) { @@ -186,10 +186,10 @@ await LoadGatewaysList(); } - public async Task ShowDeleteDialog(GatewayListItem gateway) + public async Task ShowDeleteDialog(IoTEdgeListItem gateway) { var parameters = new DialogParameters(); - parameters.Add(nameof(Gateway.DeviceId), gateway.DeviceId); + parameters.Add(nameof(IoTEdgeDevice.DeviceId), gateway.DeviceId); var result = await DialogService.Show("Confirm Deletion", parameters).Result; if (result.Cancelled) diff --git a/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeConfigurationsController.cs b/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeConfigurationsController.cs index aeb8841cc..8d9a77aab 100644 --- a/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeConfigurationsController.cs +++ b/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeConfigurationsController.cs @@ -45,12 +45,12 @@ public async Task> Get() // Azure Configurations may have different types: "Configuration", "Deployment" or "LayeredDeployment" foreach (Configuration config in configList) { - var moduleList = new List(); + var moduleList = new List(); // Only deployments have modules. If it doesn't, it's a configuration and we don't want to keep it. if (config.Content.ModulesContent != null) { - moduleList.AddRange(config.Content.ModulesContent.Select(x => new GatewayModule + moduleList.AddRange(config.Content.ModulesContent.Select(x => new IoTEdgeModule { ModuleName = x.Key })); @@ -73,7 +73,7 @@ public async Task> Get() public async Task Get(string configurationID) { var config = await this.configService.GetConfigItem(configurationID); - var moduleList = new List(); + var moduleList = new List(); // Details of every modules are stored within the EdgeAgent module data if (config.Content.ModulesContent != null @@ -93,7 +93,7 @@ public async Task Get(string configurationID) { foreach (var m in modules.Values()) { - GatewayModule newModule = ConfigHelper.CreateGatewayModule(config, m); + IoTEdgeModule newModule = ConfigHelper.CreateGatewayModule(config, m); moduleList.Add(newModule); } } @@ -103,7 +103,7 @@ public async Task Get(string configurationID) { foreach (var sm in systemModulesToken.Values()) { - GatewayModule newModule = ConfigHelper.CreateGatewayModule(config, sm); + IoTEdgeModule newModule = ConfigHelper.CreateGatewayModule(config, sm); moduleList.Add(newModule); } } diff --git a/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeDevicesController.cs b/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeDevicesController.cs index 00949f07f..b66aec693 100644 --- a/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeDevicesController.cs +++ b/src/AzureIoTHub.Portal/Server/Controllers/v1.0/EdgeDevicesController.cs @@ -79,13 +79,13 @@ public EdgeDevicesController( /// /// [HttpGet(Name = "GET IoT Edge devices")] - [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] + [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] public async Task Get() { // don't contain tags IEnumerable edgeDevices = await this.devicesService.GetAllEdgeDevice(); - List newGatewayList = new(); + List newGatewayList = new(); foreach (Twin deviceTwin in edgeDevices) { @@ -93,7 +93,7 @@ public async Task Get() if (twin != null) { - GatewayListItem gateway = new() + IoTEdgeListItem gateway = new() { DeviceId = deviceTwin.DeviceId, Status = twin.Status?.ToString(), @@ -114,7 +114,7 @@ public async Task Get() /// The device identifier. /// [HttpGet("{deviceId}", Name = "GET IoT Edge device")] - [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(Gateway))] + [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IoTEdgeDevice))] public async Task Get(string deviceId) { try @@ -122,7 +122,7 @@ public async Task Get(string deviceId) Twin deviceTwin = await this.devicesService.GetDeviceTwin(deviceId); Twin deviceWithModules = await this.devicesService.GetDeviceTwinWithModule(deviceId); - Gateway gateway = new() + IoTEdgeDevice gateway = new() { DeviceId = deviceTwin.DeviceId, Status = deviceTwin.Status?.ToString(), @@ -171,7 +171,7 @@ public async Task GetSymmetricKey(string deviceId, string deviceT [HttpPost(Name = "POST Create IoT Edge")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] - public async Task CreateGatewayAsync(Gateway gateway) + public async Task CreateGatewayAsync(IoTEdgeDevice gateway) { try { @@ -199,7 +199,7 @@ public async Task CreateGatewayAsync(Gateway gateway) /// [HttpPut(Name = "PUT Update IoT Edge")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task UpdateDeviceAsync(Gateway gateway) + public async Task UpdateDeviceAsync(IoTEdgeDevice gateway) { Device device = await this.devicesService.GetDevice(gateway.DeviceId); @@ -241,7 +241,7 @@ public async Task DeleteDeviceAsync(string deviceId) /// Name of the method. /// [HttpPost("{deviceId}/{moduleId}/{methodName}", Name = "POST Execute module command")] - public async Task ExecuteMethode(GatewayModule module, string deviceId, string methodName) + public async Task ExecuteMethode(IoTEdgeModule module, string deviceId, string methodName) { CloudToDeviceMethod method = new(methodName); string payload = string.Empty; diff --git a/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs b/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs index 9ad606e28..84290e2e3 100644 --- a/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs +++ b/src/AzureIoTHub.Portal/Server/Helpers/ConfigHelper.cs @@ -34,7 +34,7 @@ public static long RetrieveMetricValue(Configuration item, string metricName) /// Configuration object from Azure IoT Hub. /// List of modules related to this configuration. /// A configuration converted to a ConfigListItem. - public static ConfigListItem CreateConfigListItem(Configuration config, List moduleList) + public static ConfigListItem CreateConfigListItem(Configuration config, List moduleList) { return new ConfigListItem { @@ -56,9 +56,9 @@ public static ConfigListItem CreateConfigListItem(Configuration config, ListConfiguration object from Azure IoT Hub. /// Dictionnary containing the module's name and its properties. /// A module with all its details as a GatewayModule object. - public static GatewayModule CreateGatewayModule(Configuration config, JProperty module) + public static IoTEdgeModule CreateGatewayModule(Configuration config, JProperty module) { - return new GatewayModule + return new IoTEdgeModule { ModuleName = module.Name, Version = module.Value["settings"]["image"]?.Value(), diff --git a/src/AzureIoTHub.Portal/Server/Helpers/DeviceHelper.cs b/src/AzureIoTHub.Portal/Server/Helpers/DeviceHelper.cs index 965d9eabc..242060017 100644 --- a/src/AzureIoTHub.Portal/Server/Helpers/DeviceHelper.cs +++ b/src/AzureIoTHub.Portal/Server/Helpers/DeviceHelper.cs @@ -130,15 +130,15 @@ public static string RetrieveRuntimeResponse(Twin twin, string deviceId) /// the twin of the device we want. /// the module count. /// List of GatewayModule. - public static List RetrieveModuleList(Twin twin, int moduleCount) + public static List RetrieveModuleList(Twin twin, int moduleCount) { - var list = new List(); + var list = new List(); if (twin.Properties.Reported.Contains("modules") && moduleCount > 0) { foreach (var element in twin.Properties.Reported["modules"]) { - var module = new GatewayModule() + var module = new IoTEdgeModule() { ModuleName = element.Key }; diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/ConfigListItem.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/ConfigListItem.cs index 2457c1d86..1dc2e55b3 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/ConfigListItem.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/ConfigListItem.cs @@ -13,7 +13,7 @@ public class ConfigListItem /// public ConfigListItem() { - this.Modules = new List(); + this.Modules = new List(); } /// @@ -59,6 +59,6 @@ public ConfigListItem() /// /// The IoT Edge modules configuration. /// - public List Modules { get; set; } + public List Modules { get; set; } } } diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/Gateway.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeDevice.cs similarity index 89% rename from src/AzureIoTHub.Portal/Shared/Models/v1.0/Gateway.cs rename to src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeDevice.cs index fcb497904..7e1876c6c 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/Gateway.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeDevice.cs @@ -6,7 +6,7 @@ namespace AzureIoTHub.Portal.Shared.Models.V10 using System.Collections.Generic; using System.ComponentModel.DataAnnotations; - public class Gateway + public class IoTEdgeDevice { /// /// The IoT Edge identifier. @@ -73,14 +73,14 @@ public class Gateway /// /// The IoT Edge modules. /// - public List Modules { get; set; } + public List Modules { get; set; } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public Gateway() + public IoTEdgeDevice() { - this.Modules = new List(); + this.Modules = new List(); this.LastDeployment = new ConfigItem(); } } diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/GatewayListItem.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeListItem.cs similarity index 96% rename from src/AzureIoTHub.Portal/Shared/Models/v1.0/GatewayListItem.cs rename to src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeListItem.cs index 6cbe239c7..008da73d2 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/GatewayListItem.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeListItem.cs @@ -5,7 +5,7 @@ namespace AzureIoTHub.Portal.Shared.Models.V10 { - public class GatewayListItem + public class IoTEdgeListItem { /// /// The device identifier. diff --git a/src/AzureIoTHub.Portal/Shared/Models/v1.0/GatewayModule.cs b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule.cs similarity index 97% rename from src/AzureIoTHub.Portal/Shared/Models/v1.0/GatewayModule.cs rename to src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule.cs index 88849e7d8..8874b82f6 100644 --- a/src/AzureIoTHub.Portal/Shared/Models/v1.0/GatewayModule.cs +++ b/src/AzureIoTHub.Portal/Shared/Models/v1.0/IoTEdgeModule.cs @@ -6,7 +6,7 @@ namespace AzureIoTHub.Portal.Shared.Models.V10 using System.Collections.Generic; using System.ComponentModel.DataAnnotations; - public class GatewayModule + public class IoTEdgeModule { /// /// The module name.