mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Web Api Changes
- removed the old endpoints - changed querymaster to be netstandard20
This commit is contained in:
parent
c212809cf5
commit
5374b0c52a
5 changed files with 11 additions and 108 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<Configurations>Debug;Release;Debug - Beta</Configurations>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net462</TargetFramework>
|
||||
<TargetFramework>netstandard20</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ServerManager.WebApplication.Controllers
|
||||
{
|
||||
|
|
@ -11,13 +9,8 @@ namespace ServerManager.WebApplication.Controllers
|
|||
[Produces("application/json")]
|
||||
public class PluginController : ControllerBase
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<ServerController> _logger;
|
||||
|
||||
public PluginController(IConfiguration configuration, ILogger<ServerController> logger)
|
||||
public PluginController()
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/plugin/call/00000000-0000-0000-0000-000000000000/192.168.1.1
|
||||
|
|
|
|||
|
|
@ -16,24 +16,20 @@ namespace ServerManager.WebApplication.Controllers
|
|||
[Produces("application/json")]
|
||||
public class ServerController : ControllerBase
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<ServerController> _logger;
|
||||
private readonly IServerQueryService _serverQueryService;
|
||||
|
||||
public ServerController(IConfiguration configuration, ILogger<ServerController> logger, IServerQueryService serverQueryService)
|
||||
public ServerController(IServerQueryService serverQueryService)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
_serverQueryService = serverQueryService;
|
||||
}
|
||||
|
||||
// GET: api/server/call/00000000-0000-0000-0000-000000000000/192.168.1.1
|
||||
[HttpGet()]
|
||||
[Route("call/{managerCode}/{ipString}", Name = "ServerCall_V1")]
|
||||
[Route("call/{managerCode}/{ipString}", Name = "ServerCall")]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public ActionResult<bool> ServerCall_V1([FromRoute] string managerCode, [FromRoute] string ipString)
|
||||
public ActionResult<bool> ServerCall([FromRoute] string managerCode, [FromRoute] string ipString)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -45,85 +41,15 @@ namespace ServerManager.WebApplication.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
// GET: api/server/192.168.1.1/27017
|
||||
[HttpGet()]
|
||||
[Route("{ipString}/{port}", Name = "GetServerStatus_V1")]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||
public ActionResult<ServerStatusResponse> GetServerStatus_V1([FromRoute] string ipString, [FromRoute] int port)
|
||||
{
|
||||
// check for valid service
|
||||
if (_serverQueryService == null)
|
||||
{
|
||||
var response = new ErrorResponse { Errors = new List<string> { "Server query service not available." } };
|
||||
return StatusCode(StatusCodes.Status503ServiceUnavailable, response);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var result = _serverQueryService.CheckServerStatus(Guid.Empty.ToString(), "0.0", ipString, port);
|
||||
var response = new ServerStatusResponse { Available = result.ToString() };
|
||||
return Ok(response);
|
||||
}
|
||||
catch (ServerManagerApiException ex)
|
||||
{
|
||||
var response = new ErrorResponse { Errors = ex.Messages };
|
||||
return StatusCode(ex.StatusCode, response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ErrorResponse { Errors = new List<string> { ex.Message } };
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/server/00000000-0000-0000-0000-000000000000/192.168.1.1/27017
|
||||
[HttpGet()]
|
||||
[Route("{managerCode}/{ipString}/{port}", Name = "GetServerStatus_V2")]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||
public ActionResult<ServerStatusResponse> GetServerStatus_V2([FromRoute] string managerCode, [FromRoute] string ipString, [FromRoute] int port)
|
||||
{
|
||||
// check for valid service
|
||||
if (_serverQueryService == null)
|
||||
{
|
||||
var response = new ErrorResponse { Errors = new List<string> { "Server query service not available." } };
|
||||
return StatusCode(StatusCodes.Status503ServiceUnavailable, response);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var result = _serverQueryService.CheckServerStatus(managerCode, "0.0", ipString, port);
|
||||
var response = new ServerStatusResponse { Available = result.ToString() };
|
||||
return Ok(response);
|
||||
}
|
||||
catch (ServerManagerApiException ex)
|
||||
{
|
||||
var response = new ErrorResponse { Errors = ex.Messages };
|
||||
return StatusCode(ex.StatusCode, response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var response = new ErrorResponse { Errors = new List<string> { ex.Message } };
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/server/00000000-0000-0000-0000-000000000000/1.0/192.168.1.1/27017
|
||||
[HttpGet()]
|
||||
[Route("{managerCode}/{managerVersion}/{ipString}/{port}", Name = "GetServerStatus_V3")]
|
||||
[Route("{managerCode}/{managerVersion}/{ipString}/{port}", Name = "GetServerStatus")]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||
public ActionResult<ServerStatusResponse> GetServerStatus_V3([FromRoute] string managerCode, [FromRoute] string managerVersion, [FromRoute] string ipString, [FromRoute] int port)
|
||||
public ActionResult<ServerStatusResponse> GetServerStatus([FromRoute] string managerCode, [FromRoute] string managerVersion, [FromRoute] string ipString, [FromRoute] int port)
|
||||
{
|
||||
// check for valid service
|
||||
if (_serverQueryService == null)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<ApplicationIcon>Art\favicon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -8,28 +8,12 @@
|
|||
"Code": "00000000-0000-0000-0000-000000000000"
|
||||
},
|
||||
{
|
||||
"Name": "Ark-Old",
|
||||
"Code": "ED89B8FA-0E0B-46CC-A90B-595E69AE9A7E"
|
||||
},
|
||||
{
|
||||
"Name": "Ark-New",
|
||||
"Name": "Ark",
|
||||
"Code": "6DCE02B1-8F41-4AF8-A6EA-E2E026CAB023"
|
||||
},
|
||||
{
|
||||
"Name": "Conan-Old",
|
||||
"Code": "F2653C3D-BC83-440A-AD99-FD9D9466DE04"
|
||||
},
|
||||
{
|
||||
"Name": "Conan-New",
|
||||
"Name": "Conan",
|
||||
"Code": "03F9106D-2B7B-411A-B533-FB641C44218D"
|
||||
},
|
||||
{
|
||||
"Name": "Dark and Light",
|
||||
"Code": "D80E19F9-33D2-4466-9177-A11506998E48"
|
||||
},
|
||||
{
|
||||
"Name": "Pantropy",
|
||||
"Code": "BE852556-BFC7-4AF2-82F3-F8A1CAF5C241"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue