Added Call Home Endpoints - Server and Plugin

This commit is contained in:
Brett Hewitson 2021-12-20 11:32:37 +10:00
parent 8bf57a71b9
commit decf281598
2 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace ServerManager.WebApplication.Controllers
{
[Route("api/plugin")]
[ApiController]
[ApiVersion("1.0")]
[Produces("application/json")]
public class PluginController : ControllerBase
{
private readonly IConfiguration _configuration;
private readonly ILogger<ServerController> _logger;
public PluginController(IConfiguration configuration, ILogger<ServerController> logger)
{
_configuration = configuration;
_logger = logger;
}
// GET: api/plugin/call/00000000-0000-0000-0000-000000000000/192.168.1.1
[HttpGet()]
[Route("call/{pluginCode}/{ipString}", Name = "Call_V1")]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public ActionResult<bool> Call_V1([FromRoute] string pluginCode, [FromRoute] string ipString)
{
try
{
return Ok(true);
}
catch
{
return StatusCode(StatusCodes.Status500InternalServerError, false);
}
}
}
}

View file

@ -27,6 +27,24 @@ namespace ServerManager.WebApplication.Controllers
_serverQueryService = serverQueryService;
}
// GET: api/server/call/00000000-0000-0000-0000-000000000000/192.168.1.1
[HttpGet()]
[Route("call/{managerCode}/{ipString}", Name = "Call_V1")]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public ActionResult<bool> Call_V1([FromRoute] string managerCode, [FromRoute] string ipString)
{
try
{
return Ok(true);
}
catch
{
return StatusCode(StatusCodes.Status500InternalServerError, false);
}
}
// GET: api/server/192.168.1.1/27017
[HttpGet()]
[Route("{ipString}/{port}", Name = "GetServerStatus_V1")]