golift.io/starr@v1.0.0/radarr/system.go (about) 1 package radarr 2 3 import ( 4 "context" 5 "fmt" 6 "path" 7 "time" 8 9 "golift.io/starr" 10 ) 11 12 const bpSystem = APIver + "/system" 13 14 // SystemStatus is the /api/v3/system/status endpoint. 15 type SystemStatus struct { 16 AppData string `json:"appData"` 17 AppName string `json:"appName"` 18 Authentication string `json:"authentication"` 19 Branch string `json:"branch"` 20 BuildTime time.Time `json:"buildTime"` 21 DatabaseType string `json:"databaseType"` 22 DatabaseVersion string `json:"databaseVersion"` 23 InstanceName string `json:"instanceName"` 24 IsAdmin bool `json:"isAdmin"` 25 IsDebug bool `json:"isDebug"` 26 IsDocker bool `json:"isDocker"` 27 IsLinux bool `json:"isLinux"` 28 IsNetCore bool `json:"isNetCore"` 29 IsOsx bool `json:"isOsx"` 30 IsProduction bool `json:"isProduction"` 31 IsUserInteractive bool `json:"isUserInteractive"` 32 IsWindows bool `json:"isWindows"` 33 MigrationVersion int64 `json:"migrationVersion"` 34 Mode string `json:"mode"` 35 OsName string `json:"osName"` 36 PackageAuthor string `json:"packageAuthor"` 37 PackageUpdateMechanism string `json:"packageUpdateMechanism"` 38 PackageVersion string `json:"packageVersion"` 39 RuntimeName string `json:"runtimeName"` 40 RuntimeVersion string `json:"runtimeVersion"` 41 StartTime time.Time `json:"startTime"` 42 StartupPath string `json:"startupPath"` 43 URLBase string `json:"urlBase"` 44 Version string `json:"version"` 45 } 46 47 // GetSystemStatus returns system status. 48 func (r *Radarr) GetSystemStatus() (*SystemStatus, error) { 49 return r.GetSystemStatusContext(context.Background()) 50 } 51 52 // GetSystemStatusContext returns system status. 53 func (r *Radarr) GetSystemStatusContext(ctx context.Context) (*SystemStatus, error) { 54 var output SystemStatus 55 56 req := starr.Request{URI: path.Join(bpSystem, "status")} 57 if err := r.GetInto(ctx, req, &output); err != nil { 58 return nil, fmt.Errorf("api.Get(%v): %w", &req, err) 59 } 60 61 return &output, nil 62 } 63 64 // GetBackupFiles returns all available Radarr backup files. 65 // Use GetBody to download a file using BackupFile.Path. 66 func (r *Radarr) GetBackupFiles() ([]*starr.BackupFile, error) { 67 return r.GetBackupFilesContext(context.Background()) 68 } 69 70 // GetBackupFilesContext returns all available Radarr backup files. 71 // Use GetBody to download a file using BackupFile.Path. 72 func (r *Radarr) GetBackupFilesContext(ctx context.Context) ([]*starr.BackupFile, error) { 73 var output []*starr.BackupFile 74 75 req := starr.Request{URI: path.Join(bpSystem, "backup")} 76 if err := r.GetInto(ctx, req, &output); err != nil { 77 return nil, fmt.Errorf("api.Get(%s): %w", &req, err) 78 } 79 80 return output, nil 81 }