1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
|
"""Request Models."""
# pylint: disable=invalid-name, too-many-instance-attributes
from __future__ import annotations
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from ..const import ALL
from .base import BaseModel
from .const import ProtocolType
from .request_common import (
_CommandBody,
_Common,
_Common3,
_CustomFilterAttr,
_Fields,
_FilesystemDirectory,
_FilesystemFolder,
_LocalizationStrings,
_LogRecord,
_MetadataFields,
_QualityInfo,
_QualityProfileItems,
_RecordCommon,
_ReleaseProfilePreferred,
_RootFolder,
_Tag,
_UpdateChanges,
)
class AddTypes(str, Enum):
"""Add types."""
AUTOMATIC = "automatic"
MANUAL = "manual"
class AllowFingerprintingType(str, Enum):
"""Allow fingerprinting type."""
ALL_FILES = "allFiles"
NEVER = "never"
NEW_FILES = "newFiles"
class AuthenticationType(str, Enum):
"""Authentication type."""
BASIC = "basic"
FORMS = "forms"
NONE = "none"
class Commands(str, Enum):
"""Commands."""
APPLICATION_UPDATE = "ApplicationUpdate"
BACKUP = "Backup"
CHECK_HEALTH = "CheckHealth"
CLEAN_RECYCLE_BIN = "CleanUpRecycleBin"
CLEAR_BLOCKLIST = "ClearBlocklist"
DELETE_LOGS = "DeleteLogFiles"
DELETE_UPDATE_LOGS = "DeleteUpdateLogFiles"
HOUSEKEEPING = "Housekeeping"
IMPORT_LIST_SYNC = "ImportListSync"
MANUAL_IMPORT = "ManualImport"
MESSAGING_CLEANUP = "MessagingCleanup"
REFRESH_MONITORED_DOWNLOADS = "RefreshMonitoredDownloads"
RENAME_FILES = "RenameFiles"
RSS_SYNC = "RssSync"
class CertificateValidationType(str, Enum):
"""Certificate validation type."""
DISABLED = "disabled"
DISABLED_LOCAL = "disabledForLocalAddresses"
ENABLED = "enabled"
class CommandPriorityType(str, Enum):
"""Command priority type."""
HIGH = "high"
LOW = "low"
NORMAL = "normal"
class CommandStatusType(str, Enum):
"""Command status type."""
QUEUED = "queued"
STARTED = "started"
COMPLETED = "completed"
FAILED = "failed"
ABORTED = "aborted"
CANCELLED = "cancelled"
ORPHANED = "orphaned"
class CommandTriggerType(str, Enum):
"""Command trigger type."""
MANUAL = "manual"
SCHEDULED = "scheduled"
UNSPECIFIED = "unspecified"
class HealthType(str, Enum):
"""Health type."""
ERROR = "error"
NOTICE = "notice"
OK = "ok"
WARNING = "warning"
class HostUpdateType(str, Enum):
"""Host update type."""
APT = "apt"
BUILT_IN = "builtIn"
DOCKER = "docker"
EXTERNAL = "external"
SCRIPT = "script"
class ImageSize(str, Enum):
"""Image size."""
LARGE = "large"
MEDIUM = "medium"
SMALL = "small"
class ImageType(str, Enum):
"""Image type."""
BANNER = "banner"
COVER = "cover"
DISC = "disc"
FANART = "fanart"
HEADSHOT = "headshot"
LOGO = "logo"
POSTER = "poster"
SCREENSHOT = "screenshot"
UNKNOWN = "unknown"
class LogSortKeys(str, Enum):
"""Log sort keys."""
ID = "id"
LEVEL = "level"
LOGGER = "logger"
MESSAGE = "message"
TIME = "time"
class MonitoringOptionsType(str, Enum):
"""Monitoring options type."""
ALL = ALL
EXISTING = "existing"
FIRST = "first"
FUTURE = "future"
LATEST = "latest"
MISSING = "missing"
NONE = "none"
UNKNOWN = "unknown"
class ProxyType(str, Enum):
"""Proxy type."""
HTTP = "http"
SOCKS4 = "socks4"
SOCKS5 = "socks5"
class RescanAfterRefreshType(str, Enum):
"""Rescan after refresh type."""
AFTER_MANUAL = "afterManual"
ALWAYS = "always"
NEVER = "never"
class SortDirection(str, Enum):
"""Sort direction type."""
ASCENDING = "ascending"
DEFAULT = "default"
DESCENDING = "descending"
class StatusType(str, Enum):
"""Status type."""
CONTINUING = "continuing"
ENDED = "ended"
@dataclass(init=False)
class Diskspace(BaseModel):
"""Diskspace attributes."""
freeSpace: int
label: str
path: str
totalSpace: int
@dataclass(init=False)
class Logs(_RecordCommon):
"""Log attributes."""
records: list[_LogRecord] = field(default_factory=list[_LogRecord])
def __post_init__(self):
"""Post init."""
self.records = [_LogRecord(record) for record in self.records]
@dataclass(init=False)
class LogFile(BaseModel):
"""Log file attributes."""
contentsUrl: str
downloadUrl: str
filename: str
id: int
lastWriteTime: datetime
@dataclass(init=False)
class Tag(_Tag):
"""Tag attributes."""
@dataclass(init=False)
class SystemBackup(_Common3):
"""System backup attributes."""
path: str
time: datetime
type: str
@dataclass(init=False)
class CustomFilter(BaseModel):
"""Custom filter attributes."""
id: int
filters: list[_CustomFilterAttr] | None = None
label: str
type: str
def __post_init__(self):
"""Post init."""
self.filters = [_CustomFilterAttr(filter) for filter in self.filters or []]
@dataclass(init=False)
class RootFolder(_RootFolder):
"""Root folder attributes."""
@dataclass(init=False)
class HostConfig(BaseModel):
"""Host config attributes."""
analyticsEnabled: bool
apiKey: str
authenticationMethod: str
backupFolder: str
backupInterval: int
backupRetention: int
bindAddress: str
branch: str
certificateValidation: str
consoleLogLevel: str
enableSsl: bool
id: int
launchBrowser: bool
logLevel: str
password: str
port: int
proxyBypassFilter: str
proxyBypassLocalAddresses: bool
proxyEnabled: bool
proxyHostname: str
proxyPassword: str
proxyPort: int
proxyType: str
proxyUsername: str
sslCertHash: str
sslCertPassword: str
sslCertPath: str
sslPort: int
updateAutomatically: bool
updateMechanism: str
updateScriptPath: str
urlBase: str
username: str
@dataclass(init=False)
class UIConfig(BaseModel):
"""UI config attributes."""
calendarWeekColumnHeader: str
enableColorImpairedMode: bool
firstDayOfWeek: int
id: int
longDateFormat: str
movieInfoLanguage: int
movieRuntimeFormat: str
shortDateFormat: str
showRelativeDates: bool
timeFormat: str
uiLanguage: int
@dataclass(init=False)
class SystemStatus(BaseModel):
"""System status attributes."""
appData: str
appName: str
authentication: str
branch: str
buildTime: datetime
instanceName: str
isAdmin: bool
isDebug: bool
isDocker: bool
isLinux: bool
isMono: bool
isMonoRuntime: bool
isNetCore: bool
isOsx: bool
isProduction: bool
isUserInteractive: bool
isWindows: bool
migrationVersion: int
mode: str
osName: str
osVersion: str
packageUpdateMechanism: str
runtimeName: str
runtimeVersion: str
sqliteVersion: str
startTime: datetime
startupPath: str
urlBase: str
version: str
@dataclass(init=False)
class Command(_Common3):
"""Command attributes."""
body: type[_CommandBody] = field(default=_CommandBody)
commandName: str
duration: str
ended: datetime
lastExecutionTime: datetime
message: str
priority: str
queued: datetime
sendUpdatesToClient: bool
started: datetime
stateChangeTime: datetime
status: str
trigger: str
updateScheduledTask: bool
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.body = _CommandBody(self.body)
@dataclass(init=False)
class DownloadClient(_Common):
"""Download client attributes."""
configContract: str
enable: bool
id: int
priority: int
protocol: ProtocolType
tags: list[int]
@dataclass(init=False)
class DownloadClientConfig(BaseModel):
"""Download client configuration attributes."""
autoRedownloadFailed: bool
checkForFinishedDownloadInterval: int
downloadClientWorkingFolders: str
enableCompletedDownloadHandling: bool
id: int
removeCompletedDownloads: bool
removeFailedDownloads: bool
@dataclass(init=False)
class Filesystem(BaseModel):
"""Filesystem attributes."""
directories: list[_FilesystemDirectory] | None = None
files: list
parent: str
def __post_init__(self):
"""Post init."""
self.directories = [_FilesystemDirectory(x) for x in self.directories or []]
@dataclass(init=False)
class Health(BaseModel):
"""Health attributes."""
message: str
source: str
type: str
wikiUrl: str
@dataclass(init=False)
class ImportListExclusion(BaseModel):
"""Import list exclusion attributes."""
artistName: str
authorName: str
foreignId: str
id: int | None = None
movieTitle: str
movieYear: int
title: str
tmdbId: int
tvdbId: int
@dataclass(init=False)
class Indexer(_Common3):
"""Indexer attributes."""
configContract: str
enableAutomaticSearch: bool
enableInteractiveSearch: bool
enableRss: bool
fields: list[_Fields] | None = None
implementation: str
implementationName: str
infoLink: str
priority: int
protocol: ProtocolType
supportsRss: bool
supportsSearch: bool
tags: list[int]
def __post_init__(self):
"""Post init."""
self.fields = [_Fields(field) for field in self.fields or []]
@dataclass(init=False)
class IndexerConfig(BaseModel):
"""Indexer configuration attributes."""
allowHardcodedSubs: bool
availabilityDelay: int
id: int
maximumSize: int
minimumAge: int
preferIndexerFlags: bool
retention: int
rssSyncInterval: int
whitelistedHardcodedSubs: str
@dataclass(init=False)
class Language(_Common3):
"""Language attributes."""
nameLower: str
@dataclass(init=False)
class Localization(BaseModel):
"""Localization attributes."""
Strings: type[_LocalizationStrings] = field(default=_LocalizationStrings)
def __post_init__(self):
"""Post init."""
self.Strings = _LocalizationStrings(self.Strings)
@dataclass(init=False)
class MediaManagementConfig(BaseModel):
"""Media management config attributes."""
allowFingerprinting: str
autoRenameFolders: bool
autoUnmonitorPreviouslyDownloadedBooks: bool
autoUnmonitorPreviouslyDownloadedEpisodes: bool
autoUnmonitorPreviouslyDownloadedMovies: bool
autoUnmonitorPreviouslyDownloadedTracks: bool
chmodFolder: str
chownGroup: str
copyUsingHardlinks: bool
createEmptyAuthorFolders: bool
createEmptyMovieFolders: bool
createEmptySeriesFolders: bool
deleteEmptyFolders: bool
downloadPropersAndRepacks: str
enableMediaInfo: bool
episodeTitleRequired: str
extraFileExtensions: str
fileDate: str
id: int
importExtraFiles: bool
minimumFreeSpaceWhenImporting: int
pathsDefaultStatic: bool
recycleBin: str
recycleBinCleanupDays: int
rescanAfterRefresh: str
setPermissionsLinux: bool
skipFreeSpaceCheckWhenImporting: bool
watchLibraryForChanges: bool
@dataclass(init=False)
class MetadataConfig(_Common3):
"""Metadata config attributes."""
configContract: str
enable: bool
fields: list[_MetadataFields] | None = None
implementation: str
implementationName: str
infoLink: str
tags: list[int]
def __post_init__(self):
"""Post init."""
self.fields = [_MetadataFields(field) for field in self.fields or []]
@dataclass(init=False)
class QualityDefinition(BaseModel):
"""Quality definition attributes."""
id: int
maxSize: float
minSize: float
preferredSize: int
quality: type[_QualityInfo] = field(default=_QualityInfo)
title: str
weight: int
def __post_init__(self):
"""Post init."""
self.quality = _QualityInfo(self.quality)
@dataclass(init=False)
class QualityProfile(_Common3):
"""Quality profile attributes."""
cutoff: int
cutoffFormatScore: int
formatItems: list
items: list[_QualityProfileItems] | None = None
language: type[_Common3] = field(default=_Common3)
minFormatScore: int
upgradeAllowed: bool
def __post_init__(self):
"""Post init."""
self.items = [_QualityProfileItems(item) for item in self.items or []]
self.language = _Common3(self.language)
@dataclass(init=False)
class QueueStatus(BaseModel):
"""Queue status attributes."""
count: int
errors: bool
totalCount: int
unknownCount: int
unknownErrors: bool
unknownWarnings: bool
warnings: bool
@dataclass(init=False)
class ReleaseProfile(BaseModel):
"""Release profile attributes."""
enabled: bool
id: int
ignored: str
includePreferredWhenRenaming: bool
indexerId: int
preferred: list[_ReleaseProfilePreferred] | None = None
required: str
tags: list[int]
def __post_init__(self):
"""Post init."""
self.preferred = [_ReleaseProfilePreferred(x) for x in self.preferred or []]
@dataclass(init=False)
class RemotePathMapping(BaseModel):
"""Remote path mapping attributes."""
host: str
id: int
localPath: str
remotePath: str
@dataclass(init=False)
class SystemTask(_Common3):
"""System task attributes."""
interval: int
lastDuration: str
lastExecution: datetime
lastStartTime: datetime
nextExecution: datetime
taskName: str
@dataclass(init=False)
class Update(BaseModel):
"""Update attributes."""
branch: str
changes: type[_UpdateChanges] = field(default=_UpdateChanges)
fileName: str
hash: str
installable: bool
installed: bool
installedOn: datetime
latest: bool
releaseDate: datetime
url: str
version: str
def __post_init__(self):
"""Post init."""
super().__post_init__()
self.changes = _UpdateChanges(self.changes)
@dataclass(init=False)
class DelayProfile(BaseModel):
"""Delay profile attributes."""
bypassIfHighestQuality: bool
enableTorrent: bool
enableUsenet: bool
id: int
order: int
preferredProtocol: ProtocolType
tags: list[int]
torrentDelay: int
usenetDelay: int
@dataclass(init=False)
class FilesystemFolder(_FilesystemFolder):
"""Filesystem folder attributes."""
|