From b08748221af080b7e0e9e335263661bcb1bff4f0 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Fri, 14 Jan 2022 11:23:42 +0200 Subject: [PATCH] NetworkResurrector.Agent.Wrapper --- notes/nugets.txt | 1 + ...Resurrector.Agent.PublishedLanguage.csproj | 1 + .../NetworkResurrector.Agent.Wrapper.csproj | 4 ++ .../Services/IResurrectorAgentService.cs | 5 +++ .../Services/ResurrectorAgentService.cs | 45 +++++++++++++++++++ 5 files changed, 56 insertions(+) diff --git a/notes/nugets.txt b/notes/nugets.txt index 315f085..a626553 100644 --- a/notes/nugets.txt +++ b/notes/nugets.txt @@ -9,4 +9,5 @@ dotnet nuget push NetworkResurrector.Server.Wrapper.1.0.3.2.nupkg -k ***REMOVED* # Agent dotnet nuget push NetworkResurrector.Agent.PublishedLanguage.1.0.3.nupkg -k ***REMOVED*** -s https://toodle.ddns.net/public-nuget-server/nuget +dotnet nuget push NetworkResurrector.Agent.Wrapper.1.0.3.nupkg -k ***REMOVED*** -s https://toodle.ddns.net/public-nuget-server/nuget ####################################################################################################################################################### \ No newline at end of file diff --git a/src/agent/NetworkResurrector.Agent.PublishedLanguage/NetworkResurrector.Agent.PublishedLanguage.csproj b/src/agent/NetworkResurrector.Agent.PublishedLanguage/NetworkResurrector.Agent.PublishedLanguage.csproj index a19c9cc..dc8ed30 100644 --- a/src/agent/NetworkResurrector.Agent.PublishedLanguage/NetworkResurrector.Agent.PublishedLanguage.csproj +++ b/src/agent/NetworkResurrector.Agent.PublishedLanguage/NetworkResurrector.Agent.PublishedLanguage.csproj @@ -5,6 +5,7 @@ Network resurrector agent published language nuget package https://dev.azure.com/tstanciu94/NetworkResurrector https://dev.azure.com/tstanciu94/NetworkResurrector + Git diff --git a/src/agent/NetworkResurrector.Agent.Wrapper/NetworkResurrector.Agent.Wrapper.csproj b/src/agent/NetworkResurrector.Agent.Wrapper/NetworkResurrector.Agent.Wrapper.csproj index 08e4347..e71e673 100644 --- a/src/agent/NetworkResurrector.Agent.Wrapper/NetworkResurrector.Agent.Wrapper.csproj +++ b/src/agent/NetworkResurrector.Agent.Wrapper/NetworkResurrector.Agent.Wrapper.csproj @@ -2,6 +2,10 @@ net5.0 + Network resurrector agent wrapper nuget package + https://dev.azure.com/tstanciu94/NetworkResurrector + Git + https://dev.azure.com/tstanciu94/NetworkResurrector diff --git a/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs b/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs index 1790855..b9cb5ce 100644 --- a/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs +++ b/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs @@ -7,5 +7,10 @@ namespace NetworkResurrector.Agent.Wrapper.Services public interface IResurrectorAgentService { Task Shutdown(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = null); + Task Restart(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = null); + Task Sleep(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = null); + Task Logout(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null); + Task Lock(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null); + Task Cancel(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null); } } \ No newline at end of file diff --git a/src/agent/NetworkResurrector.Agent.Wrapper/Services/ResurrectorAgentService.cs b/src/agent/NetworkResurrector.Agent.Wrapper/Services/ResurrectorAgentService.cs index b7adbbc..d00eb4e 100644 --- a/src/agent/NetworkResurrector.Agent.Wrapper/Services/ResurrectorAgentService.cs +++ b/src/agent/NetworkResurrector.Agent.Wrapper/Services/ResurrectorAgentService.cs @@ -36,5 +36,50 @@ namespace NetworkResurrector.Agent.Wrapper.Services var result = await _httpClient.ExecutePostRequest(ApiRoutes.Shutdown, body); return result; } + + public async Task Restart(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = null) + { + SetHttpClientBaseAddress(ipAddressOrMachineName, agentPort); + + var body = new Restart { Owner = actionOwner, Options = actionOptions }; + var result = await _httpClient.ExecutePostRequest(ApiRoutes.Restart, body); + return result; + } + + public async Task Sleep(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = null) + { + SetHttpClientBaseAddress(ipAddressOrMachineName, agentPort); + + var body = new Sleep { Owner = actionOwner, Options = actionOptions }; + var result = await _httpClient.ExecutePostRequest(ApiRoutes.Sleep, body); + return result; + } + + public async Task Logout(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null) + { + SetHttpClientBaseAddress(ipAddressOrMachineName, agentPort); + + var body = new Logout { Owner = actionOwner }; + var result = await _httpClient.ExecutePostRequest(ApiRoutes.Logout, body); + return result; + } + + public async Task Lock(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null) + { + SetHttpClientBaseAddress(ipAddressOrMachineName, agentPort); + + var body = new Lock { Owner = actionOwner }; + var result = await _httpClient.ExecutePostRequest(ApiRoutes.Lock, body); + return result; + } + + public async Task Cancel(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null) + { + SetHttpClientBaseAddress(ipAddressOrMachineName, agentPort); + + var body = new Cancel { Owner = actionOwner }; + var result = await _httpClient.ExecutePostRequest(ApiRoutes.Cancel, body); + return result; + } } }