oqtane.framework/Oqtane.Client/Services/InstallationService.cs
2021-05-10 17:45:39 -04:00

40 lines
1.0 KiB
C#

using Oqtane.Models;
using System.Threading.Tasks;
using System.Net.Http;
using Oqtane.Shared;
namespace Oqtane.Services
{
public class InstallationService : ServiceBase, IInstallationService
{
private readonly SiteState _siteState;
public InstallationService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
}
private string ApiUrl => CreateApiUrl("Installation", _siteState.Alias);
public async Task<Installation> IsInstalled()
{
return await GetJsonAsync<Installation>($"{ApiUrl}/installed");
}
public async Task<Installation> Install(InstallConfig config)
{
return await PostJsonAsync<InstallConfig,Installation>(ApiUrl, config);
}
public async Task<Installation> Upgrade()
{
return await GetJsonAsync<Installation>($"{ApiUrl}/upgrade");
}
public async Task RestartAsync()
{
await PostAsync($"{ApiUrl}/restart");
}
}
}