diff --git a/NetworkResurrector.sln b/NetworkResurrector.sln index 4c343fe..b8074e2 100644 --- a/NetworkResurrector.sln +++ b/NetworkResurrector.sln @@ -66,6 +66,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Server.W EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Server.PublishedLanguage", "src\server\NetworkResurrector.Server.PublishedLanguage\NetworkResurrector.Server.PublishedLanguage.csproj", "{388D632D-8104-45E2-8017-D04848941F29}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Api.PublishedLanguage", "src\api\NetworkResurrector.Api.PublishedLanguage\NetworkResurrector.Api.PublishedLanguage.csproj", "{1EA9EAD7-8896-4756-A2C2-7969E9073FA6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -140,6 +142,10 @@ Global {388D632D-8104-45E2-8017-D04848941F29}.Debug|Any CPU.Build.0 = Debug|Any CPU {388D632D-8104-45E2-8017-D04848941F29}.Release|Any CPU.ActiveCfg = Release|Any CPU {388D632D-8104-45E2-8017-D04848941F29}.Release|Any CPU.Build.0 = Release|Any CPU + {1EA9EAD7-8896-4756-A2C2-7969E9073FA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1EA9EAD7-8896-4756-A2C2-7969E9073FA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EA9EAD7-8896-4756-A2C2-7969E9073FA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EA9EAD7-8896-4756-A2C2-7969E9073FA6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -167,6 +173,7 @@ Global {750531C0-CB4D-44AE-ADDE-CC815F2539C5} = {C04663A1-E0CD-41D6-A8D7-FADDF9DA8302} {696DAC79-9C18-4DC3-9925-755AD6C1FEC9} = {6889D39C-D8DA-4B99-AFC1-F0B6355E73C0} {388D632D-8104-45E2-8017-D04848941F29} = {6889D39C-D8DA-4B99-AFC1-F0B6355E73C0} + {1EA9EAD7-8896-4756-A2C2-7969E9073FA6} = {43C78941-52E6-4AB8-9170-CC7C006E4784} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {351D76E9-FE02-4C30-A464-7B29AFC64BC7} diff --git a/src/api/NetworkResurrector.Api.Application/NetworkResurrector.Api.Application.csproj b/src/api/NetworkResurrector.Api.Application/NetworkResurrector.Api.Application.csproj index 9e6acdd..3af74e1 100644 --- a/src/api/NetworkResurrector.Api.Application/NetworkResurrector.Api.Application.csproj +++ b/src/api/NetworkResurrector.Api.Application/NetworkResurrector.Api.Application.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + net5.0 @@ -15,5 +15,6 @@ + diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/PingMachine.cs b/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/PingMachine.cs new file mode 100644 index 0000000..d66d22d --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/PingMachine.cs @@ -0,0 +1,9 @@ +using NDB.Application.DataContracts; +using NetworkResurrector.Api.PublishedLanguage.Events; + +namespace NetworkResurrector.Api.PublishedLanguage.Commands +{ + public class PingMachine : Command + { + } +} diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/ShutdownMachine.cs b/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/ShutdownMachine.cs new file mode 100644 index 0000000..c5cda32 --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/ShutdownMachine.cs @@ -0,0 +1,9 @@ +using NDB.Application.DataContracts; +using NetworkResurrector.Api.PublishedLanguage.Events; + +namespace NetworkResurrector.Api.PublishedLanguage.Commands +{ + public class ShutdownMachine : Command + { + } +} diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/WakeMachine.cs b/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/WakeMachine.cs new file mode 100644 index 0000000..8c05b54 --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/Commands/WakeMachine.cs @@ -0,0 +1,9 @@ +using NDB.Application.DataContracts; +using NetworkResurrector.Api.PublishedLanguage.Events; + +namespace NetworkResurrector.Api.PublishedLanguage.Commands +{ + public class WakeMachine : Command + { + } +} diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachinePinged.cs b/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachinePinged.cs new file mode 100644 index 0000000..80d4e00 --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachinePinged.cs @@ -0,0 +1,8 @@ +namespace NetworkResurrector.Api.PublishedLanguage.Events +{ + public class MachinePinged + { + public bool Success { get; set; } + public string Status { get; set; } + } +} diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachineShutdown.cs b/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachineShutdown.cs new file mode 100644 index 0000000..0275161 --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachineShutdown.cs @@ -0,0 +1,8 @@ +namespace NetworkResurrector.Api.PublishedLanguage.Events +{ + public class MachineShutdown + { + public bool Success { get; set; } + public string Status { get; set; } + } +} diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachineWaked.cs b/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachineWaked.cs new file mode 100644 index 0000000..bbc8f95 --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/Events/MachineWaked.cs @@ -0,0 +1,8 @@ +namespace NetworkResurrector.Api.PublishedLanguage.Events +{ + public class MachineWaked + { + public bool Success { get; set; } + public string Status { get; set; } + } +} diff --git a/src/api/NetworkResurrector.Api.PublishedLanguage/NetworkResurrector.Api.PublishedLanguage.csproj b/src/api/NetworkResurrector.Api.PublishedLanguage/NetworkResurrector.Api.PublishedLanguage.csproj new file mode 100644 index 0000000..b7ec68a --- /dev/null +++ b/src/api/NetworkResurrector.Api.PublishedLanguage/NetworkResurrector.Api.PublishedLanguage.csproj @@ -0,0 +1,11 @@ + + + + net5.0 + + + + + + + diff --git a/src/api/NetworkResurrector.Api/Controllers/ResurrectorController.cs b/src/api/NetworkResurrector.Api/Controllers/ResurrectorController.cs new file mode 100644 index 0000000..103abc6 --- /dev/null +++ b/src/api/NetworkResurrector.Api/Controllers/ResurrectorController.cs @@ -0,0 +1,42 @@ +using MediatR; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using NetworkResurrector.Api.PublishedLanguage.Commands; +using System.Threading.Tasks; + +namespace NetworkResurrector.Api.Controllers +{ + [Authorize] + [ApiController] + [Route("resurrector")] + public class ResurrectorController : ControllerBase + { + private readonly IMediator _mediator; + + public ResurrectorController(IMediator mediator) + { + _mediator = mediator; + } + + [HttpPost("wake")] + public async Task WakeMachine([FromBody] WakeMachine wakeMachine) + { + var result = await _mediator.Send(wakeMachine); + return Ok(result); + } + + [HttpPost("ping")] + public async Task PingMachine([FromBody] PingMachine pingMachine) + { + var result = await _mediator.Send(pingMachine); + return Ok(result); + } + + [HttpPost("shutdown")] + public async Task ShutdownMachine([FromBody] ShutdownMachine shutdownMachine) + { + var result = await _mediator.Send(shutdownMachine); + return Ok(result); + } + } +} diff --git a/src/server/NetworkResurrector.Server.PublishedLanguage/Events/MachineShutdown.cs b/src/server/NetworkResurrector.Server.PublishedLanguage/Events/MachineShutdown.cs index f88326e..5437541 100644 --- a/src/server/NetworkResurrector.Server.PublishedLanguage/Events/MachineShutdown.cs +++ b/src/server/NetworkResurrector.Server.PublishedLanguage/Events/MachineShutdown.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace NetworkResurrector.Server.PublishedLanguage.Events +namespace NetworkResurrector.Server.PublishedLanguage.Events { public class MachineShutdown {