mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-15 17:28:26 -05:00
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using Common.Enums;
|
|
using Common.Exceptions;
|
|
|
|
namespace Executable.DTOs;
|
|
|
|
/// <summary>
|
|
/// DTO for creating a new download client (without ID)
|
|
/// </summary>
|
|
public sealed record CreateDownloadClientDto
|
|
{
|
|
/// <summary>
|
|
/// Whether this client is enabled
|
|
/// </summary>
|
|
public bool Enabled { get; init; } = false;
|
|
|
|
/// <summary>
|
|
/// Friendly name for this client
|
|
/// </summary>
|
|
public required string Name { get; init; }
|
|
|
|
/// <summary>
|
|
/// Type name of download client
|
|
/// </summary>
|
|
public required DownloadClientTypeName TypeName { get; init; }
|
|
|
|
/// <summary>
|
|
/// Type of download client
|
|
/// </summary>
|
|
public required DownloadClientType Type { get; init; }
|
|
|
|
/// <summary>
|
|
/// Host address for the download client
|
|
/// </summary>
|
|
public Uri? Host { get; init; }
|
|
|
|
/// <summary>
|
|
/// Username for authentication
|
|
/// </summary>
|
|
public string? Username { get; init; }
|
|
|
|
/// <summary>
|
|
/// Password for authentication
|
|
/// </summary>
|
|
public string? Password { get; init; }
|
|
|
|
/// <summary>
|
|
/// The base URL path component, used by clients like Transmission and Deluge
|
|
/// </summary>
|
|
public string? UrlBase { get; init; }
|
|
|
|
/// <summary>
|
|
/// Validates the configuration
|
|
/// </summary>
|
|
public void Validate()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(Name))
|
|
{
|
|
throw new ValidationException("Client name cannot be empty");
|
|
}
|
|
|
|
if (Host is null && TypeName is not DownloadClientTypeName.Usenet)
|
|
{
|
|
throw new ValidationException("Host cannot be empty for non-Usenet clients");
|
|
}
|
|
}
|
|
} |