feat(network): Added netwwork support for fetching all indexer settings for Sonarr

This commit is contained in:
2024-11-18 21:19:20 -07:00
parent 4fc2d3c94b
commit 7870bb4b5b
7 changed files with 137 additions and 8 deletions
+28
View File
@@ -10,6 +10,7 @@ mod tests {
LogResponse, MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile,
QueueEvent, RadarrSerdeable, Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
},
servarr_models::{HostConfig, SecurityConfig},
Serdeable,
};
@@ -178,6 +179,18 @@ mod tests {
assert_eq!(radarr_serdeable, RadarrSerdeable::DiskSpaces(disk_spaces));
}
#[test]
fn test_radarr_serdeable_from_host_config() {
let host_config = HostConfig {
port: 1234,
..HostConfig::default()
};
let radarr_serdeable: RadarrSerdeable = host_config.clone().into();
assert_eq!(radarr_serdeable, RadarrSerdeable::HostConfig(host_config));
}
#[test]
fn test_radarr_serdeable_from_downloads_response() {
let downloads_response = DownloadsResponse {
@@ -326,6 +339,21 @@ mod tests {
assert_eq!(radarr_serdeable, RadarrSerdeable::RootFolders(root_folders));
}
#[test]
fn test_radarr_serdeable_from_security_config() {
let security_config = SecurityConfig {
username: Some("Test".to_owned()),
..SecurityConfig::default()
};
let radarr_serdeable: RadarrSerdeable = security_config.clone().into();
assert_eq!(
radarr_serdeable,
RadarrSerdeable::SecurityConfig(security_config)
);
}
#[test]
fn test_radarr_serdeable_from_system_status() {
let system_status = SystemStatus {
@@ -4,7 +4,7 @@ use strum::EnumIter;
use crate::models::{
servarr_models::Indexer,
sonarr_models::{BlocklistItem, DownloadRecord, Episode, Series},
sonarr_models::{BlocklistItem, DownloadRecord, Episode, IndexerSettings, Series},
stateful_list::StatefulList,
stateful_table::StatefulTable,
stateful_tree::StatefulTree,
@@ -29,6 +29,7 @@ pub struct SonarrData {
pub episode_details_modal: Option<EpisodeDetailsModal>,
pub quality_profile_map: BiMap<i64, String>,
pub indexers: StatefulTable<Indexer>,
pub indexer_settings: Option<IndexerSettings>,
}
impl Default for SonarrData {
@@ -45,6 +46,7 @@ impl Default for SonarrData {
episode_details_modal: None,
quality_profile_map: BiMap::new(),
indexers: StatefulTable::default(),
indexer_settings: None,
}
}
}
@@ -45,6 +45,7 @@ mod tests {
assert!(sonarr_data.episode_details_modal.is_none());
assert!(sonarr_data.quality_profile_map.is_empty());
assert!(sonarr_data.indexers.is_empty());
assert!(sonarr_data.indexer_settings.is_none());
}
}
}
+17
View File
@@ -106,6 +106,21 @@ pub struct EpisodeFile {
pub media_info: Option<MediaInfo>,
}
#[derive(Default, Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct IndexerSettings {
#[serde(deserialize_with = "super::from_i64")]
pub id: i64,
#[serde(deserialize_with = "super::from_i64")]
pub mimimum_age: i64,
#[serde(deserialize_with = "super::from_i64")]
pub retention: i64,
#[serde(deserialize_with = "super::from_i64")]
pub maximum_size: i64,
#[serde(deserialize_with = "super::from_i64")]
pub rss_sync_interval: i64,
}
#[derive(Serialize, Deserialize, Default, Debug, Hash, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub struct Language {
pub name: String,
@@ -334,6 +349,7 @@ pub enum SonarrSerdeable {
Episode(Episode),
Episodes(Vec<Episode>),
HostConfig(HostConfig),
IndexerSettings(IndexerSettings),
Indexers(Vec<Indexer>),
QualityProfiles(Vec<QualityProfile>),
SecurityConfig(SecurityConfig),
@@ -362,6 +378,7 @@ serde_enum_from!(
Episode(Episode),
Episodes(Vec<Episode>),
HostConfig(HostConfig),
IndexerSettings(IndexerSettings),
Indexers(Vec<Indexer>),
QualityProfiles(Vec<QualityProfile>),
SecurityConfig(SecurityConfig),
+58 -2
View File
@@ -4,9 +4,11 @@ mod tests {
use serde_json::json;
use crate::models::{
servarr_models::{HostConfig, Indexer, SecurityConfig},
sonarr_models::{
BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse, Episode, Log,
LogResponse, QualityProfile, Series, SeriesStatus, SeriesType, SonarrSerdeable, SystemStatus,
BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse, Episode,
IndexerSettings, Log, LogResponse, QualityProfile, Series, SeriesStatus, SeriesType,
SonarrSerdeable, SystemStatus,
},
Serdeable,
};
@@ -101,6 +103,45 @@ mod tests {
assert_eq!(sonarr_serdeable, SonarrSerdeable::Episodes(episodes));
}
#[test]
fn test_sonarr_serdeable_from_host_config() {
let host_config = HostConfig {
port: 1234,
..HostConfig::default()
};
let sonarr_serdeable: SonarrSerdeable = host_config.clone().into();
assert_eq!(sonarr_serdeable, SonarrSerdeable::HostConfig(host_config));
}
#[test]
fn test_sonarr_serdeable_from_indexers() {
let indexers = vec![Indexer {
id: 1,
..Indexer::default()
}];
let sonarr_serdeable: SonarrSerdeable = indexers.clone().into();
assert_eq!(sonarr_serdeable, SonarrSerdeable::Indexers(indexers));
}
#[test]
fn test_sonarr_serdeable_from_indexer_settings() {
let indexer_settings = IndexerSettings {
id: 1,
..IndexerSettings::default()
};
let sonarr_serdeable: SonarrSerdeable = indexer_settings.clone().into();
assert_eq!(
sonarr_serdeable,
SonarrSerdeable::IndexerSettings(indexer_settings)
);
}
#[test]
fn test_sonarr_serdeable_from_series() {
let series = vec![Series {
@@ -189,4 +230,19 @@ mod tests {
SonarrSerdeable::QualityProfiles(quality_profiles)
);
}
#[test]
fn test_sonarr_serdeable_from_security_config() {
let security_config = SecurityConfig {
username: Some("Test".to_owned()),
..SecurityConfig::default()
};
let sonarr_serdeable: SonarrSerdeable = security_config.clone().into();
assert_eq!(
sonarr_serdeable,
SonarrSerdeable::SecurityConfig(security_config)
);
}
}