diff --git a/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs b/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs index 7b3a732..1790855 100644 --- a/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs +++ b/src/agent/NetworkResurrector.Agent.Wrapper/Services/IResurrectorAgentService.cs @@ -1,6 +1,11 @@ -namespace NetworkResurrector.Agent.Wrapper.Services +using NetworkResurrector.Agent.PublishedLanguage.Dto; +using NetworkResurrector.Agent.PublishedLanguage.Events; +using System.Threading.Tasks; + +namespace NetworkResurrector.Agent.Wrapper.Services { public interface IResurrectorAgentService { + Task Shutdown(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = 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 7605122..b7adbbc 100644 --- a/src/agent/NetworkResurrector.Agent.Wrapper/Services/ResurrectorAgentService.cs +++ b/src/agent/NetworkResurrector.Agent.Wrapper/Services/ResurrectorAgentService.cs @@ -1,5 +1,6 @@ using NDB.Extensions.Http; using NetworkResurrector.Agent.PublishedLanguage.Commands; +using NetworkResurrector.Agent.PublishedLanguage.Dto; using NetworkResurrector.Agent.PublishedLanguage.Events; using NetworkResurrector.Agent.Wrapper.Constants; using System; @@ -16,15 +17,22 @@ namespace NetworkResurrector.Agent.Wrapper.Services public ResurrectorAgentService(HttpClient httpClient) { - httpClient.BaseAddress = new Uri(""); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(_contentType)); _httpClient = httpClient; } - public async Task Shutdown(string ipAddressOrMachineName) + private void SetHttpClientBaseAddress(string ipAddressOrMachineName, int agentPort) { - var body = new Shutdown(); + var baseAddress = $"http://{ipAddressOrMachineName}:{agentPort}"; + _httpClient.BaseAddress = new Uri(baseAddress); + } + + public async Task Shutdown(string ipAddressOrMachineName, int agentPort, ActionOwner actionOwner = null, ActionOptions actionOptions = null) + { + SetHttpClientBaseAddress(ipAddressOrMachineName, agentPort); + + var body = new Shutdown { Owner = actionOwner, Options = actionOptions }; var result = await _httpClient.ExecutePostRequest(ApiRoutes.Shutdown, body); return result; }