feat(network): Support for adding tags to Sonarr
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{models::HorizontallyScrollableText, serde_enum_from};
|
||||
|
||||
use super::servarr_models::{
|
||||
HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper, QueueEvent, Release,
|
||||
RootFolder, SecurityConfig,
|
||||
RootFolder, SecurityConfig, Tag,
|
||||
};
|
||||
use super::{EnumDisplayStyle, Serdeable};
|
||||
|
||||
@@ -442,13 +442,6 @@ pub struct SystemStatus {
|
||||
pub start_time: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct Tag {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub label: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Task {
|
||||
|
||||
@@ -34,6 +34,7 @@ pub struct SonarrData {
|
||||
pub series: StatefulTable<Series>,
|
||||
pub series_history: Option<StatefulTable<SonarrHistoryItem>>,
|
||||
pub start_time: DateTime<Utc>,
|
||||
pub tags_map: BiMap<i64, String>,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
@@ -55,6 +56,7 @@ impl Default for SonarrData {
|
||||
series: StatefulTable::default(),
|
||||
series_history: None,
|
||||
start_time: DateTime::default(),
|
||||
tags_map: BiMap::default(),
|
||||
version: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ mod tests {
|
||||
assert!(sonarr_data.series.is_empty());
|
||||
assert!(sonarr_data.series_history.is_none());
|
||||
assert_eq!(sonarr_data.start_time, <DateTime<Utc>>::default());
|
||||
assert!(sonarr_data.tags_map.is_empty());
|
||||
assert!(sonarr_data.version.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +228,13 @@ pub struct SecurityConfig {
|
||||
pub certificate_validation: CertificateValidation,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct Tag {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub label: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, Eq, PartialEq)]
|
||||
pub struct UnmappedFolder {
|
||||
pub name: String,
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::serde_enum_from;
|
||||
use super::{
|
||||
servarr_models::{
|
||||
HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper, QueueEvent,
|
||||
Release, RootFolder, SecurityConfig,
|
||||
Release, RootFolder, SecurityConfig, Tag,
|
||||
},
|
||||
EnumDisplayStyle, HorizontallyScrollableText, Serdeable,
|
||||
};
|
||||
@@ -409,6 +409,8 @@ pub enum SonarrSerdeable {
|
||||
SonarrHistoryItems(Vec<SonarrHistoryItem>),
|
||||
SonarrHistoryWrapper(SonarrHistoryWrapper),
|
||||
SystemStatus(SystemStatus),
|
||||
Tag(Tag),
|
||||
Tags(Vec<Tag>),
|
||||
BlocklistResponse(BlocklistResponse),
|
||||
LogResponse(LogResponse),
|
||||
}
|
||||
@@ -444,6 +446,8 @@ serde_enum_from!(
|
||||
SonarrHistoryItems(Vec<SonarrHistoryItem>),
|
||||
SonarrHistoryWrapper(SonarrHistoryWrapper),
|
||||
SystemStatus(SystemStatus),
|
||||
Tag(Tag),
|
||||
Tags(Vec<Tag>),
|
||||
BlocklistResponse(BlocklistResponse),
|
||||
LogResponse(LogResponse),
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ mod tests {
|
||||
use crate::models::{
|
||||
servarr_models::{
|
||||
HostConfig, Indexer, Log, LogResponse, QualityProfile, QueueEvent, Release, RootFolder,
|
||||
SecurityConfig,
|
||||
SecurityConfig, Tag,
|
||||
},
|
||||
sonarr_models::{
|
||||
BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse, Episode,
|
||||
@@ -370,4 +370,28 @@ mod tests {
|
||||
SonarrSerdeable::SecurityConfig(security_config)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_tag() {
|
||||
let tag = Tag {
|
||||
id: 1,
|
||||
..Tag::default()
|
||||
};
|
||||
|
||||
let sonarr_serdeable: SonarrSerdeable = tag.clone().into();
|
||||
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::Tag(tag));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_tags() {
|
||||
let tags = vec![Tag {
|
||||
id: 1,
|
||||
..Tag::default()
|
||||
}];
|
||||
|
||||
let sonarr_serdeable: SonarrSerdeable = tags.clone().into();
|
||||
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::Tags(tags));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user