You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Core/Notifications/MediaBrowser/MediaBrowserSettings.cs

60 lines
1.8 KiB

using System;
using FluentValidation;
using Newtonsoft.Json;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.MediaBrowser
{
public class MediaBrowserSettingsValidator : AbstractValidator<MediaBrowserSettings>
{
public MediaBrowserSettingsValidator()
{
RuleFor(c => c.Host).ValidHost();
RuleFor(c => c.ApiKey).NotEmpty();
}
}
public class MediaBrowserSettings : IProviderConfig
{
private static readonly MediaBrowserSettingsValidator Validator = new MediaBrowserSettingsValidator();
public MediaBrowserSettings()
{
Port = 8096;
}
[FieldDefinition(0, Label = "Host")]
public String Host { get; set; }
[FieldDefinition(1, Label = "Port")]
public Int32 Port { get; set; }
[FieldDefinition(2, Label = "API Key")]
public String ApiKey { get; set; }
[FieldDefinition(3, Label = "Send Notifications", HelpText = "Have MediaBrowser send notfications to configured providers", Type = FieldType.Checkbox)]
public Boolean Notify { get; set; }
[FieldDefinition(4, Label = "Update Library", HelpText = "Update Library on Download & Rename?", Type = FieldType.Checkbox)]
public Boolean UpdateLibrary { get; set; }
[JsonIgnore]
public String Address { get { return String.Format("{0}:{1}", Host, Port); } }
public bool IsValid
{
get
{
return !string.IsNullOrWhiteSpace(Host) && Port > 0;
}
}
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}