more api tweaks
removed WebfrontSettings IW4MAdminSettings are only generated when the file does not exist, placeholder values stored in DefaultSettings.json
This commit is contained in:
@ -10,15 +10,13 @@ namespace IW4MAdmin.Application.API.Master
|
||||
{
|
||||
public class Heartbeat
|
||||
{
|
||||
static IMasterApi api;
|
||||
|
||||
public static async Task Send(ApplicationManager mgr, bool firstHeartbeat = false)
|
||||
{
|
||||
var api = Endpoint.Get();
|
||||
|
||||
if (firstHeartbeat)
|
||||
{
|
||||
api = RestClient.For<IMasterApi>("http://127.0.0.1");
|
||||
|
||||
var token = await api.Authenticate(new AuthenticationId()
|
||||
{
|
||||
Id = mgr.GetApplicationSettings().Configuration().Id
|
||||
@ -48,12 +46,12 @@ namespace IW4MAdmin.Application.API.Master
|
||||
|
||||
if (firstHeartbeat)
|
||||
{
|
||||
instance = await api.AddInstance(instance);
|
||||
var message = await api.AddInstance(instance);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
instance = await api.UpdateInstance(instance.Id, instance);
|
||||
var message = await api.UpdateInstance(instance.Id, instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,30 @@ namespace IW4MAdmin.Application.API.Master
|
||||
public string AccessToken { get; set; }
|
||||
}
|
||||
|
||||
public class VersionInfo
|
||||
{
|
||||
[JsonProperty("current-version-stable")]
|
||||
public float CurrentVersionStable { get; set; }
|
||||
[JsonProperty("current-version-prerelease")]
|
||||
public float CurrentVersionPrerelease { get; set; }
|
||||
}
|
||||
|
||||
public class ResultMessage
|
||||
{
|
||||
[JsonProperty("message")]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class Endpoint
|
||||
{
|
||||
#if !DEBUG
|
||||
private static IMasterApi api = RestClient.For<IMasterApi>("http://api.raidmax.org:5000");
|
||||
#else
|
||||
private static IMasterApi api = RestClient.For<IMasterApi>("http://127.0.0.1");
|
||||
#endif
|
||||
public static IMasterApi Get() => api;
|
||||
}
|
||||
|
||||
[Header("User-Agent", "IW4MAdmin-RestEase")]
|
||||
public interface IMasterApi
|
||||
{
|
||||
@ -29,9 +53,12 @@ namespace IW4MAdmin.Application.API.Master
|
||||
Task<TokenId> Authenticate([Body] AuthenticationId Id);
|
||||
|
||||
[Post("instance/")]
|
||||
Task<ApiInstance> AddInstance([Body] ApiInstance instance);
|
||||
Task<ResultMessage> AddInstance([Body] ApiInstance instance);
|
||||
|
||||
[Put("instance/{id}")]
|
||||
Task<ApiInstance> UpdateInstance([Path] string id, [Body] ApiInstance instance);
|
||||
Task<ResultMessage> UpdateInstance([Path] string id, [Body] ApiInstance instance);
|
||||
|
||||
[Get("version")]
|
||||
Task<VersionInfo> GetVersion();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user