feat(network): Added network support for fetching host and security configs from Sonarr
This commit is contained in:
@@ -9,16 +9,15 @@ mod tests {
|
|||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::indexers::IndexersHandler;
|
use crate::handlers::radarr_handlers::indexers::IndexersHandler;
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::models::radarr_models::Indexer;
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, EDIT_INDEXER_BLOCKS, INDEXERS_BLOCKS, INDEXER_SETTINGS_BLOCKS,
|
ActiveRadarrBlock, EDIT_INDEXER_BLOCKS, INDEXERS_BLOCKS, INDEXER_SETTINGS_BLOCKS,
|
||||||
};
|
};
|
||||||
|
use crate::models::servarr_models::Indexer;
|
||||||
use crate::test_handler_delegation;
|
use crate::test_handler_delegation;
|
||||||
|
|
||||||
mod test_handle_scroll_up_and_down {
|
mod test_handle_scroll_up_and_down {
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::models::radarr_models::Indexer;
|
|
||||||
use crate::{simple_stateful_iterable_vec, test_iterable_scroll};
|
use crate::{simple_stateful_iterable_vec, test_iterable_scroll};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -65,7 +64,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_home_end {
|
mod test_handle_home_end {
|
||||||
use crate::models::radarr_models::Indexer;
|
|
||||||
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
use crate::{extended_stateful_iterable_vec, test_iterable_home_and_end};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -239,11 +237,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use crate::models::radarr_models::{Indexer, IndexerField};
|
|
||||||
use crate::models::servarr_data::radarr::modals::EditIndexerModal;
|
use crate::models::servarr_data::radarr::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
RadarrData, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
RadarrData, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
|
use crate::models::servarr_models::{Indexer, IndexerField};
|
||||||
use bimap::BiMap;
|
use bimap::BiMap;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use serde_json::{Number, Value};
|
use serde_json::{Number, Value};
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ use crate::models::servarr_data::radarr::radarr_data::{
|
|||||||
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
INDEXERS_BLOCKS, INDEXER_SETTINGS_SELECTION_BLOCKS,
|
INDEXERS_BLOCKS, INDEXER_SETTINGS_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::{BlockSelectionState, Scrollable};
|
use crate::models::BlockSelectionState;
|
||||||
|
use crate::models::Scrollable;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
|
||||||
mod edit_indexer_handler;
|
mod edit_indexer_handler;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
|||||||
use sonarr_models::SonarrSerdeable;
|
use sonarr_models::SonarrSerdeable;
|
||||||
pub mod radarr_models;
|
pub mod radarr_models;
|
||||||
pub mod servarr_data;
|
pub mod servarr_data;
|
||||||
|
pub mod servarr_models;
|
||||||
pub mod sonarr_models;
|
pub mod sonarr_models;
|
||||||
pub mod stateful_list;
|
pub mod stateful_list;
|
||||||
pub mod stateful_table;
|
pub mod stateful_table;
|
||||||
|
|||||||
+1
-114
@@ -9,6 +9,7 @@ use strum_macros::EnumIter;
|
|||||||
|
|
||||||
use crate::{models::HorizontallyScrollableText, serde_enum_from};
|
use crate::{models::HorizontallyScrollableText, serde_enum_from};
|
||||||
|
|
||||||
|
use super::servarr_models::{HostConfig, Indexer, SecurityConfig};
|
||||||
use super::Serdeable;
|
use super::Serdeable;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -57,44 +58,6 @@ pub struct AddRootFolderBody {
|
|||||||
pub path: String,
|
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)]
|
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct BlocklistResponse {
|
pub struct BlocklistResponse {
|
||||||
pub records: Vec<BlocklistItem>,
|
pub records: Vec<BlocklistItem>,
|
||||||
@@ -123,26 +86,6 @@ pub struct BlocklistItemMovie {
|
|||||||
pub title: HorizontallyScrollableText,
|
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)]
|
#[derive(Serialize, Deserialize, Derivative, Default, Clone, Debug, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Collection {
|
pub struct Collection {
|
||||||
@@ -281,51 +224,6 @@ pub struct EditMovieParams {
|
|||||||
pub clear_tags: bool,
|
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,
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub ssl_port: i64,
|
|
||||||
pub ssl_cert_path: Option<String>,
|
|
||||||
pub ssl_cert_password: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct Indexer {
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub id: i64,
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub implementation: Option<String>,
|
|
||||||
pub implementation_name: Option<String>,
|
|
||||||
pub config_contract: Option<String>,
|
|
||||||
pub supports_rss: bool,
|
|
||||||
pub supports_search: bool,
|
|
||||||
pub fields: Option<Vec<IndexerField>>,
|
|
||||||
pub enable_rss: bool,
|
|
||||||
pub enable_automatic_search: bool,
|
|
||||||
pub enable_interactive_search: bool,
|
|
||||||
pub protocol: String,
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub priority: i64,
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub download_client_id: i64,
|
|
||||||
pub tags: Vec<Number>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
|
||||||
pub struct IndexerField {
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub value: Option<Value>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct IndexerSettings {
|
pub struct IndexerSettings {
|
||||||
@@ -634,17 +532,6 @@ pub struct RootFolder {
|
|||||||
pub unmapped_folders: Option<Vec<UnmappedFolder>>,
|
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)]
|
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct SystemStatus {
|
pub struct SystemStatus {
|
||||||
|
|||||||
@@ -5,41 +5,14 @@ mod tests {
|
|||||||
|
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
radarr_models::{
|
radarr_models::{
|
||||||
AddMovieSearchResult, AuthenticationMethod, AuthenticationRequired, BlocklistItem,
|
AddMovieSearchResult, BlocklistItem, BlocklistResponse, Collection, Credit, DiskSpace,
|
||||||
BlocklistResponse, CertificateValidation, Collection, Credit, DiskSpace, DownloadRecord,
|
DownloadRecord, DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult, Log,
|
||||||
DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult, Log, LogResponse,
|
LogResponse, MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile,
|
||||||
MinimumAvailability, Monitor, Movie, MovieHistoryItem, QualityProfile, QueueEvent,
|
QueueEvent, RadarrSerdeable, Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
|
||||||
RadarrSerdeable, Release, RootFolder, SystemStatus, Tag, Task, TaskName, Update,
|
|
||||||
},
|
},
|
||||||
Serdeable,
|
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]
|
#[test]
|
||||||
fn test_task_name_display() {
|
fn test_task_name_display() {
|
||||||
assert_str_eq!(
|
assert_str_eq!(
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
Collection, Credit, Indexer, MinimumAvailability, Monitor, Movie, MovieHistoryItem, Release,
|
Collection, Credit, MinimumAvailability, Monitor, Movie, MovieHistoryItem, Release, RootFolder,
|
||||||
RootFolder,
|
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::RadarrData;
|
use crate::models::servarr_data::radarr::radarr_data::RadarrData;
|
||||||
|
use crate::models::servarr_models::Indexer;
|
||||||
use crate::models::stateful_list::StatefulList;
|
use crate::models::stateful_list::StatefulList;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
use crate::models::{HorizontallyScrollableText, ScrollableText};
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{Collection, MinimumAvailability, Monitor, Movie, RootFolder};
|
||||||
Collection, Indexer, IndexerField, MinimumAvailability, Monitor, Movie, RootFolder,
|
|
||||||
};
|
|
||||||
use crate::models::servarr_data::radarr::modals::{
|
use crate::models::servarr_data::radarr::modals::{
|
||||||
AddMovieModal, EditCollectionModal, EditIndexerModal, EditMovieModal,
|
AddMovieModal, EditCollectionModal, EditIndexerModal, EditMovieModal,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::RadarrData;
|
use crate::models::servarr_data::radarr::radarr_data::RadarrData;
|
||||||
|
use crate::models::servarr_models::{Indexer, IndexerField};
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use bimap::BiMap;
|
use bimap::BiMap;
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||||
@@ -17,6 +16,8 @@ mod test {
|
|||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_edit_indexer_modal_from_radarr_data(#[values(true, false)] seed_ratio_present: bool) {
|
fn test_edit_indexer_modal_from_radarr_data(#[values(true, false)] seed_ratio_present: bool) {
|
||||||
|
use crate::models::servarr_models::{Indexer, IndexerField};
|
||||||
|
|
||||||
let mut radarr_data = RadarrData {
|
let mut radarr_data = RadarrData {
|
||||||
tags_map: BiMap::from_iter([(1, "usenet".to_owned()), (2, "test".to_owned())]),
|
tags_map: BiMap::from_iter([(1, "usenet".to_owned()), (2, "test".to_owned())]),
|
||||||
..RadarrData::default()
|
..RadarrData::default()
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ use crate::app::radarr::radarr_context_clues::{
|
|||||||
};
|
};
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
AddMovieSearchResult, BlocklistItem, Collection, CollectionMovie, DiskSpace, DownloadRecord,
|
AddMovieSearchResult, BlocklistItem, Collection, CollectionMovie, DiskSpace, DownloadRecord,
|
||||||
Indexer, IndexerSettings, Movie, QueueEvent, RootFolder, Task,
|
IndexerSettings, Movie, QueueEvent, RootFolder, Task,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::modals::{
|
use crate::models::servarr_data::radarr::modals::{
|
||||||
AddMovieModal, EditCollectionModal, EditIndexerModal, EditMovieModal, IndexerTestResultModalItem,
|
AddMovieModal, EditCollectionModal, EditIndexerModal, EditMovieModal, IndexerTestResultModalItem,
|
||||||
MovieDetailsModal,
|
MovieDetailsModal,
|
||||||
};
|
};
|
||||||
|
use crate::models::servarr_models::Indexer;
|
||||||
use crate::models::stateful_list::StatefulList;
|
use crate::models::stateful_list::StatefulList;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ use chrono::{DateTime, Utc};
|
|||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
sonarr_models::{BlocklistItem, DownloadRecord, Episode, Indexer, Series},
|
servarr_models::Indexer,
|
||||||
|
sonarr_models::{BlocklistItem, DownloadRecord, Episode, Series},
|
||||||
stateful_list::StatefulList,
|
stateful_list::StatefulList,
|
||||||
stateful_table::StatefulTable,
|
stateful_table::StatefulTable,
|
||||||
stateful_tree::StatefulTree,
|
stateful_tree::StatefulTree,
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
use std::fmt::{Display, Formatter, Result};
|
||||||
|
|
||||||
|
use clap::ValueEnum;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::{Number, Value};
|
||||||
|
|
||||||
|
use super::HorizontallyScrollableText;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[path = "servarr_models_tests.rs"]
|
||||||
|
mod servarr_models_tests;
|
||||||
|
|
||||||
|
#[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<'_>) -> 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<'_>) -> Result {
|
||||||
|
let authentication_required = match self {
|
||||||
|
AuthenticationRequired::Enabled => "enabled",
|
||||||
|
AuthenticationRequired::DisabledForLocalAddresses => "disabledForLocalAddresses",
|
||||||
|
};
|
||||||
|
write!(f, "{authentication_required}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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<'_>) -> Result {
|
||||||
|
let certificate_validation = match self {
|
||||||
|
CertificateValidation::Enabled => "enabled",
|
||||||
|
CertificateValidation::DisabledForLocalAddresses => "disabledForLocalAddresses",
|
||||||
|
CertificateValidation::Disabled => "disabled",
|
||||||
|
};
|
||||||
|
write!(f, "{certificate_validation}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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,
|
||||||
|
#[serde(deserialize_with = "super::from_i64")]
|
||||||
|
pub ssl_port: i64,
|
||||||
|
pub ssl_cert_path: Option<String>,
|
||||||
|
pub ssl_cert_password: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Indexer {
|
||||||
|
#[serde(deserialize_with = "super::from_i64")]
|
||||||
|
pub id: i64,
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub implementation: Option<String>,
|
||||||
|
pub implementation_name: Option<String>,
|
||||||
|
pub config_contract: Option<String>,
|
||||||
|
pub supports_rss: bool,
|
||||||
|
pub supports_search: bool,
|
||||||
|
pub fields: Option<Vec<IndexerField>>,
|
||||||
|
pub enable_rss: bool,
|
||||||
|
pub enable_automatic_search: bool,
|
||||||
|
pub enable_interactive_search: bool,
|
||||||
|
pub protocol: String,
|
||||||
|
#[serde(deserialize_with = "super::from_i64")]
|
||||||
|
pub priority: i64,
|
||||||
|
#[serde(deserialize_with = "super::from_i64")]
|
||||||
|
pub download_client_id: i64,
|
||||||
|
pub tags: Vec<Number>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
||||||
|
pub struct IndexerField {
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub value: Option<Value>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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,
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use pretty_assertions::assert_str_eq;
|
||||||
|
|
||||||
|
use crate::models::servarr_models::{
|
||||||
|
AuthenticationMethod, AuthenticationRequired, CertificateValidation,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,10 @@ use strum::EnumIter;
|
|||||||
|
|
||||||
use crate::serde_enum_from;
|
use crate::serde_enum_from;
|
||||||
|
|
||||||
use super::{HorizontallyScrollableText, Serdeable};
|
use super::{
|
||||||
|
servarr_models::{HostConfig, Indexer, SecurityConfig},
|
||||||
|
HorizontallyScrollableText, Serdeable,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "sonarr_models_tests.rs"]
|
#[path = "sonarr_models_tests.rs"]
|
||||||
@@ -103,35 +106,6 @@ pub struct EpisodeFile {
|
|||||||
pub media_info: Option<MediaInfo>,
|
pub media_info: Option<MediaInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct Indexer {
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub id: i64,
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub implementation: Option<String>,
|
|
||||||
pub implementation_name: Option<String>,
|
|
||||||
pub config_contract: Option<String>,
|
|
||||||
pub supports_rss: bool,
|
|
||||||
pub supports_search: bool,
|
|
||||||
pub fields: Option<Vec<IndexerField>>,
|
|
||||||
pub enable_rss: bool,
|
|
||||||
pub enable_automatic_search: bool,
|
|
||||||
pub enable_interactive_search: bool,
|
|
||||||
pub protocol: String,
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub priority: i64,
|
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
|
||||||
pub download_client_id: i64,
|
|
||||||
pub tags: Vec<Number>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
|
|
||||||
pub struct IndexerField {
|
|
||||||
pub name: Option<String>,
|
|
||||||
pub value: Option<Value>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default, Debug, Hash, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
#[derive(Serialize, Deserialize, Default, Debug, Hash, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||||
pub struct Language {
|
pub struct Language {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@@ -359,8 +333,10 @@ pub enum SonarrSerdeable {
|
|||||||
DownloadsResponse(DownloadsResponse),
|
DownloadsResponse(DownloadsResponse),
|
||||||
Episode(Episode),
|
Episode(Episode),
|
||||||
Episodes(Vec<Episode>),
|
Episodes(Vec<Episode>),
|
||||||
|
HostConfig(HostConfig),
|
||||||
Indexers(Vec<Indexer>),
|
Indexers(Vec<Indexer>),
|
||||||
QualityProfiles(Vec<QualityProfile>),
|
QualityProfiles(Vec<QualityProfile>),
|
||||||
|
SecurityConfig(SecurityConfig),
|
||||||
SeriesVec(Vec<Series>),
|
SeriesVec(Vec<Series>),
|
||||||
SystemStatus(SystemStatus),
|
SystemStatus(SystemStatus),
|
||||||
BlocklistResponse(BlocklistResponse),
|
BlocklistResponse(BlocklistResponse),
|
||||||
@@ -385,8 +361,10 @@ serde_enum_from!(
|
|||||||
DownloadsResponse(DownloadsResponse),
|
DownloadsResponse(DownloadsResponse),
|
||||||
Episode(Episode),
|
Episode(Episode),
|
||||||
Episodes(Vec<Episode>),
|
Episodes(Vec<Episode>),
|
||||||
|
HostConfig(HostConfig),
|
||||||
Indexers(Vec<Indexer>),
|
Indexers(Vec<Indexer>),
|
||||||
QualityProfiles(Vec<QualityProfile>),
|
QualityProfiles(Vec<QualityProfile>),
|
||||||
|
SecurityConfig(SecurityConfig),
|
||||||
SeriesVec(Vec<Series>),
|
SeriesVec(Vec<Series>),
|
||||||
SystemStatus(SystemStatus),
|
SystemStatus(SystemStatus),
|
||||||
BlocklistResponse(BlocklistResponse),
|
BlocklistResponse(BlocklistResponse),
|
||||||
|
|||||||
@@ -9,16 +9,17 @@ use urlencoding::encode;
|
|||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
AddMovieBody, AddMovieSearchResult, AddOptions, AddRootFolderBody, BlocklistResponse, Collection,
|
AddMovieBody, AddMovieSearchResult, AddOptions, AddRootFolderBody, BlocklistResponse, Collection,
|
||||||
CollectionMovie, CommandBody, Credit, CreditType, DeleteMovieParams, DiskSpace, DownloadRecord,
|
CollectionMovie, CommandBody, Credit, CreditType, DeleteMovieParams, DiskSpace, DownloadRecord,
|
||||||
DownloadsResponse, EditCollectionParams, EditIndexerParams, EditMovieParams, HostConfig, Indexer,
|
DownloadsResponse, EditCollectionParams, EditIndexerParams, EditMovieParams, IndexerSettings,
|
||||||
IndexerSettings, IndexerTestResult, LogResponse, Movie, MovieCommandBody, MovieHistoryItem,
|
IndexerTestResult, LogResponse, Movie, MovieCommandBody, MovieHistoryItem, QualityProfile,
|
||||||
QualityProfile, QueueEvent, RadarrSerdeable, Release, ReleaseDownloadBody, RootFolder,
|
QueueEvent, RadarrSerdeable, Release, ReleaseDownloadBody, RootFolder, SystemStatus, Tag, Task,
|
||||||
SecurityConfig, SystemStatus, Tag, Task, TaskName, Update,
|
TaskName, Update,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::modals::{
|
use crate::models::servarr_data::radarr::modals::{
|
||||||
AddMovieModal, EditCollectionModal, EditIndexerModal, EditMovieModal, IndexerTestResultModalItem,
|
AddMovieModal, EditCollectionModal, EditIndexerModal, EditMovieModal, IndexerTestResultModalItem,
|
||||||
MovieDetailsModal,
|
MovieDetailsModal,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
|
use crate::models::servarr_models::{HostConfig, Indexer, SecurityConfig};
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::models::{HorizontallyScrollableText, Route, Scrollable, ScrollableText};
|
use crate::models::{HorizontallyScrollableText, Route, Scrollable, ScrollableText};
|
||||||
use crate::network::{Network, NetworkEvent, RequestMethod};
|
use crate::network::{Network, NetworkEvent, RequestMethod};
|
||||||
@@ -192,7 +193,10 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
RadarrEvent::GetBlocklist => self.get_radarr_blocklist().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetBlocklist => self.get_radarr_blocklist().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetCollections => self.get_collections().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetCollections => self.get_collections().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetDownloads => self.get_radarr_downloads().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetDownloads => self.get_radarr_downloads().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetHostConfig => self.get_host_config().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetHostConfig => self
|
||||||
|
.get_radarr_host_config()
|
||||||
|
.await
|
||||||
|
.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetIndexers => self.get_radarr_indexers().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetIndexers => self.get_radarr_indexers().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetLogs(events) => self
|
RadarrEvent::GetLogs(events) => self
|
||||||
.get_radarr_logs(events)
|
.get_radarr_logs(events)
|
||||||
@@ -220,7 +224,10 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
self.get_releases(movie_id).await.map(RadarrSerdeable::from)
|
self.get_releases(movie_id).await.map(RadarrSerdeable::from)
|
||||||
}
|
}
|
||||||
RadarrEvent::GetRootFolders => self.get_root_folders().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetRootFolders => self.get_root_folders().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetSecurityConfig => self.get_security_config().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetSecurityConfig => self
|
||||||
|
.get_radarr_security_config()
|
||||||
|
.await
|
||||||
|
.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetStatus => self.get_radarr_status().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetStatus => self.get_radarr_status().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetTags => self.get_tags().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetTags => self.get_tags().await.map(RadarrSerdeable::from),
|
||||||
RadarrEvent::GetTasks => self.get_tasks().await.map(RadarrSerdeable::from),
|
RadarrEvent::GetTasks => self.get_tasks().await.map(RadarrSerdeable::from),
|
||||||
@@ -1382,7 +1389,7 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_host_config(&mut self) -> Result<HostConfig> {
|
async fn get_radarr_host_config(&mut self) -> Result<HostConfig> {
|
||||||
info!("Fetching Radarr host config");
|
info!("Fetching Radarr host config");
|
||||||
let event = RadarrEvent::GetHostConfig;
|
let event = RadarrEvent::GetHostConfig;
|
||||||
|
|
||||||
@@ -1788,7 +1795,7 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_security_config(&mut self) -> Result<SecurityConfig> {
|
async fn get_radarr_security_config(&mut self) -> Result<SecurityConfig> {
|
||||||
info!("Fetching Radarr security config");
|
info!("Fetching Radarr security config");
|
||||||
let event = RadarrEvent::GetSecurityConfig;
|
let event = RadarrEvent::GetSecurityConfig;
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ mod test {
|
|||||||
|
|
||||||
use crate::app::ServarrConfig;
|
use crate::app::ServarrConfig;
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
BlocklistItem, BlocklistItemMovie, CollectionMovie, IndexerField, Language, MediaInfo,
|
BlocklistItem, BlocklistItemMovie, CollectionMovie, Language, MediaInfo, MinimumAvailability,
|
||||||
MinimumAvailability, Monitor, MovieCollection, MovieFile, Quality, QualityWrapper, Rating,
|
Monitor, MovieCollection, MovieFile, Quality, QualityWrapper, Rating, RatingsList,
|
||||||
RatingsList,
|
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
|
use crate::models::servarr_models::{HostConfig, IndexerField};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::models::HorizontallyScrollableText;
|
use crate::models::HorizontallyScrollableText;
|
||||||
use crate::network::network_tests::test_utils::mock_servarr_api;
|
use crate::network::network_tests::test_utils::mock_servarr_api;
|
||||||
@@ -2225,7 +2225,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_get_host_config_event() {
|
async fn test_handle_get_radarr_host_config_event() {
|
||||||
let host_config_response = json!({
|
let host_config_response = json!({
|
||||||
"bindAddress": "*",
|
"bindAddress": "*",
|
||||||
"port": 7878,
|
"port": 7878,
|
||||||
@@ -2905,7 +2905,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_get_security_config_event() {
|
async fn test_handle_get_radarr_security_config_event() {
|
||||||
let security_config_response = json!({
|
let security_config_response = json!({
|
||||||
"authenticationMethod": "forms",
|
"authenticationMethod": "forms",
|
||||||
"authenticationRequired": "disabledForLocalAddresses",
|
"authenticationRequired": "disabledForLocalAddresses",
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ use serde_json::{json, Value};
|
|||||||
use crate::{
|
use crate::{
|
||||||
models::{
|
models::{
|
||||||
servarr_data::sonarr::{modals::EpisodeDetailsModal, sonarr_data::ActiveSonarrBlock},
|
servarr_data::sonarr::{modals::EpisodeDetailsModal, sonarr_data::ActiveSonarrBlock},
|
||||||
|
servarr_models::{HostConfig, Indexer, SecurityConfig},
|
||||||
sonarr_models::{
|
sonarr_models::{
|
||||||
BlocklistResponse, DownloadRecord, DownloadsResponse, Episode, Indexer, LogResponse,
|
BlocklistResponse, DownloadRecord, DownloadsResponse, Episode, LogResponse, QualityProfile,
|
||||||
QualityProfile, Series, SonarrSerdeable, SystemStatus,
|
Series, SonarrSerdeable, SystemStatus,
|
||||||
},
|
},
|
||||||
HorizontallyScrollableText, Route, Scrollable, ScrollableText,
|
HorizontallyScrollableText, Route, Scrollable, ScrollableText,
|
||||||
},
|
},
|
||||||
@@ -30,11 +31,13 @@ pub enum SonarrEvent {
|
|||||||
DeleteBlocklistItem(Option<i64>),
|
DeleteBlocklistItem(Option<i64>),
|
||||||
GetBlocklist,
|
GetBlocklist,
|
||||||
GetDownloads,
|
GetDownloads,
|
||||||
|
GetHostConfig,
|
||||||
GetIndexers,
|
GetIndexers,
|
||||||
GetEpisodeDetails(Option<i64>),
|
GetEpisodeDetails(Option<i64>),
|
||||||
GetEpisodes(Option<i64>),
|
GetEpisodes(Option<i64>),
|
||||||
GetLogs(Option<u64>),
|
GetLogs(Option<u64>),
|
||||||
GetQualityProfiles,
|
GetQualityProfiles,
|
||||||
|
GetSecurityConfig,
|
||||||
GetStatus,
|
GetStatus,
|
||||||
HealthCheck,
|
HealthCheck,
|
||||||
ListSeries,
|
ListSeries,
|
||||||
@@ -48,6 +51,7 @@ impl NetworkResource for SonarrEvent {
|
|||||||
SonarrEvent::GetBlocklist => "/blocklist?page=1&pageSize=10000",
|
SonarrEvent::GetBlocklist => "/blocklist?page=1&pageSize=10000",
|
||||||
SonarrEvent::GetDownloads => "/queue",
|
SonarrEvent::GetDownloads => "/queue",
|
||||||
SonarrEvent::GetEpisodes(_) | SonarrEvent::GetEpisodeDetails(_) => "/episode",
|
SonarrEvent::GetEpisodes(_) | SonarrEvent::GetEpisodeDetails(_) => "/episode",
|
||||||
|
SonarrEvent::GetHostConfig | SonarrEvent::GetSecurityConfig => "/config/host",
|
||||||
SonarrEvent::GetIndexers => "/indexer",
|
SonarrEvent::GetIndexers => "/indexer",
|
||||||
SonarrEvent::GetLogs(_) => "/log",
|
SonarrEvent::GetLogs(_) => "/log",
|
||||||
SonarrEvent::GetQualityProfiles => "/qualityprofile",
|
SonarrEvent::GetQualityProfiles => "/qualityprofile",
|
||||||
@@ -89,6 +93,10 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
.await
|
.await
|
||||||
.map(SonarrSerdeable::from),
|
.map(SonarrSerdeable::from),
|
||||||
SonarrEvent::GetIndexers => self.get_sonarr_indexers().await.map(SonarrSerdeable::from),
|
SonarrEvent::GetIndexers => self.get_sonarr_indexers().await.map(SonarrSerdeable::from),
|
||||||
|
SonarrEvent::GetHostConfig => self
|
||||||
|
.get_sonarr_host_config()
|
||||||
|
.await
|
||||||
|
.map(SonarrSerdeable::from),
|
||||||
SonarrEvent::GetQualityProfiles => self
|
SonarrEvent::GetQualityProfiles => self
|
||||||
.get_sonarr_quality_profiles()
|
.get_sonarr_quality_profiles()
|
||||||
.await
|
.await
|
||||||
@@ -97,6 +105,10 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
.get_sonarr_logs(events)
|
.get_sonarr_logs(events)
|
||||||
.await
|
.await
|
||||||
.map(SonarrSerdeable::from),
|
.map(SonarrSerdeable::from),
|
||||||
|
SonarrEvent::GetSecurityConfig => self
|
||||||
|
.get_sonarr_security_config()
|
||||||
|
.await
|
||||||
|
.map(SonarrSerdeable::from),
|
||||||
SonarrEvent::GetStatus => self.get_sonarr_status().await.map(SonarrSerdeable::from),
|
SonarrEvent::GetStatus => self.get_sonarr_status().await.map(SonarrSerdeable::from),
|
||||||
SonarrEvent::HealthCheck => self
|
SonarrEvent::HealthCheck => self
|
||||||
.get_sonarr_healthcheck()
|
.get_sonarr_healthcheck()
|
||||||
@@ -393,6 +405,19 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_sonarr_host_config(&mut self) -> Result<HostConfig> {
|
||||||
|
info!("Fetching Sonarr host config");
|
||||||
|
let event = SonarrEvent::GetHostConfig;
|
||||||
|
|
||||||
|
let request_props = self
|
||||||
|
.request_props_from(event, RequestMethod::Get, None::<()>, None, None)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
self
|
||||||
|
.handle_request::<(), HostConfig>(request_props, |_, _| ())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_sonarr_indexers(&mut self) -> Result<Vec<Indexer>> {
|
async fn get_sonarr_indexers(&mut self) -> Result<Vec<Indexer>> {
|
||||||
info!("Fetching Sonarr indexers");
|
info!("Fetching Sonarr indexers");
|
||||||
let event = SonarrEvent::GetIndexers;
|
let event = SonarrEvent::GetIndexers;
|
||||||
@@ -473,6 +498,19 @@ impl<'a, 'b> Network<'a, 'b> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_sonarr_security_config(&mut self) -> Result<SecurityConfig> {
|
||||||
|
info!("Fetching Sonarr security config");
|
||||||
|
let event = SonarrEvent::GetSecurityConfig;
|
||||||
|
|
||||||
|
let request_props = self
|
||||||
|
.request_props_from(event, RequestMethod::Get, None::<()>, None, None)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
self
|
||||||
|
.handle_request::<(), SecurityConfig>(request_props, |_, _| ())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
async fn list_series(&mut self) -> Result<Vec<Series>> {
|
async fn list_series(&mut self) -> Result<Vec<Series>> {
|
||||||
info!("Fetching Sonarr library");
|
info!("Fetching Sonarr library");
|
||||||
let event = SonarrEvent::ListSeries;
|
let event = SonarrEvent::ListSeries;
|
||||||
|
|||||||
@@ -22,9 +22,10 @@ mod test {
|
|||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||||
|
use crate::models::servarr_models::{HostConfig, Indexer, IndexerField, SecurityConfig};
|
||||||
use crate::models::sonarr_models::{
|
use crate::models::sonarr_models::{
|
||||||
BlocklistItem, DownloadRecord, DownloadsResponse, Episode, EpisodeFile, Indexer, IndexerField,
|
BlocklistItem, DownloadRecord, DownloadsResponse, Episode, EpisodeFile, Language, LogResponse,
|
||||||
Language, LogResponse, MediaInfo, QualityProfile,
|
MediaInfo, QualityProfile,
|
||||||
};
|
};
|
||||||
use crate::models::sonarr_models::{BlocklistResponse, Quality};
|
use crate::models::sonarr_models::{BlocklistResponse, Quality};
|
||||||
use crate::models::sonarr_models::{QualityWrapper, SystemStatus};
|
use crate::models::sonarr_models::{QualityWrapper, SystemStatus};
|
||||||
@@ -137,6 +138,13 @@ mod test {
|
|||||||
assert_str_eq!(event.resource(), "/series");
|
assert_str_eq!(event.resource(), "/series");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
fn test_resource_host_config(
|
||||||
|
#[values(SonarrEvent::GetHostConfig, SonarrEvent::GetSecurityConfig)] event: SonarrEvent,
|
||||||
|
) {
|
||||||
|
assert_str_eq!(event.resource(), "/config/host");
|
||||||
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_resource_indexer(#[values(SonarrEvent::GetIndexers)] event: SonarrEvent) {
|
fn test_resource_indexer(#[values(SonarrEvent::GetIndexers)] event: SonarrEvent) {
|
||||||
assert_str_eq!(event.resource(), "/indexer");
|
assert_str_eq!(event.resource(), "/indexer");
|
||||||
@@ -651,6 +659,42 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_handle_get_sonarr_host_config_event() {
|
||||||
|
let host_config_response = json!({
|
||||||
|
"bindAddress": "*",
|
||||||
|
"port": 7878,
|
||||||
|
"urlBase": "some.test.site/sonarr",
|
||||||
|
"instanceName": "Sonarr",
|
||||||
|
"applicationUrl": "https://some.test.site:7878/sonarr",
|
||||||
|
"enableSsl": true,
|
||||||
|
"sslPort": 9898,
|
||||||
|
"sslCertPath": "/app/sonarr.pfx",
|
||||||
|
"sslCertPassword": "test"
|
||||||
|
});
|
||||||
|
let response: HostConfig = serde_json::from_value(host_config_response.clone()).unwrap();
|
||||||
|
let (async_server, app_arc, _server) = mock_servarr_api(
|
||||||
|
RequestMethod::Get,
|
||||||
|
None,
|
||||||
|
Some(host_config_response),
|
||||||
|
None,
|
||||||
|
SonarrEvent::GetHostConfig,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let mut network = Network::new(&app_arc, CancellationToken::new(), Client::new());
|
||||||
|
|
||||||
|
if let SonarrSerdeable::HostConfig(host_config) = network
|
||||||
|
.handle_sonarr_event(SonarrEvent::GetHostConfig)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
{
|
||||||
|
async_server.assert_async().await;
|
||||||
|
assert_eq!(host_config, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_get_sonarr_indexers_event() {
|
async fn test_handle_get_sonarr_indexers_event() {
|
||||||
let indexers_response_json = json!([{
|
let indexers_response_json = json!([{
|
||||||
@@ -1226,6 +1270,40 @@ mod test {
|
|||||||
assert!(app_arc.lock().await.data.sonarr_data.series.sort_asc);
|
assert!(app_arc.lock().await.data.sonarr_data.series.sort_asc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_handle_get_sonarr_security_config_event() {
|
||||||
|
let security_config_response = json!({
|
||||||
|
"authenticationMethod": "forms",
|
||||||
|
"authenticationRequired": "disabledForLocalAddresses",
|
||||||
|
"username": "test",
|
||||||
|
"password": "some password",
|
||||||
|
"apiKey": "someApiKey12345",
|
||||||
|
"certificateValidation": "disabledForLocalAddresses",
|
||||||
|
});
|
||||||
|
let response: SecurityConfig =
|
||||||
|
serde_json::from_value(security_config_response.clone()).unwrap();
|
||||||
|
let (async_server, app_arc, _server) = mock_servarr_api(
|
||||||
|
RequestMethod::Get,
|
||||||
|
None,
|
||||||
|
Some(security_config_response),
|
||||||
|
None,
|
||||||
|
SonarrEvent::GetSecurityConfig,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
let mut network = Network::new(&app_arc, CancellationToken::new(), Client::new());
|
||||||
|
|
||||||
|
if let SonarrSerdeable::SecurityConfig(security_config) = network
|
||||||
|
.handle_sonarr_event(SonarrEvent::GetSecurityConfig)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
{
|
||||||
|
async_server.assert_async().await;
|
||||||
|
assert_eq!(security_config, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_get_status_event() {
|
async fn test_handle_get_status_event() {
|
||||||
let (async_server, app_arc, _server) = mock_servarr_api(
|
let (async_server, app_arc, _server) = mock_servarr_api(
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use ratatui::widgets::{Cell, Row};
|
|||||||
use ratatui::Frame;
|
use ratatui::Frame;
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::models::radarr_models::Indexer;
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, INDEXERS_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, INDEXERS_BLOCKS};
|
||||||
|
use crate::models::servarr_models::Indexer;
|
||||||
use crate::models::Route;
|
use crate::models::Route;
|
||||||
use crate::ui::radarr_ui::indexers::edit_indexer_ui::EditIndexerUi;
|
use crate::ui::radarr_ui::indexers::edit_indexer_ui::EditIndexerUi;
|
||||||
use crate::ui::radarr_ui::indexers::indexer_settings_ui::IndexerSettingsUi;
|
use crate::ui::radarr_ui::indexers::indexer_settings_ui::IndexerSettingsUi;
|
||||||
|
|||||||
Reference in New Issue
Block a user