golift.io/starr@v1.0.0/prowlarr/system.go (about) 1 package prowlarr 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/v1/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 IsMono bool `json:"isMono"` 29 IsNetCore bool `json:"isNetCore"` 30 IsOsx bool `json:"isOsx"` 31 IsProduction bool `json:"isProduction"` 32 IsUserInteractive bool `json:"isUserInteractive"` 33 IsWindows bool `json:"isWindows"` 34 MigrationVersion int64 `json:"migrationVersion"` 35 Mode string `json:"mode"` 36 OsName string `json:"osName"` 37 OsVersion string `json:"osVersion"` 38 PackageAuthor string `json:"packageAuthor"` 39 PackageUpdateMechanism string `json:"packageUpdateMechanism"` 40 PackageVersion string `json:"packageVersion"` 41 RuntimeName string `json:"runtimeName"` 42 RuntimeVersion string `json:"runtimeVersion"` 43 StartTime time.Time `json:"startTime"` 44 StartupPath string `json:"startupPath"` 45 URLBase string `json:"urlBase"` 46 Version string `json:"version"` 47 } 48 49 // GetSystemStatus returns system status. 50 func (p *Prowlarr) GetSystemStatus() (*SystemStatus, error) { 51 return p.GetSystemStatusContext(context.Background()) 52 } 53 54 // GetSystemStatusContext returns system status. 55 func (p *Prowlarr) GetSystemStatusContext(ctx context.Context) (*SystemStatus, error) { 56 var output SystemStatus 57 58 req := starr.Request{URI: path.Join(bpSystem, "status")} 59 if err := p.GetInto(ctx, req, &output); err != nil { 60 return nil, fmt.Errorf("api.Get(%s): %w", &req, err) 61 } 62 63 return &output, nil 64 } 65 66 // GetBackupFiles returns all available Prowlarr backup files. 67 // Use GetBody to download a file using BackupFile.Path. 68 func (p *Prowlarr) GetBackupFiles() ([]*starr.BackupFile, error) { 69 return p.GetBackupFilesContext(context.Background()) 70 } 71 72 // GetBackupFiles returns all available Prowlarr backup files. 73 // Use GetBody to download a file using BackupFile.Path. 74 func (p *Prowlarr) GetBackupFilesContext(ctx context.Context) ([]*starr.BackupFile, error) { 75 var output []*starr.BackupFile 76 77 req := starr.Request{URI: path.Join(bpSystem, "backup")} 78 if err := p.GetInto(ctx, req, &output); err != nil { 79 return nil, fmt.Errorf("api.Get(%s): %w", &req, err) 80 } 81 82 return output, nil 83 }