diff --git a/code/Common/Configuration/DTOs/Arr/ArrConfigDto.cs b/code/Common/Configuration/DTOs/Arr/ArrConfigDto.cs
deleted file mode 100644
index 749ce832..00000000
--- a/code/Common/Configuration/DTOs/Arr/ArrConfigDto.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// Base DTO for Arr configurations (excludes sensitive data)
-///
-public abstract class ArrConfigDto
-{
- ///
- /// Whether this configuration is enabled
- ///
- public bool Enabled { get; set; }
-
- ///
- /// Maximum number of strikes for failed imports (-1 for unlimited)
- ///
- public short FailedImportMaxStrikes { get; set; } = -1;
-
- ///
- /// Instances of the Arr application
- ///
- public List Instances { get; set; } = new();
-}
diff --git a/code/Common/Configuration/DTOs/Arr/ArrInstanceDto.cs b/code/Common/Configuration/DTOs/Arr/ArrInstanceDto.cs
deleted file mode 100644
index 8b482ac8..00000000
--- a/code/Common/Configuration/DTOs/Arr/ArrInstanceDto.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for Arr instance information (excludes sensitive data)
-///
-public class ArrInstanceDto
-{
- ///
- /// Unique identifier for this instance
- ///
- public Guid? Id { get; set; } = Guid.NewGuid();
-
- ///
- /// Friendly name for this instance
- ///
- public required string Name { get; set; }
-
- ///
- /// URL of the instance
- ///
- public required Uri Url { get; set; }
-
- // ApiKey is intentionally excluded for security
-}
diff --git a/code/Common/Configuration/DTOs/Arr/ArrInstanceUpdateDto.cs b/code/Common/Configuration/DTOs/Arr/ArrInstanceUpdateDto.cs
deleted file mode 100644
index 3f097d80..00000000
--- a/code/Common/Configuration/DTOs/Arr/ArrInstanceUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for updating Arr instance information (includes sensitive data fields)
-///
-public class ArrInstanceUpdateDto : ArrInstanceDto
-{
- ///
- /// API Key for authentication (only included in update DTO)
- ///
- public string? ApiKey { get; set; }
-}
diff --git a/code/Common/Configuration/DTOs/Arr/LidarrConfigDto.cs b/code/Common/Configuration/DTOs/Arr/LidarrConfigDto.cs
deleted file mode 100644
index 849160ee..00000000
--- a/code/Common/Configuration/DTOs/Arr/LidarrConfigDto.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for retrieving Lidarr configuration (excludes sensitive data)
-///
-public class LidarrConfigDto : ArrConfigDto
-{
-}
diff --git a/code/Common/Configuration/DTOs/Arr/LidarrConfigUpdateDto.cs b/code/Common/Configuration/DTOs/Arr/LidarrConfigUpdateDto.cs
deleted file mode 100644
index c69a7efb..00000000
--- a/code/Common/Configuration/DTOs/Arr/LidarrConfigUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for updating Lidarr configuration (includes sensitive data fields)
-///
-public class LidarrConfigUpdateDto : LidarrConfigDto
-{
- ///
- /// Instances with sensitive data for updating
- ///
- public new List Instances { get; set; } = new();
-}
diff --git a/code/Common/Configuration/DTOs/Arr/RadarrConfigDto.cs b/code/Common/Configuration/DTOs/Arr/RadarrConfigDto.cs
deleted file mode 100644
index a6283c71..00000000
--- a/code/Common/Configuration/DTOs/Arr/RadarrConfigDto.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for retrieving Radarr configuration (excludes sensitive data)
-///
-public class RadarrConfigDto : ArrConfigDto
-{
-}
diff --git a/code/Common/Configuration/DTOs/Arr/RadarrConfigUpdateDto.cs b/code/Common/Configuration/DTOs/Arr/RadarrConfigUpdateDto.cs
deleted file mode 100644
index 39e9ce91..00000000
--- a/code/Common/Configuration/DTOs/Arr/RadarrConfigUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for updating Radarr configuration (includes sensitive data fields)
-///
-public class RadarrConfigUpdateDto : RadarrConfigDto
-{
- ///
- /// Instances with sensitive data for updating
- ///
- public new List Instances { get; set; } = new();
-}
diff --git a/code/Common/Configuration/DTOs/Arr/SonarrConfigDto.cs b/code/Common/Configuration/DTOs/Arr/SonarrConfigDto.cs
deleted file mode 100644
index 92b8b31f..00000000
--- a/code/Common/Configuration/DTOs/Arr/SonarrConfigDto.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Common.Configuration.Arr;
-
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for retrieving Sonarr configuration (excludes sensitive data)
-///
-public class SonarrConfigDto : ArrConfigDto
-{
- ///
- /// Type of search used by Sonarr
- ///
- public SonarrSearchType SearchType { get; set; } = SonarrSearchType.Episode;
-}
diff --git a/code/Common/Configuration/DTOs/Arr/SonarrConfigUpdateDto.cs b/code/Common/Configuration/DTOs/Arr/SonarrConfigUpdateDto.cs
deleted file mode 100644
index 74466b4c..00000000
--- a/code/Common/Configuration/DTOs/Arr/SonarrConfigUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.Arr;
-
-///
-/// DTO for updating Sonarr configuration (includes sensitive data fields)
-///
-public class SonarrConfigUpdateDto : SonarrConfigDto
-{
- ///
- /// Instances with sensitive data for updating
- ///
- public new List Instances { get; set; } = new();
-}
diff --git a/code/Common/Configuration/DTOs/ContentBlocker/ContentBlockerConfigDto.cs b/code/Common/Configuration/DTOs/ContentBlocker/ContentBlockerConfigDto.cs
deleted file mode 100644
index 8bc01975..00000000
--- a/code/Common/Configuration/DTOs/ContentBlocker/ContentBlockerConfigDto.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using Common.Configuration.QueueCleaner;
-
-namespace Common.Configuration.DTOs.ContentBlocker;
-
-///
-/// DTO for retrieving ContentBlocker configuration
-///
-public class ContentBlockerConfigDto
-{
- ///
- /// Whether the content blocker is enabled
- ///
- public bool Enabled { get; set; }
-
- ///
- /// Cron expression for scheduling
- ///
- public string CronExpression { get; set; } = "0 0/5 * * * ?";
-
- ///
- /// Whether to ignore private torrents
- ///
- public bool IgnorePrivate { get; set; }
-
- ///
- /// Whether to delete private torrents
- ///
- public bool DeletePrivate { get; set; }
-
- ///
- /// Sonarr blocklist settings
- ///
- public BlocklistSettingsDto Sonarr { get; set; } = new();
-
- ///
- /// Radarr blocklist settings
- ///
- public BlocklistSettingsDto Radarr { get; set; } = new();
-
- ///
- /// Lidarr blocklist settings
- ///
- public BlocklistSettingsDto Lidarr { get; set; } = new();
-}
-
-///
-/// DTO for blocklist settings
-///
-public class BlocklistSettingsDto
-{
- ///
- /// Whether the blocklist settings are enabled
- ///
- public bool Enabled { get; set; }
-
- ///
- /// Type of blocklist
- ///
- public BlocklistType Type { get; set; }
-
- ///
- /// Path to blocklist file or URL
- ///
- public string? Path { get; set; }
-}
diff --git a/code/Common/Configuration/DTOs/ContentBlocker/ContentBlockerConfigUpdateDto.cs b/code/Common/Configuration/DTOs/ContentBlocker/ContentBlockerConfigUpdateDto.cs
deleted file mode 100644
index 13e6bf2d..00000000
--- a/code/Common/Configuration/DTOs/ContentBlocker/ContentBlockerConfigUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.ContentBlocker;
-
-///
-/// DTO for updating ContentBlocker configuration
-///
-///
-/// This class inherits from ContentBlockerConfigDto without adding any additional fields
-/// since ContentBlocker doesn't have sensitive data fields that need special handling
-///
-public class ContentBlockerConfigUpdateDto : ContentBlockerConfigDto
-{
-}
diff --git a/code/Common/Configuration/DTOs/DownloadClient/DownloadClientConfigDto.cs b/code/Common/Configuration/DTOs/DownloadClient/DownloadClientConfigDto.cs
deleted file mode 100644
index 55caca4a..00000000
--- a/code/Common/Configuration/DTOs/DownloadClient/DownloadClientConfigDto.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using Common.Enums;
-
-namespace Common.Configuration.DTOs.DownloadClient;
-
-///
-/// DTO for retrieving DownloadClient configuration (excludes sensitive data)
-///
-public class DownloadClientConfigDto
-{
- ///
- /// Collection of download clients configured for the application
- ///
- public List Clients { get; set; } = new();
-}
-
-///
-/// DTO for individual client configuration (excludes sensitive data)
-///
-public class ClientConfigDto
-{
- ///
- /// Whether this client is enabled
- ///
- public bool Enabled { get; set; } = true;
-
- ///
- /// Unique identifier for this client
- ///
- public Guid? Id { get; set; } = Guid.NewGuid();
-
- ///
- /// Friendly name for this client
- ///
- public string Name { get; set; } = string.Empty;
-
- ///
- /// Type of download client
- ///
- public required DownloadClientType Type { get; set; }
-
- ///
- /// Host address for the download client
- ///
- public Uri? Host { get; set; }
-
- ///
- /// Username for authentication (included without password)
- ///
- public string Username { get; set; } = string.Empty;
-
- ///
- /// The base URL path component, used by clients like Transmission and Deluge
- ///
- public string UrlBase { get; set; } = string.Empty;
-}
diff --git a/code/Common/Configuration/DTOs/DownloadClient/DownloadClientConfigUpdateDto.cs b/code/Common/Configuration/DTOs/DownloadClient/DownloadClientConfigUpdateDto.cs
deleted file mode 100644
index 07c5e35e..00000000
--- a/code/Common/Configuration/DTOs/DownloadClient/DownloadClientConfigUpdateDto.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Common.Configuration.DTOs.DownloadClient;
-
-///
-/// DTO for updating DownloadClient configuration (includes sensitive data fields)
-///
-public class DownloadClientConfigUpdateDto : DownloadClientConfigDto
-{
- ///
- /// Collection of clients for updating (with sensitive data fields)
- ///
- public new List Clients { get; set; } = new();
-}
-
-///
-/// DTO for updating individual client configuration (includes sensitive data fields)
-///
-public class ClientConfigUpdateDto : ClientConfigDto
-{
- ///
- /// Password for authentication (only included in update DTO)
- ///
- public string? Password { get; set; }
-}
diff --git a/code/Common/Configuration/DTOs/General/GeneralConfigDto.cs b/code/Common/Configuration/DTOs/General/GeneralConfigDto.cs
deleted file mode 100644
index b923c279..00000000
--- a/code/Common/Configuration/DTOs/General/GeneralConfigDto.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Common.Enums;
-using Serilog.Events;
-
-namespace Common.Configuration.DTOs.General;
-
-///
-/// DTO for retrieving General configuration (excludes sensitive data)
-///
-public class GeneralConfigDto
-{
- ///
- /// Whether the application is running in dry run mode
- ///
- public bool DryRun { get; set; }
-
- ///
- /// Maximum number of HTTP retries
- ///
- public ushort HttpMaxRetries { get; set; }
-
- ///
- /// HTTP timeout in seconds
- ///
- public ushort HttpTimeout { get; set; } = 100;
-
- ///
- /// Certificate validation type for HTTP requests
- ///
- public CertificateValidationType HttpCertificateValidation { get; set; } = CertificateValidationType.Enabled;
-
- ///
- /// Whether search functionality is enabled
- ///
- public bool SearchEnabled { get; set; } = true;
-
- ///
- /// Delay between searches in seconds
- ///
- public ushort SearchDelay { get; set; } = 30;
-
- ///
- /// Application log level
- ///
- public LogEventLevel LogLevel { get; set; } = LogEventLevel.Information;
-
- ///
- /// Ignored downloads list
- ///
- public List IgnoredDownloads { get; set; } = [];
-}
diff --git a/code/Common/Configuration/DTOs/Notification/AppriseConfigDto.cs b/code/Common/Configuration/DTOs/Notification/AppriseConfigDto.cs
deleted file mode 100644
index 7775d65a..00000000
--- a/code/Common/Configuration/DTOs/Notification/AppriseConfigDto.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// DTO for retrieving Apprise configuration (excludes sensitive data)
-///
-public class AppriseConfigDto : BaseNotificationConfigDto
-{
- ///
- /// URL of the Apprise API server
- ///
- public Uri? Url { get; set; }
-
- // Key is intentionally excluded for security
-}
diff --git a/code/Common/Configuration/DTOs/Notification/AppriseConfigUpdateDto.cs b/code/Common/Configuration/DTOs/Notification/AppriseConfigUpdateDto.cs
deleted file mode 100644
index b88a64ee..00000000
--- a/code/Common/Configuration/DTOs/Notification/AppriseConfigUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// DTO for updating Apprise configuration (includes sensitive data fields)
-///
-public class AppriseConfigUpdateDto : AppriseConfigDto
-{
- ///
- /// API Key for Apprise authentication (only included in update DTO)
- ///
- public string? Key { get; set; }
-}
diff --git a/code/Common/Configuration/DTOs/Notification/BaseNotificationConfigDto.cs b/code/Common/Configuration/DTOs/Notification/BaseNotificationConfigDto.cs
deleted file mode 100644
index 3b2b6c51..00000000
--- a/code/Common/Configuration/DTOs/Notification/BaseNotificationConfigDto.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// Base DTO for notification configuration
-///
-public abstract class BaseNotificationConfigDto
-{
- ///
- /// Whether to notify on failed import strikes
- ///
- public bool OnFailedImportStrike { get; set; }
-
- ///
- /// Whether to notify on stalled download strikes
- ///
- public bool OnStalledStrike { get; set; }
-
- ///
- /// Whether to notify on slow download strikes
- ///
- public bool OnSlowStrike { get; set; }
-
- ///
- /// Whether to notify on queue item deletion
- ///
- public bool OnQueueItemDeleted { get; set; }
-
- ///
- /// Whether to notify on download cleaning
- ///
- public bool OnDownloadCleaned { get; set; }
-
- ///
- /// Whether to notify on category changes
- ///
- public bool OnCategoryChanged { get; set; }
-
- ///
- /// Whether any notification option is enabled
- ///
- public bool IsEnabled =>
- OnFailedImportStrike ||
- OnStalledStrike ||
- OnSlowStrike ||
- OnQueueItemDeleted ||
- OnDownloadCleaned ||
- OnCategoryChanged;
-}
diff --git a/code/Common/Configuration/DTOs/Notification/NotifiarrConfigDto.cs b/code/Common/Configuration/DTOs/Notification/NotifiarrConfigDto.cs
deleted file mode 100644
index c9738a46..00000000
--- a/code/Common/Configuration/DTOs/Notification/NotifiarrConfigDto.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// DTO for retrieving Notifiarr configuration (excludes sensitive data)
-///
-public class NotifiarrConfigDto : BaseNotificationConfigDto
-{
- ///
- /// Channel ID for Notifiarr notifications
- ///
- public string? ChannelId { get; set; }
-
- // ApiKey is intentionally excluded for security
-}
diff --git a/code/Common/Configuration/DTOs/Notification/NotifiarrConfigUpdateDto.cs b/code/Common/Configuration/DTOs/Notification/NotifiarrConfigUpdateDto.cs
deleted file mode 100644
index e747826d..00000000
--- a/code/Common/Configuration/DTOs/Notification/NotifiarrConfigUpdateDto.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// DTO for updating Notifiarr configuration (includes sensitive data fields)
-///
-public class NotifiarrConfigUpdateDto : NotifiarrConfigDto
-{
- ///
- /// API Key for Notifiarr authentication (only included in update DTO)
- ///
- public string? ApiKey { get; set; }
-}
diff --git a/code/Common/Configuration/DTOs/Notification/NotificationsConfigDto.cs b/code/Common/Configuration/DTOs/Notification/NotificationsConfigDto.cs
deleted file mode 100644
index 9de06908..00000000
--- a/code/Common/Configuration/DTOs/Notification/NotificationsConfigDto.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// DTO for retrieving Notifications configuration (excludes sensitive data)
-///
-public class NotificationsConfigDto
-{
- ///
- /// Notifiarr notification configuration
- ///
- public NotifiarrConfigDto Notifiarr { get; set; } = new();
-
- ///
- /// Apprise notification configuration
- ///
- public AppriseConfigDto Apprise { get; set; } = new();
-}
diff --git a/code/Common/Configuration/DTOs/Notification/NotificationsConfigUpdateDto.cs b/code/Common/Configuration/DTOs/Notification/NotificationsConfigUpdateDto.cs
deleted file mode 100644
index 68439404..00000000
--- a/code/Common/Configuration/DTOs/Notification/NotificationsConfigUpdateDto.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace Common.Configuration.DTOs.Notification;
-
-///
-/// DTO for updating Notifications configuration (includes sensitive data fields)
-///
-public class NotificationsConfigUpdateDto : NotificationsConfigDto
-{
- ///
- /// Notifiarr notification configuration with sensitive data
- ///
- public new NotifiarrConfigUpdateDto Notifiarr { get; set; } = new();
-
- ///
- /// Apprise notification configuration with sensitive data
- ///
- public new AppriseConfigUpdateDto Apprise { get; set; } = new();
-}
diff --git a/code/Executable/Controllers/ConfigurationController.cs b/code/Executable/Controllers/ConfigurationController.cs
index 94a6df41..3f92f5cf 100644
--- a/code/Executable/Controllers/ConfigurationController.cs
+++ b/code/Executable/Controllers/ConfigurationController.cs
@@ -2,11 +2,6 @@ using Common.Configuration;
using Common.Configuration.Arr;
using Common.Configuration.DownloadCleaner;
using Common.Configuration.DownloadClient;
-using Common.Configuration.DTOs.Arr;
-using Common.Configuration.DTOs.ContentBlocker;
-using Common.Configuration.DTOs.DownloadClient;
-using Common.Configuration.DTOs.General;
-using Common.Configuration.DTOs.Notification;
using Common.Configuration.General;
using Common.Configuration.Notification;
using Common.Configuration.QueueCleaner;
@@ -59,48 +54,42 @@ public class ConfigurationController : ControllerBase
public async Task GetDownloadClientConfig()
{
var config = await _configManager.GetConfigurationAsync();
- var dto = config.Adapt();
- return Ok(dto);
+ return Ok(config);
}
[HttpGet("general")]
public async Task GetGeneralConfig()
{
var config = await _configManager.GetConfigurationAsync();
- var dto = config.Adapt();
- return Ok(dto);
+ return Ok(config);
}
[HttpGet("sonarr")]
public async Task GetSonarrConfig()
{
var config = await _configManager.GetConfigurationAsync();
- var dto = config.Adapt();
- return Ok(dto);
+ return Ok(config);
}
[HttpGet("radarr")]
public async Task GetRadarrConfig()
{
var config = await _configManager.GetConfigurationAsync();
- var dto = config.Adapt();
- return Ok(dto);
+ return Ok(config);
}
[HttpGet("lidarr")]
public async Task GetLidarrConfig()
{
var config = await _configManager.GetConfigurationAsync();
- var dto = config.Adapt();
- return Ok(dto);
+ return Ok(config);
}
[HttpGet("notifications")]
public async Task GetNotificationsConfig()
{
var config = await _configManager.GetConfigurationAsync();
- var dto = config.Adapt();
- return Ok(dto);
+ return Ok(config);
}
[HttpPut("queue_cleaner")]
@@ -164,15 +153,8 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("content_blocker")]
- public async Task UpdateContentBlockerConfig([FromBody] ContentBlockerConfigUpdateDto dto)
+ public async Task UpdateContentBlockerConfig([FromBody] ContentBlockerConfig newConfig)
{
- // Get existing config
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
// Validate the configuration
newConfig.Validate();
@@ -213,15 +195,8 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("download_client")]
- public async Task UpdateDownloadClientConfig(DownloadClientConfigUpdateDto dto)
+ public async Task UpdateDownloadClientConfig(DownloadClientConfig newConfig)
{
- // Get existing config to preserve sensitive data
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
// Validate the configuration
newConfig.Validate();
@@ -236,15 +211,8 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("general")]
- public async Task UpdateGeneralConfig([FromBody] GeneralConfig dto)
+ public async Task UpdateGeneralConfig([FromBody] GeneralConfig newConfig)
{
- // Get existing config to preserve sensitive data
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
// Validate the configuration
newConfig.Validate();
@@ -255,21 +223,14 @@ public class ConfigurationController : ControllerBase
return StatusCode(500, "Failed to save General configuration");
}
- _loggingConfigManager.SetLogLevel(oldConfig.LogLevel);
+ _loggingConfigManager.SetLogLevel(newConfig.LogLevel);
return Ok(new { Message = "General configuration updated successfully" });
}
[HttpPut("sonarr")]
- public async Task UpdateSonarrConfig([FromBody] SonarrConfigUpdateDto dto)
+ public async Task UpdateSonarrConfig([FromBody] SonarrConfig newConfig)
{
- // Get existing config to preserve sensitive data
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
// Validate the configuration
newConfig.Validate();
@@ -284,15 +245,8 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("radarr")]
- public async Task UpdateRadarrConfig([FromBody] RadarrConfigUpdateDto dto)
+ public async Task UpdateRadarrConfig([FromBody] RadarrConfig newConfig)
{
- // Get existing config to preserve sensitive data
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
// Validate the configuration
newConfig.Validate();
@@ -307,15 +261,8 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("lidarr")]
- public async Task UpdateLidarrConfig([FromBody] LidarrConfigUpdateDto dto)
+ public async Task UpdateLidarrConfig([FromBody] LidarrConfig newConfig)
{
- // Get existing config to preserve sensitive data
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
// Validate the configuration
newConfig.Validate();
@@ -330,18 +277,8 @@ public class ConfigurationController : ControllerBase
}
[HttpPut("notifications")]
- public async Task UpdateNotificationsConfig([FromBody] NotificationsConfigUpdateDto dto)
+ public async Task UpdateNotificationsConfig([FromBody] NotificationsConfig newConfig)
{
- // Get existing config to preserve sensitive data
- var oldConfig = await _configManager.GetConfigurationAsync();
-
- // Apply updates from DTO, preserving sensitive data if not provided
- var newConfig = oldConfig.Adapt();
- newConfig = dto.Adapt(newConfig);
-
- // Validate the configuration
- // newConfig.Validate();
-
// Persist the configuration
var result = await _configManager.SaveConfigurationAsync(newConfig);
if (!result)
diff --git a/code/Executable/Controllers/DownloadClientsController.cs b/code/Executable/Controllers/DownloadClientsController.cs
deleted file mode 100644
index 931eb20c..00000000
--- a/code/Executable/Controllers/DownloadClientsController.cs
+++ /dev/null
@@ -1,265 +0,0 @@
-using Common.Configuration.DownloadClient;
-using Common.Enums;
-using Infrastructure.Configuration;
-using Infrastructure.Verticals.DownloadClient;
-using Infrastructure.Verticals.DownloadClient.Factory;
-using Microsoft.AspNetCore.Mvc;
-
-namespace Executable.Controllers;
-
-///
-/// Controller for managing individual download clients
-///
-[ApiController]
-[Route("api/clients")]
-public class DownloadClientsController : ControllerBase
-{
- private readonly ILogger _logger;
- private readonly IConfigManager _configManager;
- private readonly IDownloadClientFactory _clientFactory;
-
- ///
- /// Initializes a new instance of the class
- ///
- public DownloadClientsController(
- ILogger logger,
- IConfigManager configManager,
- IDownloadClientFactory clientFactory)
- {
- _logger = logger;
- _configManager = configManager;
- _clientFactory = clientFactory;
- }
-
- ///
- /// Gets all download clients
- ///
- [HttpGet]
- public async Task GetAllClients()
- {
- try
- {
- var config = await _configManager.GetConfigurationAsync();
-
- // TODO don't expose passwords
- return Ok(config.Clients);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error retrieving download clients");
- return StatusCode(500, new { Error = "An error occurred while retrieving download clients" });
- }
- }
-
- ///
- /// Gets a specific download client by ID
- ///
- [HttpGet("{id:guid}")]
- public async Task GetClient(Guid id)
- {
- try
- {
- var config = await _configManager.GetConfigurationAsync();
-
- var client = config.GetClientConfig(id);
- if (client == null)
- {
- return NotFound(new { Message = $"Client with ID '{id}' not found" });
- }
-
- return Ok(client);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error retrieving download client {id}", id);
- return StatusCode(500, new { Error = "An error occurred while retrieving the download client" });
- }
- }
-
- ///
- /// Adds a new download client
- ///
- [HttpPost]
- public async Task AddClient([FromBody] ClientConfig clientConfig)
- {
- try
- {
- // Validate the new client configuration
- clientConfig.Validate();
-
- // Get the current configuration
- var config = await _configManager.GetConfigurationAsync();
-
- // Check if a client with the same ID already exists
- if (config.GetClientConfig(clientConfig.Id) != null)
- {
- return BadRequest(new { Error = $"A client with ID '{clientConfig.Id}' already exists" });
- }
-
- // Add the new client
- config.Clients.Add(clientConfig);
-
- // Persist the updated configuration
- var result = await _configManager.SaveConfigurationAsync(config);
- if (!result)
- {
- return StatusCode(500, new { Error = "Failed to save download client configuration" });
- }
-
- _logger.LogInformation("Added new download client: {name} ({id})", clientConfig.Name, clientConfig.Id);
- return CreatedAtAction(nameof(GetClient), new { id = clientConfig.Id }, clientConfig);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error adding download client");
- return BadRequest(new { Error = ex.Message });
- }
- }
-
- ///
- /// Updates an existing download client
- ///
- [HttpPut("{id:guid}")]
- public async Task UpdateClient(Guid id, [FromBody] ClientConfig clientConfig)
- {
- try
- {
- // Ensure the ID in the route matches the ID in the body
- if (id != clientConfig.Id)
- {
- return BadRequest(new { Error = "Client ID in the URL does not match the ID in the request body" });
- }
-
- // Validate the updated client configuration
- clientConfig.Validate();
-
- // Get the current configuration
- var config = await _configManager.GetConfigurationAsync();
-
- // Find the client to update
- var existingClientIndex = config.Clients.FindIndex(c => c.Id == id);
- if (existingClientIndex == -1)
- {
- return NotFound(new { Message = $"Client with ID '{id}' not found" });
- }
-
- // Update the client
- config.Clients[existingClientIndex] = clientConfig;
-
- // Persist the updated configuration
- var result = await _configManager.SaveConfigurationAsync(config);
- if (!result)
- {
- return StatusCode(500, new { Error = "Failed to save download client configuration" });
- }
-
- _logger.LogInformation("Updated download client: {name} ({id})", clientConfig.Name, clientConfig.Id);
- return Ok(clientConfig);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error updating download client {id}", id);
- return BadRequest(new { Error = ex.Message });
- }
- }
-
- ///
- /// Deletes a download client
- ///
- [HttpDelete("{id:guid}")]
- public async Task DeleteClient(Guid id)
- {
- try
- {
- // Get the current configuration
- var config = await _configManager.GetConfigurationAsync();
-
- // Find the client to delete
- var existingClientIndex = config.Clients.FindIndex(c => c.Id == id);
- if (existingClientIndex == -1)
- {
- return NotFound(new { Message = $"Client with ID '{id}' not found" });
- }
-
- // Remove the client
- config.Clients.RemoveAt(existingClientIndex);
-
- // Persist the updated configuration
- var result = await _configManager.SaveConfigurationAsync(config);
- if (!result)
- {
- return StatusCode(500, new { Error = "Failed to save download client configuration" });
- }
-
- _logger.LogInformation("Deleted download client with ID: {id}", id);
- return NoContent();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error deleting download client {id}", id);
- return StatusCode(500, new { Error = "An error occurred while deleting the download client" });
- }
- }
-
- ///
- /// Tests connection to a download client
- ///
- [HttpPost("{id:guid}/test")]
- public async Task TestConnection(Guid id)
- {
- try
- {
- // Get the client configuration
- var config = await _configManager.GetConfigurationAsync();
-
- var clientConfig = config.GetClientConfig(id);
- if (clientConfig == null)
- {
- return NotFound(new { Message = $"Client with ID '{id}' not found" });
- }
-
- // Ensure the client is initialized
- try
- {
- // Get the client instance
- var client = _clientFactory.GetClient(id);
-
- // Try to login
- await client.LoginAsync();
-
- _logger.LogInformation("Successfully connected to download client: {name} ({id})", clientConfig.Name, id);
- return Ok(new { Success = true, Message = "Connection successful" });
- }
- catch (Exception ex)
- {
- _logger.LogWarning(ex, "Failed to connect to download client: {name} ({id})", clientConfig.Name, id);
- return Ok(new { Success = false, Message = $"Connection failed: {ex.Message}" });
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error testing connection to download client {id}", id);
- return StatusCode(500, new { Error = "An error occurred while testing the connection" });
- }
- }
-
- ///
- /// Gets all clients of a specific type
- ///
- [HttpGet("type/{type}")]
- public async Task GetClientsByType(DownloadClientType type)
- {
- try
- {
- var config = await _configManager.GetConfigurationAsync();
-
- var clients = config.Clients.Where(c => c.Type == type).ToList();
- return Ok(clients);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error retrieving download clients of type {type}", type);
- return StatusCode(500, new { Error = "An error occurred while retrieving download clients" });
- }
- }
-}