refactor: move shared servarr types into servarr_models
SystemStatus was declared three times, byte for byte identically, in radarr_models, sonarr_models, and lidarr_models. MetadataProfile and the Lidarr release download body were each declared in a single servarr module despite having nothing servarr specific about them: MetadataProfile is an id and name pair structurally identical to QualityProfile, which already lives in servarr_models, and a download body of a guid plus an indexer id is the generic form of that request. Move all three into servarr_models, preserving that file's alphabetical ordering, and drop the prefix from LidarrReleaseDownloadBody now that it is no longer owned by one servarr. RadarrReleaseDownloadBody and SonarrReleaseDownloadBody deliberately stay where they are. Radarr's carries a movie id and Sonarr's carries optional series, episode, and season fields, so the three types are not interchangeable and only the Lidarr shape is the common one. Behavior is unchanged. Every remaining edit is an import path update or the rename at a call site.
This commit is contained in:
24 files changed
+101
-107
No files matched your search
@@ -1,8 +1,8 @@
|
||||
use super::{
|
||||
HorizontallyScrollableText, Serdeable,
|
||||
servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, IndexerTestResult, QualityProfile, QualityWrapper, RootFolder,
|
||||
SecurityConfig, Tag,
|
||||
DiskSpace, HostConfig, Indexer, IndexerTestResult, MetadataProfile, QualityProfile,
|
||||
QualityWrapper, RootFolder, SecurityConfig, SystemStatus, Tag,
|
||||
},
|
||||
};
|
||||
use crate::models::servarr_models::{IndexerSettings, LogResponse, QueueEvent, Update};
|
||||
@@ -97,22 +97,6 @@ pub struct ArtistStatistics {
|
||||
|
||||
impl Eq for ArtistStatistics {}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct MetadataProfile {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<(&i64, &String)> for MetadataProfile {
|
||||
fn from(value: (&i64, &String)) -> Self {
|
||||
MetadataProfile {
|
||||
id: *value.0,
|
||||
name: value.1.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Serialize,
|
||||
Deserialize,
|
||||
@@ -230,13 +214,6 @@ pub struct DownloadsResponse {
|
||||
pub records: Vec<DownloadRecord>,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SystemStatus {
|
||||
pub version: String,
|
||||
pub start_time: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Derivative, Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddArtistSearchResult {
|
||||
@@ -492,13 +469,6 @@ pub struct LidarrRelease {
|
||||
pub quality: QualityWrapper,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LidarrReleaseDownloadBody {
|
||||
pub guid: String,
|
||||
pub indexer_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BlocklistItem {
|
||||
|
||||
@@ -7,12 +7,13 @@ mod tests {
|
||||
use crate::models::lidarr_models::{
|
||||
AddArtistSearchResult, Album, AudioTags, BlocklistItem, BlocklistResponse, DownloadRecord,
|
||||
DownloadStatus, DownloadsResponse, LidarrHistoryEventType, LidarrHistoryItem,
|
||||
LidarrHistoryWrapper, LidarrRelease, LidarrTask, MediaInfo, Member, MetadataProfile,
|
||||
MonitorType, NewItemMonitorType, SystemStatus, Track, TrackFile,
|
||||
LidarrHistoryWrapper, LidarrRelease, LidarrTask, MediaInfo, Member, MonitorType,
|
||||
NewItemMonitorType, Track, TrackFile,
|
||||
};
|
||||
use crate::models::servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, IndexerSettings, IndexerTestResult, Log, LogResponse,
|
||||
QualityProfile, QueueEvent, RootFolder, SecurityConfig, Tag, Update,
|
||||
MetadataProfile, QualityProfile, QueueEvent, RootFolder, SecurityConfig, SystemStatus, Tag,
|
||||
Update,
|
||||
};
|
||||
use crate::models::{
|
||||
Serdeable,
|
||||
|
||||
@@ -13,7 +13,7 @@ use strum_macros::{Display, EnumIter};
|
||||
use super::Serdeable;
|
||||
use super::servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper,
|
||||
QueueEvent, RootFolder, SecurityConfig, Tag, Update,
|
||||
QueueEvent, RootFolder, SecurityConfig, SystemStatus, Tag, Update,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -401,13 +401,6 @@ pub struct RadarrReleaseDownloadBody {
|
||||
pub movie_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SystemStatus {
|
||||
pub version: String,
|
||||
pub start_time: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RadarrHistoryWrapper {
|
||||
|
||||
@@ -12,9 +12,11 @@ mod tests {
|
||||
AddMovieSearchResult, BlocklistItem, BlocklistResponse, Collection, Credit, DiskSpace,
|
||||
DownloadRecord, DownloadsResponse, Indexer, IndexerSettings, IndexerTestResult,
|
||||
MinimumAvailability, Movie, MovieHistoryItem, MovieMonitor, QualityProfile, RadarrRelease,
|
||||
RadarrSerdeable, RadarrTask, RadarrTaskName, SystemStatus, Tag, Update,
|
||||
RadarrSerdeable, RadarrTask, RadarrTaskName, Tag, Update,
|
||||
},
|
||||
servarr_models::{
|
||||
HostConfig, Log, LogResponse, QueueEvent, RootFolder, SecurityConfig, SystemStatus,
|
||||
},
|
||||
servarr_models::{HostConfig, Log, LogResponse, QueueEvent, RootFolder, SecurityConfig},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -238,6 +238,22 @@ pub struct LogResponse {
|
||||
pub records: Vec<Log>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct MetadataProfile {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<(&i64, &String)> for MetadataProfile {
|
||||
fn from(value: (&i64, &String)) -> Self {
|
||||
MetadataProfile {
|
||||
id: *value.0,
|
||||
name: value.1.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
|
||||
pub struct Quality {
|
||||
pub name: String,
|
||||
@@ -277,6 +293,13 @@ pub struct QueueEvent {
|
||||
pub duration: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ReleaseDownloadBody {
|
||||
pub guid: String,
|
||||
pub indexer_id: i64,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RootFolder {
|
||||
@@ -303,6 +326,13 @@ pub struct SecurityConfig {
|
||||
pub certificate_validation: CertificateValidation,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SystemStatus {
|
||||
pub version: String,
|
||||
pub start_time: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub struct Tag {
|
||||
#[serde(deserialize_with = "super::from_i64")]
|
||||
|
||||
@@ -17,7 +17,7 @@ use super::{
|
||||
HorizontallyScrollableText, Serdeable,
|
||||
servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper,
|
||||
QueueEvent, RootFolder, SecurityConfig, Tag, Update,
|
||||
QueueEvent, RootFolder, SecurityConfig, SystemStatus, Tag, Update,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -626,10 +626,3 @@ serde_enum_from!(
|
||||
Value(Value),
|
||||
}
|
||||
);
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SystemStatus {
|
||||
pub version: String,
|
||||
pub start_time: DateTime<Utc>,
|
||||
}
|
||||
@@ -7,13 +7,14 @@ mod tests {
|
||||
Serdeable,
|
||||
servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, IndexerSettings, IndexerTestResult, Language, Log,
|
||||
LogResponse, QualityProfile, QueueEvent, RootFolder, SecurityConfig, Tag, Update,
|
||||
LogResponse, QualityProfile, QueueEvent, RootFolder, SecurityConfig, SystemStatus, Tag,
|
||||
Update,
|
||||
},
|
||||
sonarr_models::{
|
||||
AddSeriesSearchResult, BlocklistItem, BlocklistResponse, DownloadRecord, DownloadStatus,
|
||||
DownloadsResponse, Episode, EpisodeFile, Series, SeriesMonitor, SeriesStatus, SeriesType,
|
||||
SonarrHistoryEventType, SonarrHistoryItem, SonarrRelease, SonarrSerdeable, SonarrTask,
|
||||
SonarrTaskName, SystemStatus,
|
||||
SonarrTaskName,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user