parent
bcc65857df
commit
e3d6d4f79a
@ -1,8 +1,9 @@
|
||||
using System.IO.Abstractions;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Cache;
|
||||
|
||||
public interface ICacheStoragePath
|
||||
{
|
||||
IFileInfo CalculatePath(string cacheObjectName);
|
||||
IFileInfo CalculatePath(IServiceConfiguration config, string cacheObjectName);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Cache;
|
||||
|
||||
public interface IServiceCache
|
||||
{
|
||||
T? Load<T>() where T : class;
|
||||
void Save<T>(T obj) where T : class;
|
||||
T? Load<T>(IServiceConfiguration config) where T : class;
|
||||
void Save<T>(T obj, IServiceConfiguration config) where T : class;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
using Flurl.Http;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Http;
|
||||
|
||||
public interface IServiceRequestBuilder
|
||||
{
|
||||
IFlurlRequest Request(params object[] path);
|
||||
IFlurlRequest Request(IServiceConfiguration config, params object[] path);
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Services.CustomFormat.Models;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.CustomFormat.Api;
|
||||
|
||||
public interface ICustomFormatService
|
||||
{
|
||||
Task<List<JObject>> GetCustomFormats();
|
||||
Task CreateCustomFormat(ProcessedCustomFormatData cf);
|
||||
Task UpdateCustomFormat(ProcessedCustomFormatData cf);
|
||||
Task DeleteCustomFormat(int customFormatId);
|
||||
Task<List<JObject>> GetCustomFormats(IServiceConfiguration config);
|
||||
Task CreateCustomFormat(IServiceConfiguration config, ProcessedCustomFormatData cf);
|
||||
Task UpdateCustomFormat(IServiceConfiguration config, ProcessedCustomFormatData cf);
|
||||
Task DeleteCustomFormat(IServiceConfiguration config, int customFormatId);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.CustomFormat.Api;
|
||||
|
||||
public interface IQualityProfileService
|
||||
{
|
||||
Task<List<JObject>> GetQualityProfiles();
|
||||
Task<JObject> UpdateQualityProfile(JObject profileJson, int id);
|
||||
Task<List<JObject>> GetQualityProfiles(IServiceConfiguration config);
|
||||
Task<JObject> UpdateQualityProfile(IServiceConfiguration config, JObject profileJson, int id);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
using Recyclarr.TrashLib.Config;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.CustomFormat;
|
||||
|
||||
public interface ICustomFormatUpdater
|
||||
{
|
||||
Task Process(bool isPreview, IEnumerable<CustomFormatConfig> configs, SupportedServices serviceType);
|
||||
Task Process(bool isPreview, IServiceConfiguration config);
|
||||
}
|
||||
|
@ -1,24 +1,32 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Services.CustomFormat.Api;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.CustomFormat.Processors.PersistenceSteps;
|
||||
|
||||
internal class CustomFormatApiPersistenceStep : ICustomFormatApiPersistenceStep
|
||||
{
|
||||
public async Task Process(ICustomFormatService api, CustomFormatTransactionData transactions)
|
||||
private readonly ICustomFormatService _api;
|
||||
|
||||
public CustomFormatApiPersistenceStep(ICustomFormatService api)
|
||||
{
|
||||
_api = api;
|
||||
}
|
||||
|
||||
public async Task Process(IServiceConfiguration config, CustomFormatTransactionData transactions)
|
||||
{
|
||||
foreach (var cf in transactions.NewCustomFormats)
|
||||
{
|
||||
await api.CreateCustomFormat(cf);
|
||||
await _api.CreateCustomFormat(config, cf);
|
||||
}
|
||||
|
||||
foreach (var cf in transactions.UpdatedCustomFormats)
|
||||
{
|
||||
await api.UpdateCustomFormat(cf);
|
||||
await _api.UpdateCustomFormat(config, cf);
|
||||
}
|
||||
|
||||
foreach (var cfId in transactions.DeletedCustomFormatIds)
|
||||
{
|
||||
await api.DeleteCustomFormat(cfId.CustomFormatId);
|
||||
await _api.DeleteCustomFormat(config, cfId.CustomFormatId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using Recyclarr.TrashLib.Services.CustomFormat.Api;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.CustomFormat.Processors.PersistenceSteps;
|
||||
|
||||
public interface ICustomFormatApiPersistenceStep
|
||||
{
|
||||
Task Process(ICustomFormatService api, CustomFormatTransactionData transactions);
|
||||
Task Process(IServiceConfiguration config, CustomFormatTransactionData transactions);
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.QualitySize.Api;
|
||||
|
||||
public interface IQualityDefinitionService
|
||||
{
|
||||
Task<List<ServiceQualityDefinitionItem>> GetQualityDefinition();
|
||||
Task<IList<ServiceQualityDefinitionItem>> UpdateQualityDefinition(IList<ServiceQualityDefinitionItem> newQuality);
|
||||
Task<List<ServiceQualityDefinitionItem>> GetQualityDefinition(IServiceConfiguration config);
|
||||
|
||||
Task<IList<ServiceQualityDefinitionItem>> UpdateQualityDefinition(
|
||||
IServiceConfiguration config,
|
||||
IList<ServiceQualityDefinitionItem> newQuality);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
using Recyclarr.TrashLib.Config;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.QualitySize;
|
||||
|
||||
public interface IQualitySizeUpdater
|
||||
{
|
||||
Task Process(bool isPreview, QualityDefinitionConfig config, SupportedServices serviceType);
|
||||
Task Process(bool isPreview, IServiceConfiguration config);
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
namespace Recyclarr.TrashLib.Services.Radarr;
|
||||
|
||||
public interface IRadarrCapabilityChecker
|
||||
{
|
||||
RadarrCapabilities? GetCapabilities();
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Services.ReleaseProfile.Api.Objects;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.ReleaseProfile.Api;
|
||||
|
||||
public interface IReleaseProfileApiService
|
||||
{
|
||||
Task UpdateReleaseProfile(SonarrReleaseProfile profile);
|
||||
Task<SonarrReleaseProfile> CreateReleaseProfile(SonarrReleaseProfile profile);
|
||||
Task<IList<SonarrReleaseProfile>> GetReleaseProfiles();
|
||||
Task DeleteReleaseProfile(int releaseProfileId);
|
||||
Task UpdateReleaseProfile(IServiceConfiguration config, SonarrReleaseProfile profile);
|
||||
Task<SonarrReleaseProfile> CreateReleaseProfile(IServiceConfiguration config, SonarrReleaseProfile profile);
|
||||
Task<IList<SonarrReleaseProfile>> GetReleaseProfiles(IServiceConfiguration config);
|
||||
Task DeleteReleaseProfile(IServiceConfiguration config, int releaseProfileId);
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Services.ReleaseProfile.Api.Objects;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.ReleaseProfile.Api;
|
||||
|
||||
public interface ISonarrReleaseProfileCompatibilityHandler
|
||||
{
|
||||
object CompatibleReleaseProfileForSending(SonarrReleaseProfile profile);
|
||||
Task<object> CompatibleReleaseProfileForSending(IServiceConfiguration config,
|
||||
SonarrReleaseProfile profile);
|
||||
|
||||
SonarrReleaseProfile CompatibleReleaseProfileForReceiving(JObject profile);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Services.Sonarr.Api.Objects;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.Sonarr.Api;
|
||||
|
||||
public interface ISonarrTagApiService
|
||||
{
|
||||
Task<IList<SonarrTag>> GetTags();
|
||||
Task<SonarrTag> CreateTag(string tag);
|
||||
Task<IList<SonarrTag>> GetTags(IServiceConfiguration config);
|
||||
Task<SonarrTag> CreateTag(IServiceConfiguration config, string tag);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.Sonarr.Capabilities;
|
||||
|
||||
public interface ISonarrCapabilityChecker
|
||||
{
|
||||
SonarrCapabilities? GetCapabilities();
|
||||
Task<SonarrCapabilities?> GetCapabilities(IServiceConfiguration config);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.System;
|
||||
|
||||
public interface IServiceInformation
|
||||
{
|
||||
IObservable<Version?> Version { get; }
|
||||
public Task<Version?> GetVersion(IServiceConfiguration config);
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Services.System.Dto;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.System;
|
||||
|
||||
public interface ISystemApiService
|
||||
{
|
||||
Task<SystemStatus> GetStatus();
|
||||
Task<SystemStatus> GetStatus(IServiceConfiguration config);
|
||||
}
|
||||
|
@ -1,40 +1,33 @@
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Linq;
|
||||
using Flurl.Http;
|
||||
using Recyclarr.TrashLib.Config.Services;
|
||||
using Recyclarr.TrashLib.Http;
|
||||
using Recyclarr.TrashLib.Services.System.Dto;
|
||||
|
||||
namespace Recyclarr.TrashLib.Services.System;
|
||||
|
||||
public class ServiceInformation : IServiceInformation
|
||||
{
|
||||
private readonly ISystemApiService _api;
|
||||
private readonly ILogger _log;
|
||||
|
||||
public ServiceInformation(ISystemApiService api, ILogger log)
|
||||
{
|
||||
_api = api;
|
||||
_log = log;
|
||||
Version = Observable.FromAsync(async () => await api.GetStatus(), ThreadPoolScheduler.Instance)
|
||||
.Timeout(TimeSpan.FromSeconds(15))
|
||||
.Do(LogServiceInfo)
|
||||
.Select(x => new Version(x.Version))
|
||||
.Catch((Exception ex) =>
|
||||
{
|
||||
log.Error("Exception trying to obtain service version: {Message}", ex switch
|
||||
{
|
||||
FlurlHttpException flex => flex.SanitizedExceptionMessage(),
|
||||
_ => ex.Message
|
||||
});
|
||||
|
||||
return Observable.Return((Version?) null);
|
||||
})
|
||||
.Replay(1)
|
||||
.AutoConnect();
|
||||
}
|
||||
|
||||
public IObservable<Version?> Version { get; }
|
||||
|
||||
private void LogServiceInfo(SystemStatus status)
|
||||
public async Task<Version?> GetVersion(IServiceConfiguration config)
|
||||
{
|
||||
_log.Debug("{Service} Version: {Version}", status.AppName, status.Version);
|
||||
try
|
||||
{
|
||||
var status = await _api.GetStatus(config);
|
||||
_log.Debug("{Service} Version: {Version}", status.AppName, status.Version);
|
||||
return new Version(status.Version);
|
||||
}
|
||||
catch (FlurlHttpException ex)
|
||||
{
|
||||
_log.Error("Exception trying to obtain service version: {Message}", ex.SanitizedExceptionMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue