Added the ability to fetch host configs and security configs to the CLI
This commit is contained in:
@@ -57,6 +57,44 @@ pub struct AddRootFolderBody {
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone, Copy, Debug, ValueEnum)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum AuthenticationMethod {
|
||||
#[default]
|
||||
Basic,
|
||||
Forms,
|
||||
None,
|
||||
}
|
||||
|
||||
impl Display for AuthenticationMethod {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let authentication_method = match self {
|
||||
AuthenticationMethod::Basic => "basic",
|
||||
AuthenticationMethod::Forms => "forms",
|
||||
AuthenticationMethod::None => "none",
|
||||
};
|
||||
write!(f, "{authentication_method}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone, Copy, Debug, ValueEnum)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum AuthenticationRequired {
|
||||
Enabled,
|
||||
#[default]
|
||||
DisabledForLocalAddresses,
|
||||
}
|
||||
|
||||
impl Display for AuthenticationRequired {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let authentication_required = match self {
|
||||
AuthenticationRequired::Enabled => "enabled",
|
||||
AuthenticationRequired::DisabledForLocalAddresses => "disabledForLocalAddresses",
|
||||
};
|
||||
write!(f, "{authentication_required}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct BlocklistResponse {
|
||||
pub records: Vec<BlocklistItem>,
|
||||
@@ -85,6 +123,26 @@ pub struct BlocklistItemMovie {
|
||||
pub title: HorizontallyScrollableText,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Clone, Copy, Debug, ValueEnum)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum CertificateValidation {
|
||||
#[default]
|
||||
Enabled,
|
||||
DisabledForLocalAddresses,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
impl Display for CertificateValidation {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let certificate_validation = match self {
|
||||
CertificateValidation::Enabled => "enabled",
|
||||
CertificateValidation::DisabledForLocalAddresses => "disabledForLocalAddresses",
|
||||
CertificateValidation::Disabled => "disabled",
|
||||
};
|
||||
write!(f, "{certificate_validation}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Derivative, Default, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Collection {
|
||||
@@ -223,6 +281,18 @@ pub struct EditMovieParams {
|
||||
pub clear_tags: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct HostConfig {
|
||||
pub bind_address: HorizontallyScrollableText,
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub port: i64,
|
||||
pub url_base: Option<HorizontallyScrollableText>,
|
||||
pub instance_name: Option<HorizontallyScrollableText>,
|
||||
pub application_url: Option<HorizontallyScrollableText>,
|
||||
pub enable_ssl: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Indexer {
|
||||
@@ -560,6 +630,17 @@ pub struct RootFolder {
|
||||
pub unmapped_folders: Option<Vec<UnmappedFolder>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SecurityConfig {
|
||||
pub authentication_method: AuthenticationMethod,
|
||||
pub authentication_required: AuthenticationRequired,
|
||||
pub username: String,
|
||||
pub password: Option<String>,
|
||||
pub api_key: String,
|
||||
pub certificate_validation: CertificateValidation,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SystemStatus {
|
||||
@@ -647,6 +728,7 @@ pub enum RadarrSerdeable {
|
||||
Credits(Vec<Credit>),
|
||||
DiskSpaces(Vec<DiskSpace>),
|
||||
DownloadsResponse(DownloadsResponse),
|
||||
HostConfig(HostConfig),
|
||||
Indexers(Vec<Indexer>),
|
||||
IndexerSettings(IndexerSettings),
|
||||
LogResponse(LogResponse),
|
||||
@@ -657,6 +739,7 @@ pub enum RadarrSerdeable {
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
Releases(Vec<Release>),
|
||||
RootFolders(Vec<RootFolder>),
|
||||
SecurityConfig(SecurityConfig),
|
||||
SystemStatus(SystemStatus),
|
||||
Tags(Vec<Tag>),
|
||||
Tasks(Vec<Task>),
|
||||
@@ -686,6 +769,7 @@ serde_enum_from!(
|
||||
Credits(Vec<Credit>),
|
||||
DiskSpaces(Vec<DiskSpace>),
|
||||
DownloadsResponse(DownloadsResponse),
|
||||
HostConfig(HostConfig),
|
||||
Indexers(Vec<Indexer>),
|
||||
IndexerSettings(IndexerSettings),
|
||||
LogResponse(LogResponse),
|
||||
@@ -696,6 +780,7 @@ serde_enum_from!(
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
Releases(Vec<Release>),
|
||||
RootFolders(Vec<RootFolder>),
|
||||
SecurityConfig(SecurityConfig),
|
||||
SystemStatus(SystemStatus),
|
||||
Tags(Vec<Tag>),
|
||||
Tasks(Vec<Task>),
|
||||
|
||||
@@ -5,14 +5,41 @@ mod tests {
|
||||
|
||||
use crate::models::{
|
||||
radarr_models::{
|
||||
AddMovieSearchResult, BlocklistItem, BlocklistResponse, Collection, Credit, DiskSpace,
|
||||
DownloadRecord, DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult, Log,
|
||||
LogResponse, MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile,
|
||||
QueueEvent, RadarrSerdeable, Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
|
||||
AddMovieSearchResult, AuthenticationMethod, AuthenticationRequired, BlocklistItem,
|
||||
BlocklistResponse, CertificateValidation, Collection, Credit, DiskSpace, DownloadRecord,
|
||||
DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult, Log, LogResponse,
|
||||
MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile, QueueEvent,
|
||||
RadarrSerdeable, Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
|
||||
},
|
||||
Serdeable,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_authentication_method_display() {
|
||||
assert_str_eq!(AuthenticationMethod::Basic.to_string(), "basic");
|
||||
assert_str_eq!(AuthenticationMethod::Forms.to_string(), "forms");
|
||||
assert_str_eq!(AuthenticationMethod::None.to_string(), "none");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_authentication_required_display() {
|
||||
assert_str_eq!(AuthenticationRequired::Enabled.to_string(), "enabled");
|
||||
assert_str_eq!(
|
||||
AuthenticationRequired::DisabledForLocalAddresses.to_string(),
|
||||
"disabledForLocalAddresses"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_certificate_validation_display() {
|
||||
assert_str_eq!(CertificateValidation::Enabled.to_string(), "enabled");
|
||||
assert_str_eq!(
|
||||
CertificateValidation::DisabledForLocalAddresses.to_string(),
|
||||
"disabledForLocalAddresses"
|
||||
);
|
||||
assert_str_eq!(CertificateValidation::Disabled.to_string(), "disabled");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task_name_display() {
|
||||
assert_str_eq!(
|
||||
|
||||
Reference in New Issue
Block a user