using System.Net.Http; using System.Threading.Tasks; using System.Collections.Generic; using Oqtane.Documentation; using Oqtane.Shared; namespace Oqtane.Services { /// /// Service to retrieve and update system information. /// public interface ISystemService { /// /// returns a key-value dictionary with the current system configuration information /// /// Task> GetSystemInfoAsync(); /// /// returns a key-value dictionary with the current system information - "environment" or "configuration" /// /// Task> GetSystemInfoAsync(string type); /// /// returns a config value /// /// Task GetSystemInfoAsync(string settingKey, object defaultValue); /// /// Updates system information /// /// /// Task UpdateSystemInfoAsync(Dictionary settings); /// /// returns a key-value dictionary with default system icons /// /// Task> GetIconsAsync(); } [PrivateApi("Don't show in the documentation, as everything should use the Interface")] public class SystemService : ServiceBase, ISystemService { public SystemService(HttpClient http, SiteState siteState) : base(http, siteState) { } private string Apiurl => CreateApiUrl("System"); public async Task> GetSystemInfoAsync() { return await GetSystemInfoAsync("configuration"); } public async Task> GetSystemInfoAsync(string type) { return await GetJsonAsync>($"{Apiurl}?type={type}"); } public async Task GetSystemInfoAsync(string settingKey, object defaultValue) { return await GetJsonAsync($"{Apiurl}/{settingKey}/{defaultValue}"); } public async Task UpdateSystemInfoAsync(Dictionary settings) { await PostJsonAsync(Apiurl, settings); } public async Task> GetIconsAsync() { return await GetJsonAsync>($"{Apiurl}/icons"); } } }